aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/midi/alsa.cpp11
-rw-r--r--backends/midi/coreaudio.cpp22
-rw-r--r--backends/midi/coremidi.cpp16
-rw-r--r--backends/midi/seq.cpp7
-rw-r--r--backends/midi/windows.cpp30
-rw-r--r--backends/midi/zodiac.cpp5
6 files changed, 45 insertions, 46 deletions
diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp
index a5fc13124f..1a4049faa3 100644
--- a/backends/midi/alsa.cpp
+++ b/backends/midi/alsa.cpp
@@ -196,15 +196,16 @@ void MidiDriver_ALSA::send(uint32 b) {
}
void MidiDriver_ALSA::sysEx(const byte *msg, uint16 length) {
- unsigned char buf[1024];
+ unsigned char buf[256];
- if (length > 254) {
- warning("Cannot send SysEx block - data too large");
- return;
- }
+ assert(length + 2 <= 256);
+
+ // Add SysEx frame
buf[0] = 0xF0;
memcpy(buf + 1, msg, length);
buf[length + 1] = 0xF7;
+
+ // Send it
snd_seq_ev_set_sysex(&ev, length + 2, &buf);
send_event(1);
}
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index c79454652d..e058e96f6f 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -178,22 +178,18 @@ void MidiDriver_CORE::send(uint32 b) {
}
void MidiDriver_CORE::sysEx(const byte *msg, uint16 length) {
- assert(_auGraph != NULL);
+ unsigned char buf[256];
- // Add SysEx frame if missing
- byte *buf = 0;
- if (*msg != 0xF0) {
- buf = (byte *)malloc(length + 2);
- buf[0] = 0xF0;
- memcpy(buf+1, msg, length);
- buf[length+1] = 0xF7;
- msg = buf;
- length += 2;
- }
+ assert(length + 2 <= 256);
+ assert(_auGraph != NULL);
- MusicDeviceSysEx(_synth, msg, length);
+ // Add SysEx frame
+ buf[0] = 0xF0;
+ memcpy(buf + 1, msg, length);
+ buf[length + 1] = 0xF7;
- free(buf);
+ // Send it
+ MusicDeviceSysEx(_synth, buf, length+2);
}
MidiDriver *MidiDriver_CORE_create() {
diff --git a/backends/midi/coremidi.cpp b/backends/midi/coremidi.cpp
index d92f775a2d..0aac75e2c2 100644
--- a/backends/midi/coremidi.cpp
+++ b/backends/midi/coremidi.cpp
@@ -163,17 +163,13 @@ void MidiDriver_CoreMIDI::sysEx(const byte *msg, uint16 length) {
packet->timeStamp = 0;
- // Add SysEx frame if missing
- if (*msg != 0xF0) {
- packet->length = length + 2;
- packet->data[0] = 0xF0;
- memcpy(packet->data + 1, msg, length);
- packet->data[length + 1] = 0xF7;
- } else {
- packet->length = length;
- memcpy(packet->data, msg, length);
- }
+ // Add SysEx frame
+ packet->length = length + 2;
+ packet->data[0] = 0xF0;
+ memcpy(packet->data + 1, msg, length);
+ packet->data[length + 1] = 0xF7;
+ // Send it
MIDISend(mOutPort, mDest, packetList);
}
diff --git a/backends/midi/seq.cpp b/backends/midi/seq.cpp
index 8052344879..66ba88a4b1 100644
--- a/backends/midi/seq.cpp
+++ b/backends/midi/seq.cpp
@@ -141,15 +141,12 @@ void MidiDriver_SEQ::send(uint32 b) {
}
void MidiDriver_SEQ::sysEx (const byte *msg, uint16 length) {
- if (length > 254) {
- warning ("Cannot send SysEx block - data too large");
- return;
- }
-
unsigned char buf [1024];
int position = 0;
const byte *chr = msg;
+ assert(length + 2 <= 256);
+
buf[position++] = SEQ_MIDIPUTC;
buf[position++] = 0xF0;
buf[position++] = _device_num;
diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp
index f03716f0eb..c93468a35a 100644
--- a/backends/midi/windows.cpp
+++ b/backends/midi/windows.cpp
@@ -34,7 +34,7 @@
class MidiDriver_WIN : public MidiDriver_MPU401 {
private:
MIDIHDR _streamHeader;
- byte _streamBuffer [258]; // SysEx blocks should be no larger than 256 bytes
+ byte _streamBuffer[256]; // SysEx blocks should be no larger than 256 bytes
HANDLE _streamEvent;
HMIDIOUT _mo;
bool _isOpen;
@@ -42,19 +42,19 @@ private:
void check_error(MMRESULT result);
public:
- MidiDriver_WIN() : _isOpen (false) { }
+ MidiDriver_WIN() : _isOpen(false) { }
int open();
void close();
void send(uint32 b);
- void sysEx (const byte *msg, uint16 length);
+ void sysEx(const byte *msg, uint16 length);
};
int MidiDriver_WIN::open() {
if (_isOpen)
return MERR_ALREADY_OPEN;
- _streamEvent = CreateEvent (NULL, true, true, NULL);
- MMRESULT res = midiOutOpen((HMIDIOUT *)&_mo, MIDI_MAPPER, (unsigned long) _streamEvent, 0, CALLBACK_EVENT);
+ _streamEvent = CreateEvent(NULL, true, true, NULL);
+ MMRESULT res = midiOutOpen((HMIDIOUT *)&_mo, MIDI_MAPPER, (unsigned long)_streamEvent, 0, CALLBACK_EVENT);
if (res != MMSYSERR_NOERROR) {
check_error(res);
CloseHandle(_streamEvent);
@@ -70,9 +70,9 @@ void MidiDriver_WIN::close() {
return;
_isOpen = false;
MidiDriver_MPU401::close();
- midiOutUnprepareHeader (_mo, &_streamHeader, sizeof (_streamHeader));
+ midiOutUnprepareHeader(_mo, &_streamHeader, sizeof(_streamHeader));
check_error(midiOutClose(_mo));
- CloseHandle (_streamEvent);
+ CloseHandle(_streamEvent);
}
void MidiDriver_WIN::send(uint32 b) {
@@ -98,25 +98,29 @@ void MidiDriver_WIN::sysEx(const byte *msg, uint16 length) {
return;
}
- midiOutUnprepareHeader (_mo, &_streamHeader, sizeof (_streamHeader));
- _streamBuffer [0] = 0xF0;
+ assert(length+2 <= 256);
+
+ midiOutUnprepareHeader(_mo, &_streamHeader, sizeof(_streamHeader));
+
+ // Add SysEx frame
+ _streamBuffer[0] = 0xF0;
memcpy(&_streamBuffer[1], msg, length);
- _streamBuffer [length+1] = 0xF7;
+ _streamBuffer[length+1] = 0xF7;
- _streamHeader.lpData = (char *) _streamBuffer;
+ _streamHeader.lpData = (char *)_streamBuffer;
_streamHeader.dwBufferLength = length + 2;
_streamHeader.dwBytesRecorded = length + 2;
_streamHeader.dwUser = 0;
_streamHeader.dwFlags = 0;
- MMRESULT result = midiOutPrepareHeader (_mo, &_streamHeader, sizeof (_streamHeader));
+ MMRESULT result = midiOutPrepareHeader(_mo, &_streamHeader, sizeof(_streamHeader));
if (result != MMSYSERR_NOERROR) {
check_error (result);
return;
}
ResetEvent(_streamEvent);
- result = midiOutLongMsg (_mo, &_streamHeader, sizeof (_streamHeader));
+ result = midiOutLongMsg(_mo, &_streamHeader, sizeof(_streamHeader));
if (result != MMSYSERR_NOERROR) {
check_error(result);
SetEvent(_streamEvent);
diff --git a/backends/midi/zodiac.cpp b/backends/midi/zodiac.cpp
index 891d3c3de0..e626db687e 100644
--- a/backends/midi/zodiac.cpp
+++ b/backends/midi/zodiac.cpp
@@ -110,6 +110,11 @@ void MidiDriver_Zodiac::send(uint32 b) {
}
void MidiDriver_Zodiac::sysEx(const byte *msg, uint16 length) {
+FIXME: We may have to add the 0xF0 / 0xF7 frame here.
+Or not -- maybe TwMidiSysEx doesn't expect it either.
+But since I couldn't find any documentation on this API,
+I'll leave it to the porter to decide that. -- Fingolfin
+
TwMidiSysEx(_midiHandle, 0, (byte *)msg, length);
}