1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2004, 2005 Grame * |
* Copyright (C) 2004, 2005 Grame * |
4 |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
* Copyright (C) 2005 - 2009 Christian Schoenebeck * |
5 |
* * |
* * |
6 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
7 |
* 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 * |
65 |
MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::MidiInputPortCoreMidi(MidiInputDeviceCoreMidi* pDevice) throw (MidiInputException) : MidiInputPort(pDevice, -1) { |
MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::MidiInputPortCoreMidi(MidiInputDeviceCoreMidi* pDevice) throw (MidiInputException) : MidiInputPort(pDevice, -1) { |
66 |
// create CoreMidi virtual destination |
// create CoreMidi virtual destination |
67 |
|
|
68 |
MIDIDestinationCreate(pDevice->hCoreMidiClient, CFSTR("LinuxSampler_in"), ReadProc, this, &pDestination); |
/* 20080105 Toshi Nagata */ |
69 |
|
char buf[32]; |
70 |
|
CFStringRef str; |
71 |
|
snprintf(buf, sizeof buf, "LinuxSampler_in_%d", pPortID); |
72 |
|
str = CFStringCreateWithCString(NULL, buf, kCFStringEncodingUTF8); |
73 |
|
MIDIDestinationCreate(pDevice->hCoreMidiClient, str, ReadProc, this, &pDestination); |
74 |
|
/* */ |
75 |
|
|
76 |
if (!pDestination) throw MidiInputException("Error creating CoreMidi virtual destination"); |
if (!pDestination) throw MidiInputException("Error creating CoreMidi virtual destination"); |
77 |
this->portNumber = pPortID++; |
this->portNumber = pPortID++; |
78 |
|
|
91 |
|
|
92 |
for (unsigned int i = 0; i < pktlist->numPackets; ++i) { |
for (unsigned int i = 0; i < pktlist->numPackets; ++i) { |
93 |
|
|
|
int cin = packet->data[0] & 0xF0; |
|
|
|
|
94 |
// To be checked : several events per packet |
// To be checked : several events per packet |
95 |
|
|
96 |
switch(cin) { // status byte |
port->DispatchRaw(packet->data); |
|
|
|
|
case 0xB0: |
|
|
if (packet->data[1] == 0) |
|
|
port->DispatchBankSelectMsb(packet->data[2],packet->data[0]&0x0F); |
|
|
else if (packet->data[1] == 32) |
|
|
port->DispatchBankSelectLsb(packet->data[2],packet->data[0]&0x0F); |
|
|
else |
|
|
port->DispatchControlChange(packet->data[1],packet->data[2],packet->data[0]&0x0F); |
|
|
break; |
|
|
|
|
|
case 0xD0: |
|
|
port->DispatchControlChange(128,packet->data[1],packet->data[0]&0x0F); |
|
|
break; |
|
|
|
|
|
case 0xE0: |
|
|
port->DispatchPitchbend(packet->data[1],packet->data[0]&0x0F); |
|
|
break; |
|
|
|
|
|
case 0x90: |
|
|
if (packet->data[1] < 0x80) { |
|
|
if (packet->data[2] > 0){ |
|
|
port->DispatchNoteOn(packet->data[1],packet->data[2], packet->data[0]&0x0F); |
|
|
}else{ |
|
|
port->DispatchNoteOff(packet->data[1],packet->data[2],packet->data[0]&0x0F); |
|
|
} |
|
|
} |
|
|
break; |
|
|
|
|
|
case 0x80: |
|
|
if (packet->data[1] < 0x80) { |
|
|
port->DispatchNoteOff(packet->data[1],packet->data[2],packet->data[0]&0x0F); |
|
|
} |
|
|
break; |
|
|
|
|
|
case 0xC0: |
|
|
if (packet->data[1] < 0x80) { |
|
|
port->DispatchProgramChange(packet->data[1], packet->data[0] & 0x0F); |
|
|
} |
|
|
break; |
|
|
} |
|
97 |
|
|
98 |
packet = MIDIPacketNext(packet); |
packet = MIDIPacketNext(packet); |
99 |
} |
} |
134 |
} |
} |
135 |
|
|
136 |
String MidiInputDeviceCoreMidi::Version() { |
String MidiInputDeviceCoreMidi::Version() { |
137 |
String s = "$Revision: 1.9 $"; |
String s = "$Revision: 1.12 $"; |
138 |
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 |
139 |
} |
} |
140 |
|
|