本文整理汇总了Python中mido.get_output_names函数的典型用法代码示例。如果您正苦于以下问题:Python get_output_names函数的具体用法?Python get_output_names怎么用?Python get_output_names使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_output_names函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_midi_stream
def start_midi_stream(file_name, display):
last_note = int(round(time.time() * 1000))
mido.get_output_names()
port_name = mido.get_input_names()[0]
print('Starting on port: ' + port_name)
with MidiFile() as mid:
track = MidiTrack()
try:
print("Waiting For Keyboard Input ... ")
with mido.open_input(port_name) as inport:
for msg in inport:
now = int(round(time.time() * 1000))
msg.time = now - last_note
last_note = now
if hasattr(msg, 'velocity') and msg.velocity == 0:
msg = Message('note_off', note=msg.note, velocity=msg.velocity, time=msg.time)
track.append(msg)
if display:
print(msg)
except KeyboardInterrupt:
if file_name:
print("\nStopping and saving file ... ")
else:
print("\nStopping ...")
finally:
if file_name:
print(file_name)
mid.tracks.append(track)
mid.save(file_name)
print("File Saved!")
print("File Location: " + file_name)
else:
print("Done!")
示例2: main
def main():
output_names = mido.get_output_names()
for index, each in enumerate(output_names):
print('out id: %d name: %s' % (index, each))
input_names = mido.get_input_names()
for index, each in enumerate(input_names):
print('in id: %d name: %s' % (index, each))
示例3: open_output
def open_output(self):
if self.backend == 'mido':
if self.debug>0:
print('------ OUTPUT ------')
for port in mido.get_output_names():
print(port)
print('-------------------------')
try:
self.outputport = mido.open_output(self.config.get('midi', 'device'))
print "Connected to MIDI output"
except:
print "Error: cannot connect to MIDI output"
raise RuntimeError("Error: cannot connect to MIDI output")
elif self.backend == 'midiosc':
try:
self.outputport = OSC.OSCClient()
self.outputport.connect((self.config.get('midi','hostname'), self.config.getint('midi','port')))
print "Connected to OSC server"
except:
print "Error: cannot connect to OSC server"
raise RuntimeErrror("cannot connect to OSC server")
else:
print 'Error: unsupported backend: ' + self.backend
raise RuntimeError('unsupported backend: ' + self.backend)
示例4: __init__
def __init__(self, _save_path, songfile, _plyr_ctrls):
super(PlayerThread, self).__init__()
self.name = 'Player'
self.stoprequest = threading.Event()
self.plyr_ctrls = _plyr_ctrls
self.chan_roles = [0 for i in range(10)]
self.plyr_ctrls['songfile'] = songfile
self.midifile = MidiFile(_save_path + songfile)
# 0 - drum fill
self.counter = [0 for i in range(4)]
self.wt = WolfTonesSong()
self.save_path = _save_path
self.load_song(songfile)
self.alt_meas = []
#get the portname (system specific)
env = socket.gethostname()
if(env == 'record_synth'):
names = str(mido.get_output_names())
ports = names.split(',')
sobj = re.search(r'Synth input port \(\d*:0\)', ports[0], flags=0)
portname = sobj.group()
if(env == 'colinsullivan.me'):
#dummy port for testing on a headless server with no audio
portname = 'Midi Through:Midi Through Port-0 14:0'
self.outport = mido.open_output(portname, autoreset=True)
示例5: command
def command(args):
import mido
ports = mido.get_output_names()
print(len(ports), 'outputs:')
for port in ports:
print('-', port)
示例6: list_ports
def list_ports(self):
""" List MIDI ports """
ports = get_output_names()
if len(ports) < 1:
self.log.error('No open MIDI ports')
sys.exit(1)
print 'Open Ports'
print '----------'
print '\n'.join(ports)
示例7: open_pair
def open_pair(input, output):
if not isinstance(input, mido.ports.BaseInput):
state.inp = mido.open_input([i for i in mido.get_input_names() if i.lower().startswith(input.lower())][0])
else:
state.inp = input
if not isinstance(output, mido.ports.BaseOutput):
state.out = mido.open_output([i for i in mido.get_output_names() if i.lower().startswith(output.lower())][0])
else: state.out = output
setup_threads()
state.metronome = Metronome()
示例8: _open_output
def _open_output(self, port):
if self._out_port is None:
try:
self._out_port = mido.open_output(port)
except IOError:
print "Couldn't open output port '%s'. The following MIDI ports are available:" % port
for p in mido.get_output_names():
print "'%s'" % p
raise
else:
assert self._out_port.name == port
return self._out_port
示例9: __init__
def __init__(self):
port_names = mido.get_output_names()
if not port_names:
raise IndexError("No MIDI output ports found")
if len(port_names) == 1:
idx = 0
logging.info("Choosing MIDI output port %s", port_names[0])
else:
print("MIDI output ports:")
for (idx, name) in enumerate(port_names):
print("{}. {}".format(idx, name))
idx = int(raw_input("Which MIDI output port? "))
assert 0 <= idx < len(port_names)
self.midi_out = mido.open_output(port_names[idx])
示例10: process_appl_cmd
def process_appl_cmd(self, appl_cmd):
cmd_type, payload = appl_cmd
if cmd_type == 'quit':
self.running = False
return "Show application is quitting."
elif cmd_type == 'load':
self.load(payload)
return "Loaded show {}".format(payload)
elif cmd_type == 'save':
self.save(payload)
return "Saved show {}".format(payload)
elif cmd_type == 'list_midi':
return mido.get_output_names()
return None
示例11: __init__
def __init__(self, target=MIDIOUT_DEFAULT):
self.midi = None
self.debug = False
ports = mido.get_output_names()
if len(ports) == 0:
raise Exception("No MIDI output ports found")
for name in ports:
if name == target:
isobar.log("Found MIDI output (%s)" % name)
self.midi = mido.open_output(name)
if self.midi is None:
print "Could not find MIDI target %s, using default" % target
self.midi = mido.open_output()
示例12: main
def main(screen):
main_options = Options()
if main_options.settings['writeinifile']:
main_options.write_options_ini()
quit()
elif main_options.settings['listmidiports']:
print("\nAvailable MIDI ports:")
print("\n".join(mido.get_output_names()))
print("")
quit()
#screen.clear()
midi_receiver = MidiReceiver(main_options)
#screen.refresh()
midi_receiver.start()
示例13: main
def main(unused_argv):
if FLAGS.list:
print "Input ports: '" + "', '".join(mido.get_input_names()) + "'"
print "Output ports: '" + "', '".join(mido.get_output_names()) + "'"
return
if FLAGS.input_port is None or FLAGS.output_port is None:
print '--inport_port and --output_port must be specified.'
return
if (FLAGS.start_capture_control_number == FLAGS.stop_capture_control_number
and
(FLAGS.start_capture_control_value == FLAGS.stop_capture_control_value or
FLAGS.start_capture_control_value is None or
FLAGS.stop_capture_control_value is None)):
print('If using the same number for --start_capture_control_number and '
'--stop_capture_control_number, --start_capture_control_value and '
'--stop_capture_control_value must both be defined and unique.')
return
if not 0 <= FLAGS.metronome_playback_velocity <= 127:
print 'The metronome_playback_velocity must be an integer between 0 and 127'
return
generator = Generator(
FLAGS.generator_name,
FLAGS.num_bars_to_generate,
ast.literal_eval(FLAGS.hparams if FLAGS.hparams else '{}'),
FLAGS.checkpoint)
hub = MonoMidiHub(FLAGS.input_port, FLAGS.output_port)
stdout_write_and_flush('Waiting for start control signal...\n')
while True:
hub.wait_for_control_signal(FLAGS.start_capture_control_number,
FLAGS.start_capture_control_value)
hub.stop_playback()
hub.start_capture(FLAGS.bpm)
stdout_write_and_flush('Capturing notes until stop control signal...')
hub.wait_for_control_signal(FLAGS.stop_capture_control_number,
FLAGS.stop_capture_control_value)
captured_sequence = hub.stop_capture()
stdout_write_and_flush('Generating response...')
generated_sequence = generator.generate_melody(captured_sequence)
stdout_write_and_flush('Done\n')
hub.start_playback(generated_sequence, FLAGS.metronome_playback_velocity)
示例14: __init__
def __init__(self, options):
self.midi_processor = MidiProcessor(options)
if options.settings['midiout']:
if options.settings['outport'] == 'default':
available_ports = mido.get_output_names()
if available_ports:
options.settings['outport'] = available_ports[0]
else:
options.settings['outport'] = ""
if options.settings['outport']:
self.midi_processor.midi_outport = mido.open_output(
options.settings['outport'])
if options.settings['getbeats'] == 'True':
self.beat_finder = BeatFinder(options)
self.beat_finder.midi_processor = self.midi_processor
else:
self.beat_finder = None
if options.settings['gettempo'] == 'True':
self.tempo_finder = TempoFinder(options)
self.tempo_finder.midi_processor = self.midi_processor
else:
self.tempo_finder = None
if options.settings['getrms'] == 'True':
self.rms_finder = RMSFinder(options)
self.rms_finder.midi_processor = self.midi_processor
else:
self.rms_finder = None
if options.settings['getfrequencies'] == 'True':
self.frequencies_finder = FrequenciesFinder(options)
self.frequencies_finder.midi_processor = self.midi_processor
else:
self.frequencies_finder = None
if options.settings['getpitch'] == 'True':
self.pitch_finder = PitchFinder(options)
self.pitch_finder.midi_processor = self.midi_processor
else:
self.pitch_finder = None
if options.settings['inputdevice'] == 'default':
options.settings['inputdevice'] = sd.default.device['input']
self.input_device = options.settings['inputdevice']
self.channels = int(options.settings['channels'])
self.blocksize = int(options.settings['framesize'])
self.samplerate = int(options.settings['samplerate'])
示例15: __init__
def __init__(self):
cmd.Cmd.__init__(self)
print "Color Organist"
print "Using midi port {}.".format(mido.get_output_names()[0])
# TODO: add port selection, mido makes this tricky because it doesn't
# play nicely with threads.
#
#while port is None:
# print "Please select a midi port."
# print str(mido.get_output_names()) + '\n'
# port = readline()
print "Starting empty show."
self.cmd_queue = Queue()
self.resp_queue = Queue()
show = Show(60., self.cmd_queue, self.resp_queue)
self.show_thread = Thread(target=show.run)
self.show_thread.start()
print "Show is running."
self.cmdloop()