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 
26 namespace gx_jack { class GxJack; }
27 
28 namespace gx_engine {
29 
30 /****************************************************************
31  ** MonoMute, StereoMute, MaxLevel
32  */
33 
34 class MonoMute: public PluginDef {
35 private:
36  static void process(int count, float *input, float *output, PluginDef*);
37 public:
38  MonoMute();
39 };
40 
41 class StereoMute: public PluginDef {
42 private:
43  static void process(int count, float *input0, float *input1,
44  float *output0, float *output1, PluginDef*);
45 public:
46  StereoMute();
47 };
48 
49 class MaxLevel: public PluginDef {
50 public:
51  static const unsigned int channelcount = 2;
52 private:
53  static float maxlevel[channelcount];
54  static void process(int count, float *input0, float *input1,
55  float *output0, float *output1, PluginDef*);
56  static int activate(bool start, PluginDef *plugin);
57  static int regparam(const ParamReg& reg);
58 public:
59  static float get(unsigned int channel) {
60  assert(channel < channelcount);
61  float v = maxlevel[channel];
62  maxlevel[channel] = 0;
63  return v;
64  }
65  MaxLevel();
66 };
67 
68 
69 /****************************************************************
70  ** class TunerAdapter
71  */
72 
73 #include "faust/low_high_cut.h"
74 
75 class TunerAdapter: public ModuleSelector, private PluginDef, public sigc::trackable {
76 private:
77  static void feed_tuner(int count, float *input, float *output, PluginDef*);
78  static int regparam(const ParamReg& reg);
79  static int activate(bool start, PluginDef *plugin);
80  static void init(unsigned int samplingFreq, PluginDef *plugin);
81  low_high_cut::Dsp lhc;
83  int state;
85  enum { tuner_use = 0x01, switcher_use = 0x02, midi_use = 0x04 };
86  void set_and_check(int use, bool on);
88 public:
91  void used_for_switching(bool on) { set_and_check(switcher_use, on); }
92  void used_for_display(bool on) { set_and_check(tuner_use, on); }
93  bool used_for_display() { return state & tuner_use; }
94  void used_by_midi(bool on) { set_and_check(midi_use, on); }
95  void set_dep_module(Plugin* dep) { dep_plugin = dep; }
96  void set_module();
97  Glib::Dispatcher& signal_freq_changed() { return pitch_tracker.new_freq; }
98  float get_freq() { return pitch_tracker.get_estimated_freq(); }
99  float get_note() { return pitch_tracker.get_estimated_note(); }
100 };
101 
102 
103 /****************************************************************
104  ** class NoiseGate
105  */
106 
107 class NoiseGate {
108 private:
110  static float fnglevel;
111  static float ngate;
112  static bool off;
113  static int noisegate_register(const ParamReg& reg);
114  static void inputlevel_compute(int count, float *input0, float *output0, PluginDef*);
115  static void outputgate_compute(int count, float *input, float *output, PluginDef*);
116  static int outputgate_activate(bool start, PluginDef *pdef);
117 public:
120  NoiseGate();
121 };
122 
123 
124 /****************************************************************
125  ** class OscilloscopeAdapter
126  */
127 
129 private:
131  sigc::signal<void(unsigned int, float*)> size_change;
132  float *buffer;
133  unsigned int buffer_size;
134  friend class OscilloscopeAdapter;
135 public:
136  int load;
137  int frames;
138  bool is_rt;
139  jack_nframes_t bsize;
140 
141  public:
143  jack(nullptr), size_change(), buffer(nullptr), buffer_size(0),
144  load(0), frames(0), is_rt(false), bsize(0) {}
145  void readJSON(gx_system::JsonParser& jp);
146  void writeJSON(gx_system::JsonWriter& w) const;
147  void update();
148  float *get_buffer() const { return buffer; }
149  unsigned int get_buffer_size() const { return buffer_size; }
150  sigc::signal<void(unsigned int, float*)> signal_size_change() { return size_change; }
151 };
152 
153 template<>
155 private:
158  sigc::signal<void, const OscilloscopeInfo&> changed;
159  void trigger_changed() override;
160 public:
161  ParameterV(const string& id, OscilloscopeInfo *v);
163  ~ParameterV();
164  virtual void serializeJSON(gx_system::JsonWriter& jw) override;
165  sigc::signal<void, const OscilloscopeInfo&>& signal_changed() { return changed; }
166  static ParameterV<OscilloscopeInfo> *insert_param(
167  ParamMap &pmap, const string& id, OscilloscopeInfo *v);
168  OscilloscopeInfo& get_value() const { return *value; }
169  virtual void stdJSON_value() override;
170  virtual bool on_off_value() override;
171  virtual void writeJSON(gx_system::JsonWriter& jw) const override;
172  virtual bool compareJSON_value() override;
173  virtual void setJSON_value() override;
174  virtual void readJSON_value(gx_system::JsonParser& jp) override;
175 };
176 
178 
180 public:
182 private:
184  static void fill_buffer(int count, float *input0, float *output0, PluginDef*);
185  static int osc_register(const ParamReg& reg);
186  static int osc_load_ui(const UiBuilder& builder, int format);
187  void change_buffersize(unsigned int);
189 public:
191  void clear_buffer();
192  unsigned int get_size() const { return info.buffer_size; }
193  inline float *get_buffer() const { return info.buffer; }
194  int get_mul_buffer() { return mul_buffer; }
195  void set_mul_buffer(int a, unsigned int b) { mul_buffer = a; change_buffersize(b); }
197  void set_jack(gx_jack::GxJack& jack) { info.jack = &jack; }
198 };
199 
200 
201 /****************************************************************
202  ** class GxSeqSettings
203  */
204 
206  private:
207 
208  std::vector<int> seqline;
209  void read_seqline(gx_system::JsonParser& jp);
210  friend class SequencerAdapter;
211  friend class ParameterV<GxSeqSettings>;
212  public:
213  GxSeqSettings();
214  GxSeqSettings& operator=(GxSeqSettings const& seqset);
215  bool operator==(const GxSeqSettings& seqset) const;
216  // getters and setters
217  inline const std::vector<int>& getseqline() const { return seqline; }
218 
219  inline void setseqline(const std::vector<int>& seq) { seqline = seq; }
220 
221  public:
222  void readJSON(gx_system::JsonParser& jp);
223  void writeJSON(gx_system::JsonWriter& w) const;
224 };
225 
226 template<>
228 private:
233  sigc::signal<void, const GxSeqSettings*> changed;
234 public:
235  ParameterV(const string& id, GxSeqSettings *v);
237  ~ParameterV();
238  virtual void serializeJSON(gx_system::JsonWriter& jw);
239  sigc::signal<void, const GxSeqSettings*>& signal_changed() { return changed; }
240  static ParameterV<GxSeqSettings> *insert_param(
241  ParamMap &pmap, const string& id, GxSeqSettings *v);
242  bool set(const GxSeqSettings& val) const;
243  const GxSeqSettings& get_value() const { return *value; }
244  virtual void stdJSON_value();
245  virtual bool on_off_value();
246  virtual void writeJSON(gx_system::JsonWriter& jw) const;
247  virtual bool compareJSON_value();
248  virtual void setJSON_value();
249  virtual void readJSON_value(gx_system::JsonParser& jp);
250 };
251 
253 
254 /****************************************************************
255  ** class GxJConvSettings
256  */
257 
259  private:
260  // main jconv setting
261  std::string fIRFile;
262  std::string fIRDir;
263 
264  float fGain; // jconv gain
265  guint fOffset; // offset in IR where to start comvolution
266  guint fLength; // length of the IR to use for convolution
267  guint fDelay; // delay when to apply reverb
268  Gainline gainline;
269  bool fGainCor;
270  void read_gainline(gx_system::JsonParser& jp);
271  inline void setIRDir(string name) { fIRDir = name; }
272  friend class ConvolverAdapter;
274  public:
275  GxJConvSettings();
276  GxJConvSettings& operator=(GxJConvSettings const& jcset);
277  bool operator==(const GxJConvSettings& jcset) const;
278  // getters and setters
279  inline const std::string& getIRFile() const { return fIRFile; }
280  std::string getFullIRPath() const;
281  inline float getGain() const { return fGain; }
282  inline guint getOffset() const { return fOffset; }
283  inline guint getLength() const { return fLength; }
284  inline guint getDelay() const { return fDelay; }
285  inline bool getGainCor() const { return fGainCor; }
286  inline const Gainline& getGainline() const { return gainline; }
287  const std::string& getIRDir() const { return fIRDir; }
288  void setFullIRPath(string name);
289  inline void setIRFile(string name) { fIRFile = name; }
290  inline void setGain(float gain) { fGain = gain; }
291  inline void setGainCor(bool gain) { fGainCor = gain; }
292  inline void setOffset(guint offs) { fOffset = offs; }
293  inline void setLength(guint leng) { fLength = leng; }
294  inline void setDelay(guint del) { fDelay = del; }
295  inline void setGainline(const Gainline& gain) { gainline = gain; }
296 
297  public:
298  void readJSON(gx_system::JsonParser& jp);
299  void writeJSON(gx_system::JsonWriter& w) const;
300 };
301 
302 class ConvolverAdapter;
303 
304 template<>
306 private:
311  sigc::signal<void, const GxJConvSettings*> changed;
312 public:
313  ParameterV(const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
315  ~ParameterV();
316  virtual void serializeJSON(gx_system::JsonWriter& jw);
317  sigc::signal<void, const GxJConvSettings*>& signal_changed() { return changed; }
318  static ParameterV<GxJConvSettings> *insert_param(
319  ParamMap &pmap, const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
320  bool set(const GxJConvSettings& val) const;
321  const GxJConvSettings& get_value() const { return *value; }
322  virtual void stdJSON_value();
323  virtual bool on_off_value();
324  virtual void writeJSON(gx_system::JsonWriter& jw) const;
325  virtual bool compareJSON_value();
326  virtual void setJSON_value();
327  virtual void readJSON_value(gx_system::JsonParser& jp);
328 };
329 
331 
332 
333 /****************************************************************
334  ** class ConvolverAdapter
335  */
336 
337 class ConvolverAdapter: protected PluginDef, public sigc::trackable {
338 protected:
340  boost::mutex activate_mutex;
342  sigc::slot<void> sync;
343  bool activated;
344  // wrapper for the rack order function pointers
345  void change_buffersize(unsigned int size);
347  JConvParameter *jcp;
348 public:
350 public:
351  ConvolverAdapter(EngineControl& engine, sigc::slot<void> sync);
352  ~ConvolverAdapter();
353  void restart();
354  bool conv_start();
355  inline const std::string& getIRFile() const { return jcset.getIRFile(); }
356  inline void set_sync(bool val) { conv.set_sync(val); }
357  inline std::string getFullIRPath() const { return jcset.getFullIRPath(); }
358  inline const std::string& getIRDir() const { return jcset.getIRDir(); }
359  bool set(const GxJConvSettings& jcset) const { return jcp->set(jcset); }
360  const GxJConvSettings& get_jcset() const { return jcset; }
361  ParamMap& get_parameter_map() const { return engine.get_param(); }
362 };
363 
364 
365 /****************************************************************
366  ** class ConvolverStereoAdapter
367  */
368 
369 #include "faust/jconv_post.h"
370 #include "faust/jconv_post_mono.h"
371 
373 private:
374  jconv_post::Dsp jc_post;
375  // wrapper for the rack order function pointers
376  static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
377  static int activate(bool start, PluginDef *pdef);
378  static void convolver(int count, float *input0, float *input1,
379  float *output0, float *output1, PluginDef*);
380  static int convolver_register(const ParamReg& reg);
381  static int jconv_load_ui(const UiBuilder& builder, int format);
382 public:
383  ConvolverStereoAdapter(EngineControl& engine, sigc::slot<void> sync);
385 };
386 
387 
388 /****************************************************************
389  ** class ConvolverMonoAdapter
390  */
391 
393 private:
394  jconv_post_mono::Dsp jc_post_mono;
395  // wrapper for the rack order function pointers
396  static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
397  static int activate(bool start, PluginDef *pdef);
398  static void convolver(int count, float *input, float *output, PluginDef*);
399  static int convolver_register(const ParamReg& reg);
400  static int jconv_load_ui(const UiBuilder& builder, int format);
401 public:
402  ConvolverMonoAdapter(EngineControl& engine, sigc::slot<void> sync);
404 };
405 
406 
407 /****************************************************************
408  ** class BaseConvolver
409  */
410 
411 
412 class BaseConvolver: protected PluginDef {
413 protected:
415  boost::mutex activate_mutex;
417  sigc::slot<void> sync;
418  bool activated;
419  sigc::connection update_conn;
420  static void init(unsigned int samplingFreq, PluginDef *p);
421  static int activate(bool start, PluginDef *pdef);
422  void change_buffersize(unsigned int);
423  int conv_start();
424  bool check_update_timeout();
425  virtual void check_update() = 0;
426  virtual bool start(bool force = false) = 0;
427 public:
429 public:
430  BaseConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
431  virtual ~BaseConvolver();
432  inline void set_sync(bool val) { conv.set_sync(val); }
433 };
434 
435 /****************************************************************
436  ** class FixedBaseConvolver
437  */
438 
439 
440 class FixedBaseConvolver: protected PluginDef {
441 protected:
443  boost::mutex activate_mutex;
445  sigc::slot<void> sync;
446  bool activated;
447  unsigned int SamplingFreq;
448  unsigned int buffersize;
449  unsigned int bz;
450  sigc::connection update_conn;
451  static void init(unsigned int samplingFreq, PluginDef *p);
452  unsigned int getSamplingFreq() { return SamplingFreq;};
453  static int activate(bool start, PluginDef *pdef);
454  void change_buffersize(unsigned int);
455  int conv_start();
456  bool check_update_timeout();
457  virtual void check_update() = 0;
458  virtual bool start(bool force = false) = 0;
459 public:
461 public:
462  FixedBaseConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
463  virtual ~FixedBaseConvolver();
464  inline void set_sync(bool val) { conv.set_sync(val); }
465 };
466 
467 /****************************************************************
468  ** class CabinetConvolver
469  */
470 
471 #include "faust/cabinet_impulse_former.h"
472 
474 private:
476  float level;
477  int cabinet;
478  float bass;
479  float treble;
480  float sum;
482  cabinet_impulse_former::Dsp impf;
484  static void run_cab_conf(int count, float *input, float *output, PluginDef*);
485  static int register_cab(const ParamReg& reg);
486  bool do_update();
487  virtual void check_update();
488  virtual bool start(bool force = false);
489  bool cabinet_changed() { return current_cab != cabinet; }
490  void update_cabinet() { current_cab = cabinet; }
491  bool sum_changed() { return std::abs(sum - (level + bass + treble)) > 0.01; }
492  void update_sum() { sum = level + bass + treble; }
493 public:
494  CabinetConvolver(EngineControl& engine, sigc::slot<void> sync,
496  ~CabinetConvolver();
497 };
498 
499 #include "faust/cabinet_impulse_former_st.h"
500 
502 private:
504  float level;
505  int cabinet;
506  float bass;
507  float treble;
508  float sum;
510  cabinet_impulse_former_st::Dsp impf;
513  static void run_cab_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
514  static int register_cab(const ParamReg& reg);
515  bool do_update();
516  virtual void check_update();
517  virtual bool start(bool force = false);
518  bool cabinet_changed() { return current_cab != cabinet; }
519  void update_cabinet() { current_cab = cabinet; }
520  bool sum_changed() { return fabs(sum - (level + bass + treble)) > 0.01; }
521  void update_sum() { sum = level + bass + treble; }
522 public:
523  CabinetStereoConvolver(EngineControl& engine, sigc::slot<void> sync,
526 };
527 
528 
529 /****************************************************************
530  ** class PreampConvolver
531  */
532 
533 #include "faust/preamp_impulse_former.h"
534 
536 private:
538  float level;
539  int preamp;
540  float bass;
541  float treble;
542  float sum;
544  preamp_impulse_former::Dsp impf;
546  static void run_pre_conf(int count, float *input, float *output, PluginDef*);
547  static int register_pre(const ParamReg& reg);
548  bool do_update();
549  virtual void check_update();
550  virtual bool start(bool force = false);
551  bool preamp_changed() { return current_pre != preamp; }
552  void update_preamp() { current_pre = preamp; }
553  bool sum_changed() { return std::abs(sum - (level + bass + treble)) > 0.01; }
554  void update_sum() { sum = level + bass + treble; }
555 public:
556  PreampConvolver(EngineControl& engine, sigc::slot<void> sync,
558  ~PreampConvolver();
559 };
560 
561 #include "faust/preamp_impulse_former_st.h"
562 
564 private:
566  float level;
567  int preamp;
568  float bass;
569  float treble;
570  float sum;
572  preamp_impulse_former_st::Dsp impf;
575  static void run_pre_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
576  static int register_pre(const ParamReg& reg);
577  bool do_update();
578  virtual void check_update();
579  virtual bool start(bool force = false);
580  bool preamp_changed() { return current_pre != preamp; }
581  void update_preamp() { current_pre = preamp; }
582  bool sum_changed() { return fabs(sum - (level + bass + treble)) > 0.01; }
583  void update_sum() { sum = level + bass + treble; }
584 public:
585  PreampStereoConvolver(EngineControl& engine, sigc::slot<void> sync,
588 };
589 
590 /****************************************************************
591  ** class ContrastConvolver
592  */
593 
594 #include "faust/presence_level.h"
595 
597 private:
598  float level;
599  float sum;
600  presence_level::Dsp presl;
602  static void run_contrast(int count, float *input, float *output, PluginDef*);
603  static int register_con(const ParamReg& reg);
604  inline void update_sum() { sum = level; }
605  virtual void check_update();
606  bool do_update();
607  inline bool sum_changed() { return std::abs(sum - level) > 0.01; }
608  virtual bool start(bool force = false);
609 public:
610  ContrastConvolver(EngineControl& engine, sigc::slot<void> sync,
613 };
614 
615 /****************************************************************
616  ** class LV2Features
617  */
618 
619 class LV2Features {
620 private:
621 
622  static LV2_Options_Option gx_options[2];
623  static LV2_Feature gx_options_feature;
624 
625  static LV2_URID lv2_urid_map(LV2_URID_Map_Handle, const char* const uri_);
626  static LV2_Feature gx_urid_map_feature;
627 
628 #pragma GCC diagnostic push
629 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
630  static uint32_t lv2_uri_to_id(LV2_URI_Map_Callback_Data handle, const char*, const char* uri);
631  static LV2_URI_Map_Feature gx_uri_map;
632  static LV2_Feature gx_uri_map_feature;
633 #pragma GCC diagnostic pop
634 
635  static const char* lv2_urid_unmap(LV2_URID_Unmap_Handle, const LV2_URID urid);
636  static LV2_Feature gx_urid_unmap_feature;
638 
639 public:
641  {
642  static LV2Features instance;
643  return instance;
644  }
645  static LV2_Feature* gx_features[];
646  static LV2_URID_Map gx_urid_map;
647  static LV2_URID_Unmap gx_urid_unmap;
648 
649  LV2Features(LV2Features const&) = delete;
650  void operator=(LV2Features const&) = delete;
651 
652 };
653 
654 /****************************************************************
655  ** class LadspaLoader
656  */
657 
659 
660 struct paradesc: boost::noncopyable {
661  int index;
662  std::string name;
663  float dflt;
664  float low;
665  float up;
666  float step;
668  bool newrow;
671  paradesc(): index(), name(), dflt(), low(), up(), step(), tp(), newrow(), has_caption(true), values() {}
672  ~paradesc();
673  void set_valuelist(const std::vector<std::string>& v);
674  void readJSON(gx_system::JsonParser& jp);
675  void writeJSON(gx_system::JsonWriter& jw);
676 };
677 
678 enum quirkflag { need_activate = 1, no_cleanup = 2, is_lv2 = 4 };
679 
680 class plugdesc {
681 public:
682  std::string path;
683  unsigned int index;
684  unsigned long UniqueID;
685  Glib::ustring Label;
686  Glib::ustring shortname;
687  Glib::ustring category;
688  int quirks; // quirkflag bits
692  Glib::ustring master_label;
693  std::vector<paradesc*> names;
694  std::string id_str;
695 private:
696  plugdesc() {}
697  ~plugdesc();
698  friend class LadspaLoader;
699 public:
700  void readJSON(gx_system::JsonParser& jp);
701  void writeJSON(gx_system::JsonWriter& jw);
702 };
703 
705 public:
706  typedef std::vector<plugdesc*> pluginarray;
707 private:
709  pluginarray plugins;
710  LilvWorld* world;
712  const LilvPlugins* lv2_plugins;
713  LilvNode* lv2_AudioPort;
714  LilvNode* lv2_ControlPort;
715  LilvNode* lv2_InputPort;
716  LilvNode* lv2_OutputPort;
717  LilvNode* lv2_AtomPort;
718 private:
719  void read_module_config(const std::string& filename, plugdesc *p);
720  void read_module_list(pluginarray& p);
721 public:
722  LadspaLoader(const gx_system::CmdlineOptions& options, ParamMap& param);
723  ~LadspaLoader();
724  bool load(pluginarray& p);
725  unsigned int size() { return plugins.size(); }
726  PluginDef *create(unsigned int idx) { return create(plugins[idx]); }
727  PluginDef *create(const plugdesc *p);
728  pluginarray::iterator begin() { return plugins.begin(); }
729  pluginarray::iterator end() { return plugins.end(); }
730  pluginarray::iterator find(plugdesc* desc);
731  void clear_list();
732  void set_plugins(pluginarray& new_plugins);
733  void update_instance(PluginDef *pdef, plugdesc *pdesc);
734  static std::string get_ladspa_filename(unsigned long uid)
735  { return "ladspa"+gx_system::to_string(uid)+".js"; }
736  static std::string get_ladspa_filename(std::string uid_key)
737  { return "ladspa"+uid_key.substr(9)+".js"; }
738  ParamMap& get_parameter_map() const { return param; }
739  friend class Lv2Dsp;
740 };
741 
742 
743 /****************************************************************
744  ** class Directout
745  */
746 
747 class Directout: public PluginDef {
748 public:
749  float* outdata;
750 private:
752  int bsize;
753  bool fdfill;
755  sigc::slot<void> sync;
756  void mem_alloc();
757  void mem_free();
758  void init(unsigned int samplingFreq);
759  void compute(int count, float *input0, float *input1, float *output0, float *output1);
760  void change_buffersize(unsigned int size);
761 
762  static void init_static(unsigned int samplingFreq, PluginDef*);
763  static void compute_static(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
764 public:
766  float* get_buffer() {return outdata;};
767  void set_data(bool dfill);
770  Directout( EngineControl& engine, sigc::slot<void> sync);
771  ~Directout();
772 };
773 
774 
775 /****************************************************************
776  ** class LiveLooper
777  */
778 
779 class LiveLooper: public PluginDef {
780 
781 
783 private:
784  Resampler r_file;
785  int inputRate, outputRate;
786 public:
787  int setup(int _inputRate, int _outputRate);
788  int run(int count, float *input, float *output);
789  int max_out_count(int in_count) {
790  return static_cast<int>(ceil((in_count*static_cast<double>(outputRate))/inputRate)); }
791 };
792 
793 private:
795  float gain;
796  float fRec0[2];
797  float gain_out;
798  float fclip1;
799  float fclip2;
800  float fclip3;
801  float fclip4;
802  float fclips1;
803  float fclips2;
804  float fclips3;
805  float fclips4;
806  float fspeed1;
807  float fspeed2;
808  float fspeed3;
809  float fspeed4;
810  float rplay1;
811  float rplay2;
812  float rplay3;
813  float rplay4;
814  float od1;
815  float od2;
816  float od3;
817  float od4;
818  float fod1;
819  float fod2;
820  float fod3;
821  float fod4;
822  float record1;
823  int iVec0[2];
824  int IOTA1;
825  int IOTA2;
826  int IOTA3;
827  int IOTA4;
828  float IOTAR1;
829  float IOTAR2;
830  float IOTAR3;
831  float IOTAR4;
832  float *tape1;
834  float fConst0;
835  float fConst1;
836  float fConst2;
837  float reset1;
838  int RecSize1[2];
839  float rectime0;
840  float fRec1[2];
841  float fRec2[2];
842  int iRec3[2];
843  int iRec4[2];
844  float play1;
845  float playh1;
846  float gain1;
847  float record2;
848  int iVec2[2];
849  float *tape2;
851  float reset2;
852  int RecSize2[2];
853  float rectime1;
854  float fRec6[2];
855  float fRec7[2];
856  int iRec8[2];
857  int iRec9[2];
858  float play2;
859  float playh2;
860  float gain2;
861  float record3;
862  int iVec4[2];
863  float *tape3;
865  float reset3;
866  int RecSize3[2];
867  float rectime2;
868  float fRec11[2];
869  float fRec12[2];
870  int iRec13[2];
871  int iRec14[2];
872  float play3;
873  float playh3;
874  float gain3;
875  float record4;
876  int iVec6[2];
877  float *tape4;
879  float reset4;
880  int RecSize4[2];
881  float rectime3;
882  float fRec16[2];
883  float fRec17[2];
884  int iRec18[2];
885  int iRec19[2];
886  float play4;
887  float playh4;
888  float gain4;
889  float play_all;
890  float dout;
891  float* outbuffer;
892  bool save1;
893  bool save2;
894  bool save3;
895  bool save4;
896  bool first1;
897  bool first2;
898  bool first3;
899  bool first4;
900  bool RP1;
901  bool RP2;
902  bool RP3;
903  bool RP4;
904  Glib::ustring preset_name;
905  Glib::ustring load_file1;
906  Glib::ustring load_file2;
907  Glib::ustring load_file3;
908  Glib::ustring load_file4;
909  Glib::ustring cur_name;
910  Glib::ustring loop_dir;
911  bool save_p;
914  sigc::slot<void> sync;
915  volatile int ready;
918 
919  int do_resample(int inrate, int insize, float *input, int maxsize);
920  int do_mono(int c, int f, float *oIn, float *tape, int n);
921  void play_all_tapes();
922  void mem_alloc();
923  void mem_free();
924  void clear_state_f();
925  int activate(bool start);
926  int load_ui_f(const UiBuilder& b, int form);
927  void init(unsigned int samplingFreq);
928  void compute(int count, float *input0, float *output0);
929  int register_par(const ParamReg& reg);
930  void save_array(std::string name);
931  void load_array(std::string name);
932  void save_to_wave(std::string fname, float *tape, float fSize, int tape_size);
933  int load_from_wave(std::string fname, float **tape, int tape_size);
934  void set_p_state();
935  void load_tape1();
936  void load_tape2();
937  void load_tape3();
938  void load_tape4();
939 
940  static void clear_state_f_static(PluginDef*);
941  static int activate_static(bool start, PluginDef*);
942  static int load_ui_f_static(const UiBuilder& b, int form);
943  static void init_static(unsigned int samplingFreq, PluginDef*);
944  static void compute_static(int count, float *input0, float *output0, PluginDef*);
945  static int register_params_static(const ParamReg& reg);
946  static void del_instance(PluginDef *p);
947 public:
949  LiveLooper(ParamMap& param_, sigc::slot<void> sync, const string& loop_dir_);
950  ~LiveLooper();
951 };
952 
953 
954 /****************************************************************
955  ** class SCapture
956  */
957 
958 
959 class SCapture: public PluginDef {
960 private:
961  SNDFILE * recfile;
964  int channel;
965  float fcheckbox0;
966  float fcheckbox1;
967  float fslider0;
968  float fbargraph0;
969  float fRecC0[2];
970  float fformat;
971  int IOTA;
972  int iA;
973  int savesize;
974  int filesize;
975  float *fRec0;
976  float *fRec1;
977  float *tape;
978  sem_t m_trig;
979  pthread_t m_pthr;
980  volatile bool keep_stream;
982  bool is_wav;
983  bool err;
984  float fConst0;
985  float fRecb0[2];
986  int iRecb1[2];
987  float fRecb2[2];
988  void mem_alloc();
989  void mem_free();
990  void clear_state_f();
991  int activate(bool start);
992  int load_ui_f(const UiBuilder& b, int form);
993  void init(unsigned int samplingFreq);
994  void compute(int count, float *input0, float *output0);
995  void compute_st(int count, float *input0, float *input1, float *output0, float *output1);
996  int register_par(const ParamReg& reg);
997  void save_to_wave(SNDFILE * sf, float *tape, int lSize);
998  SNDFILE *open_stream(std::string fname);
999  void close_stream(SNDFILE **sf);
1000  void stop_thread();
1001  void start_thread();
1002  void disc_stream();
1003  inline std::string get_ffilename();
1004 
1005  static void *run_thread(void* p);
1006  static void clear_state_f_static(PluginDef*);
1007  static int activate_static(bool start, PluginDef*);
1008  static const char *glade_def;
1009  static const char *glade_def_st;
1010  static int load_ui_f_static(const UiBuilder& b, int form);
1011  static void init_static(unsigned int samplingFreq, PluginDef*);
1012  static void compute_static(int count, float *input0, float *output0, PluginDef*);
1013  static void compute_static_st(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1014  static int register_params_static(const ParamReg& reg);
1015  static void del_instance(PluginDef *p);
1016 public:
1018  SCapture(EngineControl& engine, int channel_);
1019  ~SCapture();
1020 };
1021 
1022 /****************************************************************
1023  ** class DrumSequencer
1024  */
1025 
1026 #include "faust/drumseq.h"
1027 
1028 class Drumout {
1029 private:
1030  static float* set;
1031  static bool mb;
1032  static float* data;
1034  static void outputdrum_compute(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1035 public:
1036  static void set_plugin(Plugin p);
1037  static void set_data(float* mode, bool ready, float* buf);
1040  Drumout();
1041 };
1042 
1043 
1044 class DrumSequencer: public PluginDef {
1045 private:
1052  drumseq::Dsp drums;
1053 
1054  int counter;
1056  int bsize;
1069  std::vector<int> Vectom;
1070  std::vector<int> Vectom1;
1071  std::vector<int> Vectom2;
1072  std::vector<int> Veckick;
1073  std::vector<int> Vecsnare;
1074  std::vector<int> Vechat;
1075 
1078  sigc::slot<void> sync;
1079  volatile bool ready;
1080  float *outdata;
1082  SeqParameter *tomp;
1084  SeqParameter *tomp1;
1086  SeqParameter *tomp2;
1088  SeqParameter *snarep;
1090  SeqParameter *hatp;
1092  SeqParameter *kickp;
1093 
1094  void mem_alloc();
1095  void mem_free();
1096  void init(unsigned int samplingFreq);
1097  void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
1098  void change_buffersize(unsigned int size);
1099  int register_par(const ParamReg& reg);
1100 
1101  int min_seq_size();
1102  void reset_tom();
1103  void reset_tom1();
1104  void reset_tom2();
1105  void reset_kick();
1106  void reset_hat();
1107  void reset_snare();
1108 
1109  static void init_static(unsigned int samplingFreq, PluginDef*);
1110  static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef*);
1111  static int register_params_static(const ParamReg& reg);
1112  static void del_instance(PluginDef *p);
1113  static int drum_load_ui(const UiBuilder& builder, int format);
1114 public:
1116  DrumSequencer(EngineControl& engine, sigc::slot<void> sync);
1117  ~DrumSequencer();
1118 };
1119 
1120 /****************************************************************************
1121 *
1122 * NAME: smbPitchShift.cpp
1123 * VERSION: 1.2
1124 * HOME URL: http://www.dspdimension.com
1125 * KNOWN BUGS: none
1126 *
1127 *
1128 * COPYRIGHT 1999-2009 Stephan M. Bernsee <smb [AT] dspdimension [DOT] com>
1129 *
1130 * Modified for guitarix by Hermann Meyer 2014
1131 *
1132 * The Wide Open License (WOL)
1133 *
1134 * Permission to use, copy, modify, distribute and sell this software and its
1135 * documentation for any purpose is hereby granted without fee, provided that
1136 * the above copyright notice and this license appear in all source copies.
1137 * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
1138 * ANY KIND. See http://www.dspguru.com/wol.htm for more information.
1139 *
1140 *****************************************************************************/
1141 
1142 
1143 #define M_PI 3.14159265358979323846
1144 #define MAX_FRAME_LENGTH 8096
1145 
1146 class smbPitchShift : public PluginDef {
1147 private:
1151  sigc::slot<void> sync;
1152  volatile bool ready;
1153  float gInFIFO[MAX_FRAME_LENGTH];
1154  float gOutFIFO[MAX_FRAME_LENGTH];
1155  float *fpb;
1156  float *expect;
1157  float *hanning;
1158  float *hanningd;
1159  float *resampin;
1160  float *resampin2;
1161  float *resampout;
1162  float *indata2;
1163  float gLastPhase[MAX_FRAME_LENGTH/2+1];
1164  float gSumPhase[MAX_FRAME_LENGTH/2+1];
1165  float gOutputAccum[2*MAX_FRAME_LENGTH];
1166  float gAnaFreq[MAX_FRAME_LENGTH];
1167  float gAnaMagn[MAX_FRAME_LENGTH];
1168  float gSynFreq[MAX_FRAME_LENGTH];
1169  float gSynMagn[MAX_FRAME_LENGTH];
1170  float semitones;
1171  float a,b,c,d,l;
1172  float wet;
1173  float dry;
1174  float mpi, mpi1;
1175  float tone;
1176  int octave, osamp, numSampsToResamp, numSampsToProcess, fftFrameSize, sampleRate ;
1177  int latency;
1178  int ai;
1179  int aio;
1180  int ii;
1181  long gRover ;
1182  double magn, phase, tmp, real, imag;
1183  double freqPerBin, freqPerBin1, freqPerBin2, expct;
1186  double osamp1,osamp2;
1187  long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2;
1188 
1189  fftwf_complex fftw_in[MAX_FRAME_LENGTH], fftw_out[MAX_FRAME_LENGTH];
1190  fftwf_plan ftPlanForward, ftPlanInverse;
1191 
1192  inline int load_ui_f(const UiBuilder& b, int form);
1193  int register_par(const ParamReg& reg);
1194  void change_latency();
1195 
1196  void mem_alloc();
1197  void mem_free();
1198  void clear_state();
1199  int activate(bool start);
1200  bool setParameters( int sampleRate);
1201  void PitchShift(int count, float *indata, float *outdata);
1202  void change_buffersize(unsigned int size);
1203  static int activate_static(bool start, PluginDef*);
1204  static void del_instance(PluginDef *p);
1205  static int registerparam(const ParamReg& reg);
1206  static int load_ui_f_static(const UiBuilder& b, int form);
1207  static void init(unsigned int sampleRate, PluginDef *plugin);
1208  static void compute_static(int count, float *input0, float *output0, PluginDef *p);
1209 
1210 public:
1212  smbPitchShift(EngineControl& engine, sigc::slot<void> sync);
1213  ~smbPitchShift();
1214 };
1215 
1216 
1217 } // namespace gx_engine
ParameterV< GxSeqSettings > SeqParameter
static LV2_URID_Unmap gx_urid_unmap
void setseqline(const std::vector< int > &seq)
pluginarray::iterator end()
gx_resample::SimpleResampler resamp
const std::vector< int > & getseqline() const
unsigned int get_buffer_size() const
ParameterV< GxJConvSettings > JConvParameter
sigc::signal< void, const OscilloscopeInfo & > changed
ParameterV< OscilloscopeInfo > OscParameter
const std::string & getIRDir() const
const Gainline & getGainline() const
bool set(const GxJConvSettings &val) const
std::string getFullIRPath() const
gx_resample::FixedRateResampler smp
static std::string get_ladspa_filename(std::string uid_key)
std::vector< plugdesc * > pluginarray
static LV2_Feature gx_options_feature
static LV2_Feature gx_uri_map_feature
preamp_impulse_former::Dsp impf
std::string getFullIRPath() const
sigc::signal< void(unsigned int, float *)> signal_size_change()
const std::string & getIRDir() const
static LV2_URI_Map_Feature gx_uri_map
preamp_impulse_former_st::Dsp impf
static LV2_Feature gx_urid_unmap_feature
ParamMap & get_parameter_map() const
const LilvPlugins * lv2_plugins
gx_resample::FixedRateResampler smp
sigc::signal< void, const GxJConvSettings * > & signal_changed()
#define FAUSTFLOAT
const GxJConvSettings & get_jcset() const
const std::string & getIRFile() const
sigc::signal< void, const OscilloscopeInfo & > & signal_changed()
static PluginDef outputdrum
void set_jack(gx_jack::GxJack &jack)
PluginDef * create(unsigned int idx)
static PluginDef outputgate
gx_resample::FixedRateResampler smp
static const char * glade_def
cabinet_impulse_former::Dsp impf
Parameter registration function pointers.
Definition: gx_plugin.h:141
sigc::slot< void > sync
gx_resample::FixedRateResampler smp
const std::string & getIRFile() const
static LV2_URID_Map gx_urid_map
static const char * glade_def_st
std::string to_string(const T &t)
Definition: gx_system.h:554
#define MAX_FRAME_LENGTH
std::vector< paradesc * > names
sigc::slot< void > sync
const GxJConvSettings & get_value() const
static LV2Features & getInstance()
pluginarray::iterator begin()
void setGainline(const Gainline &gain)
gx_resample::FixedRateResampler smp
cabinet_impulse_former_st::Dsp impf
gx_resample::FixedRateResampler smps
void set_dep_module(Plugin *dep)
Glib::Dispatcher & signal_freq_changed()
sigc::signal< void, const GxSeqSettings * > & signal_changed()
const gx_system::CmdlineOptions & options
ParamMap & get_parameter_map() const
static std::string get_ladspa_filename(unsigned long uid)
static LV2_Feature gx_urid_map_feature
static PluginDef inputdef
sigc::signal< void, const GxJConvSettings * > changed
Glib::Dispatcher new_freq
const GxSeqSettings & get_value() const
sigc::signal< void, const GxSeqSettings * > changed
void set_mul_buffer(int a, unsigned int b)
sigc::signal< void(unsigned int, float *)> size_change
gx_resample::FixedRateResampler smps