def ports(cls): print >> sys.stderr, "Available sources:" print >> sys.stderr, " " + "\n ".join([s.name for s in MIDISource.list()]) print >> sys.stderr, "" print >> sys.stderr, "Available destinations:" print >> sys.stderr, " " + "\n ".join([d.name for d in MIDIDestination.list()]) return 1
def ports(cls): print >> sys.stderr, "Available sources:" print >> sys.stderr, " " + "\n ".join( [s.name for s in MIDISource.list()]) print >> sys.stderr, "" print >> sys.stderr, "Available destinations:" print >> sys.stderr, " " + "\n ".join( [d.name for d in MIDIDestination.list()]) return 1
def find_endpoints(self, source_substring, destination_substring): sources = [s for s in MIDISource.list() if s.name.find(source_substring) != -1] if sources: self.source = sources[0] logger.info("Using \"%s\" as the midi source" % self.source.name) else: raise EndpointError("Unable to find a source with a substring of %s" % source_substring) destinations = [s for s in MIDIDestination.list() if s.name.find(destination_substring) != -1] if destinations: self.destination = destinations[0] logger.info("Using \"%s\" as the midi destination" % self.destination.name) else: raise EndpointError("Unable to find a destination with a substring of %s" % destination_substring)
def find_endpoints(self, source_substring, destination_substring): sources = [ s for s in MIDISource.list() if s.name.find(source_substring) != -1 ] if sources: self.source = sources[0] logger.info("Using \"%s\" as the midi source" % self.source.name) else: raise EndpointError( "Unable to find a source with a substring of %s" % source_substring) destinations = [ s for s in MIDIDestination.list() if s.name.find(destination_substring) != -1 ] if destinations: self.destination = destinations[0] logger.info("Using \"%s\" as the midi destination" % self.destination.name) else: raise EndpointError( "Unable to find a destination with a substring of %s" % destination_substring)
import os.path import sys __dir__ = os.path.dirname(__file__) sys.path.append(os.path.join(__dir__, '..')) from simplecoremidi import MIDIDestination, MIDISource, NoteOnMessage, NoteOffMessage from time import sleep NOTE_ON = 0x90 channel = 1 MIDDLE_C = 60 for d in MIDIDestination.list(): print("send message to %s" % d.name) d.send(NoteOnMessage(channel, MIDDLE_C, 127)) sleep(1) d.send(NoteOffMessage(channel, MIDDLE_C).asNoteOn()) while (True): for s in MIDISource.list(): message = s.receive(timeout=2) if message == None: sys.stdout.write('.') else: print (s.name, str(message))
import os.path import sys __dir__ = os.path.dirname(__file__) sys.path.append(os.path.join(__dir__, '..')) from simplecoremidi import MIDIDestination, MIDISource, NoteOnMessage, NoteOffMessage from time import sleep NOTE_ON = 0x90 channel = 1 MIDDLE_C = 60 for d in MIDIDestination.list(): print("send message to %s" % d.name) d.send(NoteOnMessage(channel, MIDDLE_C, 127)) sleep(1) d.send(NoteOffMessage(channel, MIDDLE_C).asNoteOn()) while (True): for s in MIDISource.list(): message = s.receive(timeout=2) if message == None: sys.stdout.write('.') else: print(s.name, str(message))