/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#define USE_ERROR
#define USE_TRACE
#if USE_PLATFORM_MIDI_OUT == TRUE
#include <alsa/asoundlib.h>
#include "PlatformMidi.h"
#include "PLATFORM_API_BsdOS_ALSA_MidiUtils.h"
static int CHANNEL_MESSAGE_LENGTH[] = {
-1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 2, 2, 3 };
/* 8x 9x Ax Bx Cx Dx Ex */
static int SYSTEM_MESSAGE_LENGTH[] = {
-1, 2, 3, 2, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1 };
/* F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF */
// the returned length includes the status byte.
// for illegal messages, -1 is returned.
int dataLength = 0;
} else {
}
return dataLength;
}
/*
* implementation of the platform-dependent
* MIDI out functions declared in PlatformMidi.h
*/
return (char*) getErrorStr(err);
}
TRACE0("MIDI_OUT_GetNumDevices()\n");
}
TRACE0("MIDI_OUT_GetDeviceName()\n");
name, nameLength);
}
TRACE0("MIDI_OUT_GetDeviceVendor()\n");
}
TRACE0("MIDI_OUT_GetDeviceDescription()\n");
name, nameLength);
}
TRACE0("MIDI_OUT_GetDeviceVersion()\n");
}
/* *************************** MidiOutDevice implementation *************** */
}
TRACE0("MIDI_OUT_CloseDevice()\n");
return closeMidiDevice(handle);
}
return getMidiTimestamp(handle);
}
int err;
int status;
int data1;
int data2;
if (!handle) {
ERROR0("< ERROR: MIDI_OUT_SendShortMessage(): handle is NULL\n");
return MIDI_INVALID_HANDLE;
}
if (!handle->deviceHandle) {
ERROR0("< ERROR: MIDI_OUT_SendLongMessage(): native handle is NULL\n");
return MIDI_INVALID_HANDLE;
}
TRACE4("status: %d, data1: %d, data2: %d, length: %d\n", (int) buffer[0], (int) buffer[1], (int) buffer[2], getShortMessageLength(status));
err = snd_rawmidi_write((snd_rawmidi_t*) handle->deviceHandle, buffer, getShortMessageLength(status));
if (err < 0) {
}
TRACE0("< MIDI_OUT_SendShortMessage()\n");
return err;
}
int err;
TRACE2("> MIDI_OUT_SendLongMessage() size %u, time: %u\n", (unsigned int) size, (unsigned int) timestamp);
if (!handle) {
ERROR0("< ERROR: MIDI_OUT_SendLongMessage(): handle is NULL\n");
return MIDI_INVALID_HANDLE;
}
if (!handle->deviceHandle) {
ERROR0("< ERROR: MIDI_OUT_SendLongMessage(): native handle is NULL\n");
return MIDI_INVALID_HANDLE;
}
if (!data) {
ERROR0("< ERROR: MIDI_OUT_SendLongMessage(): data is NULL\n");
return MIDI_INVALID_HANDLE;
}
if (err < 0) {
}
TRACE0("< MIDI_OUT_SendLongMessage()\n");
return err;
}
#endif /* USE_PLATFORM_MIDI_OUT */