9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 //#define USE_ERROR 27 //#define USE_TRACE 28 29 #if USE_PLATFORM_MIDI_OUT == TRUE 30 31 #include "PLATFORM_API_MacOSX_MidiUtils.h" 32 33 char* MIDI_OUT_GetErrorStr(INT32 err) { 34 return (char *) MIDI_Utils_GetErrorMsg((int) err); 35 } 36 37 38 INT32 MIDI_OUT_GetNumDevices() { 39 return MIDI_Utils_GetNumDevices(MIDI_OUT); 40 } 41 42 43 INT32 MIDI_OUT_GetDeviceName(INT32 deviceID, char *name, UINT32 nameLength) { 44 return MIDI_Utils_GetDeviceName(MIDI_OUT, deviceID, name, nameLength); 45 } 46 47 48 INT32 MIDI_OUT_GetDeviceVendor(INT32 deviceID, char *name, UINT32 nameLength) { 111 case 0x80: // Note off 112 case 0x90: // Note on 113 case 0xA0: // Aftertouch 114 case 0xB0: // Controller 115 case 0xE0: // Pitch wheel 116 nData = 3; 117 break; 118 119 case 0xC0: // Program change 120 case 0xD0: // Channel pressure 121 nData = 2; 122 break; 123 124 case 0xF0: { 125 // System common message 126 switch (data[0]) { 127 case 0xF0: 128 case 0xF7: 129 // System exclusive 130 fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n", 131 __FILE__, __LINE__, data[0]); 132 byteIsInvalid = TRUE; 133 break; 134 135 case 0xF1: // MTC quarter frame message 136 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: MTC quarter frame message....\n"); 137 nData = 2; 138 break; 139 case 0xF3: // Song select 140 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: Song select....\n"); 141 nData = 2; 142 break; 143 144 case 0xF2: // Song position pointer 145 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: Song position pointer....\n"); 146 nData = 3; 147 break; 148 149 case 0xF6: // Tune request 150 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: Tune request....\n"); 151 nData = 1; 152 break; 153 154 default: 155 // Invalid message 156 fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n", 157 __FILE__, __LINE__, data[0]); 158 byteIsInvalid = TRUE; 159 break; 160 } 161 break; 162 } 163 164 default: 165 // This can't happen, but handle it anyway. 166 fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n", 167 __FILE__, __LINE__, data[0]); 168 byteIsInvalid = TRUE; 169 break; 170 } 171 172 if (byteIsInvalid) return -1; 173 174 MIDIPacketListAdd(packetList, sizeof(mBuffers), packet, 0, nData, data); 175 err = MIDISend(macHandle->port, (MIDIEndpointRef) (intptr_t) handle->deviceHandle, packetList); 176 177 MIDI_CHECK_ERROR; 178 TRACE0("< MIDI_OUT_SendShortMessage\n"); 179 return (err == noErr ? MIDI_SUCCESS : -1); 180 } 181 182 183 INT32 MIDI_OUT_SendLongMessage(MidiDeviceHandle* handle, UBYTE* data, UINT32 size, UINT32 timestamp) { 184 OSStatus err = noErr; 185 186 TRACE2("> MIDI_OUT_SendLongMessage size %d, time: %d\n", (int) size, (int) timestamp); 187 if (!handle || !data) { | 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 //#define USE_ERROR 27 //#define USE_TRACE 28 29 /* Use THIS_FILE when it is available. */ 30 #ifndef THIS_FILE 31 #define THIS_FILE __FILE__ 32 #endif 33 34 #if USE_PLATFORM_MIDI_OUT == TRUE 35 36 #include "PLATFORM_API_MacOSX_MidiUtils.h" 37 38 char* MIDI_OUT_GetErrorStr(INT32 err) { 39 return (char *) MIDI_Utils_GetErrorMsg((int) err); 40 } 41 42 43 INT32 MIDI_OUT_GetNumDevices() { 44 return MIDI_Utils_GetNumDevices(MIDI_OUT); 45 } 46 47 48 INT32 MIDI_OUT_GetDeviceName(INT32 deviceID, char *name, UINT32 nameLength) { 49 return MIDI_Utils_GetDeviceName(MIDI_OUT, deviceID, name, nameLength); 50 } 51 52 53 INT32 MIDI_OUT_GetDeviceVendor(INT32 deviceID, char *name, UINT32 nameLength) { 116 case 0x80: // Note off 117 case 0x90: // Note on 118 case 0xA0: // Aftertouch 119 case 0xB0: // Controller 120 case 0xE0: // Pitch wheel 121 nData = 3; 122 break; 123 124 case 0xC0: // Program change 125 case 0xD0: // Channel pressure 126 nData = 2; 127 break; 128 129 case 0xF0: { 130 // System common message 131 switch (data[0]) { 132 case 0xF0: 133 case 0xF7: 134 // System exclusive 135 fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n", 136 THIS_FILE, __LINE__, data[0]); 137 byteIsInvalid = TRUE; 138 break; 139 140 case 0xF1: // MTC quarter frame message 141 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: MTC quarter frame message....\n"); 142 nData = 2; 143 break; 144 case 0xF3: // Song select 145 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: Song select....\n"); 146 nData = 2; 147 break; 148 149 case 0xF2: // Song position pointer 150 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: Song position pointer....\n"); 151 nData = 3; 152 break; 153 154 case 0xF6: // Tune request 155 //fprintf(stderr, ">>>MIDI_OUT_SendShortMessage: Tune request....\n"); 156 nData = 1; 157 break; 158 159 default: 160 // Invalid message 161 fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n", 162 THIS_FILE, __LINE__, data[0]); 163 byteIsInvalid = TRUE; 164 break; 165 } 166 break; 167 } 168 169 default: 170 // This can't happen, but handle it anyway. 171 fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n", 172 THIS_FILE, __LINE__, data[0]); 173 byteIsInvalid = TRUE; 174 break; 175 } 176 177 if (byteIsInvalid) return -1; 178 179 MIDIPacketListAdd(packetList, sizeof(mBuffers), packet, 0, nData, data); 180 err = MIDISend(macHandle->port, (MIDIEndpointRef) (intptr_t) handle->deviceHandle, packetList); 181 182 MIDI_CHECK_ERROR; 183 TRACE0("< MIDI_OUT_SendShortMessage\n"); 184 return (err == noErr ? MIDI_SUCCESS : -1); 185 } 186 187 188 INT32 MIDI_OUT_SendLongMessage(MidiDeviceHandle* handle, UBYTE* data, UINT32 size, UINT32 timestamp) { 189 OSStatus err = noErr; 190 191 TRACE2("> MIDI_OUT_SendLongMessage size %d, time: %d\n", (int) size, (int) timestamp); 192 if (!handle || !data) { |