Example #1
0
int JackWinMMEDriver::Write()
{
    for (int chan = 0; chan < fPlaybackChannels; chan++)  {

        if (fGraphManager->GetConnectionsNum(fPlaybackPortList[chan]) > 0) {

            JackMidiBuffer* midi_buffer = GetOutputBuffer(chan);

            // TODO : use timestamp

            for (unsigned int j = 0; j < midi_buffer->event_count; j++) {
                JackMidiEvent* ev = &midi_buffer->events[j];
                if (ev->size <= 3) {
                    jack_midi_data_t *d = ev->GetData(midi_buffer);
                    DWORD winev = 0;
                    if (ev->size > 0) winev |= d[0];
                    if (ev->size > 1) winev |= (d[1] << 8);
                    if (ev->size > 2) winev |= (d[2] << 16);
                    MMRESULT res = midiOutShortMsg((HMIDIOUT)fMidiSource[chan].fHandle, winev);
                    if (res != MMSYSERR_NOERROR)
                        jack_error ("midiOutShortMsg error res %d", res);
                } else  {

                }
            }
        }
    }

    return 0;
}
Example #2
0
jack_midi_event_t *
JackMidiBufferReadQueue::DequeueEvent()
{
    jack_midi_event_t *e = 0;
    if (index < event_count) {
        JackMidiEvent *event = &(buffer->events[index]);
        midi_event.buffer = event->GetData(buffer);
        midi_event.size = event->size;
        midi_event.time = last_frame_time + event->time;
        e = &midi_event;
        index++;
    }
    return e;
}
Example #3
0
LIB_EXPORT
int jack_midi_event_get(jack_midi_event_t *event, void* port_buffer, uint32_t event_index)
{
    JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer;
    if (!buf || !buf->IsValid()) {
        return -EINVAL;
    }
    if (event_index >= buf->event_count) {
        return -ENOBUFS;
    }
    JackMidiEvent* ev = &buf->events[event_index];
    event->time = ev->time;
    event->size = ev->size;
    event->buffer = ev->GetData(buf);
    return 0;
}