1 /* 2 * Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch) 3 * 4 * This is free software: you can redistribute it and/or modify 5 * it under the terms of the Artistic License 2.0 as published by 6 * The Perl Foundation. 7 * 8 * This source is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * Artistic License 2.0 for more details. 12 * 13 * You should have received a copy of the Artistic License 2.0 14 * along the source as a COPYING file. If not, obtain it from 15 * http://www.perlfoundation.org/artistic_license_2_0. 16 */ 17 18 #ifndef _ESPRESSIVO_LV2_H 19 #define _ESPRESSIVO_LV2_H 20 21 #include <math.h> 22 #include <stdlib.h> 23 24 #include <xpress.lv2/xpress.h> 25 26 #include <lv2/lv2plug.in/ns/lv2core/lv2.h> 27 #include <lv2/lv2plug.in/ns/ext/atom/atom.h> 28 #include <lv2/lv2plug.in/ns/ext/atom/forge.h> 29 #include <lv2/lv2plug.in/ns/ext/urid/urid.h> 30 #include <lv2/lv2plug.in/ns/ext/midi/midi.h> 31 #include <lv2/lv2plug.in/ns/ext/state/state.h> 32 #include <lv2/lv2plug.in/ns/ext/worker/worker.h> 33 #include <lv2/lv2plug.in/ns/ext/patch/patch.h> 34 #include <lv2/lv2plug.in/ns/ext/log/log.h> 35 #include <lv2/lv2plug.in/ns/ext/log/logger.h> 36 37 #ifdef LV2_ATOM_TUPLE_FOREACH 38 # undef LV2_ATOM_TUPLE_FOREACH 39 # define LV2_ATOM_TUPLE_FOREACH(tuple, iter) \ 40 for (LV2_Atom* (iter) = lv2_atom_tuple_begin(tuple); \ 41 !lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), (tuple)->atom.size, (iter)); \ 42 (iter) = lv2_atom_tuple_next(iter)) 43 #endif 44 45 // bundle uri 46 #define ESPRESSIVO_URI "http://open-music-kontrollers.ch/lv2/espressivo" 47 48 // event uri 49 #define ESPRESSIVO_EVENT_URI ESPRESSIVO_URI"#Event" 50 51 // state uris 52 #define ESPRESSIVO_STATE_ON_URI ESPRESSIVO_URI"#on" 53 #define ESPRESSIVO_STATE_SET_URI ESPRESSIVO_URI"#set" 54 #define ESPRESSIVO_STATE_OFF_URI ESPRESSIVO_URI"#off" 55 #define ESPRESSIVO_STATE_IDLE_URI ESPRESSIVO_URI"#idle" 56 57 // plugin uris 58 #define ESPRESSIVO_TUIO2_IN_URI ESPRESSIVO_URI"#tuio2_in" 59 #define ESPRESSIVO_TUIO2_OUT_URI ESPRESSIVO_URI"#tuio2_out" 60 #define ESPRESSIVO_MIDI_IN_URI ESPRESSIVO_URI"#midi_in" 61 #define ESPRESSIVO_MIDI_OUT_URI ESPRESSIVO_URI"#midi_out" 62 #define ESPRESSIVO_MPE_IN_URI ESPRESSIVO_URI"#mpe_in" 63 #define ESPRESSIVO_MPE_OUT_URI ESPRESSIVO_URI"#mpe_out" 64 #define ESPRESSIVO_SNH_URI ESPRESSIVO_URI"#snh" 65 #define ESPRESSIVO_THROUGH_URI ESPRESSIVO_URI"#through" 66 #define ESPRESSIVO_MODULATOR_URI ESPRESSIVO_URI"#modulator" 67 #define ESPRESSIVO_REDIRECTOR_URI ESPRESSIVO_URI"#redirector" 68 #define ESPRESSIVO_CHORD_URI ESPRESSIVO_URI"#chord" 69 #define ESPRESSIVO_REDUCTO_URI ESPRESSIVO_URI"#reducto" 70 #define ESPRESSIVO_DISCRETO_URI ESPRESSIVO_URI"#discreto" 71 #define ESPRESSIVO_SC_OUT_URI ESPRESSIVO_URI"#sc_out" 72 #define ESPRESSIVO_SQEW_URI ESPRESSIVO_URI"#sqew" 73 #define ESPRESSIVO_MONITOR_OUT_URI ESPRESSIVO_URI"#monitor_out" 74 75 #define MAX_NVOICES 64 76 77 extern const LV2_Descriptor tuio2_in; 78 extern const LV2_Descriptor tuio2_out; 79 extern const LV2_Descriptor midi_in; 80 extern const LV2_Descriptor midi_out; 81 extern const LV2_Descriptor mpe_in; 82 extern const LV2_Descriptor mpe_out; 83 extern const LV2_Descriptor snh; 84 extern const LV2_Descriptor through; 85 extern const LV2_Descriptor modulator; 86 extern const LV2_Descriptor redirector; 87 extern const LV2_Descriptor chord; 88 extern const LV2_Descriptor reducto; 89 extern const LV2_Descriptor discreto; 90 extern const LV2_Descriptor sc_out; 91 extern const LV2_Descriptor sqew; 92 extern const LV2_Descriptor monitor_out; 93 94 static inline float _midi2cps(float pitch)95_midi2cps(float pitch) 96 { 97 return exp2f( (pitch - 69.f) / 12.f) * 440.f; 98 } 99 100 static inline float _cps2midi(float cps)101_cps2midi(float cps) 102 { 103 return log2f(cps / 440.f) * 12.f + 69.f; 104 } 105 106 #endif // _ESPRESSIVO_LV2_H 107