static uint_fast8_t _oscmidi_format(const char *path, const char *fmt, uint_fast8_t argc, osc_data_t *buf) { (void)fmt; osc_data_t *buf_ptr = buf; uint16_t size = 0; uint8_t *format = &config.oscmidi.format; int32_t uuid; buf_ptr = osc_get_int32(buf_ptr, &uuid); if(argc == 1) size = CONFIG_SUCCESS("iss", uuid, path, oscmidi_format_args_values[*format].s); else { uint_fast8_t i; const char *s; buf_ptr = osc_get_string(buf_ptr, &s); for(i=0; i<sizeof(oscmidi_format_args_values)/sizeof(OSC_Query_Value); i++) if(!strcmp(s, oscmidi_format_args_values[i].s)) { *format = i; break; } size = CONFIG_SUCCESS("is", uuid, path); } CONFIG_SEND(size); return 1; }
static uint_fast8_t _oscmidi_path(const char *path, const char *fmt, uint_fast8_t argc, osc_data_t *buf) { (void)fmt; osc_data_t *buf_ptr = buf; uint16_t size = 0; int32_t uuid; buf_ptr = osc_get_int32(buf_ptr, &uuid); if(argc == 1) size = CONFIG_SUCCESS("iss", uuid, path, config.oscmidi.path); else { const char *opath; buf_ptr = osc_get_string(buf_ptr, &opath); if(osc_check_path(opath)) { strcpy(config.oscmidi.path, opath); size = CONFIG_SUCCESS("is", uuid, path); } else size = CONFIG_FAIL("iss", uuid, path, "invalid OSC path"); } CONFIG_SEND(size); return 1; }
static uint_fast8_t _oscmidi_mapping(const char *path, const char *fmt, uint_fast8_t argc, osc_data_t *buf) { (void)fmt; (void)argc; osc_data_t *buf_ptr = buf; uint16_t size; OSC_MIDI_Group *grp = OSCMIDI_GID(path); int32_t uuid; buf_ptr = osc_get_int32(buf_ptr, &uuid); if(argc == 1) { size = CONFIG_SUCCESS("iss", uuid, path, oscmidi_mapping_args_values[grp->mapping]); } else // argc == 2 { const char *mapping; buf_ptr = osc_get_string(buf_ptr, &mapping); uint_fast8_t i; for(i=0; i<sizeof(oscmidi_mapping_args_values)/sizeof(OSC_Query_Value); i++) if(!strcmp(mapping, oscmidi_mapping_args_values[i].s)) { grp->mapping = i; break; } size = CONFIG_SUCCESS("is", uuid, path); } CONFIG_SEND(size); return 1; }
// rt static int _message(osc_time_t timestamp, const char *path, const char *fmt, const osc_data_t *buf, size_t size, void *data) { prog_t *handle = data; LV2_Atom_Forge *forge = &handle->forge; LV2_Atom_Forge_Frame frame [2]; const osc_data_t *ptr = buf; LV2_Atom_Forge_Ref ref = handle->ref; if(ref) ref = osc_forge_message_push(&handle->oforge, forge, frame, path, fmt); for(const char *type = fmt; *type; type++) switch(*type) { case 'i': { int32_t i = 0; ptr = osc_get_int32(ptr, &i); if(ref) ref = osc_forge_int32(&handle->oforge, forge, i); break; } case 'f': { float f = 0.f; ptr = osc_get_float(ptr, &f); if(ref) ref = osc_forge_float(&handle->oforge, forge, f); break; } case 's': case 'S': { const char *s = ""; ptr = osc_get_string(ptr, &s); if(ref) ref = osc_forge_string(&handle->oforge, forge, s); break; } case 'b': { osc_blob_t b = {.size = 0, .payload=NULL}; ptr = osc_get_blob(ptr, &b); if(ref) ref = osc_forge_blob(&handle->oforge, forge, b.size, b.payload); break; } case 'h': { int64_t h = 0; ptr = osc_get_int64(ptr, &h); if(ref) ref = osc_forge_int64(&handle->oforge, forge, h); break; } case 'd': { double d = 0.f; ptr = osc_get_double(ptr, &d); if(ref) ref = osc_forge_double(&handle->oforge, forge, d); break; } case 't': { uint64_t t = 0; ptr = osc_get_timetag(ptr, &t); if(ref) ref = osc_forge_timestamp(&handle->oforge, forge, t); break; } case 'T': case 'F': case 'N': case 'I': { break; } case 'c': { char c = '\0'; ptr = osc_get_char(ptr, &c); if(ref) ref = osc_forge_char(&handle->oforge, forge, c); break; } case 'm': { const uint8_t *m = NULL; ptr = osc_get_midi(ptr, &m); if(ref) ref = osc_forge_midi(&handle->oforge, forge, 3, m + 1); // skip port byte break; } } if(ref) osc_forge_message_pop(&handle->oforge, forge, frame); handle->ref = ref; return 1; } static const osc_method_t methods [] = { {NULL, NULL, _message}, {NULL, NULL, NULL} }; // rt static void _bundle_push_cb(uint64_t timestamp, void *data) { prog_t *handle = data; handle->osc_ptr = osc_start_bundle(handle->osc_ptr, handle->osc_end, timestamp, &handle->bndl[handle->bndl_cnt++]); }