Guitarix
Loading...
Searching...
No Matches
gx_neural_plugins.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 Hermann Meyer
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 * --------------------------------------------------------------------------
18 */
19
20/* ------- This is the guitarix Engine namespace ------- */
21
22#pragma once
23
24
25#pragma GCC diagnostic push
26#pragma GCC diagnostic ignored "-Wreorder"
27#pragma GCC diagnostic ignored "-Winfinite-recursion"
28#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
29#include "dsp.h"
30#include "get_dsp.h"
31#include "activations.h"
32#include "RTNeural.h"
33#pragma GCC diagnostic pop
34
35namespace gx_jack { class GxJack; }
36
37namespace gx_engine {
38
39class Ramp {
40public:
41 int mode;
42 float ramp_down;
43 float ramp_up;
44 float ramp_step;
46
47 enum {
48 OFF = 0x0001,
49 UP = 0x0002,
50 DOWN = 0x0004,
51 DEAD = 0x0008,
52 };
53
54 Ramp() {};
55 ~Ramp() {};
56 inline void init(unsigned int rate);
57 inline void startRampDown();
58 inline void checkRampMode();
59 inline void rampDown(int count, float *output);
60 inline void rampUp(int count, float *output);
61
62};
63
64/****************************************************************
65 ** class Neural Amp Modeler
66 */
67
68class NeuralAmp: public PluginDef {
69private:
70 nam::DSP* model;
74 sigc::slot<void> sync;
75 volatile int ready;
78 float fVslider0;
79 float fVslider1;
80 double fRec0[2];
81 double fRec1[2];
83 float loudness;
85 float filelist;
86 Glib::ustring load_file;
87 Glib::ustring current_file;
88 Glib::ustring load_path;
89 std::string idstring;
90
92 int load_ui_f(const UiBuilder& b, int form);
93 void init(unsigned int sample_rate);
94 void compute(int count, float *input0, float *output0);
98 int register_par(const ParamReg& reg);
99
101 static void init_static(unsigned int sample_rate, PluginDef*);
102 static int load_ui_f_static(const UiBuilder& b, int form);
103 static void compute_static(int count, float *input0, float *output0, PluginDef*);
104 static int register_params_static(const ParamReg& reg);
105 static void del_instance(PluginDef *p);
106public:
107 std::vector<Glib::ustring> nam_file_names;
109 NeuralAmp(ParamMap& param_, std::string id, sigc::slot<void> sync);
111};
112
113/****************************************************************
114 ** class NeuralAmpMulti
115 */
116
118private:
119 nam::DSP* modela;
120 nam::DSP* modelb;
127 sigc::slot<void> sync;
128 volatile int ready;
132 float *buf;
138 int IOTA0;
139 double fDec0[16384];
141 double fDel4[2];
142 double fDel0[2];
143 double fDel1[2];
144 double fDel2[2];
145 double fDel3[2];
146 double fRec0[2];
147 double fRec01[2];
148 double fRec1[2];
149 double fRec2[2];
157 Glib::ustring load_afile;
158 Glib::ustring current_afile;
159 Glib::ustring load_bfile;
160 Glib::ustring current_bfile;
161 Glib::ustring load_apath;
162 Glib::ustring load_bpath;
163 std::string idstring;
164
166 int load_ui_f(const UiBuilder& b, int form);
167 void init(unsigned int sample_rate);
168 void compute(int count, float *input0, float *output0);
169 void processDelay(int count, float *buf);
170 void processModelA(int count, float *buf);
178 int register_par(const ParamReg& reg);
179
181 static void init_static(unsigned int sample_rate, PluginDef*);
182 static int load_ui_f_static(const UiBuilder& b, int form);
183 static void compute_static(int count, float *input0, float *output0, PluginDef*);
184 static int register_params_static(const ParamReg& reg);
185 static void del_instance(PluginDef *p);
186public:
187 std::vector<Glib::ustring> nam_afile_names;
188 std::vector<Glib::ustring> nam_bfile_names;
190 NeuralAmpMulti(ParamMap& param_, std::string id, ParallelThread *pro_, sigc::slot<void> sync);
192};
193
194/****************************************************************
195 ** class RTNeural
196 */
197
198class RtNeural: public PluginDef {
199private:
200 RTNeural::Model<float> *model;
204 sigc::slot<void> sync;
205 volatile int ready;
210 double fRec0[2];
211 double fRec1[2];
214 float filelist;
215 Glib::ustring load_file;
216 Glib::ustring current_file;
217 Glib::ustring load_path;
218 std::string idstring;
219
221 int load_ui_f(const UiBuilder& b, int form);
222 void init(unsigned int sample_rate);
223 void compute(int count, float *input0, float *output0);
224 void get_samplerate(std::string config_file);
228 int register_par(const ParamReg& reg);
229
231 static void init_static(unsigned int sample_rate, PluginDef*);
232 static int load_ui_f_static(const UiBuilder& b, int form);
233 static void compute_static(int count, float *input0, float *output0, PluginDef*);
234 static int register_params_static(const ParamReg& reg);
235 static void del_instance(PluginDef *p);
236public:
237 std::vector<Glib::ustring> rtneural_file_names;
239 RtNeural(ParamMap& param_, std::string id, sigc::slot<void> sync);
241};
242
243/****************************************************************
244 ** class RTNeuralMulti
245 */
246
248private:
249 RTNeural::Model<float> *modela;
250 RTNeural::Model<float> *modelb;
257 sigc::slot<void> sync;
258 volatile int ready;
262 float *buf;
268 int IOTA0;
269 double fDec0[16384];
271 double fDel4[2];
272 double fDel0[2];
273 double fDel1[2];
274 double fDel2[2];
275 double fDel3[2];
276 double fRec0[2];
277 double fRec01[2];
278 double fRec1[2];
279 double fRec2[2];
285 Glib::ustring load_afile;
286 Glib::ustring current_afile;
287 Glib::ustring load_bfile;
288 Glib::ustring current_bfile;
289 Glib::ustring load_apath;
290 Glib::ustring load_bpath;
291 std::string idstring;
292
294 int load_ui_f(const UiBuilder& b, int form);
295 void init(unsigned int sample_rate);
296 void processDelay(int count, float *buf);
297 void processModelA(int count, float *buf);
299 void compute(int count, float *input0, float *output0);
300 void get_samplerate(std::string config_file, int *mSampleRate);
307 int register_par(const ParamReg& reg);
308
310 static void init_static(unsigned int sample_rate, PluginDef*);
311 static int load_ui_f_static(const UiBuilder& b, int form);
312 static void compute_static(int count, float *input0, float *output0, PluginDef*);
313 static int register_params_static(const ParamReg& reg);
314 static void del_instance(PluginDef *p);
315public:
316 std::vector<Glib::ustring> rtneural_afile_names;
317 std::vector<Glib::ustring> rtneural_bfile_names;
319 RtNeuralMulti(ParamMap& param_, std::string id, ParallelThread *pro_, sigc::slot<void> sync);
321};
322
323} // namespace gx_engine
static int register_params_static(const ParamReg &reg)
NeuralAmp(ParamMap &param_, std::string id, sigc::slot< void > sync)
static int load_ui_f_static(const UiBuilder &b, int form)
std::vector< Glib::ustring > nam_file_names
void compute(int count, float *input0, float *output0)
static void init_static(unsigned int sample_rate, PluginDef *)
int load_ui_f(const UiBuilder &b, int form)
void init(unsigned int sample_rate)
static void compute_static(int count, float *input0, float *output0, PluginDef *)
sigc::slot< void > sync
gx_resample::FixedRateResampler smp
int register_par(const ParamReg &reg)
static void del_instance(PluginDef *p)
static void clear_state_f_static(PluginDef *)
gx_resample::FixedRateResampler smpb
gx_resample::FixedRateResampler smpa
static void clear_state_f_static(PluginDef *)
std::vector< Glib::ustring > nam_afile_names
NeuralAmpMulti(ParamMap &param_, std::string id, ParallelThread *pro_, sigc::slot< void > sync)
void compute(int count, float *input0, float *output0)
void processDelay(int count, float *buf)
int load_ui_f(const UiBuilder &b, int form)
static void compute_static(int count, float *input0, float *output0, PluginDef *)
static int register_params_static(const ParamReg &reg)
static void init_static(unsigned int sample_rate, PluginDef *)
static int load_ui_f_static(const UiBuilder &b, int form)
static void del_instance(PluginDef *p)
void processModelA(int count, float *buf)
void init(unsigned int sample_rate)
std::vector< Glib::ustring > nam_bfile_names
int register_par(const ParamReg &reg)
void startRampDown()
void init(unsigned int rate)
void checkRampMode()
void rampUp(int count, float *output)
void rampDown(int count, float *output)
static int load_ui_f_static(const UiBuilder &b, int form)
RtNeural(ParamMap &param_, std::string id, sigc::slot< void > sync)
void compute(int count, float *input0, float *output0)
std::vector< Glib::ustring > rtneural_file_names
gx_resample::FixedRateResampler smp
int load_ui_f(const UiBuilder &b, int form)
sigc::slot< void > sync
static void compute_static(int count, float *input0, float *output0, PluginDef *)
int register_par(const ParamReg &reg)
static void init_static(unsigned int sample_rate, PluginDef *)
void create_rtneural_filelist()
static int register_params_static(const ParamReg &reg)
static void del_instance(PluginDef *p)
void init(unsigned int sample_rate)
void get_samplerate(std::string config_file)
static void clear_state_f_static(PluginDef *)
RTNeural::Model< float > * model
gx_resample::FixedRateResampler smpa
RTNeural::Model< float > * modela
void compute(int count, float *input0, float *output0)
static void clear_state_f_static(PluginDef *)
RTNeural::Model< float > * modelb
void processModelA(int count, float *buf)
static int register_params_static(const ParamReg &reg)
gx_resample::FixedRateResampler smpb
static void del_instance(PluginDef *p)
int load_ui_f(const UiBuilder &b, int form)
std::vector< Glib::ustring > rtneural_bfile_names
void processDelay(int count, float *buf)
int register_par(const ParamReg &reg)
static int load_ui_f_static(const UiBuilder &b, int form)
void get_samplerate(std::string config_file, int *mSampleRate)
std::vector< Glib::ustring > rtneural_afile_names
RtNeuralMulti(ParamMap &param_, std::string id, ParallelThread *pro_, sigc::slot< void > sync)
static void init_static(unsigned int sample_rate, PluginDef *)
void init(unsigned int sample_rate)
static void compute_static(int count, float *input0, float *output0, PluginDef *)
Parameter registration function pointers.
Definition gx_plugin.h:141