本文整理汇总了Python中pygame.midi.get_device_info函数的典型用法代码示例。如果您正苦于以下问题:Python get_device_info函数的具体用法?Python get_device_info怎么用?Python get_device_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_device_info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: restoreSettings
def restoreSettings(self, mainWindowHandler):
mainWindowHandler.midiInputChannel = self.settings.value('midiInputChannel').toInt()[0]
if not mainWindowHandler.midiInputChannel:
self.midiInputChannel = 1
self.midiOutputChannel = self.settings.value('midiOutputChannel').toInt()[0]
if not mainWindowHandler.midiOutputChannel:
mainWindowHandler.midiOutputChannel = 1
registryInputDeviceList = []
for inputDeviceHash in self.settings.value('midiInputDevices', []).toList():
inputDeviceHash = str(inputDeviceHash.toString())
for deviceWidget, index in self.midiInputDevicesDict.iteritems():
deviceName = midi.get_device_info(index)[1]
deviceHash = hashlib.md5(deviceName).hexdigest()
if deviceHash == inputDeviceHash:
deviceWidget.setChecked(True)
self.windowHandler.midiInputSelect(self, deviceWidget)
registryInputDeviceList.append(deviceHash)
self.settings.setValue('midiInputDevices', registryInputDeviceList)
#update the registry so unplugged devices aren't
#reselected when plugged back in at some later time
outputDeviceHash = str(self.settings.value('midiOutputDevice').toString())
registryOutputDevice = None
for deviceWidget, index in self.midiOutputDevicesDict.iteritems():
deviceName = midi.get_device_info(index)[1]
deviceHash = hashlib.md5(deviceName).hexdigest()
if deviceHash == outputDeviceHash:
deviceWidget.setChecked(True)
self.windowHandler.midiOutputSelect(self, deviceWidget)
registryOutputDevice = deviceHash
self.settings.setValue('midiOutputDevice', registryOutputDevice)
开发者ID:bitrex,项目名称:meeblip-control,代码行数:31,代码来源:meeblipControl.py
示例2: __init__
def __init__(self):
if sequencer.running:
sequencer.stop()
BUTTON_S = BUTTON_W, BUTTON_H = (310, 27)
SPACE = 5
ypos = SPACE
midi_in = 'Midi In: None'
if midi.m_in:
name = pm.get_device_info(midi.m_in.device_id)[1]
midi_in = 'Midi In: {}'.format(name)
self.midi_in_button = ActionButton((SPACE, ypos),
BUTTON_S,
midi_in,
True, True)
self.channel_counter = Counter((SPACE * 2 + BUTTON_W, ypos),
BUTTON_H,
'Channel', 1, 16, start=midi.in_channel)
ypos += SPACE + BUTTON_H
midi_out = 'Midi Out: None'
if midi.out:
name = pm.get_device_info(midi.out.device_id)[1]
midi_out = 'Midi Out: {}'.format(name)
self.midi_out_button = ActionButton((SPACE, ypos),
BUTTON_S,
midi_out,
True, True)
ypos += SPACE + BUTTON_H
self.bpm_counter = Counter((SPACE, ypos),
BUTTON_H,
'BPM', 20, 320,
start=sequencer.project['bpm'])
开发者ID:Kungsgeten,项目名称:chipquencer,代码行数:35,代码来源:config.py
示例3: get_device
def get_device(self, dev_name):
for i in xrange(0, midi.get_count()):
name = midi.get_device_info(i)[1]
print midi.get_device_info(i)
if name == dev_name:
if midi.get_device_info(i)[3]: #Checking if output device
return midi.Output(i)
开发者ID:marcdjulien,项目名称:PhysCompFinal,代码行数:7,代码来源:MidiDevice.py
示例4: __getDeviceId
def __getDeviceId(self, midiport):
n_device = pm.get_count()
foundId = -1
for id in range(n_device):
if int(pm.get_device_info(id)[1] == midiport) & \
int(pm.get_device_info(id)[3] == 1):
foundId = id
return foundId
开发者ID:DrKrantz,项目名称:snn,代码行数:8,代码来源:outputDevices.py
示例5: construct_input
def construct_input(type='MK-449C USB MIDI Keyboard'):
pm.init()
n_device = pm.get_count()
in_id = -1
for id in range(n_device):
if int(pm.get_device_info(id)[1]==type) & int(pm.get_device_info(id)[2]==1):
in_id = id
print "input: "+type
# if in_id == -1:
# print "desired input: "+type+ " not available"
eingang = pm.Input(in_id)
return eingang
开发者ID:DrKrantz,项目名称:snn,代码行数:13,代码来源:Dunkel_functions.py
示例6: close
def close(self):
sequencer.project['bpm'] = self.bpm_counter.value
midi.in_channel = self.channel_counter.value
in_name = None
out_name = None
if midi.m_in:
in_name = pm.get_device_info(midi.m_in.device_id)[1]
if midi.out:
out_name = pm.get_device_info(midi.out.device_id)[1]
config_dict = {'midi_out': out_name,
'midi_in': in_name,
'midi_in_channel': midi.in_channel}
stream = file('config.yml', 'w')
yaml.dump(config_dict, stream)
开发者ID:Kungsgeten,项目名称:chipquencer,代码行数:14,代码来源:config.py
示例7: construct_output
def construct_output(type='SimpleSynth virtual input',instrument=1):
# this constructs an output
pygame.init()
pm.init()
pm.init()
n_device = pm.get_count()
out_id = -1
for id in range(n_device):
if int(pm.get_device_info(id)[1]==type) & int(pm.get_device_info(id)[3]==1):
out_id = id
ausgang = pm.Output(out_id,0)
ausgang.set_instrument(instrument)
print "output: "+type
return ausgang
print "output: "+type+" not available"
开发者ID:DrKrantz,项目名称:snn,代码行数:15,代码来源:Dunkel_functions.py
示例8: _get_device
def _get_device(device_id):
keys = ['interface', 'name', 'is_input', 'is_output', 'opened']
info = dict(zip(keys, midi.get_device_info(device_id)))
# TODO: correct encoding?
info['name'] = info['name'].decode('utf-8')
info['id'] = device_id
return info
开发者ID:olemb,项目名称:mido,代码行数:7,代码来源:pygame.py
示例9: parse_args
def parse_args():
if '-l' in sys.argv or '-d' in sys.argv or '-t' in sys.argv:
testMode = False
if '-t' in sys.argv: testMode = True
if '-l' in sys.argv:
list_devices()
if '-d' in sys.argv:
i = sys.argv.index('-d')
if len(sys.argv)>i+1:
# get devices list
devices_t = sys.argv[i+1].split(',')
devices = []
for i in range(0,len(devices_t)):
device = int(devices_t[i])
# if device exists add it to list
if device_exists(device):
devices.append(device)
print("Using midi device: %s" % (midi.get_device_info(device)[1]))
else:
print("Seems like the device #%d does not exist. Is it plugged in?" % device)
return
if testMode:
print("Running in test mode. No server was opened and your midi signals will be printed.")
test_mode(devices)
else: start(devices)
else:
print("Please specify the number of midi-in device(s)")
return
else:
print("Command line arguments:\n-l Print out a list of midi-devices\n-d [device numbers] Comma seperated list of device numbers to use. E.g. '2,3' (no spaces!)\-t Run in test mode")
开发者ID:der-On,项目名称:X-Plane-Python-MidiControl,代码行数:34,代码来源:midi_control.py
示例10: midiInputSelect
def midiInputSelect(self, mainWindowInstance, device):
deviceIndex = mainWindowInstance.midiInputDevicesDict[device]
if not device.isChecked():
try:
self.midiSelectedInputDevicesDict.pop(deviceIndex).close()
device.setChecked(False)
except midi.MidiException as e:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", unicode(e))
except:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", "Device error.")
mainWindowInstance.midiInputDevicesDict.pop(device)
mainWindowInstance.ui.midiInputDevicesMenu.removeAction(device)
else:
try:
self.midiSelectedInputDevicesDict[deviceIndex] = midi.Input(deviceIndex)
except midi.MidiException as e:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", unicode(e))
except:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", "Device error.")
mainWindowInstance.midiInputDevicesDict.pop(device)
mainWindowInstance.ui.midiInputDevicesMenu.removeAction(device)
deviceNameList = []
for deviceIndex in self.midiSelectedInputDevicesDict.keys():
deviceNameList.append(hashlib.md5(midi.get_device_info(deviceIndex)[1]).hexdigest())
mainWindowInstance.settings.setValue('midiInputDevices', deviceNameList)
开发者ID:bitrex,项目名称:meeblip-control,代码行数:27,代码来源:windowHandler.py
示例11: getMIDIDevices
def getMIDIDevices(self):
midiOutputDevices = []
midiInputDevices = []
for index in xrange(0, midi.get_count()):
device = midi.get_device_info(index)
deviceName = device[1]
if device[3] == 1 and device[4] == 0: #if the device is an output and not opened
setattr(self, deviceName, QtGui.QAction(QtGui.QIcon(''), deviceName, self))
deviceWidget = getattr(self, deviceName)
deviceWidget.setCheckable(True)
midiOutputDevices.append(deviceWidget)
self.midiOutputDevicesDict[deviceWidget] = index
elif device[2] == 1 and device[4] == 0: #if devices is an input and not opened
deviceName = device[1]
setattr(self, deviceName, QtGui.QAction(QtGui.QIcon(''), deviceName, self))
deviceWidget = getattr(self, deviceName)
deviceWidget.setCheckable(True)
midiInputDevices.append(deviceWidget)
self.midiInputDevicesDict[deviceWidget] = index
if midiOutputDevices:
self.ui.midiOutputDevicesMenu = self.ui.menubar.addMenu("&Midi Output Device")
self.ui.midiOutputDevicesMenu.addActions(midiOutputDevices)
if midiInputDevices:
self.ui.midiInputDevicesMenu = self.ui.menubar.addMenu("&Midi Input Devices")
self.ui.midiInputDevicesMenu.addActions(midiInputDevices)
for device in midiOutputDevices:
outputFunction = partial(self.windowHandler.midiOutputSelect, mainWindowInstance=self, device=device)
device.triggered.connect(outputFunction)
for device in midiInputDevices:
inputFunction = partial(self.windowHandler.midiInputSelect, mainWindowInstance=self, device=device)
device.triggered.connect(inputFunction)
开发者ID:bitrex,项目名称:meeblip-control,代码行数:34,代码来源:meeblipControl.py
示例12: midi_info
def midi_info():
"""
midi is an instance of pygame.midi
Returns a dictionary containing info
about the systems MIDI devices.
The dictionary contains:
'count' - number of devices.
'def_in' - default input.
'def_out' - default output.
'devices' - a list of device info.
"""
info = {}
#Store info.
info.keys().append('count')
info['count'] = midi.get_count()
info.keys().append('def_in')
info['def_in'] = midi.get_default_input_id()
info.keys().append('def_out')
info['def_out'] = midi.get_default_output_id()
devices = []
for i in range(0, midi.get_count()):
devices.append(midi.get_device_info(i))
info.keys().append('devices')
info['devices'] = devices
return info
开发者ID:NFJones,项目名称:pyWave,代码行数:32,代码来源:midi.py
示例13: midiInputSelect
def midiInputSelect(self, mainWindowInstance, device):
deviceIndex = mainWindowInstance.midiInputDevicesDict[device]
if not device.isChecked():
try:
# in nachfolgender Anweisung tritt ein Problem auf
# PortMidi attempts to close open streams when the application exits -- this is particularly difficult under Windows.
# Exception Exception: "PortMidi: `Bad pointer'" in <pypm.Input object at 0x00BAFA58> ignored
self.midiSelectedInputDevicesDict.pop(deviceIndex).close()
device.setChecked(False)
except midi.MidiException as e:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", unicode(e))
except:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", "Device error.")
mainWindowInstance.midiInputDevicesDict.pop(device)
mainWindowInstance.ui.midiInputDevicesMenu.removeAction(device)
else:
try:
self.midiSelectedInputDevicesDict[deviceIndex] = midi.Input(deviceIndex)
except midi.MidiException as e:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", unicode(e))
except:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", "Device error.")
mainWindowInstance.midiInputDevicesDict.pop(device)
mainWindowInstance.ui.midiInputDevicesMenu.removeAction(device)
deviceNameList = []
for deviceIndex in self.midiSelectedInputDevicesDict.keys():
deviceNameList.append(hashlib.md5(midi.get_device_info(deviceIndex)[1]).hexdigest())
mainWindowInstance.settings.setValue("midiInputDevices", deviceNameList)
开发者ID:ataweg,项目名称:meeblip-control,代码行数:29,代码来源:windowHandler.py
示例14: midiOutputSelect
def midiOutputSelect(self, mainWindowInstance, device):
deviceIndex = mainWindowInstance.midiOutputDevicesDict[device]
for outputDevice in mainWindowInstance.midiOutputDevicesDict.keys():
if outputDevice != device:
outputDevice.setChecked(False)
else:
if outputDevice.isChecked():
try:
self.midiSelectedOutputDevice = midi.Output(deviceIndex)
if not self.midiSelectedOutputDevice:
raise Exception
mainWindowInstance.settings.setValue(
"midiOutputDevice", hashlib.md5(midi.get_device_info(deviceIndex)[1]).hexdigest()
)
except midi.MidiException as e:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", unicode(e))
except:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", "Device error.")
mainWindowInstance.midiOutputDevicesDict.pop(device)
mainWindowInstance.ui.midiOutputDevicesMenu.removeAction(device)
else:
try:
self.midiSelectedOutputDevice.close()
except midi.MidiException as e:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", unicode(e))
except:
QtGui.QMessageBox.warning(mainWindowInstance, "MIDI Error", "Device error.")
mainWindowInstance.midiOutputDevicesDict.pop(device)
mainWindowInstance.ui.midiOutputDevicesMenu.removeAction(device)
self.midiSelectedOutputDevice = None
mainWindowInstance.settings.setValue("midiOutputDevice", "")
开发者ID:ataweg,项目名称:meeblip-control,代码行数:33,代码来源:windowHandler.py
示例15: getInputDevices
def getInputDevices():
for i in xrange(midi.get_count()):
info = midi.get_device_info(i)
(unusedInterface, name, isInput,
unusedIsOutput, unusedOpened) = info
if isInput:
yield i, name
开发者ID:rdoursenaud,项目名称:Listen--Learn--Play,代码行数:7,代码来源:editControls.py
示例16: get_device
def get_device(device_id):
midi.init()
keys = ['interface', 'name', 'is_input', 'is_output', 'opened']
info = dict(zip(keys, midi.get_device_info(device_id)))
info['device_id'] = device_id
return info
开发者ID:rbinkys,项目名称:mido,代码行数:7,代码来源:mido_pygame.py
示例17: select
def select(self, index, *largs):
try:
self.parent.midi.setDevice(index)
self.selected = index
self.selectedname = midi.get_device_info(index)[1]
except:
raise
self.refresh()
开发者ID:arasbm,项目名称:pymt-apps,代码行数:8,代码来源:tonepads.py
示例18: get_info
def get_info(self):
l = []
for x in range(pm.get_count()):
l.append(pm.get_device_info(x))
#dev = DeviceInfo(Index=x, info=pm.get_device_info(x))
#self.dev_info[dev.type].add_child(existing_object=dev)
#dev.bind(active=self.on_dev_info_active_set)
return l
开发者ID:nocarryr,项目名称:node_mapper,代码行数:8,代码来源:pygame_midiIO.py
示例19: createInterfaces
def createInterfaces(self):
"""
creates all midi interfaces available as devices
@todo: sort in- and output of one hardware
"""
n = midi.get_count()
for i in xrange(n/2):
info = midi.get_device_info(i*2)
newIf = Interface(info[1], i*2-1, i*2)
开发者ID:p-friedrich,项目名称:midimanager,代码行数:9,代码来源:midimanager.py
示例20: get_midi_output_id
def get_midi_output_id():
for id in range(midi.get_count()):
interface, name, input, output, open = midi.get_device_info(id)
if not output:
continue
name = name.decode('utf-8').lower()
if name.find('synth') != -1:
return id
return midi.get_default_output_id()
开发者ID:ZhanruiLiang,项目名称:pysheetmusic,代码行数:9,代码来源:player.py
注:本文中的pygame.midi.get_device_info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论