Guitarix
gx_internal_plugins.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3 * Copyright (C) 2011 Pete Shorthose
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * --------------------------------------------------------------------------
19 */
20
21/* ------- This is the guitarix Engine namespace ------- */
22
23#pragma once
24
25#include "dsp.h"
26#include "activations.h"
27
28namespace gx_jack { class GxJack; }
29
30namespace gx_engine {
31
32/****************************************************************
33 ** MonoMute, StereoMute, MaxLevel
34 */
35
36class MonoMute: public PluginDef {
37private:
38 static void process(int count, float *input, float *output, PluginDef*);
39public:
41};
42
43class StereoMute: public PluginDef {
44private:
45 static void process(int count, float *input0, float *input1,
46 float *output0, float *output1, PluginDef*);
47public:
49};
50
51class MaxLevel: public PluginDef {
52public:
53 static const unsigned int channelcount = 2;
54private:
55 static float maxlevel[channelcount];
56 static void process(int count, float *input0, float *input1,
57 float *output0, float *output1, PluginDef*);
58 static int activate(bool start, PluginDef *plugin);
59 static int regparam(const ParamReg& reg);
60public:
61 static float get(unsigned int channel) {
62 assert(channel < channelcount);
63 float v = maxlevel[channel];
64 maxlevel[channel] = 0;
65 return v;
66 }
68};
69
70
71/****************************************************************
72 ** class TunerAdapter
73 */
74
75#ifndef GUITARIX_AS_PLUGIN
76#include "faust/low_high_cut.h"
77#else
78#include "low_high_cut.h"
79#endif
80
81class TunerAdapter: public ModuleSelector, private PluginDef, public sigc::trackable {
82private:
83 static void feed_tuner(int count, float *input, float *output, PluginDef*);
84 static int regparam(const ParamReg& reg);
85 static int activate(bool start, PluginDef *plugin);
86 static void init(unsigned int samplingFreq, PluginDef *plugin);
87 low_high_cut::Dsp lhc;
89 int state;
91 enum { tuner_use = 0x01, switcher_use = 0x02, midi_use = 0x04 };
92 void set_and_check(int use, bool on);
94public:
99 bool used_for_display() { return state & tuner_use; }
100 void used_by_midi(bool on) { set_and_check(midi_use, on); }
101 void set_dep_module(Plugin* dep) { dep_plugin = dep; }
104 sigc::signal<void >& signal_freq_changed() { return pitch_tracker.new_freq; }
107};
108
109
110/****************************************************************
111 ** class NoiseGate
112 */
113
114class NoiseGate : public PluginDef {
115private:
116 inline void inputlevel_process(int count, float *input0, float *output0);
117 inline int noisegate_register(const ParamReg& reg);
118 inline int noisegate_start(bool start);
119 static int noisegate_params_static(const ParamReg& reg);
120 static void inputlevel_compute(int count, float *input0, float *output0, PluginDef*);
121 static int noisegate_activate(bool start, PluginDef *pdef);
122public:
123 bool off;
124 float fnglevel;
125 float ngate;
129};
130
131/****************************************************************
132 ** class OutPutGate
133 */
134
135class OutPutGate : public PluginDef {
136private:
137 inline void outputgate_process(int count, float *input, float *output);
138 static void outputgate_compute(int count, float *input, float *output, PluginDef*);
139public:
144};
145
146/****************************************************************
147 ** class OscilloscopeAdapter
148 */
149
151private:
153 sigc::signal<void(unsigned int, float*)> size_change;
154 float *buffer;
155 unsigned int buffer_size;
157public:
158 int load;
160 bool is_rt;
161 jack_nframes_t bsize;
162
163 public:
165 jack(nullptr), size_change(), buffer(nullptr), buffer_size(0),
166 load(0), frames(0), is_rt(false), bsize(0) {}
169 void update();
170 float *get_buffer() const { return buffer; }
171 unsigned int get_buffer_size() const { return buffer_size; }
172 sigc::signal<void(unsigned int, float*)> signal_size_change() { return size_change; }
173};
174
175template<>
177private:
180 sigc::signal<void, const OscilloscopeInfo&> changed;
181 void trigger_changed() override;
182public:
183 ParameterV(const string& id, OscilloscopeInfo *v);
186 virtual void serializeJSON(gx_system::JsonWriter& jw) override;
187 sigc::signal<void, const OscilloscopeInfo&>& signal_changed() { return changed; }
189 ParamMap &pmap, const string& id, OscilloscopeInfo *v);
190 OscilloscopeInfo& get_value() const { return *value; }
191 virtual void stdJSON_value() override;
192 virtual bool on_off_value() override;
193 virtual void writeJSON(gx_system::JsonWriter& jw) const override;
194 virtual bool compareJSON_value() override;
195 virtual void setJSON_value() override;
196 virtual void readJSON_value(gx_system::JsonParser& jp) override;
197};
198
200
202public:
204private:
206 static void fill_buffer(int count, float *input0, float *output0, PluginDef*);
207 static int osc_register(const ParamReg& reg);
208 static int osc_load_ui(const UiBuilder& builder, int format);
209 void change_buffersize(unsigned int);
211public:
214 unsigned int get_size() const { return info.buffer_size; }
215 inline float *get_buffer() const { return info.buffer; }
216 int get_mul_buffer() { return mul_buffer; }
217 void set_mul_buffer(int a, unsigned int b) { mul_buffer = a; change_buffersize(b); }
219 void set_jack(gx_jack::GxJack& jack) { info.jack = &jack; }
220};
221
222
223/****************************************************************
224 ** class GxSeqSettings
225 */
226
228 private:
229
230 std::vector<int> seqline;
232 friend class SequencerAdapter;
233 friend class ParameterV<GxSeqSettings>;
234 public:
237 bool operator==(const GxSeqSettings& seqset) const;
238 // getters and setters
239 inline const std::vector<int>& getseqline() const { return seqline; }
240
241 inline void setseqline(const std::vector<int>& seq) { seqline = seq; }
242
243 public:
246};
247
248template<>
250private:
255 sigc::signal<void, const GxSeqSettings*> changed;
256public:
257 ParameterV(const string& id, GxSeqSettings *v);
261 sigc::signal<void, const GxSeqSettings*>& signal_changed() { return changed; }
263 ParamMap &pmap, const string& id, GxSeqSettings *v);
264 bool set(const GxSeqSettings& val) const;
265 const GxSeqSettings& get_value() const { return *value; }
266 virtual void stdJSON_value();
267 virtual bool on_off_value();
268 virtual void writeJSON(gx_system::JsonWriter& jw) const;
269 virtual bool compareJSON_value();
270 virtual void setJSON_value();
272};
273
275
276/****************************************************************
277 ** class GxJConvSettings
278 */
279
281 private:
282 // main jconv setting
283 std::string fIRFile;
284 std::string fIRDir;
285
286 float fGain; // jconv gain
287 guint fOffset; // offset in IR where to start comvolution
288 guint fLength; // length of the IR to use for convolution
289 guint fDelay; // delay when to apply reverb
290 Gainline gainline;
293 inline void setIRDir(string name) { fIRDir = name; }
294 friend class ConvolverAdapter;
295 friend class ParameterV<GxJConvSettings>;
296 public:
299 bool operator==(const GxJConvSettings& jcset) const;
300 // getters and setters
301 inline const std::string& getIRFile() const { return fIRFile; }
302 std::string getFullIRPath() const;
303 inline float getGain() const { return fGain; }
304 inline guint getOffset() const { return fOffset; }
305 inline guint getLength() const { return fLength; }
306 inline guint getDelay() const { return fDelay; }
307 inline bool getGainCor() const { return fGainCor; }
308 inline const Gainline& getGainline() const { return gainline; }
309 const std::string& getIRDir() const { return fIRDir; }
310 void setFullIRPath(string name);
311 inline void setIRFile(string name) { fIRFile = name; }
312 inline void setGain(float gain) { fGain = gain; }
313 inline void setGainCor(bool gain) { fGainCor = gain; }
314 inline void setOffset(guint offs) { fOffset = offs; }
315 inline void setLength(guint leng) { fLength = leng; }
316 inline void setDelay(guint del) { fDelay = del; }
317 inline void setGainline(const Gainline& gain) { gainline = gain; }
318
319 public:
322};
323
324class ConvolverAdapter;
325
326template<>
328private:
333 sigc::signal<void, const GxJConvSettings*> changed;
334public:
335 ParameterV(const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
339 sigc::signal<void, const GxJConvSettings*>& signal_changed() { return changed; }
341 ParamMap &pmap, const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
342 bool set(const GxJConvSettings& val) const;
343 const GxJConvSettings& get_value() const { return *value; }
344 virtual void stdJSON_value();
345 virtual bool on_off_value();
346 virtual void writeJSON(gx_system::JsonWriter& jw) const;
347 virtual bool compareJSON_value();
348 virtual void setJSON_value();
350};
351
353
354
355/****************************************************************
356 ** class ConvolverAdapter
357 */
358
359class ConvolverAdapter: protected PluginDef, public sigc::trackable {
360protected:
362 boost::mutex activate_mutex;
364 sigc::slot<void> sync;
366 // wrapper for the rack order function pointers
367 void change_buffersize(unsigned int size);
370public:
372public:
375 void restart();
377 inline const std::string& getIRFile() const { return jcset.getIRFile(); }
378 inline void set_sync(bool val) { conv.set_sync(val); }
379 inline std::string getFullIRPath() const { return jcset.getFullIRPath(); }
380 inline const std::string& getIRDir() const { return jcset.getIRDir(); }
381 bool set(const GxJConvSettings& jcset) const { return jcp->set(jcset); }
382 const GxJConvSettings& get_jcset() const { return jcset; }
384};
385
386
387/****************************************************************
388 ** class ConvolverStereoAdapter
389 */
390
391#ifndef GUITARIX_AS_PLUGIN
392#include "faust/jconv_post.h"
393#include "faust/jconv_post_mono.h"
394#else
395#include "jconv_post.h"
396#include "jconv_post_mono.h"
397#endif
398
400private:
401 jconv_post::Dsp jc_post;
402 // wrapper for the rack order function pointers
403 static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
404 static int activate(bool start, PluginDef *pdef);
405 static void convolver(int count, float *input0, float *input1,
406 float *output0, float *output1, PluginDef*);
407 static int convolver_register(const ParamReg& reg);
408 static int jconv_load_ui(const UiBuilder& builder, int format);
409public:
412};
413
414
415/****************************************************************
416 ** class ConvolverMonoAdapter
417 */
418
420private:
421 jconv_post_mono::Dsp jc_post_mono;
422 // wrapper for the rack order function pointers
423 static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
424 static int activate(bool start, PluginDef *pdef);
425 static void convolver(int count, float *input, float *output, PluginDef*);
426 static int convolver_register(const ParamReg& reg);
427 static int jconv_load_ui(const UiBuilder& builder, int format);
428public:
431};
432
433
434/****************************************************************
435 ** class BaseConvolver
436 */
437
438
439class BaseConvolver: protected PluginDef {
440protected:
442 boost::mutex activate_mutex;
444 sigc::slot<void> sync;
446 sigc::connection update_conn;
447 static void init(unsigned int samplingFreq, PluginDef *p);
448 static int activate(bool start, PluginDef *pdef);
449 void change_buffersize(unsigned int);
452 virtual void check_update() = 0;
453 virtual bool start(bool force = false) = 0;
454public:
456public:
458 virtual ~BaseConvolver();
459 inline void set_sync(bool val) { conv.set_sync(val); }
460};
461
462/****************************************************************
463 ** class FixedBaseConvolver
464 */
465
466
468protected:
470 boost::mutex activate_mutex;
472 sigc::slot<void> sync;
474 unsigned int SamplingFreq;
475 unsigned int buffersize;
476 unsigned int bz;
477 sigc::connection update_conn;
478 static void init(unsigned int samplingFreq, PluginDef *p);
479 unsigned int getSamplingFreq() { return SamplingFreq;};
480 static int activate(bool start, PluginDef *pdef);
481 void change_buffersize(unsigned int);
484 virtual void check_update() = 0;
485 virtual bool start(bool force = false) = 0;
486public:
488public:
491 inline void set_sync(bool val) { conv.set_sync(val); }
492};
493
494/****************************************************************
495 ** class CabinetConvolver
496 */
497
498#ifndef GUITARIX_AS_PLUGIN
499#include "faust/cabinet_impulse_former.h"
500#else
501#include "cabinet_impulse_former.h"
502#endif
503
505private:
507 float level;
509 float bass;
510 float treble;
512 cabinet_impulse_former::Dsp impf;
514 static void run_cab_conf(int count, float *input, float *output, PluginDef*);
515 static int register_cab(const ParamReg& reg);
516 bool do_update();
517 virtual void check_update() override;
518 virtual bool start(bool force = false) override;
519 bool cabinet_changed() { return current_cab != cabinet; }
521public:
525#ifdef GUITARIX_AS_PLUGIN
526 void pl_check_update() { return check_update();}
527#endif
528};
529
530#ifndef GUITARIX_AS_PLUGIN
531#include "faust/cabinet_impulse_former_st.h"
532#else
533#include "cabinet_impulse_former_st.h"
534#endif
535
537private:
539 float level;
541 float bass;
542 float treble;
544 cabinet_impulse_former_st::Dsp impf;
547 static void run_cab_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
548 static int register_cab(const ParamReg& reg);
549 bool do_update();
550 virtual void check_update() override;
551 virtual bool start(bool force = false) override;
552 bool cabinet_changed() { return current_cab != cabinet; }
554public:
558#ifdef GUITARIX_AS_PLUGIN
559 void pl_check_update() { return check_update();}
560#endif
561};
562
563
564/****************************************************************
565 ** class PreampConvolver
566 */
567
568#ifndef GUITARIX_AS_PLUGIN
569#include "faust/preamp_impulse_former.h"
570#else
571#include "preamp_impulse_former.h"
572#endif
573
575private:
577 float level;
579 float bass;
580 float treble;
582 preamp_impulse_former::Dsp impf;
584 static void run_pre_conf(int count, float *input, float *output, PluginDef*);
585 static int register_pre(const ParamReg& reg);
586 bool do_update();
587 virtual void check_update() override;
588 virtual bool start(bool force = false) override;
589 bool preamp_changed() { return current_pre != preamp; }
591public:
595#ifdef GUITARIX_AS_PLUGIN
596 void pl_check_update() { return check_update();}
597#endif
598};
599
600#ifndef GUITARIX_AS_PLUGIN
601#include "faust/preamp_impulse_former_st.h"
602#else
603#include "preamp_impulse_former_st.h"
604#endif
605
607private:
609 float level;
611 float bass;
612 float treble;
614 preamp_impulse_former_st::Dsp impf;
617 static void run_pre_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
618 static int register_pre(const ParamReg& reg);
619 bool do_update();
620 virtual void check_update() override;
621 virtual bool start(bool force = false) override;
622 bool preamp_changed() { return current_pre != preamp; }
624public:
628#ifdef GUITARIX_AS_PLUGIN
629 void pl_check_update() { return check_update();}
630#endif
631};
632
633/****************************************************************
634 ** class ContrastConvolver
635 */
636
637#ifndef GUITARIX_AS_PLUGIN
638#include "faust/presence_level.h"
639#else
640#include "presence_level.h"
641#endif
642
644private:
645 float level;
646 float sum;
647 presence_level::Dsp presl;
649 static void run_contrast(int count, float *input, float *output, PluginDef*);
650 static int register_con(const ParamReg& reg);
651 inline void update_sum() { sum = level; }
652 virtual void check_update() override;
653 bool do_update();
654 inline bool sum_changed() { return std::abs(sum - level) > 0.01; }
655 virtual bool start(bool force = false) override;
656public:
660#ifdef GUITARIX_AS_PLUGIN
661 void pl_check_update() { return check_update();}
662#endif
663};
664
665/****************************************************************
666 ** class Neural Amp Modeler
667 */
668
669class NeuralAmp: public PluginDef {
670private:
671 nam::DSP* model;
674 sigc::slot<void> sync;
675 volatile int ready;
680 double fRec0[2];
681 double fRec1[2];
683 float loudness;
685 Glib::ustring load_file;
686
688 int load_ui_f(const UiBuilder& b, int form);
689 void init(unsigned int sample_rate);
690 void compute(int count, float *input0, float *output0);
692 int register_par(const ParamReg& reg);
693
695 static void init_static(unsigned int sample_rate, PluginDef*);
696 static int load_ui_f_static(const UiBuilder& b, int form);
697 static void compute_static(int count, float *input0, float *output0, PluginDef*);
698 static int register_params_static(const ParamReg& reg);
699 static void del_instance(PluginDef *p);
700public:
702 NeuralAmp(ParamMap& param_, sigc::slot<void> sync);
704};
705
706/****************************************************************
707 ** class LV2Features
708 */
709
711private:
712
713 static LV2_Options_Option gx_options[2];
714 static LV2_Feature gx_options_feature;
715
716 static LV2_URID lv2_urid_map(LV2_URID_Map_Handle, const char* const uri_);
717 static LV2_Feature gx_urid_map_feature;
718
719#pragma GCC diagnostic push
720#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
721 static uint32_t lv2_uri_to_id(LV2_URI_Map_Callback_Data handle, const char*, const char* uri);
722 static LV2_URI_Map_Feature gx_uri_map;
723 static LV2_Feature gx_uri_map_feature;
724#pragma GCC diagnostic pop
725
726 static const char* lv2_urid_unmap(LV2_URID_Unmap_Handle, const LV2_URID urid);
727 static LV2_Feature gx_urid_unmap_feature;
729
730public:
732 {
733 static LV2Features instance;
734 return instance;
735 }
736 static LV2_Feature* gx_features[];
737 static LV2_URID_Map gx_urid_map;
738 static LV2_URID_Unmap gx_urid_unmap;
739
740 LV2Features(LV2Features const&) = delete;
741 void operator=(LV2Features const&) = delete;
742
743};
744
745/****************************************************************
746 ** class LadspaLoader
747 */
748
750
751struct paradesc: boost::noncopyable {
752 int index;
753 std::string name;
754 float dflt;
755 float low;
756 float up;
757 float step;
759 bool newrow;
762 paradesc(): index(), name(), dflt(), low(), up(), step(), tp(), newrow(), has_caption(true), values() {}
764 void set_valuelist(const std::vector<std::string>& v);
767};
768
770
771class plugdesc {
772public:
773 std::string path;
774 unsigned int index;
775 unsigned long UniqueID;
776 Glib::ustring Label;
777 Glib::ustring shortname;
778 Glib::ustring category;
779 int quirks; // quirkflag bits
783 Glib::ustring master_label;
784 std::vector<paradesc*> names;
785 std::string id_str;
786private:
789 friend class LadspaLoader;
790public:
793};
794
796public:
797 typedef std::vector<plugdesc*> pluginarray;
798private:
801 LilvWorld* world;
803 const LilvPlugins* lv2_plugins;
804 LilvNode* lv2_AudioPort;
806 LilvNode* lv2_InputPort;
807 LilvNode* lv2_OutputPort;
808 LilvNode* lv2_AtomPort;
809private:
810 void read_module_config(const std::string& filename, plugdesc *p);
812public:
816 unsigned int size() { return plugins.size(); }
817 PluginDef *create(unsigned int idx) { return create(plugins[idx]); }
819 pluginarray::iterator begin() { return plugins.begin(); }
820 pluginarray::iterator end() { return plugins.end(); }
821 pluginarray::iterator find(plugdesc* desc);
823 void set_plugins(pluginarray& new_plugins);
824 void update_instance(PluginDef *pdef, plugdesc *pdesc);
825 static std::string get_ladspa_filename(unsigned long uid)
826 { return "ladspa"+gx_system::to_string(uid)+".js"; }
827 static std::string get_ladspa_filename(std::string uid_key)
828 { return "ladspa"+uid_key.substr(9)+".js"; }
829 ParamMap& get_parameter_map() const { return param; }
830 friend class Lv2Dsp;
831};
832
833
834/****************************************************************
835 ** class Directout
836 */
837
838class Directout: public PluginDef {
839public:
840 float* outdata;
841private:
843 int bsize;
844 bool fdfill;
846 sigc::slot<void> sync;
847 void mem_alloc();
848 void mem_free();
849 void init(unsigned int samplingFreq);
850 void compute(int count, float *input0, float *input1, float *output0, float *output1);
851 void change_buffersize(unsigned int size);
852
853 static void init_static(unsigned int samplingFreq, PluginDef*);
854 static void compute_static(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
855public:
857 float* get_buffer() {return outdata;};
858 void set_data(bool dfill);
860 Directout( EngineControl& engine, sigc::slot<void> sync);
862};
863
864
865/****************************************************************
866 ** class LiveLooper
867 */
868
869class LiveLooper: public PluginDef {
870
871
873private:
874 Resampler r_file;
876public:
877 int setup(int _inputRate, int _outputRate);
878 int run(int count, float *input, float *output);
879 int max_out_count(int in_count) {
880 return static_cast<int>(ceil((in_count*static_cast<double>(outputRate))/inputRate)); }
881};
882
883private:
885 float gain;
886 float fRec0[2];
887 float gain_out;
888 float fclip1;
889 float fclip2;
890 float fclip3;
891 float fclip4;
892 float fclips1;
893 float fclips2;
894 float fclips3;
895 float fclips4;
896 float fspeed1;
897 float fspeed2;
898 float fspeed3;
899 float fspeed4;
900 float rplay1;
901 float rplay2;
902 float rplay3;
903 float rplay4;
904 float od1;
905 float od2;
906 float od3;
907 float od4;
908 float fod1;
909 float fod2;
910 float fod3;
911 float fod4;
912 float record1;
913 int iVec0[2];
914 int IOTA1;
915 int IOTA2;
916 int IOTA3;
917 int IOTA4;
918 float IOTAR1;
919 float IOTAR2;
920 float IOTAR3;
921 float IOTAR4;
922 float *tape1;
924 float fConst0;
925 float fConst1;
926 float fConst2;
927 float reset1;
928 int RecSize1[2];
929 float rectime0;
930 float fRec1[2];
931 float fRec2[2];
932 int iRec3[2];
933 int iRec4[2];
934 float play1;
935 float playh1;
936 float gain1;
937 float record2;
938 int iVec2[2];
939 float *tape2;
941 float reset2;
942 int RecSize2[2];
943 float rectime1;
944 float fRec6[2];
945 float fRec7[2];
946 int iRec8[2];
947 int iRec9[2];
948 float play2;
949 float playh2;
950 float gain2;
951 float record3;
952 int iVec4[2];
953 float *tape3;
955 float reset3;
956 int RecSize3[2];
957 float rectime2;
958 float fRec11[2];
959 float fRec12[2];
960 int iRec13[2];
961 int iRec14[2];
962 float play3;
963 float playh3;
964 float gain3;
965 float record4;
966 int iVec6[2];
967 float *tape4;
969 float reset4;
970 int RecSize4[2];
971 float rectime3;
972 float fRec16[2];
973 float fRec17[2];
974 int iRec18[2];
975 int iRec19[2];
976 float play4;
977 float playh4;
978 float gain4;
979 float play_all;
980 float dout;
981 float* outbuffer;
982 bool save1;
983 bool save2;
984 bool save3;
985 bool save4;
986 bool first1;
987 bool first2;
988 bool first3;
989 bool first4;
990 bool RP1;
991 bool RP2;
992 bool RP3;
993 bool RP4;
994 Glib::ustring preset_name;
995 Glib::ustring load_file1;
996 Glib::ustring load_file2;
997 Glib::ustring load_file3;
998 Glib::ustring load_file4;
999 Glib::ustring cur_name;
1000 Glib::ustring loop_dir;
1004 sigc::slot<void> sync;
1005 volatile int ready;
1008
1009 int do_resample(int inrate, int insize, float *input, int maxsize);
1010 int do_mono(int c, int f, float *oIn, float *tape, int n);
1013 void mem_free();
1015 int activate(bool start);
1016 int load_ui_f(const UiBuilder& b, int form);
1017 void init(unsigned int samplingFreq);
1018 void compute(int count, float *input0, float *output0);
1019 int register_par(const ParamReg& reg);
1020 void save_array(std::string name);
1021 void load_array(std::string name);
1022 void save_to_wave(std::string fname, float *tape, float fSize, int tape_size);
1023 int load_from_wave(std::string fname, float **tape, int tape_size);
1029
1031 static int activate_static(bool start, PluginDef*);
1032 static int load_ui_f_static(const UiBuilder& b, int form);
1033 static void init_static(unsigned int samplingFreq, PluginDef*);
1034 static void compute_static(int count, float *input0, float *output0, PluginDef*);
1035 static int register_params_static(const ParamReg& reg);
1036 static void del_instance(PluginDef *p);
1037public:
1039 LiveLooper(ParamMap& param_, Directout* d, sigc::slot<void> sync, const string& loop_dir_);
1041};
1042
1043
1044/****************************************************************
1045 ** class SCapture
1046 */
1047
1048
1049class SCapture: public PluginDef {
1050private:
1051 SNDFILE * recfile;
1059 float fRecC0[2];
1060 float fformat;
1061 int IOTA;
1062 int iA;
1065 float *fRec0;
1066 float *fRec1;
1067 float *tape;
1068 sem_t m_trig;
1069 pthread_t m_pthr;
1070 volatile bool keep_stream;
1073 bool err;
1074 float fConst0;
1075 float fRecb0[2];
1076 int iRecb1[2];
1077 float fRecb2[2];
1079 void mem_free();
1081 int activate(bool start);
1082 int load_ui_f(const UiBuilder& b, int form);
1083 void init(unsigned int samplingFreq);
1084 void compute(int count, float *input0, float *output0);
1085 void compute_st(int count, float *input0, float *input1, float *output0, float *output1);
1086 int register_par(const ParamReg& reg);
1087 void save_to_wave(SNDFILE * sf, float *tape, int lSize);
1088 SNDFILE *open_stream(std::string fname);
1089 void close_stream(SNDFILE **sf);
1093 inline std::string get_ffilename();
1094
1095 static void *run_thread(void* p);
1097 static int activate_static(bool start, PluginDef*);
1098 static const char *glade_def;
1099 static const char *glade_def_st;
1100 static int load_ui_f_static(const UiBuilder& b, int form);
1101 static void init_static(unsigned int samplingFreq, PluginDef*);
1102 static void compute_static(int count, float *input0, float *output0, PluginDef*);
1103 static void compute_static_st(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1104 static int register_params_static(const ParamReg& reg);
1105 static void del_instance(PluginDef *p);
1106public:
1110};
1111
1112/****************************************************************
1113 ** class DrumSequencer
1114 */
1115
1116#ifndef GUITARIX_AS_PLUGIN
1117#include "faust/drumseq.h"
1118#else
1119#include "drumseq.h"
1120#endif
1121
1122class Drumout {
1123private:
1124 static float* set;
1125 static bool mb;
1126 static float* data;
1128 static void outputdrum_compute(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1129public:
1130 static void set_plugin(Plugin p);
1131 static void set_data(float* mode, bool ready, float* buf);
1135};
1136
1137
1139private:
1146 drumseq::Dsp drums;
1147
1163 std::vector<int> Vectom;
1164 std::vector<int> Vectom1;
1165 std::vector<int> Vectom2;
1166 std::vector<int> Veckick;
1167 std::vector<int> Vecsnare;
1168 std::vector<int> Vechat;
1169
1172 sigc::slot<void> sync;
1173 volatile bool ready;
1174 float *outdata;
1187
1189 void mem_free();
1190 void init(unsigned int samplingFreq);
1191 void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
1192 void change_buffersize(unsigned int size);
1193 int register_par(const ParamReg& reg);
1194
1202
1203 static void init_static(unsigned int samplingFreq, PluginDef*);
1204 static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef*);
1205 static int register_params_static(const ParamReg& reg);
1206 static void del_instance(PluginDef *p);
1207 static int drum_load_ui(const UiBuilder& builder, int format);
1208public:
1212};
1213
1214/****************************************************************************
1215*
1216* NAME: smbPitchShift.cpp
1217* VERSION: 1.2
1218* HOME URL: http://www.dspdimension.com
1219* KNOWN BUGS: none
1220*
1221*
1222* COPYRIGHT 1999-2009 Stephan M. Bernsee <smb [AT] dspdimension [DOT] com>
1223*
1224* Modified for guitarix by Hermann Meyer 2014
1225*
1226* The Wide Open License (WOL)
1227*
1228* Permission to use, copy, modify, distribute and sell this software and its
1229* documentation for any purpose is hereby granted without fee, provided that
1230* the above copyright notice and this license appear in all source copies.
1231* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
1232* ANY KIND. See http://www.dspguru.com/wol.htm for more information.
1233*
1234*****************************************************************************/
1235
1236
1237#define M_PI 3.14159265358979323846
1238#define MAX_FRAME_LENGTH 8096
1239
1240class smbPitchShift : public PluginDef {
1241private:
1245 sigc::slot<void> sync;
1246 volatile bool ready;
1249 float *fpb;
1250 float *expect;
1251 float *hanning;
1252 float *hanningd;
1253 float *resampin;
1256 float *indata2;
1265 float a,b,c,d,l;
1266 float wet;
1267 float dry;
1268 float mpi, mpi1;
1269 float tone;
1272 int ai;
1273 int aio;
1274 int ii;
1275 long gRover ;
1276 double magn, phase, tmp, real, imag;
1282
1285
1286 inline int load_ui_f(const UiBuilder& b, int form);
1287 int register_par(const ParamReg& reg);
1289
1291 void mem_free();
1293 int activate(bool start);
1295 void PitchShift(int count, float *indata, float *outdata);
1296 void change_buffersize(unsigned int size);
1297 static int activate_static(bool start, PluginDef*);
1298 static void del_instance(PluginDef *p);
1299 static int registerparam(const ParamReg& reg);
1300 static int load_ui_f_static(const UiBuilder& b, int form);
1301 static void init(unsigned int sampleRate, PluginDef *plugin);
1302 static void compute_static(int count, float *input0, float *output0, PluginDef *p);
1303
1304public:
1308};
1309
1310
1311} // namespace gx_engine
virtual bool start(bool force=false)=0
static int activate(bool start, PluginDef *pdef)
BaseConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
virtual void check_update()=0
void change_buffersize(unsigned int)
static void init(unsigned int samplingFreq, PluginDef *p)
virtual void check_update() override
cabinet_impulse_former::Dsp impf
gx_resample::FixedRateResampler smp
static void run_cab_conf(int count, float *input, float *output, PluginDef *)
CabinetConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
static int register_cab(const ParamReg &reg)
virtual bool start(bool force=false) override
virtual bool start(bool force=false) override
virtual void check_update() override
CabinetStereoConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
gx_resample::FixedRateResampler smps
static void run_cab_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef *)
gx_resample::FixedRateResampler smp
cabinet_impulse_former_st::Dsp impf
static int register_cab(const ParamReg &reg)
static int register_con(const ParamReg &reg)
gx_resample::FixedRateResampler smp
static void run_contrast(int count, float *input, float *output, PluginDef *)
virtual bool start(bool force=false) override
ContrastConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
virtual void check_update() override
const std::string & getIRFile() const
void change_buffersize(unsigned int size)
const std::string & getIRDir() const
ParamMap & get_parameter_map() const
const GxJConvSettings & get_jcset() const
std::string getFullIRPath() const
bool set(const GxJConvSettings &jcset) const
ConvolverAdapter(EngineControl &engine, sigc::slot< void > sync)
static int convolver_register(const ParamReg &reg)
static void convolver(int count, float *input, float *output, PluginDef *)
ConvolverMonoAdapter(EngineControl &engine, sigc::slot< void > sync)
static void convolver_init(unsigned int samplingFreq, PluginDef *pdef)
static int activate(bool start, PluginDef *pdef)
static int jconv_load_ui(const UiBuilder &builder, int format)
static void convolver(int count, float *input0, float *input1, float *output0, float *output1, PluginDef *)
static void convolver_init(unsigned int samplingFreq, PluginDef *pdef)
ConvolverStereoAdapter(EngineControl &engine, sigc::slot< void > sync)
static int activate(bool start, PluginDef *pdef)
static int convolver_register(const ParamReg &reg)
static int jconv_load_ui(const UiBuilder &builder, int format)
static void compute_static(int count, float *input0, float *input1, float *output0, float *output1, PluginDef *)
void set_data(bool dfill)
static void init_static(unsigned int samplingFreq, PluginDef *)
Directout(EngineControl &engine, sigc::slot< void > sync)
void change_buffersize(unsigned int size)
sigc::slot< void > sync
void compute(int count, float *input0, float *input1, float *output0, float *output1)
void init(unsigned int samplingFreq)
void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0)
DrumSequencer(EngineControl &engine, sigc::slot< void > sync)
static void init_static(unsigned int samplingFreq, PluginDef *)
void change_buffersize(unsigned int size)
void init(unsigned int samplingFreq)
static int drum_load_ui(const UiBuilder &builder, int format)
static void del_instance(PluginDef *p)
static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef *)
int register_par(const ParamReg &reg)
static int register_params_static(const ParamReg &reg)
static void set_plugin(Plugin p)
static void set_data(float *mode, bool ready, float *buf)
static void outputdrum_compute(int count, float *input0, float *input1, float *output0, float *output1, PluginDef *)
static PluginDef outputdrum
virtual void check_update()=0
FixedBaseConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
static int activate(bool start, PluginDef *pdef)
static void init(unsigned int samplingFreq, PluginDef *p)
virtual bool start(bool force=false)=0
void change_buffersize(unsigned int)
void read_gainline(gx_system::JsonParser &jp)
void writeJSON(gx_system::JsonWriter &w) const
void readJSON(gx_system::JsonParser &jp)
const Gainline & getGainline() const
std::string getFullIRPath() const
bool operator==(const GxJConvSettings &jcset) const
void setFullIRPath(string name)
const std::string & getIRFile() const
GxJConvSettings & operator=(GxJConvSettings const &jcset)
const std::string & getIRDir() const
void setGainline(const Gainline &gain)
void writeJSON(gx_system::JsonWriter &w) const
bool operator==(const GxSeqSettings &seqset) const
GxSeqSettings & operator=(GxSeqSettings const &seqset)
const std::vector< int > & getseqline() const
void read_seqline(gx_system::JsonParser &jp)
void readJSON(gx_system::JsonParser &jp)
void setseqline(const std::vector< int > &seq)
LV2Features(LV2Features const &)=delete
static LV2_Options_Option gx_options[2]
static LV2Features & getInstance()
static const char * lv2_urid_unmap(LV2_URID_Unmap_Handle, const LV2_URID urid)
void operator=(LV2Features const &)=delete
static uint32_t lv2_uri_to_id(LV2_URI_Map_Callback_Data handle, const char *, const char *uri)
static LV2_Feature gx_options_feature
static LV2_Feature gx_urid_map_feature
static LV2_URID_Map gx_urid_map
static LV2_Feature gx_uri_map_feature
static LV2_Feature gx_urid_unmap_feature
static LV2_URID_Unmap gx_urid_unmap
static LV2_URID lv2_urid_map(LV2_URID_Map_Handle, const char *const uri_)
static LV2_Feature * gx_features[]
static LV2_URI_Map_Feature gx_uri_map
void update_instance(PluginDef *pdef, plugdesc *pdesc)
pluginarray::iterator begin()
static std::string get_ladspa_filename(unsigned long uid)
pluginarray::iterator end()
void read_module_list(pluginarray &p)
const LilvPlugins * lv2_plugins
void set_plugins(pluginarray &new_plugins)
bool load(pluginarray &p)
static std::string get_ladspa_filename(std::string uid_key)
LadspaLoader(const gx_system::CmdlineOptions &options, ParamMap &param)
ParamMap & get_parameter_map() const
const gx_system::CmdlineOptions & options
std::vector< plugdesc * > pluginarray
PluginDef * create(const plugdesc *p)
void read_module_config(const std::string &filename, plugdesc *p)
PluginDef * create(unsigned int idx)
pluginarray::iterator find(plugdesc *desc)
int setup(int _inputRate, int _outputRate)
int run(int count, float *input, float *output)
void save_to_wave(std::string fname, float *tape, float fSize, int tape_size)
static void del_instance(PluginDef *p)
int do_mono(int c, int f, float *oIn, float *tape, int n)
LiveLooper(ParamMap &param_, Directout *d, sigc::slot< void > sync, const string &loop_dir_)
int register_par(const ParamReg &reg)
void init(unsigned int samplingFreq)
int load_from_wave(std::string fname, float **tape, int tape_size)
static int activate_static(bool start, PluginDef *)
int do_resample(int inrate, int insize, float *input, int maxsize)
static void compute_static(int count, float *input0, float *output0, PluginDef *)
void save_array(std::string name)
static void init_static(unsigned int samplingFreq, PluginDef *)
static void clear_state_f_static(PluginDef *)
int load_ui_f(const UiBuilder &b, int form)
void load_array(std::string name)
void compute(int count, float *input0, float *output0)
static int register_params_static(const ParamReg &reg)
int activate(bool start)
static int load_ui_f_static(const UiBuilder &b, int form)
static const unsigned int channelcount
static float get(unsigned int channel)
static void process(int count, float *input0, float *input1, float *output0, float *output1, PluginDef *)
static int regparam(const ParamReg &reg)
static int activate(bool start, PluginDef *plugin)
static float maxlevel[channelcount]
static void process(int count, float *input, float *output, PluginDef *)
static int register_params_static(const ParamReg &reg)
static int load_ui_f_static(const UiBuilder &b, int form)
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 *)
NeuralAmp(ParamMap &param_, sigc::slot< void > sync)
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 *)
void inputlevel_process(int count, float *input0, float *output0)
static void inputlevel_compute(int count, float *input0, float *output0, PluginDef *)
int noisegate_start(bool start)
int noisegate_register(const ParamReg &reg)
static int noisegate_activate(bool start, PluginDef *pdef)
static int noisegate_params_static(const ParamReg &reg)
void set_jack(gx_jack::GxJack &jack)
static int osc_register(const ParamReg &reg)
OscilloscopeAdapter(ModuleSequencer &engine)
void set_mul_buffer(int a, unsigned int b)
static int osc_load_ui(const UiBuilder &builder, int format)
void change_buffersize(unsigned int)
static void fill_buffer(int count, float *input0, float *output0, PluginDef *)
sigc::signal< void(unsigned int, float *)> signal_size_change()
void writeJSON(gx_system::JsonWriter &w) const
unsigned int get_buffer_size() const
sigc::signal< void(unsigned int, float *)> size_change
void readJSON(gx_system::JsonParser &jp)
static void outputgate_compute(int count, float *input, float *output, PluginDef *)
const NoiseGate * noisegate
OutPutGate(const NoiseGate *noisegate)
void outputgate_process(int count, float *input, float *output)
virtual void serializeJSON(gx_system::JsonWriter &jw)
ParameterV(const string &id, ConvolverAdapter &conv, GxJConvSettings *v)
bool set(const GxJConvSettings &val) const
virtual void readJSON_value(gx_system::JsonParser &jp)
const GxJConvSettings & get_value() const
static ParameterV< GxJConvSettings > * insert_param(ParamMap &pmap, const string &id, ConvolverAdapter &conv, GxJConvSettings *v)
sigc::signal< void, const GxJConvSettings * > changed
virtual void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void, const GxJConvSettings * > & signal_changed()
ParameterV(gx_system::JsonParser &jp)
bool set(const GxSeqSettings &val) const
virtual void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void, const GxSeqSettings * > & signal_changed()
virtual void readJSON_value(gx_system::JsonParser &jp)
const GxSeqSettings & get_value() const
virtual void serializeJSON(gx_system::JsonWriter &jw)
sigc::signal< void, const GxSeqSettings * > changed
ParameterV(gx_system::JsonParser &jp)
static ParameterV< GxSeqSettings > * insert_param(ParamMap &pmap, const string &id, GxSeqSettings *v)
ParameterV(const string &id, GxSeqSettings *v)
ParameterV(const string &id, OscilloscopeInfo *v)
ParameterV(gx_system::JsonParser &jp)
sigc::signal< void, const OscilloscopeInfo & > & signal_changed()
virtual bool compareJSON_value() override
virtual void serializeJSON(gx_system::JsonWriter &jw) override
virtual void writeJSON(gx_system::JsonWriter &jw) const override
static ParameterV< OscilloscopeInfo > * insert_param(ParamMap &pmap, const string &id, OscilloscopeInfo *v)
sigc::signal< void, const OscilloscopeInfo & > changed
virtual void readJSON_value(gx_system::JsonParser &jp) override
sigc::signal< void > new_freq
void set_fast_note_detection(bool v)
virtual bool start(bool force=false) override
gx_resample::FixedRateResampler smp
static int register_pre(const ParamReg &reg)
static void run_pre_conf(int count, float *input, float *output, PluginDef *)
preamp_impulse_former::Dsp impf
virtual void check_update() override
PreampConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
gx_resample::FixedRateResampler smps
virtual bool start(bool force=false) override
static int register_pre(const ParamReg &reg)
virtual void check_update() override
preamp_impulse_former_st::Dsp impf
PreampStereoConvolver(EngineControl &engine, sigc::slot< void > sync, gx_resample::BufferResampler &resamp)
static void run_pre_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef *)
gx_resample::FixedRateResampler smp
static int activate_static(bool start, PluginDef *)
void close_stream(SNDFILE **sf)
void save_to_wave(SNDFILE *sf, float *tape, int lSize)
static void compute_static_st(int count, float *input0, float *input1, float *output0, float *output1, PluginDef *)
int activate(bool start)
std::string get_ffilename()
void compute(int count, float *input0, float *output0)
SNDFILE * open_stream(std::string fname)
static void init_static(unsigned int samplingFreq, PluginDef *)
static void * run_thread(void *p)
void init(unsigned int samplingFreq)
static void clear_state_f_static(PluginDef *)
int load_ui_f(const UiBuilder &b, int form)
SCapture(EngineControl &engine, int channel_)
static const char * glade_def
static void compute_static(int count, float *input0, float *output0, PluginDef *)
static int load_ui_f_static(const UiBuilder &b, int form)
void compute_st(int count, float *input0, float *input1, float *output0, float *output1)
int register_par(const ParamReg &reg)
static void del_instance(PluginDef *p)
static int register_params_static(const ParamReg &reg)
static const char * glade_def_st
static void process(int count, float *input0, float *input1, float *output0, float *output1, PluginDef *)
static int regparam(const ParamReg &reg)
static void feed_tuner(int count, float *input, float *output, PluginDef *)
void set_fast_note_detection(bool on)
void set_and_check(int use, bool on)
static int activate(bool start, PluginDef *plugin)
TunerAdapter(ModuleSequencer &engine)
void set_dep_module(Plugin *dep)
sigc::signal< void > & signal_freq_changed()
static void init(unsigned int samplingFreq, PluginDef *plugin)
void readJSON(gx_system::JsonParser &jp)
std::vector< paradesc * > names
void writeJSON(gx_system::JsonWriter &jw)
float gSynMagn[MAX_FRAME_LENGTH]
void PitchShift(int count, float *indata, float *outdata)
float gInFIFO[MAX_FRAME_LENGTH]
gx_resample::SimpleResampler resamp
float gAnaMagn[MAX_FRAME_LENGTH]
float gLastPhase[MAX_FRAME_LENGTH/2+1]
int activate(bool start)
float gSynFreq[MAX_FRAME_LENGTH]
int load_ui_f(const UiBuilder &b, int form)
fftwf_complex fftw_out[MAX_FRAME_LENGTH]
float gAnaFreq[MAX_FRAME_LENGTH]
static void compute_static(int count, float *input0, float *output0, PluginDef *p)
static int activate_static(bool start, PluginDef *)
smbPitchShift(EngineControl &engine, sigc::slot< void > sync)
float gOutputAccum[2 *MAX_FRAME_LENGTH]
static void init(unsigned int sampleRate, PluginDef *plugin)
static int registerparam(const ParamReg &reg)
static int load_ui_f_static(const UiBuilder &b, int form)
fftwf_complex fftw_in[MAX_FRAME_LENGTH]
static void del_instance(PluginDef *p)
float gSumPhase[MAX_FRAME_LENGTH/2+1]
int register_par(const ParamReg &reg)
void change_buffersize(unsigned int size)
bool setParameters(int sampleRate)
float gOutFIFO[MAX_FRAME_LENGTH]
#define FAUSTFLOAT
#define MAX_FRAME_LENGTH
ParameterV< OscilloscopeInfo > OscParameter
ParameterV< GxSeqSettings > SeqParameter
ParameterV< GxJConvSettings > JConvParameter
std::string to_string(const T &t)
Definition: gx_system.h:572
Parameter registration function pointers.
Definition: gx_plugin.h:141
const char * name
Definition: gx_plugin.h:200
void writeJSON(gx_system::JsonWriter &jw)
void readJSON(gx_system::JsonParser &jp)
void set_valuelist(const std::vector< std::string > &v)