def __init__(self, clientport, verbose_init): SynthCommon.__init__(self) self.m_type_major = "ALSA" self.m_sequencer = alsaseq.Sequencer(name='default', clientname=self.name, streams=alsaseq.SEQ_OPEN_OUTPUT, mode=alsaseq.SEQ_NONBLOCK) if verbose_init: print("clientport:", clientport) print("Sequencer", self.m_sequencer) print("\tname:", self.m_sequencer.name) print("\tclientname", self.m_sequencer.clientname) print("\tstreams: %d (%s)" % (self.m_sequencer.streams, str(self.m_sequencer.streams))) print("\tmode: %d (%s)" % (self.m_sequencer.mode, str(self.m_sequencer.mode))) print("\tclient_id: %s" % self.m_sequencer.client_id) self.m_port = self.m_sequencer.create_simple_port( name=self.name, type=alsaseq.SEQ_PORT_TYPE_MIDI_GENERIC | alsaseq.SEQ_PORT_TYPE_APPLICATION, caps=alsaseq.SEQ_PORT_CAP_NONE) self.m_queue = self.m_sequencer.create_queue(name=self.name) self.m_clientport = clientport self.m_sequencer.connect_ports( (self.m_sequencer.client_id, self.m_port), clientport)
def __init__(self, name): self.seq = alsaseq.Sequencer(clientname=name) self.intput = self.seq.create_simple_port( 'Midi Input', SEQ_PORT_TYPE_APPLICATION, SEQ_PORT_CAP_WRITE | SEQ_PORT_CAP_SUBS_WRITE, ) self.ports = {}
def __init__(self, parent=None): QThread.__init__(self, parent) self.bridge = Bridge() self.counter = 0 self.counter2 = 0 self.seq = alsaseq.Sequencer() self.evnt = {'type': "", 'param': "", 'value': ""} self.seq.create_simple_port( "topot_reader", alsaseq.SEQ_PORT_TYPE_APPLICATION, alsaseq.SEQ_PORT_CAP_SUBS_WRITE | alsaseq.SEQ_PORT_CAP_WRITE)
def __init__(self, Midi_Port_Name='Nano Basket MIDI 1'): self.Seq = alsaseq.Sequencer(clientname='Nano Basket') self.Event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_SYSEX) self.Controller = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_CONTROLLER) self.Port = self.Seq.create_simple_port(name=Midi_Port_Name, type=alsaseq.SEQ_PORT_TYPE_APPLICATION, caps=alsaseq.SEQ_PORT_CAP_SUBS_READ | \ alsaseq.SEQ_PORT_CAP_READ | \ alsaseq.SEQ_PORT_CAP_WRITE | \ alsaseq.SEQ_PORT_CAP_SUBS_WRITE) self.Response_Wait = 0.2
def get_connection_list(): sequencer = alsaseq.Sequencer(name = 'default', clientname = "solfege-alsa.py", streams = alsaseq.SEQ_OPEN_OUTPUT, mode = alsaseq.SEQ_NONBLOCK) retval = [] clientports = sequencer.connection_list() for connections in clientports: clientname, clientid, connectedports = connections for port in connectedports: portname, portid, connections = port portinfo = sequencer.get_port_info(portid, clientid) type = portinfo['type'] caps = portinfo['capability'] if (type & alsaseq.SEQ_PORT_TYPE_MIDI_GENERIC or type & alsaseq.SEQ_PORT_TYPE_APPLICATION) and \ caps & (alsaseq.SEQ_PORT_CAP_WRITE | alsaseq.SEQ_PORT_CAP_SUBS_WRITE): retval.append((clientid, portid, clientname, portname, u"%i:%i %s %s" % (clientid, portid, clientname, portname))) return retval
def __init__(self, name, connect=False): self.seq = alsaseq.Sequencer(clientname=name, streams=alsaseq.SEQ_OPEN_OUTPUT, mode=alsaseq.SEQ_BLOCK) self.outq = self.seq.create_queue() self.inq = Queue.Queue() self.velocity = {} # map instr_id -> key velocity self.cid, self.pid = 0, 0 if connect: for cname, cid, ports in self.seq.connection_list(): if cname == 'TiMidity': pname, pid, pconns = ports[0] print 'Found timidity at %d:%d' % (cid, pid) #self.seq.connect_ports((self.cid, self.port), # (cid, pid)) self.cid = cid self.pid = pid if self.cid == 0: self.pid = self.seq.create_simple_port( 'out', alsaseq.SEQ_PORT_TYPE_APPLICATION, alsaseq.SEQ_PORT_CAP_READ | alsaseq.SEQ_PORT_CAP_SUBS_READ) self.cid = self.seq.client_id
def __init__(self, main): QtCore.QObject.__init__(self) self.main = main self.type = ALSA self.active = False self.sysex_buffer = [] self.seq = alsaseq.Sequencer(clientname='Bigglesworth') self.keep_going = True input_id = self.seq.create_simple_port( name='input', type=alsaseq.SEQ_PORT_TYPE_MIDI_GENERIC | alsaseq.SEQ_PORT_TYPE_APPLICATION, caps=alsaseq.SEQ_PORT_CAP_WRITE | alsaseq.SEQ_PORT_CAP_SUBS_WRITE | alsaseq.SEQ_PORT_CAP_SYNC_WRITE) output_id = self.seq.create_simple_port( name='output', type=alsaseq.SEQ_PORT_TYPE_MIDI_GENERIC | alsaseq.SEQ_PORT_TYPE_APPLICATION, caps=alsaseq.SEQ_PORT_CAP_READ | alsaseq.SEQ_PORT_CAP_SUBS_READ | alsaseq.SEQ_PORT_CAP_SYNC_READ) self.seq.connect_ports( (alsaseq.SEQ_CLIENT_SYSTEM, alsaseq.SEQ_PORT_SYSTEM_ANNOUNCE), (self.seq.client_id, input_id)) # self.seq.connect_ports((16, 0), (self.seq.client_id, input_id)) # self.seq.connect_ports((self.seq.client_id, output_id), (130, 0)) # self.seq.connect_ports((self.seq.client_id, output_id), (132, 0)) self.graph = self.main.graph = Graph(self.seq) # self.graph.client_start.connect(self.client_start) # self.graph.client_exit.connect(self.client_exit) # self.graph.port_start.connect(self.port_start) # self.graph.port_exit.connect(self.port_exit) self.graph.conn_register.connect(self.conn_register) self.id = self.seq.client_id self.input = self.graph.port_id_dict[self.id][input_id] self.output = self.graph.port_id_dict[self.id][output_id]
THRESHOLD = 200 WIDTH = 320 HEIGHT = 240 NOTE_OFFSET = 47 VELOCITY = 90 import sys, math import cv from pyalsa import alsaseq seq = alsaseq.Sequencer(name="default", clientname=sys.argv[0], streams=alsaseq.SEQ_OPEN_DUPLEX, mode=alsaseq.SEQ_NONBLOCK) port = seq.create_simple_port(name='out', type=alsaseq.SEQ_PORT_TYPE_MIDI_GENERIC | alsaseq.SEQ_PORT_TYPE_APPLICATION, caps=alsaseq.SEQ_PORT_CAP_READ | alsaseq.SEQ_PORT_CAP_SUBS_READ) def note(n, state=False): if state: etype = alsaseq.SEQ_EVENT_NOTEON else: etype = alsaseq.SEQ_EVENT_NOTEOFF event = alsaseq.SeqEvent(type=etype) event.set_data({'note.channel': 0, 'note.note': n, 'note.velocity': 90})
def __init__(self, app_name, main_window): self.factory = MidiEventFactory() CCMidiEvent.register_event_type_builder() CCMidiEvent.register(self.one_parameter_cc_callback) PrgChangeEvent.register_event_type_builder() PrgChangeEvent.register(self.program_change_callback) JStationSysexEvent.register_event_type_builder() BankDumpRequest.register() EndBankDumpResponse.register(self.end_bank_dump_callback) NotifyStore.register(self.notify_store_callback) NotifyUtility.register(self.notify_utility_callback) OneProgramRequest.register() OneProgramResponse.register(self.one_program_callback) PRGIndicesRequest.register() PRGIndicesResponse.register(self.program_indices_callback) ReceiveProgramUpdate.register(self.program_update_response) ReloadProgram.register() RequestProgramUpdate.register() StartBankDumpResponse.register(self.default_event_callback) ToMessageResponse.register(self.response_to_message_callback) UtilitySettingsRequest.register() UtilitySettingsResponse.register(self.utility_settings_callback) WhoAmIRequest.register(self.who_am_i_callback_req) WhoAmIResponse.register(self.who_am_i_callback) self.is_connected = False self.is_disconnecting = Event() self.is_response_received_cndt = Condition() self.receive_channel = -1 self.sysex_channel = -1 self.js_port_in = None self.js_port_out = None self.jstation_wait_for_events_thread = None self.main_window = main_window self.is_disconnecting.clear() self.seq = alsaseq.Sequencer('hw', app_name, alsaseq.SEQ_OPEN_DUPLEX, alsaseq.SEQ_NONBLOCK, 1) if self.seq == None: print('Error while opening sequencer') exit(1) self.get_clients() self.port_out = self.seq.create_simple_port( 'Output', alsaseq.SEQ_PORT_CAP_READ | alsaseq.SEQ_PORT_CAP_SUBS_READ) self.port_in = self.seq.create_simple_port( 'Input', alsaseq.SEQ_PORT_TYPE_APPLICATION, alsaseq.SEQ_PORT_CAP_WRITE | alsaseq.SEQ_PORT_CAP_SUBS_WRITE)
s += '\n'.join(client) s += '\n' elif output: s = 'Output clients:\n' for client in c_output: if len(client) > 1: s += '\n'.join(client) s += '\n' else: s = 'Input clients:\n' for client in c_input: if len(client) > 1: s += '\n'.join(client) s += '\n' print s @property def client_name_dict(self): name_dict = {} for client_id, client in self.client_id_dict.items(): name_l = name_dict.get(client.name, []) name_l.append(client_id) name_dict[client.name] = name_l return name_dict if __name__ == '__main__': seq = alsaseq.Sequencer(clientname='lister') g = Graph(seq) g.graph_full(True, True)