midiport.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2004 Ian Esten
00003     
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU Lesser General Public License as published by
00006     the Free Software Foundation; either version 2.1 of the License, or
00007     (at your option) any later version.
00008     
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU Lesser General Public License for more details.
00013     
00014     You should have received a copy of the GNU Lesser General Public License
00015     along with this program; if not, write to the Free Software 
00016     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 
00018 */
00019 
00020 
00021 #ifndef __JACK_MIDIPORT_H
00022 #define __JACK_MIDIPORT_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027         
00028 #include <jack/types.h>
00029 #include <stdlib.h>
00030 
00032 typedef unsigned char jack_midi_data_t;
00033 
00034 /* buffer is a pointer to the midi data. time is the sample index at which this
00035  * event is valid. size_t is how many bytes of data are in 'buffer'. the events
00036  * in 'buffer' are standard midi messages. note that there is no event type field
00037  * anymore. that is now just byte 0 of the buffer.
00038  */
00039 typedef struct _jack_midi_event
00040 {
00041         jack_nframes_t time;
00042         size_t size;
00043         jack_midi_data_t* buffer;
00044 } jack_midi_event_t;
00045 
00046 typedef struct _jack_midi_port_info
00047 {
00048         jack_nframes_t event_count;
00049 } jack_midi_port_info_t;
00050 
00051 /* returns an info struct. only info in there at the moment is how many
00052  * events are in the buffer
00053  */
00054 jack_midi_port_info_t* jack_midi_port_get_info(void* port_buffer, jack_nframes_t nframes);
00055 
00056 
00069 int jack_midi_event_get(jack_midi_event_t* event, void* port_buffer, jack_nframes_t event_idx, jack_nframes_t nframes);
00070 
00071 
00073 void jack_midi_reset_new_port(void* port_buffer, jack_nframes_t nframes);
00074 
00075 
00085 void jack_midi_clear_buffer(void* port_buffer, jack_nframes_t nframes);
00086 
00087 
00101 jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time, 
00102                                                                                   size_t data_size, jack_nframes_t nframes);
00103 
00104 
00117 int jack_midi_event_write(void* port_buffer, jack_nframes_t time, jack_midi_data_t* data, size_t data_size, jack_nframes_t nframes);
00118 
00119 
00120 
00121 /* function to make dealing with running status easier. calls to write update the
00122  * running status byte stored in a port, and this function returns it. note that
00123  * when a port is initialised, last_status_byte is set to 0, which is not a valid
00124  * status byte. valid status bytes are in the range 0x80 <= valid < 0xf8 */
00125 /* this function cannot be supported because it cannot be guaranteed that the
00126  * last status byte stored will be correct. it was intended that
00127  * jack_midi_write_next_event would cache the status byte from the previous write.
00128  * this assumes that users are going to alternate calls to
00129  * jack_midi_write_next_event with writing of actual data. it is a pity that this
00130  * can't be forced as it makes things more efficient. it would have be made clear
00131  * in the api doc that users must write data after calling
00132  * jack_midi_write_next_event for this function to be implementable. either that
00133  * or jack_midi_write_next_event must be removed from the api, and only
00134  * jack_midi_write_next_event2 would be supported. jack_midi_write_next_event is
00135  * heavily used in the hardware i/o client, and removing it would make the input
00136  * thread more complex and use more memory.
00137  * the other way of making this function possible to implement is to force users
00138  * to pass in the first byte of the message (which they should know, as the
00139  * message size they request depends on it). this is probably the best way to do
00140  * things as now that i think about it, the first method suggested in this
00141  * comment might result in erroneous status byte reporting as last_status_byte
00142  * updated with a delay of one message */
00143 /*jack_midi_data_t jack_midi_get_last_status_byte(void* port_buffer, jack_nframes_t nframes);*/
00144 
00145 
00147 jack_midi_data_t jack_midi_get_status_before_event_n(void* port_buffer, jack_nframes_t event_index, jack_nframes_t nframes);
00148                                                            
00158 jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer, jack_nframes_t nframes);
00159 
00160 
00161 #ifdef __cplusplus
00162 }
00163 #endif
00164 
00165 
00166 #endif /* __JACK_MIDIPORT_H */
00167 
00168 

Generated on Wed May 31 09:49:00 2006 for JACK-AUDIO-CONNECTION-KIT by  doxygen 1.4.6