1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2008 Andreas Persson * |
* Copyright (C) 2008 - 2010 Andreas Persson * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
165 |
hJackClient = pJackClient->hJackClient; |
hJackClient = pJackClient->hJackClient; |
166 |
existingJackDevices++; |
existingJackDevices++; |
167 |
|
|
168 |
AcquirePorts(((DeviceCreationParameterInt*)Parameters["PORTS"])->ValueAsInt()); |
AcquirePorts(((DeviceCreationParameterInt*)Parameters["PORTS"])->ValueAsInt()); |
169 |
if (((DeviceCreationParameterBool*)Parameters["ACTIVE"])->ValueAsBool()) { |
if (((DeviceCreationParameterBool*)Parameters["ACTIVE"])->ValueAsBool()) { |
170 |
Listen(); |
Listen(); |
171 |
} |
} |
172 |
} |
} |
173 |
|
|
174 |
MidiInputDeviceJack::~MidiInputDeviceJack() { |
MidiInputDeviceJack::~MidiInputDeviceJack() { |
182 |
Ports.clear(); |
Ports.clear(); |
183 |
|
|
184 |
JackClient::ReleaseMidi(((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString()); |
JackClient::ReleaseMidi(((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString()); |
185 |
existingJackDevices--; |
existingJackDevices--; //FIXME: this is too simple, can lead to multiple clients with the same name |
186 |
} |
} |
187 |
|
|
188 |
MidiInputDeviceJack::MidiInputPortJack* MidiInputDeviceJack::CreateMidiPort() { |
MidiInputDeviceJack::MidiInputPortJack* MidiInputDeviceJack::CreateMidiPort() { |
210 |
} |
} |
211 |
|
|
212 |
String MidiInputDeviceJack::Version() { |
String MidiInputDeviceJack::Version() { |
213 |
String s = "$Revision: 1.1 $"; |
String s = "$Revision: 1.5 $"; |
214 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
215 |
} |
} |
216 |
|
|
225 |
#else |
#else |
226 |
int event_count = jack_midi_get_event_count(port_buffer); |
int event_count = jack_midi_get_event_count(port_buffer); |
227 |
#endif |
#endif |
228 |
for (int i = 0 ; i < event_count ; i++) |
for (int i = 0 ; i < event_count ; i++) { |
|
{ |
|
229 |
jack_midi_event_t ev; |
jack_midi_event_t ev; |
230 |
#if JACK_MIDI_FUNCS_NEED_NFRAMES |
#if JACK_MIDI_FUNCS_NEED_NFRAMES |
231 |
jack_midi_event_get(&ev, port_buffer, i, nsamples); // old jack version |
jack_midi_event_get(&ev, port_buffer, i, nsamples); // old jack version |
232 |
#else |
#else |
233 |
jack_midi_event_get(&ev, port_buffer, i); |
jack_midi_event_get(&ev, port_buffer, i); |
234 |
#endif |
#endif |
235 |
uint8_t* data = ev.buffer; |
if (ev.buffer) { // jack2 1.9.5 has been seen sending NULL here |
236 |
uint8_t channel = data[0] & 0x0f; |
port->DispatchRaw(ev.buffer, ev.time); |
|
switch (data[0] & 0xf0) { |
|
|
case 0xb0: |
|
|
if (data[1] == 0) { |
|
|
port->DispatchBankSelectMsb(data[2], channel); |
|
|
} else if (data[1] == 32) { |
|
|
port->DispatchBankSelectLsb(data[2], channel); |
|
|
} else { |
|
|
port->DispatchControlChange(data[1], data[2], channel, ev.time); |
|
|
} |
|
|
break; |
|
|
|
|
|
case 0xd0: |
|
|
port->DispatchControlChange(128, data[1], channel, ev.time); |
|
|
break; |
|
|
|
|
|
case 0xe0: |
|
|
port->DispatchPitchbend(data[1], channel, ev.time); |
|
|
break; |
|
|
|
|
|
case 0x90: |
|
|
if (data[2]) { |
|
|
port->DispatchNoteOn(data[1], data[2], channel, ev.time); |
|
|
} else { |
|
|
port->DispatchNoteOff(data[1], data[2], channel, ev.time); |
|
|
} |
|
|
break; |
|
|
|
|
|
case 0x80: |
|
|
port->DispatchNoteOff(data[1], data[2], channel, ev.time); |
|
|
break; |
|
|
|
|
|
case 0xc0: |
|
|
port->DispatchProgramChange(data[1], channel); |
|
|
break; |
|
237 |
} |
} |
238 |
} |
} |
239 |
} |
} |