本文整理汇总了Python中pygame.midi.get_count函数的典型用法代码示例。如果您正苦于以下问题:Python get_count函数的具体用法?Python get_count怎么用?Python get_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_count函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: main
def main():
"""Initiates program and loop."""
pygame.init()
midi.init()
print "Number of MIDI devices:", midi.get_count()
if midi.get_count() == 0:
print "No MIDI devices detected :P"
return
out_device = midi.get_default_output_id()
if out_device == -1:
print "No MIDI output device detected :P"
return
print "Uses device no:", out_device
try:
output = midi.Output( out_device )
output.set_instrument( instrument )
keyboard = init_keyboard(53)
screen = pygame.display.set_mode([250,80])
screen.fill((0,0,0))
pygame.display.set_caption("MIDI Keyboard")
pygame.display.flip()
io_loop(keyboard, output, instrument)
finally:
del output
midi.quit()
开发者ID:introprogramming,项目名称:exercises,代码行数:31,代码来源:midi.py
示例3: __init__
def __init__(self):
self.devIn = None
self.devOut = None
midi.init()
# TODO: this sucks...
try:
midi.get_count()
except:
print("ERROR: MIDI not available...")
开发者ID:timonweb,项目名称:Novation-Launchpad-Spectrum-Analyzer,代码行数:12,代码来源:launchpad.py
示例4: 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
示例5: 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
示例6: 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
示例7: __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
示例8: 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
示例9: 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
示例10: 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
示例11: GetPorts
def GetPorts(self):
i = {}
o = {}
for j in range(pm.get_count()):
s,name,ins,outs,throughs = pm.get_device_info(j)
if ins > 0:
i[name] = j
if outs > 0:
o[name] = j
return (i,o)
开发者ID:Captain-Sandwich,项目名称:akai.py,代码行数:10,代码来源:gui.py
示例12: list_devices
def list_devices(self):
for i in range(pm.get_count()):
r = pm.get_device_info(i)
(interf, name, input, output, opened) = r
in_out = ""
if input:
in_out = "(input)"
if output:
in_out = "(output)"
print ("%2i: interface :%s:, name :%s:, opened :%s: %s" % (i, interf, name, opened, in_out))
开发者ID:sovannara-hak,项目名称:RemixStation_mhd2013,代码行数:10,代码来源:midi_read.py
示例13: get_devices
def get_devices(name):
id_in, id_out = None, None
for i in range(midi.get_count()):
info = midi.get_device_info(i)
if info[1] == name:
if info[2]:
id_in = i
elif info[3]:
id_out = i
return id_in, id_out
开发者ID:javadan,项目名称:l-s-dome,代码行数:10,代码来源:input.py
示例14: create_initial_data
def create_initial_data(mox):
pin = {}
pout = {}
for i in xrange(pym.get_count()):
info = pym.get_device_info(i)
name = info[1]
if info[2]:
pin[name] = i
if info[3]:
pout[name] = i
return {"ports_in": pin, "ports_out": pout}
开发者ID:Soul-Burn,项目名称:moxmidimaster,代码行数:12,代码来源:MOX_Midi_Master.py
示例15: get_devices
def get_devices():
"""Get a list of all MIDI output devices connected to the system."""
if _midi is None:
return
outdevices = []
all_ids = _midi.get_count()
for device_id in all_ids:
info = _midi.get_device_info(device_id)
if info[3] == 1:
outdevices.add([device_id, info[1]])
return outdevices
开发者ID:Dannnno,项目名称:expyriment,代码行数:12,代码来源:_midiout.py
示例16: devices
def devices(self):
devices = []
for i in range(midi.get_count()):
driver, name, inp, outp, opened = midi.get_device_info(i)
if outp:
devices.append((i, driver, name, inp, outp))
return devices
开发者ID:bjvanderweij,项目名称:pymuco,代码行数:12,代码来源:lhl.py
示例17: _open_device
def _open_device(name='SSCOM MIDI 1', device_index=1):
'''Opens midi device with given name and port number'''
# This code stinks. Is there any better way to find the device?
for dn in range(midi.get_count()):
md = midi.get_device_info(dn)
if (md[1] == name) and (md[3] == 1): # md[3] == 1 <=> output device
device_index -= 1
if device_index == 0:
return midi.Output(dn)
raise RuntimeError("Could not find a SoftStep Controller")
开发者ID:amiguet,项目名称:foococo,代码行数:12,代码来源:hardware.py
示例18: __init__
def __init__(self):
self.pin = {}
self.pout = {}
for i in xrange(pym.get_count()):
info = pym.get_device_info(i)
if info[2]:
self.pin[i] = pym.Input(i)
if info[3]:
self.pout[i] = pym.Output(i)
self.thread = threading.Thread(target=self._run)
self.thread.daemon = True
self.thread.start()
开发者ID:Soul-Burn,项目名称:moxmidimaster,代码行数:13,代码来源:MOX_Midi_Master.py
示例19: 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
示例20: refresh
def refresh(self):
self.children = SafeList()
for index in xrange(midi.get_count()):
info = midi.get_device_info(index)
interf, name, input, output, opened = info
if output <= 0:
continue
btn = MTToggleButton(label=name, size=(200, 30))
btn.size = btn.label_obj.content_width + 20, 30
btn.push_handlers(on_press=curry(self.select, index))
self.add_widget(btn)
if self.selected == index and \
self.selectedname == name:
btn.state = 'down'
开发者ID:arasbm,项目名称:pymt-apps,代码行数:14,代码来源:tonepads.py
注:本文中的pygame.midi.get_count函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论