• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mido.get_output_names函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mido.get_output_names函数的典型用法代码示例。如果您正苦于以下问题:Python get_output_names函数的具体用法?Python get_output_names怎么用?Python get_output_names使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_output_names函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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!")
开发者ID:sookool99,项目名称:Summer2015,代码行数:33,代码来源:midi_stream.py


示例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))
开发者ID:btbuxton,项目名称:python-midi-gen,代码行数:7,代码来源:display_midi_devices.py


示例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)
开发者ID:neuroidss,项目名称:eegsynth,代码行数:26,代码来源:EEGsynth.py


示例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)
开发者ID:csully220,项目名称:rcrd_synth,代码行数:26,代码来源:player.py


示例5: command

def command(args):
    import mido

    ports = mido.get_output_names()
    print(len(ports), 'outputs:')
    for port in ports:
        print('-', port)
开发者ID:prophile,项目名称:srcomp-unified,代码行数:7,代码来源:list_midi_ports.py


示例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)
开发者ID:robhardwick,项目名称:markovmusic,代码行数:9,代码来源:player.py


示例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()
开发者ID:fwilson42,项目名称:mt2,代码行数:10,代码来源:mt2.py


示例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
开发者ID:arru,项目名称:turbopatch,代码行数:13,代码来源:SysexPatch.py


示例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])
开发者ID:nanotone,项目名称:midihub,代码行数:14,代码来源:midi.py


示例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
开发者ID:generalelectrix,项目名称:color_organist,代码行数:14,代码来源:show.py


示例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()
开发者ID:RocketScienceAbteilung,项目名称:isobar,代码行数:15,代码来源:midi.py


示例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()
开发者ID:williamoverall,项目名称:soundtomidi,代码行数:15,代码来源:standalone_curses.py


示例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)
开发者ID:cooijmanstim,项目名称:magenta,代码行数:47,代码来源:midi.py


示例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'])
开发者ID:williamoverall,项目名称:soundtomidi,代码行数:44,代码来源:soundtomidi.py


示例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()
开发者ID:generalelectrix,项目名称:color_organist,代码行数:19,代码来源:application.py


示例16: main

def main():
    pattern_options = ', '.join(arpeggiators.keys())

    parser = argparse.ArgumentParser()
    parser.add_argument('pattern',
        help='Arpeggiator pattern to apply to notes. options: {}'.format(pattern_options))
    parser.add_argument('bpm', type=int,
        help='Beats Per Minute to run arpeggio.  Notes are played as quarter notes.')
    parser.add_argument('notes', 
        help='Comma separated list of semitones up to an octave above the root (0-12)')
    parser.add_argument('--fakeoutport', dest='fakeoutport', action='store_true',
        help='No output port. Print MIDI messages to console for debugging.')
    args = parser.parse_args()

    # TODO validate
    pattern_name = args.pattern

    notes = [int(note) for note in args.notes.split(',')]

    bpm = args.bpm

    if args.fakeoutport:
        outport = PrintPort()
    else:
        # ask which interface to use
        outputs = mido.get_output_names()
        if len(outputs) < 1:
            sys.stderr.write("Error: No MIDI output interfaces detected.\n")
            exit(errno.ENODEV)

        print "MIDI Output Interfaces:"
        for i, interface in enumerate(outputs):
            print "\t{}) {}".format(i + 1, interface)
        print "Enter the number of the interface your Whammy is connected to:",
        raw_value = raw_input()
        output_index = int(raw_value) - 1
        outport = mido.open_output(outputs[output_index])

    whammy_interface = whammy.WhammyInterface(outport)
    whammy_arp = whammy.WhammyArp(whammy_interface, notes, pattern_name, bpm)

    while (True):
        whammy_arp.play_next_step()
开发者ID:rush340,项目名称:whammy-py,代码行数:43,代码来源:main.py


示例17: initialize_MIDI_inout

def initialize_MIDI_inout():
    """Initialize MIDI input and output ports using RTMIDI through mido

    We will go ahead and initialize all four of the input ports from the MIDIPLUS
    interface, plus the output port to the console.
    """

    # select rtmidi as our backend
    mido.set_backend('mido.backends.rtmidi')
    # print "Backend selected is %s " % mido.backend

    # Enumerate the available port names
    outports = mido.get_output_names()

    # Now try to pick the right port to output on.
    # If we're in the deployed configuration, it's a MIO adapter.
    outport = None
    for name in outports:
        if re.match(r'mio', name):
            try:
                outport = mido.open_output(name)
                break
            except:
                pass

    if not outport:
        print("Unable to open the MIO MIDI output port.")
        sys.exit(1)

    # Now locate the ports of the MIDIPLUS interface and open them for input.
    port_prefix = 'MIDI4x4.*:'
    inports = []
    for port in ('0', '1', '2', '3'):
        inports.append(open_midi_input_port(port_prefix + port))

    if len(inports) != 4:
        print("Unable to open MIDI input ports. Is the MIDIPLUS connected?")
        sys.exit(1)

    return (inports, outport)
开发者ID:OrganDonor,项目名称:Organelle,代码行数:40,代码来源:gui-play-midi.py


示例18: initialize_MIDI_out

def initialize_MIDI_out():
    """Initialize a MIDI output port using RTMIDI through mido
    """

    # select rtmidi as our backend
    mido.set_backend('mido.backends.rtmidi')
    # print "Backend selected is %s " % mido.backend

    # Enumerate the available port names
    outports = mido.get_output_names()

    # Now try to pick the right port to output on.
    # If we're in the deployed configuration, it's a MIO adapter, but
    # if we're in the lab, it might be something else.
    # In either event, there might be more than one matching adapter!
    # In that case, we'll punt and take the first one we find.
    out = None
    for name in outports:
        if re.match(r'mio', name):
            try:
                out = mido.open_output(name)
                break
            except:
                pass

    if not out:
        for name in outports:
            try:
                out = mido.open_output(name)
                break
            except:
                pass

    if not out:
        print("Sorry, unable to open any MIDI output port.")
        sys.exit(1)

    return out
开发者ID:OrganDonor,项目名称:Organelle,代码行数:38,代码来源:autoplay.py


示例19: select_midi_output_port

 def select_midi_output_port(self):
     acc = []
     for p in mido.get_output_names():
         acc.append(p)
     while True:
         print()
         mrn = self.config["midi-transmitter-name"]
         for n, p in enumerate(acc):
             print("    [%d] %s" % (n+1, p))
         print()
         print("\nPress [Enter] to select default")
         usr = infn("Select MIDI output port (%s) > " % mrn)
         if not usr: break
         try:
             n = int(usr)
             if 0 < n <= len(acc):
                 mrn = acc[n-1]
                 self.config["midi-transmitter-name"] = mrn
                 break
             else:
                 raise ValueError()
         except ValueError:
             print("ERROR")                
开发者ID:kaos,项目名称:Llia,代码行数:23,代码来源:splash.py


示例20: print_ports

#!/usr/bin/env python
"""
List available PortMidi ports.
"""

from __future__ import print_function
import sys
import mido

def print_ports(heading, port_names):
    print(heading)
    for name in port_names:
        print("    '{}'".format(name))
    print()

print()
print_ports('Input Ports:', mido.get_input_names())
print_ports('Output Ports:', mido.get_output_names())
开发者ID:EasonSun,项目名称:mido,代码行数:18,代码来源:list_ports.py



注:本文中的mido.get_output_names函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mido.open_input函数代码示例发布时间:2022-05-27
下一篇:
Python MidiFile.MIDIFile类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap