git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1675 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.68
@@ -20,6 +20,7 @@ Tom Szilagyi | |||||
* Linux Makefile now install jack headers. | * Linux Makefile now install jack headers. | ||||
* Use of JACK_CLIENT_DEBUG environment variable to activate debug client mode. | * Use of JACK_CLIENT_DEBUG environment variable to activate debug client mode. | ||||
* Definition of JACK_LOCATION variable using -D in the Makefile. | * Definition of JACK_LOCATION variable using -D in the Makefile. | ||||
* Restore jack 0.103.0 MIDI API version. | |||||
2007-10-25 Stephane Letz <letz@grame.fr> | 2007-10-25 Stephane Letz <letz@grame.fr> | ||||
@@ -28,6 +28,9 @@ This program is free software; you can redistribute it and/or modify | |||||
#define ENOBUFS 55 | #define ENOBUFS 55 | ||||
#endif | #endif | ||||
/* | |||||
Post jack 0.103.0 version | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern "C" { | extern "C" { | ||||
#endif | #endif | ||||
@@ -131,3 +134,108 @@ jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer) | |||||
return buf->lost_events; | return buf->lost_events; | ||||
return 0; | return 0; | ||||
} | } | ||||
*/ | |||||
#ifdef __cplusplus | |||||
extern "C" { | |||||
#endif | |||||
EXPORT jack_nframes_t jack_midi_get_event_count(void* port_buffer, jack_nframes_t nframes); | |||||
EXPORT int jack_midi_event_get(jack_midi_event_t* event, | |||||
void* port_buffer, jack_nframes_t event_index, jack_nframes_t nframes); | |||||
EXPORT void jack_midi_clear_buffer(void* port_buffer, jack_nframes_t nframes); | |||||
EXPORT size_t jack_midi_max_event_size(void* port_buffer, jack_nframes_t nframes); | |||||
EXPORT jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, | |||||
jack_nframes_t time, size_t data_size, jack_nframes_t nframes); | |||||
EXPORT int jack_midi_event_write(void* port_buffer, | |||||
jack_nframes_t time, const jack_midi_data_t* data, size_t data_size, jack_nframes_t nframes); | |||||
EXPORT jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer, jack_nframes_t nframes); | |||||
#ifdef __cplusplus | |||||
} | |||||
#endif | |||||
using namespace Jack; | |||||
EXPORT | |||||
jack_nframes_t jack_midi_get_event_count(void* port_buffer, jack_nframes_t) | |||||
{ | |||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
if (!buf || !buf->IsValid()) | |||||
return 0; | |||||
return buf->event_count; | |||||
} | |||||
EXPORT | |||||
int jack_midi_event_get(jack_midi_event_t *event, void* port_buffer, jack_nframes_t event_index, jack_nframes_t) | |||||
{ | |||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
if (!buf || !buf->IsValid()) | |||||
return -EINVAL; | |||||
if (event_index < 0 || 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; | |||||
} | |||||
EXPORT | |||||
void jack_midi_clear_buffer(void* port_buffer, jack_nframes_t) | |||||
{ | |||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
if (buf && buf->IsValid()) | |||||
buf->Reset(buf->nframes); | |||||
} | |||||
EXPORT | |||||
size_t jack_midi_max_event_size(void* port_buffer, jack_nframes_t) | |||||
{ | |||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
if (buf && buf->IsValid()) | |||||
return buf->MaxEventSize(); | |||||
return 0; | |||||
} | |||||
EXPORT | |||||
jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size, jack_nframes_t) | |||||
{ | |||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
if (!buf && !buf->IsValid()) | |||||
return 0; | |||||
if (time < 0 || time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time)) | |||||
return 0; | |||||
return buf->ReserveEvent(time, data_size); | |||||
} | |||||
EXPORT | |||||
int jack_midi_event_write(void* port_buffer, | |||||
jack_nframes_t time, const jack_midi_data_t* data, size_t data_size, jack_nframes_t) | |||||
{ | |||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
if (!buf && !buf->IsValid()) | |||||
return -EINVAL; | |||||
if (time < 0 || time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time)) | |||||
return -EINVAL; | |||||
jack_midi_data_t* dest = buf->ReserveEvent(time, data_size); | |||||
if (!dest) | |||||
return -ENOBUFS; | |||||
memcpy(dest, data, data_size); | |||||
return 0; | |||||
} | |||||
EXPORT | |||||
jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer, jack_nframes_t) | |||||
{ | |||||
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
if (buf && buf->IsValid()) | |||||
return buf->lost_events; | |||||
return 0; | |||||
} |
@@ -45,10 +45,12 @@ typedef struct _jack_midi_event | |||||
/* Get number of events in a port buffer. | /* Get number of events in a port buffer. | ||||
* | * | ||||
* @param port_buffer Port buffer from which to retrieve event. | * @param port_buffer Port buffer from which to retrieve event. | ||||
* @param nframes Number of valid frames this cycle. | |||||
* @return number of events inside @a port_buffer | * @return number of events inside @a port_buffer | ||||
*/ | */ | ||||
jack_nframes_t | jack_nframes_t | ||||
jack_midi_get_event_count(void* port_buffer); | |||||
jack_midi_get_event_count(void* port_buffer, | |||||
jack_nframes_t nframes); | |||||
/** Get a MIDI event from an event port buffer. | /** Get a MIDI event from an event port buffer. | ||||
@@ -60,12 +62,14 @@ jack_midi_get_event_count(void* port_buffer); | |||||
* @param event Event structure to store retrieved event in. | * @param event Event structure to store retrieved event in. | ||||
* @param port_buffer Port buffer from which to retrieve event. | * @param port_buffer Port buffer from which to retrieve event. | ||||
* @param event_index Index of event to retrieve. | * @param event_index Index of event to retrieve. | ||||
* @param nframes Number of valid frames this cycle. | |||||
* @return 0 on success, ENODATA if buffer is empty. | * @return 0 on success, ENODATA if buffer is empty. | ||||
*/ | */ | ||||
int | int | ||||
jack_midi_event_get(jack_midi_event_t *event, | jack_midi_event_get(jack_midi_event_t *event, | ||||
void *port_buffer, | void *port_buffer, | ||||
jack_nframes_t event_index); | |||||
jack_nframes_t event_index, | |||||
jack_nframes_t nframes); | |||||
/** Clear an event buffer. | /** Clear an event buffer. | ||||
@@ -75,9 +79,11 @@ jack_midi_event_get(jack_midi_event_t *event, | |||||
* function may not be called on an input port's buffer. | * function may not be called on an input port's buffer. | ||||
* | * | ||||
* @param port_buffer Port buffer to clear (must be an output port buffer). | * @param port_buffer Port buffer to clear (must be an output port buffer). | ||||
* @param nframes Number of valid frames this cycle. | |||||
*/ | */ | ||||
void | void | ||||
jack_midi_clear_buffer(void *port_buffer); | |||||
jack_midi_clear_buffer(void *port_buffer, | |||||
jack_nframes_t nframes); | |||||
/** Get the size of the largest event that can be stored by the port. | /** Get the size of the largest event that can be stored by the port. | ||||
@@ -86,9 +92,10 @@ jack_midi_clear_buffer(void *port_buffer); | |||||
* events already stored in the port. | * events already stored in the port. | ||||
* | * | ||||
* @param port_buffer Port buffer to check size of. | * @param port_buffer Port buffer to check size of. | ||||
* @param nframes Number of valid frames this cycle. | |||||
*/ | */ | ||||
size_t | size_t | ||||
jack_midi_max_event_size(void* port_buffer); | |||||
jack_midi_max_event_size(void* port_buffer, jack_nframes_t nframes); | |||||
/** Allocate space for an event to be written to an event port buffer. | /** Allocate space for an event to be written to an event port buffer. | ||||
@@ -103,13 +110,15 @@ jack_midi_max_event_size(void* port_buffer); | |||||
* @param port_buffer Buffer to write event to. | * @param port_buffer Buffer to write event to. | ||||
* @param time Sample offset of event. | * @param time Sample offset of event. | ||||
* @param data_size Length of event's raw data in bytes. | * @param data_size Length of event's raw data in bytes. | ||||
* @param nframes Number of valid frames this event. | |||||
* @return Pointer to the beginning of the reserved event's data buffer, or | * @return Pointer to the beginning of the reserved event's data buffer, or | ||||
* NULL on error (ie not enough space). | * NULL on error (ie not enough space). | ||||
*/ | */ | ||||
jack_midi_data_t* | jack_midi_data_t* | ||||
jack_midi_event_reserve(void *port_buffer, | jack_midi_event_reserve(void *port_buffer, | ||||
jack_nframes_t time, | jack_nframes_t time, | ||||
size_t data_size); | |||||
size_t data_size, | |||||
jack_nframes_t nframes); | |||||
/** Write an event into an event port buffer. | /** Write an event into an event port buffer. | ||||
@@ -122,13 +131,15 @@ jack_midi_event_reserve(void *port_buffer, | |||||
* @param time Sample offset of event. | * @param time Sample offset of event. | ||||
* @param data Message data to be written. | * @param data Message data to be written. | ||||
* @param data_size Length of @a data in bytes. | * @param data_size Length of @a data in bytes. | ||||
* @param nframes Number of valid frames this event. | |||||
* @return 0 on success, ENOBUFS if there's not enough space in buffer for event. | * @return 0 on success, ENOBUFS if there's not enough space in buffer for event. | ||||
*/ | */ | ||||
int | int | ||||
jack_midi_event_write(void *port_buffer, | jack_midi_event_write(void *port_buffer, | ||||
jack_nframes_t time, | jack_nframes_t time, | ||||
const jack_midi_data_t *data, | const jack_midi_data_t *data, | ||||
size_t data_size); | |||||
size_t data_size, | |||||
jack_nframes_t nframes); | |||||
/** Get the number of events that could not be written to @a port_buffer. | /** Get the number of events that could not be written to @a port_buffer. | ||||
@@ -137,10 +148,12 @@ jack_midi_event_write(void *port_buffer, | |||||
* Currently the only way this can happen is if events are lost on port mixdown. | * Currently the only way this can happen is if events are lost on port mixdown. | ||||
* | * | ||||
* @param port_buffer Port to receive count for. | * @param port_buffer Port to receive count for. | ||||
* @param nframes Number of valid frames this cycle. | |||||
* @returns Number of events that could not be written to @a port_buffer. | * @returns Number of events that could not be written to @a port_buffer. | ||||
*/ | */ | ||||
jack_nframes_t | jack_nframes_t | ||||
jack_midi_get_lost_event_count(void *port_buffer); | |||||
jack_midi_get_lost_event_count(void *port_buffer, | |||||
jack_nframes_t nframes); | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
@@ -45,7 +45,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
int i,j; | int i,j; | ||||
void* port_buf = jack_port_get_buffer(output_port, nframes); | void* port_buf = jack_port_get_buffer(output_port, nframes); | ||||
unsigned char* buffer; | unsigned char* buffer; | ||||
jack_midi_clear_buffer(port_buf); | |||||
jack_midi_clear_buffer(port_buf, nframes); | |||||
/*memset(buffer, 0, nframes*sizeof(jack_default_audio_sample_t));*/ | /*memset(buffer, 0, nframes*sizeof(jack_default_audio_sample_t));*/ | ||||
for(i=0; i<nframes; i++) | for(i=0; i<nframes; i++) | ||||
@@ -54,7 +54,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
{ | { | ||||
if(note_starts[j] == loop_index) | if(note_starts[j] == loop_index) | ||||
{ | { | ||||
buffer = jack_midi_event_reserve(port_buf, i, 3); | |||||
buffer = jack_midi_event_reserve(port_buf, i, 3, nframes); | |||||
/* printf("wrote a note on, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | /* printf("wrote a note on, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | ||||
buffer[2] = 64; /* velocity */ | buffer[2] = 64; /* velocity */ | ||||
buffer[1] = note_frqs[j]; | buffer[1] = note_frqs[j]; | ||||
@@ -62,7 +62,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
} | } | ||||
else if(note_starts[j] + note_lengths[j] == loop_index) | else if(note_starts[j] + note_lengths[j] == loop_index) | ||||
{ | { | ||||
buffer = jack_midi_event_reserve(port_buf, i, 3); | |||||
buffer = jack_midi_event_reserve(port_buf, i, 3, nframes); | |||||
/* printf("wrote a note off, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | /* printf("wrote a note off, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | ||||
buffer[2] = 64; /* velocity */ | buffer[2] = 64; /* velocity */ | ||||
buffer[1] = note_frqs[j]; | buffer[1] = note_frqs[j]; | ||||
@@ -49,18 +49,18 @@ int process(jack_nframes_t nframes, void *arg) | |||||
jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer (output_port, nframes); | jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer (output_port, nframes); | ||||
jack_midi_event_t in_event; | jack_midi_event_t in_event; | ||||
jack_nframes_t event_index = 0; | jack_nframes_t event_index = 0; | ||||
jack_nframes_t event_count = jack_midi_get_event_count(port_buf); | |||||
jack_nframes_t event_count = jack_midi_get_event_count(port_buf, nframes); | |||||
if(event_count > 1) | if(event_count > 1) | ||||
{ | { | ||||
printf(" midisine: have %d events\n", event_count); | printf(" midisine: have %d events\n", event_count); | ||||
for(i=0; i<event_count; i++) | for(i=0; i<event_count; i++) | ||||
{ | { | ||||
jack_midi_event_get(&in_event, port_buf, i); | |||||
jack_midi_event_get(&in_event, port_buf, i, nframes); | |||||
printf(" event %d time is %d. 1st byte is 0x%x\n", i, in_event.time, *(in_event.buffer)); | printf(" event %d time is %d. 1st byte is 0x%x\n", i, in_event.time, *(in_event.buffer)); | ||||
} | } | ||||
/* printf("1st byte of 1st event addr is %p\n", in_events[0].buffer);*/ | /* printf("1st byte of 1st event addr is %p\n", in_events[0].buffer);*/ | ||||
} | } | ||||
jack_midi_event_get(&in_event, port_buf, 0); | |||||
jack_midi_event_get(&in_event, port_buf, 0, nframes); | |||||
for(i=0; i<nframes; i++) | for(i=0; i<nframes; i++) | ||||
{ | { | ||||
if((in_event.time == i) && (event_index < event_count)) | if((in_event.time == i) && (event_index < event_count)) | ||||
@@ -79,7 +79,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
} | } | ||||
event_index++; | event_index++; | ||||
if(event_index < event_count) | if(event_index < event_count) | ||||
jack_midi_event_get(&in_event, port_buf, event_index); | |||||
jack_midi_event_get(&in_event, port_buf, event_index, nframes); | |||||
} | } | ||||
ramp += note_frqs[note]; | ramp += note_frqs[note]; | ||||
ramp = (ramp > 1.0) ? ramp - 2.0 : ramp; | ramp = (ramp > 1.0) ? ramp - 2.0 : ramp; | ||||
@@ -520,9 +520,6 @@ | |||||
4B5A1BBD0CD1CC110005BF74 /* midiseq.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = midiseq.c; path = "../example-clients/midiseq.c"; sourceTree = SOURCE_ROOT; }; | 4B5A1BBD0CD1CC110005BF74 /* midiseq.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = midiseq.c; path = "../example-clients/midiseq.c"; sourceTree = SOURCE_ROOT; }; | ||||
4B5A1BDA0CD1CCE10005BF74 /* jack_midisine */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_midisine; sourceTree = BUILT_PRODUCTS_DIR; }; | 4B5A1BDA0CD1CCE10005BF74 /* jack_midisine */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_midisine; sourceTree = BUILT_PRODUCTS_DIR; }; | ||||
4B5A1BDC0CD1CD420005BF74 /* midisine.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = midisine.c; path = "../example-clients/midisine.c"; sourceTree = SOURCE_ROOT; }; | 4B5A1BDC0CD1CD420005BF74 /* midisine.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = midisine.c; path = "../example-clients/midisine.c"; sourceTree = SOURCE_ROOT; }; | ||||
4B5A1D3C0CD1F4990005BF74 /* FadeConnect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = FadeConnect.cpp; path = "../example-clients/FadeConnect.cpp"; sourceTree = SOURCE_ROOT; }; | |||||
4B5A1D3D0CD1F4990005BF74 /* FadeConnect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FadeConnect.h; path = "../example-clients/FadeConnect.h"; sourceTree = SOURCE_ROOT; }; | |||||
4B5A1D700CD1F63F0005BF74 /* fade_connect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = fade_connect.cpp; path = "../example-clients/fade_connect.cpp"; sourceTree = SOURCE_ROOT; }; | |||||
4B60CE480AAABA31004956AA /* connect.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = connect.c; path = "../example-clients/connect.c"; sourceTree = SOURCE_ROOT; }; | 4B60CE480AAABA31004956AA /* connect.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = connect.c; path = "../example-clients/connect.c"; sourceTree = SOURCE_ROOT; }; | ||||
4B66A8580934964500A89560 /* JackConstants.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = JackConstants.h; path = ../common/JackConstants.h; sourceTree = SOURCE_ROOT; }; | 4B66A8580934964500A89560 /* JackConstants.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = JackConstants.h; path = ../common/JackConstants.h; sourceTree = SOURCE_ROOT; }; | ||||
4B699BB1097D421600A18468 /* jackdmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jackdmp; sourceTree = BUILT_PRODUCTS_DIR; }; | 4B699BB1097D421600A18468 /* jackdmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jackdmp; sourceTree = BUILT_PRODUCTS_DIR; }; | ||||
@@ -962,9 +959,6 @@ | |||||
4B03383E0797E19900686131 /* Simple clients */ = { | 4B03383E0797E19900686131 /* Simple clients */ = { | ||||
isa = PBXGroup; | isa = PBXGroup; | ||||
children = ( | children = ( | ||||
4B5A1D700CD1F63F0005BF74 /* fade_connect.cpp */, | |||||
4B5A1D3C0CD1F4990005BF74 /* FadeConnect.cpp */, | |||||
4B5A1D3D0CD1F4990005BF74 /* FadeConnect.h */, | |||||
4B5A1BDC0CD1CD420005BF74 /* midisine.c */, | 4B5A1BDC0CD1CD420005BF74 /* midisine.c */, | ||||
4B5A1BBD0CD1CC110005BF74 /* midiseq.c */, | 4B5A1BBD0CD1CC110005BF74 /* midiseq.c */, | ||||
4BA692D60CBE4CC600EAD520 /* ipunload.c */, | 4BA692D60CBE4CC600EAD520 /* ipunload.c */, | ||||