1 // samplv1_lv2.h 2 // 3 /**************************************************************************** 4 Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved. 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License along 17 with this program; if not, write to the Free Software Foundation, Inc., 18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 20 *****************************************************************************/ 21 22 #ifndef __samplv1_lv2_h 23 #define __samplv1_lv2_h 24 25 #include "samplv1.h" 26 27 #include "lv2/lv2plug.in/ns/ext/urid/urid.h" 28 #include "lv2/lv2plug.in/ns/ext/atom/atom.h" 29 #include "lv2/lv2plug.in/ns/ext/atom/forge.h" 30 31 #include "lv2/lv2plug.in/ns/ext/worker/worker.h" 32 33 #define SAMPLV1_LV2_URI "http://samplv1.sourceforge.net/lv2" 34 #define SAMPLV1_LV2_PREFIX SAMPLV1_LV2_URI "#" 35 36 37 #ifdef CONFIG_LV2_PROGRAMS 38 #include "lv2_programs.h" 39 #include <QByteArray> 40 #endif 41 42 // Forward decls. 43 class QApplication; 44 45 46 //------------------------------------------------------------------------- 47 // samplv1_lv2 - decl. 48 // 49 50 class samplv1_lv2 : public samplv1 51 { 52 public: 53 54 samplv1_lv2(double sample_rate, const LV2_Feature *const *host_features); 55 56 ~samplv1_lv2(); 57 58 enum PortIndex { 59 60 MidiIn = 0, 61 Notify, 62 AudioInL, 63 AudioInR, 64 AudioOutL, 65 AudioOutR, 66 ParamBase 67 }; 68 69 void connect_port(uint32_t port, void *data); 70 71 void run(uint32_t nframes); 72 73 void activate(); 74 void deactivate(); 75 76 uint32_t urid_map(const char *uri) const; 77 78 #ifdef CONFIG_LV2_PROGRAMS 79 const LV2_Program_Descriptor *get_program(uint32_t index); 80 void select_program(uint32_t bank, uint32_t program); 81 #endif 82 83 bool worker_work(const void *data, uint32_t size); 84 bool worker_response(const void *data, uint32_t size); 85 86 static void qapp_instantiate(); 87 static void qapp_cleanup(); 88 89 static QApplication *qapp_instance(); 90 91 protected: 92 93 void updatePreset(bool bDirty); 94 void updateParam(samplv1::ParamIndex index); 95 void updateParams(); 96 97 void updateSample(); 98 99 void updateOffsetRange(); 100 void updateLoopRange(); 101 void updateLoopFade(); 102 void updateLoopZero(); 103 104 void updateTuning(); 105 106 bool state_changed(); 107 108 #ifdef CONFIG_LV2_PATCH 109 bool patch_set(LV2_URID key); 110 bool patch_get(LV2_URID key); 111 #endif 112 113 #ifdef CONFIG_LV2_PORT_EVENT 114 bool port_event(samplv1::ParamIndex index); 115 bool port_events(); 116 #endif 117 118 private: 119 120 LV2_URID_Map *m_urid_map; 121 122 struct lv2_urids 123 { 124 #if 1//SAMPLV1_LV2_LEGACY 125 LV2_URID gen1_sample; 126 LV2_URID gen1_offset_start; 127 LV2_URID gen1_offset_end; 128 LV2_URID gen1_loop_start; 129 LV2_URID gen1_loop_end; 130 LV2_URID gen1_loop_fade; 131 LV2_URID gen1_loop_zero; 132 #endif 133 LV2_URID p101_sample_file; 134 LV2_URID p102_offset_start; 135 LV2_URID p103_offset_end; 136 LV2_URID p104_loop_start; 137 LV2_URID p105_loop_end; 138 LV2_URID p106_loop_fade; 139 LV2_URID p107_loop_zero; 140 LV2_URID p108_sample_otabs; 141 LV2_URID gen1_update; 142 LV2_URID p201_tuning_enabled; 143 LV2_URID p202_tuning_refPitch; 144 LV2_URID p203_tuning_refNote; 145 LV2_URID p204_tuning_scaleFile; 146 LV2_URID p205_tuning_keyMapFile; 147 LV2_URID tun1_update; 148 LV2_URID atom_Blank; 149 LV2_URID atom_Object; 150 LV2_URID atom_Float; 151 LV2_URID atom_Int; 152 LV2_URID atom_Bool; 153 LV2_URID atom_Path; 154 #ifdef CONFIG_LV2_PORT_EVENT 155 LV2_URID atom_PortEvent; 156 LV2_URID atom_portTuple; 157 #endif 158 LV2_URID time_Position; 159 LV2_URID time_beatsPerMinute; 160 LV2_URID midi_MidiEvent; 161 LV2_URID bufsz_minBlockLength; 162 LV2_URID bufsz_maxBlockLength; 163 LV2_URID bufsz_nominalBlockLength; 164 LV2_URID state_StateChanged; 165 #ifdef CONFIG_LV2_PATCH 166 LV2_URID patch_Get; 167 LV2_URID patch_Set; 168 LV2_URID patch_property; 169 LV2_URID patch_value; 170 #endif 171 } m_urids; 172 173 LV2_Atom_Forge m_forge; 174 LV2_Atom_Forge_Frame m_notify_frame; 175 176 LV2_Worker_Schedule *m_schedule; 177 178 uint32_t m_ndelta; 179 180 LV2_Atom_Sequence *m_atom_in; 181 LV2_Atom_Sequence *m_atom_out; 182 183 float **m_ins; 184 float **m_outs; 185 186 #ifdef CONFIG_LV2_PROGRAMS 187 LV2_Program_Descriptor m_program; 188 QByteArray m_aProgramName; 189 #endif 190 191 static QApplication *g_qapp_instance; 192 static unsigned int g_qapp_refcount; 193 }; 194 195 196 #endif// __samplv1_lv2_h 197 198 // end of samplv1_lv2.h 199 200