pygame.midi.MidiException:'设备ID无效,超出范围. [英] pygame.midi.MidiException: 'Device id invalid, out of range.'

查看:175
本文介绍了pygame.midi.MidiException:'设备ID无效,超出范围.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OSX Yosemite 10.10.5上,并且尝试使用pygame.midi播放具有以下代码的Midi声音:

I'm on Mac OSX Yosemite 10.10.5 and I'm trying to play midi sounds with pygame.midi with this code:

import pygame.midi
pygame.midi.init()
print pygame.midi.get_default_output_id() # -1
print pygame.midi.get_device_info(0) # None
player = pygame.midi.Output(0)

我得到以下输出:

-1
None
Traceback (most recent call last):
  File "midi.py", line 11, in <module>
    player = pygame.midi.Output(0)
  File "/Library/Python/2.7/site-packages/pygame/midi.py", line 414, in __init__
    raise MidiException("Device id invalid, out of range.")
pygame.midi.MidiException: 'Device id invalid, out of range.'

我尝试了一堆不同的设备ID(0-128),以查看可以在哪里找到我的输出扬声器,但找不到任何东西.就像我的Mac没有音频输出,但应该有.

I've tried a bunch of different device id's (0-128) to look where my output speakers might be found, but I can't find anything. It's like my mac doesn't have an audio output, but it should.

推荐答案

pygame.midi的目的是访问MIDI设备.

The purpose of pygame.midi is to access MIDI devices.

扬声器不是MIDI设备.您的计算机上也没有其他东西.

Speakers are not MIDI devices. Neither is anything else on your computer.

如果要确保程序可以输出MIDI数据,则必须安装软件合成器.

If you want to ensure that your program can output MIDI data, you have to install a software synthesizer.

这篇关于pygame.midi.MidiException:'设备ID无效,超出范围.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆