當前位置: 首頁>>代碼示例>>Python>>正文


Python mido.get_output_names方法代碼示例

本文整理匯總了Python中mido.get_output_names方法的典型用法代碼示例。如果您正苦於以下問題:Python mido.get_output_names方法的具體用法?Python mido.get_output_names怎麽用?Python mido.get_output_names使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mido的用法示例。


在下文中一共展示了mido.get_output_names方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send_clock

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def send_clock():
  # We find the proper input port for the software synth
  # (which is the output port for Magenta)
  output_ports = [name for name in mido.get_output_names()
                  if args.midi_port in name]
  if not output_ports:
    raise Exception(f"Cannot find proper output ports in: "
                    f"{mido.get_output_names()}")
  print(f"Sending clock to output port names: {output_ports}")

  # Start a new MIDI hub on that port (output only)
  midi_hub = MidiHub(input_midi_ports=[],
                     output_midi_ports=output_ports,
                     texture_type=None)
  outport = midi_hub._outport

  # Starts the metronome at 120 QPM
  metronome = Metronome(outport, 120)
  metronome.start()

  # Waits for 16 seconds and send the stop command
  metronome.join(timeout=16)
  metronome.stop()

  return 0 
開發者ID:PacktPublishing,項目名稱:hands-on-music-generation-with-magenta,代碼行數:27,代碼來源:chapter_09_example_04.py

示例2: get_available_output_ports

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def get_available_output_ports():
  """Returns a list of available output MIDI ports."""
  return mido.get_output_names() 
開發者ID:magenta,項目名稱:magenta,代碼行數:5,代碼來源:midi_hub.py

示例3: __init__

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def __init__(self):
        self.Window = None
        self.TextElem = None
        self.PortList = mido.get_output_names()        # use to get the list of midi ports
        self.PortList = self.PortList[::-1]            # reverse the list so the last one is first

    # ---------------------------------------------------------------------- #
    #  PlayerChooseSongGUI                                                   #
    #   Show a GUI get to the file to playback                               #
    # ---------------------------------------------------------------------- # 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:12,代碼來源:Demo_MIDI_Player.py

示例4: __init__

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def __init__(self):
        self.Window = None
        self.TextElem = None
        # use to get the list of midi ports
        self.PortList = mido.get_output_names()
        # reverse the list so the last one is first
        self.PortList = self.PortList[::-1]

    # ---------------------------------------------------------------------- #
    #  PlayerChooseSongGUI                                                   #
    #   Show a GUI get to the file to playback                               #
    # ---------------------------------------------------------------------- # 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:14,代碼來源:Demo_MIDI_Player.py

示例5: find_midi_ports

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def find_midi_ports():
  print(f"Input ports: {mido.get_input_names()}")
  print(f"Output ports: {mido.get_output_names()}") 
開發者ID:PacktPublishing,項目名稱:hands-on-music-generation-with-magenta,代碼行數:5,代碼來源:chapter_09_example_01.py

示例6: configure_midi_out

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def configure_midi_out(self):
        if self.midi_out_port is None:
            port_name_to_use = None
            for port_name in mido.get_output_names():
                if is_push_midi_out_port_name(port_name, use_user_port=self.use_user_midi_port):
                    port_name_to_use = port_name
                    break
                    
            if port_name_to_use is None:
                raise Push2MIDIeviceNotFound
            
            try:
                self.midi_out_port = mido.open_output(port_name_to_use)
            except OSError as e:
                raise Push2MIDIeviceNotFound 
開發者ID:ffont,項目名稱:push2-python,代碼行數:17,代碼來源:__init__.py

示例7: __init__

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def __init__(self, device, deviceid):
        self.log = get_logger("midi_to_obs_device")
        self._id = deviceid
        self._devicename = device["devicename"]
        self._port_in = 0
        self._port_out = 0

        try:
            self.log.debug("Attempting to open midi port `%s`" % self._devicename)
            # a device can be input, output or ioport. in the latter case it can also be the other two
            # so we first check if we can use it as an ioport
            if self._devicename in mido.get_ioport_names():
                self._port_in = mido.open_ioport(name=self._devicename, callback=self.callback, autoreset=True)
                self._port_out = self._port_in
            # otherwise we try to use it separately as input and output
            else:
                if self._devicename in mido.get_input_names():
                    self._port_in = mido.open_input(name=self._devicename, callback=self.callback)
                if self._devicename in mido.get_output_names():
                    self._port_out = mido.open_output(name=self._devicename, callback=self.callback, autoreset=True)
        except:
            self.log.critical("\nCould not open device `%s`" % self._devicename)
            self.log.critical("The midi device might be used by another application/not plugged in/have a different name.")
            self.log.critical("Please close the device in the other application/plug it in/select the rename option in the device management menu and restart this script.")
            self.log.critical("Currently connected devices:")
            for name in mido.get_input_names():
                self.log.critical("  - %s" % name)
            # EIO 5 (Input/output error)
            exit(5) 
開發者ID:lebaston100,項目名稱:MIDItoOBS,代碼行數:31,代碼來源:main.py

示例8: _start

# 需要導入模塊: import mido [as 別名]
# 或者: from mido import get_output_names [as 別名]
def _start():
    """Start the module
    This uses the global variables from setup and adds a set of global variables
    """
    global parser, args, config, r, response, patch, name
    global monitor, debug, mididevice, outputport, lock, trigger, port, channel, previous_val, previous_port_val

    # this can be used to show parameters that have changed
    monitor = EEGsynth.monitor(name=name, debug=patch.getint('general', 'debug'))

    # get the options from the configuration file
    debug = patch.getint('general', 'debug')
    mididevice = patch.getstring('midi', 'device')
    mididevice = EEGsynth.trimquotes(mididevice)
    mididevice = process.extractOne(mididevice, mido.get_output_names())[0]  # select the closest match

    # this is only for debugging, check which MIDI devices are accessible
    monitor.info('------ OUTPUT ------')
    for port in mido.get_output_names():
        monitor.info(port)
    monitor.info('-------------------------')

    try:
        outputport = mido.open_output(mididevice)
        monitor.success('Connected to MIDI output')
    except:
        raise RuntimeError("cannot connect to MIDI output")

    # this is to prevent two messages from being sent at the same time
    lock = threading.Lock()

    # each of the gates that can be triggered is mapped onto a different message
    trigger = []
    for channel in range(0, 16):

        # channels are one-offset in the ini file, zero-offset in the code
        name = 'channel{}'.format(channel + 1)
        if config.has_option('gate', name):

            # start the background thread that deals with this channel
            this = TriggerThread(patch.getstring('gate', name), channel)
            trigger.append(this)
            monitor.debug(name + ' trigger configured')

    # start the thread for each of the notes
    for thread in trigger:
        thread.start()

    # control values are only relevant when different from the previous value
    previous_val = {}
    previous_port_val = {}
    for channel in range(0, 16):
        name = 'channel{}'.format(channel + 1)
        previous_val[name] = None
        previous_port_val[name] = None

    # there should not be any local variables in this function, they should all be global
    if len(locals()):
        print("LOCALS: " + ", ".join(locals().keys())) 
開發者ID:eegsynth,項目名稱:eegsynth,代碼行數:61,代碼來源:endorphines.py


注:本文中的mido.get_output_names方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。