当前位置: 首页>>代码示例>>Python>>正文


Python mido.get_input_names方法代码示例

本文整理汇总了Python中mido.get_input_names方法的典型用法代码示例。如果您正苦于以下问题:Python mido.get_input_names方法的具体用法?Python mido.get_input_names怎么用?Python mido.get_input_names使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mido的用法示例。


在下文中一共展示了mido.get_input_names方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def __init__(self):
        self.pending_queue = []
    
        ports = mido.get_input_names()
        try:
            for port in ports:
                if "Through" not in port and "RPi" not in port and "RtMidOut" not in port and "USB-USB" not in port:
                    self.inport =  mido.open_input(port)
                    print("Inport set to "+port)
        except:
            print ("no input port")
        try:            
            for port in ports:
                if "Through" not in port and "RPi" not in port and "RtMidOut" not in port and "USB-USB" not in port:
                    self.playport =  mido.open_output(port)
                    print("playport set to "+port)
        except:
            print("no playback port")
            
        self.portname = "inport" 
开发者ID:onlaj,项目名称:Piano-LED-Visualizer,代码行数:22,代码来源:visualizer.py

示例2: configure_midi_in

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def configure_midi_in(self):
        if self.midi_in_port is None:
            port_name_to_use = None
            for port_name in mido.get_input_names():
                if is_push_midi_in_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_in_port = mido.open_input(port_name_to_use)
                # Disable Active Sense message filtering so we can receive those messages comming from Push and
                # detect if Push MIDI gets disconnected
                self.midi_in_port._rt.ignore_types(False, False, False)
                self.midi_in_port.callback = self.on_midi_message
            except OSError as e:
                raise Push2MIDIeviceNotFound 
开发者ID:ffont,项目名称:push2-python,代码行数:21,代码来源:__init__.py

示例3: messages

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def messages(self):
        if not mido:
            raise ValueError(MIDO_ERROR)
        try:
            input_names = mido.get_input_names()
        except AttributeError as e:
            e.args = (MIDO_ERROR,) + e.args
            raise

        ports = [mido.open_input(i) for i in input_names]

        if not ports:
            log.error('control.midi: no MIDI ports found')
            return

        port_names = ', '.join('"%s"' % p.name for p in ports)
        log.info('Starting to listen for MIDI on port%s %s',
                 '' if len(ports) == 1 else 's', port_names)
        for port, msg in mido.ports.multi_receive(ports, yield_ports=True):
            mdict = dict(vars(msg), port=port)

            if self.use_note_off:
                if msg.type == 'note_on' and not msg.velocity:
                    mdict.update(type='note_off')
            elif self.use_note_off is False:
                if msg.type == 'note_off':
                    mdict.update(type='note_on', velocity=0)

            yield mdict 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:31,代码来源:midi.py

示例4: midi

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def midi():
        import mido
        return set(mido.get_input_names()) - MIDI_PORTS_TO_REMOVE 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:5,代码来源:features.py

示例5: open_this_port_and_start_listening

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def open_this_port_and_start_listening(self, port_phrase):
        midi_ports = mido.get_input_names()
        midi_device_on_port = [s for s in midi_ports if port_phrase in s]
        if midi_device_on_port:
            if self.data.midi_status == 'disconnected':
                subport_index = self.port_index % len(midi_device_on_port) 
                self.midi_device = mido.open_input(midi_device_on_port[subport_index])
                self.data.midi_status = 'connected'
                self.message_handler.set_message('INFO', 'connected to midi device {}'.format(self.midi_device.name))
                self.poll_midi_input()
        elif self.data.midi_status == 'connected':
            self.data.midi_status = 'disconnected' 
开发者ID:langolierz,项目名称:r_e_c_u_r,代码行数:14,代码来源:midi_input.py

示例6: get_available_input_ports

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def get_available_input_ports():
  """Returns a list of available input MIDI ports."""
  return mido.get_input_names() 
开发者ID:magenta,项目名称:magenta,代码行数:5,代码来源:midi_hub.py

示例7: _start

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_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, output_scale, output_offset, port, inputport

    # 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)

    # the scale and offset are used to map MIDI values to Redis values
    output_scale = patch.getfloat('output', 'scale', default=1. / 127)  # MIDI values are from 0 to 127
    output_offset = patch.getfloat('output', 'offset', default=0.)    # MIDI values are from 0 to 127

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

    try:
        inputport = mido.open_input(mididevice)
        monitor.success('Connected to MIDI input')
    except:
        raise RuntimeError("Cannot connect to MIDI input")

    # 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,代码行数:36,代码来源:inputmidi.py

示例8: find_midi_ports

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_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

示例9: update_ports

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def update_ports(self):
        ports = mido.get_input_names()
        self.update_sequence_list()
        for port in ports:            
            element = self.DOMTree.createElement("Input")
            element.appendChild(self.DOMTree.createTextNode(""))
            element.setAttribute("text"  , port)
            mc = self.DOMTree.getElementsByTagName("Ports_Settings")[0]
            mc.appendChild(element)

            element = self.DOMTree.createElement("Playback")
            element.appendChild(self.DOMTree.createTextNode(""))
            element.setAttribute("text"  , port)
            mc = self.DOMTree.getElementsByTagName("Ports_Settings")[2]
            mc.appendChild(element) 
开发者ID:onlaj,项目名称:Piano-LED-Visualizer,代码行数:17,代码来源:visualizer.py

示例10: __init__

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_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

示例11: renameDevice

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def renameDevice():
    devices = devdb.all()
    counter = 0
    print("Please select a device for your configuration that you want to \"rename\" to another device:")
    for (index, device) in enumerate(devices):
        print("%s: %s" % (counter, device["devicename"]))
        counter += 1
    old_device_select = int(input("Select 0-%s: " % str(len(devices)-1)))
    old_device_name = devices[old_device_select]["devicename"]
    print("Selected:", old_device_name)
    print("Please select the new device name now:")
    availableDeviceList = mido.get_input_names()
    deviceList = []
    for device in availableDeviceList:
            if devInDB(device, devices):
                pass
            else:
                deviceList.append(device)
    if len(deviceList) > 0:
        counter = 0
        for (index, device) in enumerate(deviceList):
            print("%s: %s" % (counter, device))
            counter += 1
        new_device_select = int(input("Select 0-%s: " % str(len(deviceList)-1)))
        new_device_name = deviceList[new_device_select]
        print("Selected:", new_device_name, "as the new device name")
        print("Updating \"", old_device_name, "\" to \"", new_device_name, "\" now", sep="")
        try:
            devdb.update({"devicename": new_device_name}, Query().devicename == old_device_name)
            print("Sucessfully renamed the device")
        except:
            print("There was an error renaming the device")
    else:
        print("There is no other device available to switch over to. Aborting...") 
开发者ID:lebaston100,项目名称:MIDItoOBS,代码行数:36,代码来源:setup.py

示例12: configureDevices

# 需要导入模块: import mido [as 别名]
# 或者: from mido import get_input_names [as 别名]
def configureDevices(switch):
    dbresult = devdb.all()
    if switch:
        print("\nTell me: What do you want to do?\n1: Rename a device and transfer their action assignments (because you plugged it into another USB port and windows decided to give the device a new name now)\n2: Delete all devices from config and re-add (Warning: this will dereference all button and fader actions(so they will no longer work). This might cause device confusion later.\n3: Remove a single device from the configuration INCLUDING their midi assignments\n4: Add new device\n5: Skip device configuration (Warning: If no device has been configured before, MIDItoOBS will NOT work)")
        action_select = int(input("Select 1-4: "))
        if action_select == 1:
            renameDevice()
            return
        elif action_select == 2:
            print("Removing all devices from the database....")
            devdb.purge() #purge database table before adding new devices
        elif action_select == 3:
            removeDevice()
            return
        elif action_select == 4:
            pass
        else:
            return
    
    print("\nWhich device do you want to add?")
    exitflag = 0
    while not exitflag:
        availableDeviceList = mido.get_input_names()
        deviceList = []
        counter = 0
        inUseDeviceList = devdb.all()
        for device in availableDeviceList:
            if devInDB(device, inUseDeviceList):
                pass
            else:
                print("%s: %s" % (counter, device))
                counter += 1
                deviceList.append(device)
            
        if len(deviceList) == 0:
            print("No midi input device available")
            return
        if len(deviceList) < 2:
            input_select = int(input("Select 0: "))
        else:
            input_select = int(input("Select 0-%s: " % str(len(deviceList)-1)))
        print("Adding:", deviceList[input_select])
        result = devdb.search(Query().devicename == deviceList[input_select])
        if not result:
            deviceID = devdb.insert({"devicename": deviceList[input_select]})
        print("Do you want to add another device?\n1: Yes\n2: No")
        action_select = int(input("Select 1 or 2: "))
        if action_select == 2:
            exitflag = 1 
开发者ID:lebaston100,项目名称:MIDItoOBS,代码行数:51,代码来源:setup.py


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