Guitarix
Loading...
Searching...
No Matches
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 "gx_neural_plugins.h"
26
27namespace gx_jack { class GxJack; }
28
29namespace gx_engine {
30
31/****************************************************************
32 ** MonoMute, StereoMute, MaxLevel
33 */
34
35class MonoMute: public PluginDef {
36private:
37 static void process(int count, float *input, float *output, PluginDef*);
38public:
40};
41
42class StereoMute: public PluginDef {
43private:
44 static void process(int count, float *input0, float *input1,
45 float *output0, float *output1, PluginDef*);
46public:
48};
49
50class MaxLevel: public PluginDef {
51public:
52 static const unsigned int channelcount = 2;
53private:
54 static float maxlevel[channelcount];
55 static void process(int count, float *input0, float *input1,
56 float *output0, float *output1, PluginDef*);
57 static int activate(bool start, PluginDef *plugin);
58 static int regparam(const ParamReg& reg);
59public:
60 static float get(unsigned int channel) {
61 assert(channel < channelcount);
62 float v = maxlevel[channel];
63 maxlevel[channel] = 0;
64 return v;
65 }
67};
68
69
70/****************************************************************
71 ** class TunerAdapter
72 */
73
74#ifndef GUITARIX_AS_PLUGIN
75#include "faust/low_high_cut.h"
76#else
77#include "low_high_cut.h"
78#endif
79
80class TunerAdapter: public ModuleSelector, private PluginDef, public sigc::trackable {
81private:
82 static void feed_tuner(int count, float *input, float *output, PluginDef*);
83 static int regparam(const ParamReg& reg);
84 static int activate(bool start, PluginDef *plugin);
85 static void init(unsigned int samplingFreq, PluginDef *plugin);
86 low_high_cut::Dsp lhc;
88 int state;
90 enum { tuner_use = 0x01, switcher_use = 0x02, midi_use = 0x04 };
91 void set_and_check(int use, bool on);
93public:
98 bool used_for_display() { return state & tuner_use; }
99 void used_by_midi(bool on) { set_and_check(midi_use, on); }
100 void set_dep_module(Plugin* dep) { dep_plugin = dep; }
102 void set_fast_note_detection(bool on) { return pitch_tracker.set_fast_note_detection(on); }
103 sigc::signal<void >& signal_freq_changed() { return pitch_tracker.new_freq; }
104 float get_freq() { return pitch_tracker.get_estimated_freq(); }
105 float get_note() { return pitch_tracker.get_estimated_note(); }
106};
107
108
109/****************************************************************
110 ** class NoiseGate
111 */
112
113class NoiseGate : public PluginDef {
114private:
115 inline void inputlevel_process(int count, float *input0, float *output0);
116 inline int noisegate_register(const ParamReg& reg);
117 inline int noisegate_start(bool start);
118 static int noisegate_params_static(const ParamReg& reg);
119 static void inputlevel_compute(int count, float *input0, float *output0, PluginDef*);
120 static int noisegate_activate(bool start, PluginDef *pdef);
121public:
122 bool off;
123 float fnglevel;
124 float ngate;
128};
129
130/****************************************************************
131 ** class OutPutGate
132 */
133
134class OutPutGate : public PluginDef {
135private:
136 inline void outputgate_process(int count, float *input, float *output);
137 static void outputgate_compute(int count, float *input, float *output, PluginDef*);
138public:
143};
144
145/****************************************************************
146 ** class OscilloscopeAdapter
147 */
148
150private:
152 sigc::signal<void(unsigned int, float*)> size_change;
153 float *buffer;
154 unsigned int buffer_size;
156public:
157 int load;
159 bool is_rt;
160 jack_nframes_t bsize;
161
162 public:
164 jack(nullptr), size_change(), buffer(nullptr), buffer_size(0),
165 load(0), frames(0), is_rt(false), bsize(0) {}
168 void update();
169 float *get_buffer() const { return buffer; }
170 unsigned int get_buffer_size() const { return buffer_size; }
171 sigc::signal<void(unsigned int, float*)> signal_size_change() { return size_change; }
172};
173
174template<>
176private:
179 sigc::signal<void, const OscilloscopeInfo&> changed;
180 void trigger_changed() override;
181public:
182 ParameterV(const string& id, OscilloscopeInfo *v);
185 virtual void serializeJSON(gx_system::JsonWriter& jw) override;
186 sigc::signal<void, const OscilloscopeInfo&>& signal_changed() { return changed; }
188 ParamMap &pmap, const string& id, OscilloscopeInfo *v);
189 OscilloscopeInfo& get_value() const { return *value; }
190 virtual void stdJSON_value() override;
191 virtual bool on_off_value() override;
192 virtual void writeJSON(gx_system::JsonWriter& jw) const override;
193 virtual bool compareJSON_value() override;
194 virtual void setJSON_value() override;
195 virtual void readJSON_value(gx_system::JsonParser& jp) override;
196};
197
199
201public:
203private:
205 static void fill_buffer(int count, float *input0, float *output0, PluginDef*);
206 static int osc_register(const ParamReg& reg);
207 static int osc_load_ui(const UiBuilder& builder, int format);
208 void change_buffersize(unsigned int);
210public:
213 unsigned int get_size() const { return info.buffer_size; }
214 inline float *get_buffer() const { return info.buffer; }
215 int get_mul_buffer() { return mul_buffer; }
216 void set_mul_buffer(int a, unsigned int b) { mul_buffer = a; change_buffersize(b); }
218 void set_jack(gx_jack::GxJack& jack) { info.jack = &jack; }
219};
220
221
222/****************************************************************
223 ** class GxSeqSettings
224 */
225
227 private:
228
229 std::vector<int> seqline;
231 friend class SequencerAdapter;
232 friend class ParameterV<GxSeqSettings>;
233 public:
236 bool operator==(const GxSeqSettings& seqset) const;
237 // getters and setters
238 inline const std::vector<int>& getseqline() const { return seqline; }
239
240 inline void setseqline(const std::vector<int>& seq) { seqline = seq; }
241
242 public:
245};
246
247template<>
249private:
254 sigc::signal<void, const GxSeqSettings*> changed;
255public:
256 ParameterV(const string& id, GxSeqSettings *v);
260 sigc::signal<void, const GxSeqSettings*>& signal_changed() { return changed; }
262 ParamMap &pmap, const string& id, GxSeqSettings *v);
263 bool set(const GxSeqSettings& val) const;
264 const GxSeqSettings& get_value() const { return *value; }
265 virtual void stdJSON_value();
266 virtual bool on_off_value();
267 virtual void writeJSON(gx_system::JsonWriter& jw) const;
268 virtual bool compareJSON_value();
269 virtual void setJSON_value();
271};
272
274
275/****************************************************************
276 ** class GxJConvSettings
277 */
278
280 private:
281 // main jconv setting
282 std::string fIRFile;
283 std::string fIRDir;
284
285 float fGain; // jconv gain
286 guint fOffset; // offset in IR where to start comvolution
287 guint fLength; // length of the IR to use for convolution
288 guint fDelay; // delay when to apply reverb
289 Gainline gainline;
292 inline void setIRDir(string name) { fIRDir = name; }
293 friend class ConvolverAdapter;
294 friend class ParameterV<GxJConvSettings>;
295 public:
298 bool operator==(const GxJConvSettings& jcset) const;
299 // getters and setters
300 inline const std::string& getIRFile() const { return fIRFile; }
301 std::string getFullIRPath() const;
302 inline float getGain() const { return fGain; }
303 inline guint getOffset() const { return fOffset; }
304 inline guint getLength() const { return fLength; }
305 inline guint getDelay() const { return fDelay; }
306 inline bool getGainCor() const { return fGainCor; }
307 inline const Gainline& getGainline() const { return gainline; }
308 const std::string& getIRDir() const { return fIRDir; }
309 void setFullIRPath(string name);
310 inline void setIRFile(string name) { fIRFile = name; }
311 inline void setGain(float gain) { fGain = gain; }
312 inline void setGainCor(bool gain) { fGainCor = gain; }
313 inline void setOffset(guint offs) { fOffset = offs; }
314 inline void setLength(guint leng) { fLength = leng; }
315 inline void setDelay(guint del) { fDelay = del; }
316 inline void setGainline(const Gainline& gain) { gainline = gain; }
317
318 public:
321};
322
323class ConvolverAdapter;
324
325template<>
327private:
332 sigc::signal<void, const GxJConvSettings*> changed;
333public:
334 ParameterV(const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
338 sigc::signal<void, const GxJConvSettings*>& signal_changed() { return changed; }
340 ParamMap &pmap, const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
341 bool set(const GxJConvSettings& val) const;
342 const GxJConvSettings& get_value() const { return *value; }
343 virtual void stdJSON_value();
344 virtual bool on_off_value();
345 virtual void writeJSON(gx_system::JsonWriter& jw) const;
346 virtual bool compareJSON_value();
347 virtual void setJSON_value();
349};
350
352
353
354/****************************************************************
355 ** class ConvolverAdapter
356 */
357
358class ConvolverAdapter: protected PluginDef, public sigc::trackable {
359protected:
361 boost::mutex activate_mutex;
363 sigc::slot<void> sync;
365 // wrapper for the rack order function pointers
366 void change_buffersize(unsigned int size);
369public:
371public:
374 void restart();
376 inline const std::string& getIRFile() const { return jcset.getIRFile(); }
377 inline void set_sync(bool val) { conv.set_sync(val); }
378 inline std::string getFullIRPath() const { return jcset.getFullIRPath(); }
379 inline const std::string& getIRDir() const { return jcset.getIRDir(); }
380 bool set(const GxJConvSettings& jcset) const { return jcp->set(jcset); }
381 const GxJConvSettings& get_jcset() const { return jcset; }
382 ParamMap& get_parameter_map() const { return engine.get_param(); }
383};
384
385
386/****************************************************************
387 ** class ConvolverStereoAdapter
388 */
389
390#ifndef GUITARIX_AS_PLUGIN
391#include "faust/jconv_post.h"
392#include "faust/jconv_post_mono.h"
393#else
394#include "jconv_post.h"
395#include "jconv_post_mono.h"
396#endif
397
399private:
400 jconv_post::Dsp jc_post;
401 // wrapper for the rack order function pointers
402 static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
403 static int activate(bool start, PluginDef *pdef);
404 static void convolver(int count, float *input0, float *input1,
405 float *output0, float *output1, PluginDef*);
406 static int convolver_register(const ParamReg& reg);
407 static int jconv_load_ui(const UiBuilder& builder, int format);
408public:
411};
412
413
414/****************************************************************
415 ** class ConvolverMonoAdapter
416 */
417
419private:
420 jconv_post_mono::Dsp jc_post_mono;
421 // wrapper for the rack order function pointers
422 static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
423 static int activate(bool start, PluginDef *pdef);
424 static void convolver(int count, float *input, float *output, PluginDef*);
425 static int convolver_register(const ParamReg& reg);
426 static int jconv_load_ui(const UiBuilder& builder, int format);
427public:
430};
431
432
433/****************************************************************
434 ** class BaseConvolver
435 */
436
437
438class BaseConvolver: protected PluginDef {
439protected:
441 boost::mutex activate_mutex;
443 sigc::slot<void> sync;
445 sigc::connection update_conn;
446 static void init(unsigned int samplingFreq, PluginDef *p);
447 static int activate(bool start, PluginDef *pdef);
448 void change_buffersize(unsigned int);
451 virtual void check_update() = 0;
452 virtual bool start(bool force = false) = 0;
453public:
455public:
457 virtual ~BaseConvolver();
458 inline void set_sync(bool val) { conv.set_sync(val); }
459};
460
461/****************************************************************
462 ** class FixedBaseConvolver
463 */
464
465
467protected:
469 boost::mutex activate_mutex;
471 sigc::slot<void> sync;
473 unsigned int SamplingFreq;
474 unsigned int buffersize;
475 unsigned int bz;
476 sigc::connection update_conn;
477 static void init(unsigned int samplingFreq, PluginDef *p);
478 unsigned int getSamplingFreq() { return SamplingFreq;};
479 static int activate(bool start, PluginDef *pdef);
480 void change_buffersize(unsigned int);
483 virtual void check_update() = 0;
484 virtual bool start(bool force = false) = 0;
485public:
487public:
490 inline void set_sync(bool val) { conv.set_sync(val); }
491};
492
493/****************************************************************
494 ** class CabinetConvolver
495 */
496
497#ifndef GUITARIX_AS_PLUGIN
498#include "faust/cabinet_impulse_former.h"
499#else
500#include "cabinet_impulse_former.h"
501#endif
502
504private:
506 float level;
508 float bass;
509 float treble;
511 cabinet_impulse_former::Dsp impf;
513 static void run_cab_conf(int count, float *input, float *output, PluginDef*);
514 static int register_cab(const ParamReg& reg);
515 bool do_update();
516 virtual void check_update() override;
517 virtual bool start(bool force = false) override;
518 bool cabinet_changed() { return current_cab != cabinet; }
520public:
524#ifdef GUITARIX_AS_PLUGIN
525 void pl_check_update() { return check_update();}
526#endif
527};
528
529#ifndef GUITARIX_AS_PLUGIN
530#include "faust/cabinet_impulse_former_st.h"
531#else
532#include "cabinet_impulse_former_st.h"
533#endif
534
536private:
538 float level;
540 float bass;
541 float treble;
543 cabinet_impulse_former_st::Dsp impf;
546 static void run_cab_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
547 static int register_cab(const ParamReg& reg);
548 bool do_update();
549 virtual void check_update() override;
550 virtual bool start(bool force = false) override;
551 bool cabinet_changed() { return current_cab != cabinet; }
553public:
557#ifdef GUITARIX_AS_PLUGIN
558 void pl_check_update() { return check_update();}
559#endif
560};
561
562
563/****************************************************************
564 ** class PreampConvolver
565 */
566
567#ifndef GUITARIX_AS_PLUGIN
568#include "faust/preamp_impulse_former.h"
569#else
570#include "preamp_impulse_former.h"
571#endif
572
574private:
576 float level;
578 float bass;
579 float treble;
581 preamp_impulse_former::Dsp impf;
583 static void run_pre_conf(int count, float *input, float *output, PluginDef*);
584 static int register_pre(const ParamReg& reg);
585 bool do_update();
586 virtual void check_update() override;
587 virtual bool start(bool force = false) override;
588 bool preamp_changed() { return current_pre != preamp; }
590public:
594#ifdef GUITARIX_AS_PLUGIN
595 void pl_check_update() { return check_update();}
596#endif
597};
598
599#ifndef GUITARIX_AS_PLUGIN
600#include "faust/preamp_impulse_former_st.h"
601#else
602#include "preamp_impulse_former_st.h"
603#endif
604
606private:
608 float level;
610 float bass;
611 float treble;
613 preamp_impulse_former_st::Dsp impf;
616 static void run_pre_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
617 static int register_pre(const ParamReg& reg);
618 bool do_update();
619 virtual void check_update() override;
620 virtual bool start(bool force = false) override;
621 bool preamp_changed() { return current_pre != preamp; }
623public:
627#ifdef GUITARIX_AS_PLUGIN
628 void pl_check_update() { return check_update();}
629#endif
630};
631
632/****************************************************************
633 ** class ContrastConvolver
634 */
635
636#ifndef GUITARIX_AS_PLUGIN
637#include "faust/presence_level.h"
638#else
639#include "presence_level.h"
640#endif
641
643private:
644 float level;
645 float sum;
646 presence_level::Dsp presl;
648 static void run_contrast(int count, float *input, float *output, PluginDef*);
649 static int register_con(const ParamReg& reg);
650 inline void update_sum() { sum = level; }
651 virtual void check_update() override;
652 bool do_update();
653 inline bool sum_changed() { return std::abs(sum - level) > 0.01; }
654 virtual bool start(bool force = false) override;
655public:
659#ifdef GUITARIX_AS_PLUGIN
660 void pl_check_update() { return check_update();}
661#endif
662};
663
664/****************************************************************
665 ** class LV2Features
666 */
667
669private:
670
671 static LV2_Options_Option gx_options[2];
672 static LV2_Feature gx_options_feature;
673
674 static LV2_URID lv2_urid_map(LV2_URID_Map_Handle, const char* const uri_);
675 static LV2_Feature gx_urid_map_feature;
676
677#pragma GCC diagnostic push
678#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
679 static uint32_t lv2_uri_to_id(LV2_URI_Map_Callback_Data handle, const char*, const char* uri);
680 static LV2_URI_Map_Feature gx_uri_map;
681 static LV2_Feature gx_uri_map_feature;
682#pragma GCC diagnostic pop
683
684 static const char* lv2_urid_unmap(LV2_URID_Unmap_Handle, const LV2_URID urid);
685 static LV2_Feature gx_urid_unmap_feature;
687
688public:
690 {
691 static LV2Features instance;
692 return instance;
693 }
694 static LV2_Feature* gx_features[];
695 static LV2_URID_Map gx_urid_map;
696 static LV2_URID_Unmap gx_urid_unmap;
697
698 LV2Features(LV2Features const&) = delete;
699 void operator=(LV2Features const&) = delete;
700
701};
702
703/****************************************************************
704 ** class LadspaLoader
705 */
706
708
709struct paradesc: boost::noncopyable {
710 int index;
711 std::string name;
712 float dflt;
713 float low;
714 float up;
715 float step;
717 bool newrow;
720 paradesc(): index(), name(), dflt(), low(), up(), step(), tp(), newrow(), has_caption(true), values() {}
722 void set_valuelist(const std::vector<std::string>& v);
725};
726
728
729class plugdesc {
730public:
731 std::string path;
732 unsigned int index;
733 unsigned long UniqueID;
734 Glib::ustring Label;
735 Glib::ustring shortname;
736 Glib::ustring category;
737 int quirks; // quirkflag bits
741 Glib::ustring master_label;
742 std::vector<paradesc*> names;
743 std::string id_str;
744private:
747 friend class LadspaLoader;
748public:
751};
752
754public:
755 typedef std::vector<plugdesc*> pluginarray;
756private:
759 LilvWorld* world;
761 const LilvPlugins* lv2_plugins;
762 LilvNode* lv2_AudioPort;
764 LilvNode* lv2_InputPort;
765 LilvNode* lv2_OutputPort;
766 LilvNode* lv2_AtomPort;
767private:
768 void read_module_config(const std::string& filename, plugdesc *p);
770public:
774 unsigned int size() { return plugins.size(); }
775 PluginDef *create(unsigned int idx) { return create(plugins[idx]); }
777 pluginarray::iterator begin() { return plugins.begin(); }
778 pluginarray::iterator end() { return plugins.end(); }
779 pluginarray::iterator find(plugdesc* desc);
781 void set_plugins(pluginarray& new_plugins);
782 void update_instance(PluginDef *pdef, plugdesc *pdesc);
783 static std::string get_ladspa_filename(unsigned long uid)
784 { return "ladspa"+gx_system::to_string(uid)+".js"; }
785 static std::string get_ladspa_filename(std::string uid_key)
786 { return "ladspa"+uid_key.substr(9)+".js"; }
787 ParamMap& get_parameter_map() const { return param; }
788 friend class Lv2Dsp;
789};
790
791
792/****************************************************************
793 ** class Directout
794 */
795
796class Directout: public PluginDef {
797public:
798 float* outdata;
799private:
801 int bsize;
802 bool fdfill;
804 sigc::slot<void> sync;
805 void mem_alloc();
806 void mem_free();
807 void init(unsigned int samplingFreq);
808 void compute(int count, float *input0, float *input1, float *output0, float *output1);
809 void change_buffersize(unsigned int size);
810
811 static void init_static(unsigned int samplingFreq, PluginDef*);
812 static void compute_static(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
813public:
815 float* get_buffer() {return outdata;};
816 void set_data(bool dfill);
818 Directout( EngineControl& engine, sigc::slot<void> sync);
820};
821
822
823/****************************************************************
824 ** class LiveLooper
825 */
826
827class LiveLooper: public PluginDef {
828
829
831private:
832 Resampler r_file;
834public:
835 int setup(int _inputRate, int _outputRate);
836 int run(int count, float *input, float *output);
837 int max_out_count(int in_count) {
838 return static_cast<int>(ceil((in_count*static_cast<double>(outputRate))/inputRate)); }
839};
840
841private:
843 float gain;
844 float fRec0[2];
845 float gain_out;
846 float fclip1;
847 float fclip2;
848 float fclip3;
849 float fclip4;
850 float fclips1;
851 float fclips2;
852 float fclips3;
853 float fclips4;
854 float fspeed1;
855 float fspeed2;
856 float fspeed3;
857 float fspeed4;
858 float rplay1;
859 float rplay2;
860 float rplay3;
861 float rplay4;
862 float od1;
863 float od2;
864 float od3;
865 float od4;
866 float fod1;
867 float fod2;
868 float fod3;
869 float fod4;
870 float record1;
871 int iVec0[2];
872 int IOTA1;
873 int IOTA2;
874 int IOTA3;
875 int IOTA4;
876 float IOTAR1;
877 float IOTAR2;
878 float IOTAR3;
879 float IOTAR4;
880 float *tape1;
882 float fConst0;
883 float fConst1;
884 float fConst2;
885 float reset1;
886 int RecSize1[2];
887 float rectime0;
888 float fRec1[2];
889 float fRec2[2];
890 int iRec3[2];
891 int iRec4[2];
892 float play1;
893 float playh1;
894 float gain1;
895 float record2;
896 int iVec2[2];
897 float *tape2;
899 float reset2;
900 int RecSize2[2];
901 float rectime1;
902 float fRec6[2];
903 float fRec7[2];
904 int iRec8[2];
905 int iRec9[2];
906 float play2;
907 float playh2;
908 float gain2;
909 float record3;
910 int iVec4[2];
911 float *tape3;
913 float reset3;
914 int RecSize3[2];
915 float rectime2;
916 float fRec11[2];
917 float fRec12[2];
918 int iRec13[2];
919 int iRec14[2];
920 float play3;
921 float playh3;
922 float gain3;
923 float record4;
924 int iVec6[2];
925 float *tape4;
927 float reset4;
928 int RecSize4[2];
929 float rectime3;
930 float fRec16[2];
931 float fRec17[2];
932 int iRec18[2];
933 int iRec19[2];
934 float play4;
935 float playh4;
936 float gain4;
937 float play_all;
938 float dout;
939 float* outbuffer;
940 bool save1;
941 bool save2;
942 bool save3;
943 bool save4;
944 bool first1;
945 bool first2;
946 bool first3;
947 bool first4;
948 bool RP1;
949 bool RP2;
950 bool RP3;
951 bool RP4;
952 Glib::ustring preset_name;
953 Glib::ustring load_file1;
954 Glib::ustring load_file2;
955 Glib::ustring load_file3;
956 Glib::ustring load_file4;
957 Glib::ustring cur_name;
958 Glib::ustring loop_dir;
959 bool save_p;
962 sigc::slot<void> sync;
963 volatile int ready;
966
967 int do_resample(int inrate, int insize, float *input, int maxsize);
968 int do_mono(int c, int f, float *oIn, float *tape, int n);
970 void mem_alloc();
971 void mem_free();
973 int activate(bool start);
974 int load_ui_f(const UiBuilder& b, int form);
975 void init(unsigned int samplingFreq);
976 void compute(int count, float *input0, float *output0);
977 int register_par(const ParamReg& reg);
978 void save_array(std::string name);
979 void load_array(std::string name);
980 void save_to_wave(std::string fname, float *tape, float fSize, int tape_size);
981 int load_from_wave(std::string fname, float **tape, int tape_size);
987
989 static int activate_static(bool start, PluginDef*);
990 static int load_ui_f_static(const UiBuilder& b, int form);
991 static void init_static(unsigned int samplingFreq, PluginDef*);
992 static void compute_static(int count, float *input0, float *output0, PluginDef*);
993 static int register_params_static(const ParamReg& reg);
994 static void del_instance(PluginDef *p);
995public:
997 LiveLooper(ParamMap& param_, Directout* d, sigc::slot<void> sync, const string& loop_dir_);
999};
1000
1001
1002/****************************************************************
1003 ** class SCapture
1004 */
1005
1006
1007class SCapture: public PluginDef {
1008private:
1009 SNDFILE * recfile;
1017 float fRecC0[2];
1018 float fformat;
1019 int IOTA;
1020 int iA;
1023 float *fRec0;
1024 float *fRec1;
1025 float *tape;
1026 sem_t m_trig;
1027 pthread_t m_pthr;
1028 volatile bool keep_stream;
1031 bool err;
1032 float fConst0;
1033 float fRecb0[2];
1034 int iRecb1[2];
1035 float fRecb2[2];
1037 void mem_free();
1039 int activate(bool start);
1040 int load_ui_f(const UiBuilder& b, int form);
1041 void init(unsigned int samplingFreq);
1042 void compute(int count, float *input0, float *output0);
1043 void compute_st(int count, float *input0, float *input1, float *output0, float *output1);
1044 int register_par(const ParamReg& reg);
1045 void save_to_wave(SNDFILE * sf, float *tape, int lSize);
1046 SNDFILE *open_stream(std::string fname);
1047 void close_stream(SNDFILE **sf);
1051 inline std::string get_ffilename();
1052
1053 static void *run_thread(void* p);
1055 static int activate_static(bool start, PluginDef*);
1056 static const char *glade_def;
1057 static const char *glade_def_st;
1058 static int load_ui_f_static(const UiBuilder& b, int form);
1059 static void init_static(unsigned int samplingFreq, PluginDef*);
1060 static void compute_static(int count, float *input0, float *output0, PluginDef*);
1061 static void compute_static_st(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1062 static int register_params_static(const ParamReg& reg);
1063 static void del_instance(PluginDef *p);
1064public:
1068};
1069
1070/****************************************************************
1071 ** class DrumSequencer
1072 */
1073
1074#ifndef GUITARIX_AS_PLUGIN
1075#include "faust/drumseq.h"
1076#else
1077#include "drumseq.h"
1078#endif
1079
1080class Drumout {
1081private:
1082 static float* set;
1083 static bool mb;
1084 static float* data;
1086 static void outputdrum_compute(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1087public:
1088 static void set_plugin(Plugin p);
1089 static void set_data(float* mode, bool ready, float* buf);
1093};
1094
1095
1097private:
1104 drumseq::Dsp drums;
1105
1121 std::vector<int> Vectom;
1122 std::vector<int> Vectom1;
1123 std::vector<int> Vectom2;
1124 std::vector<int> Veckick;
1125 std::vector<int> Vecsnare;
1126 std::vector<int> Vechat;
1127
1130 sigc::slot<void> sync;
1131 volatile bool ready;
1132 float *outdata;
1145
1147 void mem_free();
1148 void init(unsigned int samplingFreq);
1149 void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
1150 void change_buffersize(unsigned int size);
1151 int register_par(const ParamReg& reg);
1152
1160
1161 static void init_static(unsigned int samplingFreq, PluginDef*);
1162 static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef*);
1163 static int register_params_static(const ParamReg& reg);
1164 static void del_instance(PluginDef *p);
1165 static int drum_load_ui(const UiBuilder& builder, int format);
1166public:
1170};
1171
1172/****************************************************************************
1173*
1174* NAME: smbPitchShift.cpp
1175* VERSION: 1.2
1176* HOME URL: http://www.dspdimension.com
1177* KNOWN BUGS: none
1178*
1179*
1180* COPYRIGHT 1999-2009 Stephan M. Bernsee <smb [AT] dspdimension [DOT] com>
1181*
1182* Modified for guitarix by Hermann Meyer 2014
1183*
1184* The Wide Open License (WOL)
1185*
1186* Permission to use, copy, modify, distribute and sell this software and its
1187* documentation for any purpose is hereby granted without fee, provided that
1188* the above copyright notice and this license appear in all source copies.
1189* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
1190* ANY KIND. See http://www.dspguru.com/wol.htm for more information.
1191*
1192*****************************************************************************/
1193
1194
1195#define M_PI 3.14159265358979323846
1196#define MAX_FRAME_LENGTH 8096
1197
1198class smbPitchShift : public PluginDef {
1199private:
1203 sigc::slot<void> sync;
1204 volatile bool ready;
1207 float *fpb;
1208 float *expect;
1209 float *hanning;
1210 float *hanningd;
1211 float *resampin;
1214 float *indata2;
1223 float a,b,c,d,l;
1224 float wet;
1225 float dry;
1226 float mpi, mpi1;
1227 float tone;
1230 int ai;
1231 int aio;
1232 int ii;
1233 long gRover ;
1234 double magn, phase, tmp, real, imag;
1240
1243
1244 inline int load_ui_f(const UiBuilder& b, int form);
1245 int register_par(const ParamReg& reg);
1247
1249 void mem_free();
1251 int activate(bool start);
1253 void PitchShift(int count, float *indata, float *outdata);
1254 void change_buffersize(unsigned int size);
1255 static int activate_static(bool start, PluginDef*);
1256 static void del_instance(PluginDef *p);
1257 static int registerparam(const ParamReg& reg);
1258 static int load_ui_f_static(const UiBuilder& b, int form);
1259 static void init(unsigned int sampleRate, PluginDef *plugin);
1260 static void compute_static(int count, float *input0, float *output0, PluginDef *p);
1261
1262public:
1266};
1267
1268
1269} // 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
const GxJConvSettings & get_jcset() 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]
ModuleSelector(EngineControl &seq_)
static void process(int count, float *input, float *output, 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)
Parameter(const string &id, const string &name, value_type vtp, ctrl_type ctp, bool preset, bool ctrl)
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
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_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)