jack_osc.h (3249B)
1 /* 2 * Copyright (c) 2014 Hanspeter Portner (dev@open-music-kontrollers.ch) 3 * 4 * This software is provided 'as-is', without any express or implied 5 * warranty. In no event will the authors be held liable for any damages 6 * arising from the use of this software. 7 * 8 * Permission is granted to anyone to use this software for any purpose, 9 * including commercial applications, and to alter it and redistribute it 10 * freely, subject to the following restrictions: 11 * 12 * 1. The origin of this software must not be misrepresented; you must not 13 * claim that you wrote the original software. If you use this software 14 * in a product, an acknowledgment in the product documentation would be 15 * appreciated but is not required. 16 * 17 * 2. Altered source versions must be plainly marked as such, and must not be 18 * misrepresented as being the original software. 19 * 20 * 3. This notice may not be removed or altered from any source 21 * distribution. 22 */ 23 24 #ifndef __JACK_OSC_H 25 #define __JACK_OSC_H 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif /* __cplusplus */ 30 31 #include <jack/jack.h> 32 #include <jack/types.h> 33 #include <jack/midiport.h> 34 35 /* 36 * It is not necessary to use this header since it contains transparent 37 * macros referring to the Jack MIDI API, but developers are encouraged 38 * to use this header (or at least the same definitions) to make their 39 * code more clear. 40 */ 41 42 /* 43 * Use this as port type in jack_port_register to make it clear that 44 * this MIDI port is used to route OSC messages. 45 * 46 * jack_port_t *osc_in; 47 * osc_in = jack_port_register(client, "osc.in", JACK_DEFAULT_OSC_TYPE, 48 * JackPortIsInput, 0); 49 */ 50 #define JACK_DEFAULT_OSC_TYPE JACK_DEFAULT_MIDI_TYPE 51 52 /* 53 * Use this as value for metadata key JACKEY_EVENT_TYPES 54 * (http://jackaudio.org/metadata/event-type) to mark/query/unmark a port 55 * as OSC carrier in jack_{set,get,remove}_property. 56 * 57 * jack_uuid_t uuid_in = jack_port_uuid(osc_in); 58 * 59 * // set port event type to OSC 60 * jack_set_property(client, uuid_in, JACKEY_EVENT_TYPES, 61 * JACK_EVENT_TYPE__OSC, NULL); 62 * 63 * // query port event type 64 * char *value = NULL; 65 * char *type = NULL; 66 * if( (jack_get_property(uuid, JACKEY_EVENT_TYPES, &value, &type) == 0) 67 * && (strstr(value, JACK_EVENT_TYPE__OSC) != NULL) ) 68 * printf("This port routes OSC!\n"); 69 * jack_free(value); 70 * jack_free(type); 71 * 72 * // clear port event type 73 * jack_remove_property(client, uuid_in, JACKEY_EVENT_TYPES); 74 */ 75 #define JACK_EVENT_TYPE__OSC "OSC" 76 77 /* 78 * The Jack OSC API is a direct map to the Jack MIDI API. 79 */ 80 typedef jack_midi_data_t jack_osc_data_t; 81 typedef jack_midi_event_t jack_osc_event_t; 82 83 #define jack_osc_get_event_count jack_midi_get_event_count 84 #define jack_osc_event_get jack_midi_event_get 85 #define jack_osc_clear_buffer jack_midi_clear_buffer 86 #define jack_osc_max_event_size jack_midi_max_event_size 87 #define jack_osc_event_reserve jack_midi_event_reserve 88 #define jack_osc_event_write jack_midi_event_write 89 #define jack_osc_get_lost_event_count jack_midi_get_lost_event_count 90 91 #ifdef __cplusplus 92 } 93 #endif /* __cplusplus */ 94 95 #endif /* __JACK_OSC_H */