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, MidiAudioBuffer
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 public:
58  static float get(unsigned int channel) {
59  assert(channel < channelcount);
60  float v = maxlevel[channel];
61  maxlevel[channel] = 0;
62  return v;
63  }
64  MaxLevel();
65 };
66 
67 
68 /****************************************************************
69  ** class TunerAdapter
70  */
71 
72 class TunerAdapter: public ModuleSelector, private PluginDef, public sigc::trackable {
73 private:
74  static void feed_tuner(int count, float *input, float *output, PluginDef*);
75  static int regparam(const ParamReg& reg);
76  static int activate(bool start, PluginDef *plugin);
77  static void init(unsigned int samplingFreq, PluginDef *plugin);
78  PitchTracker pitch_tracker;
79  int state;
80  ModuleSequencer& engine;
81  enum { tuner_use = 0x01, switcher_use = 0x02, midi_use = 0x04 };
82  void set_and_check(int use, bool on);
83  Plugin* dep_plugin;
84 public:
87  void used_for_switching(bool on) { set_and_check(switcher_use, on); }
88  void used_for_display(bool on) { set_and_check(tuner_use, on); }
89  bool used_for_display() { return state & tuner_use; }
90  void used_by_midi(bool on) { set_and_check(midi_use, on); }
91  void set_dep_module(Plugin* dep) { dep_plugin = dep; }
92  void set_module();
93  Glib::Dispatcher& signal_freq_changed() { return pitch_tracker.new_freq; }
94  float get_freq() { return pitch_tracker.get_estimated_freq(); }
95  float get_note() { return pitch_tracker.get_estimated_note(); }
96 };
97 
98 
99 /****************************************************************
100  ** class MidiAudioBuffer
101  */
102 
104 private:
105  float fslider45;
106  float fslider38;
107  float fslider31;
108  float fslider27;
109  float fslider29;
110  float fslider30;
111  float fslider26;
112  float fslider33;
113  float fslider34;
114  float fslider35;
115  float fslider36;
116  float fslider42;
117  float fslider43;
118  float fslider40;
119  float fslider41;
120  float fslider44;
121  float fslider37;
122  float fslider39;
123  float fslider46;
124  float fslider47;
125  float fslider48;
126  float fConstlog;
127  float fConstlog2;
128  float beat0;
129  float midi_gain;
130  float fConstun0;
131  float fslider32;
132  float BeatFilter1;
133  float BeatFilter2;
134  float BeatFilterk;
135  bool fautogain;
136  bool fpitch;
137  bool fautogain1;
138  bool fpitch1;
139  bool fpitch2;
140  bool fautogain2;
141  bool midistat;
142  bool midistat1;
143  bool midistat2;
144  bool midistat3;
145 
146  int weg;
147  int program;
148  int program2;
149  int volume2;
150  int Beat_is;
151  int send;
152  int volume;
153  int noten;
154  int program1;
155  int send1;
156  int noten1;
157  int volume1;
158  int send2;
159  int noten2;
160 
161  bool fcheckbox10;
162  bool fcheckbox11;
163 
164  unsigned char* midi_send;
165  unsigned char* midi_send1;
166  unsigned char* midi_send2;
167 
168 public:
169  void register_parameter(const ParamReg& reg);
170  void init(int samplingFreq);
171  void process_midi(int len, float *audiodata, void *midi_port_buf, float jcpu_load,
172  float fConsta4, float fConsta1t);
173  bool get_midistat() { return midistat; }
174 };
175 
176 
178 public:
179  enum Load { load_off = -1, load_low = 0, load_high = 1, load_over = 2 };
180 private:
181  MidiVariables midi;
183  gx_jack::GxJack* jack;
184  Load jack_overload;
185  Glib::Dispatcher overload_change;
186  static void fill_buffer(int count, float *input0, float *output0, PluginDef*);
187  static int regparam(const ParamReg& reg);
188  static void init(unsigned int samplingFreq, PluginDef *plugin);
189  static int activate(bool start, PluginDef *plugin);
190 public:
193  void set_jack(gx_jack::GxJack* jack_) { jack = jack_; }
194  bool get_midistat() { return midi.get_midistat(); }
195  Load jack_load_status() { return jack_overload; }
196  Glib::Dispatcher& signal_jack_load_change() { return overload_change; }
197 };
198 
199 
200 /****************************************************************
201  ** class NoiseGate
202  */
203 
204 class NoiseGate {
205 private:
206  static PluginDef inputdef;
207  static float fnglevel;
208  static float ngate;
209  static bool off;
210  static int noisegate_register(const ParamReg& reg);
211  static void inputlevel_compute(int count, float *input0, float *output0, PluginDef*);
212  static void outputgate_compute(int count, float *input, float *output, PluginDef*);
213  static int outputgate_activate(bool start, PluginDef *pdef);
214 public:
217  NoiseGate();
218 };
219 
220 
221 /****************************************************************
222  ** class OscilloscopeAdapter
223  */
224 
226 private:
227  static float* buffer;
228  static unsigned int size;
229  static void fill_buffer(int count, float *input0, float *output0, PluginDef*);
230  static int osc_register(const ParamReg& reg);
231  static int activate(bool start, PluginDef *p);
232  void change_buffersize(unsigned int);
233  int mul_buffer;
234 public:
236  sigc::signal<int, bool> activation;
237  sigc::signal<void, unsigned int> size_change;
238  void clear_buffer();
239  unsigned int get_size() { return size; }
240  inline float *get_buffer() { return buffer; }
241  int get_mul_buffer() { return mul_buffer; }
242  void set_mul_buffer(int a, unsigned int b) { mul_buffer = a; change_buffersize(b); }
244 };
245 
246 
247 /****************************************************************
248  ** class GxSeqSettings
249  */
250 
252  private:
253 
254  std::vector<int> seqline;
255  void read_seqline(gx_system::JsonParser& jp);
256  friend class SequencerAdapter;
257  friend class ParameterV<GxSeqSettings>;
258  public:
259  GxSeqSettings();
260  GxSeqSettings& operator=(GxSeqSettings const& seqset);
261  bool operator==(const GxSeqSettings& seqset) const;
262  // getters and setters
263  inline const std::vector<int>& getseqline() const { return seqline; }
264 
265  inline void setseqline(const std::vector<int>& seq) { seqline = seq; }
266 
267  public:
268  void readJSON(gx_system::JsonParser& jp);
269  void writeJSON(gx_system::JsonWriter& w) const;
270 };
271 
272 template<>
274 private:
275  GxSeqSettings json_value;
276  GxSeqSettings *value;
277  GxSeqSettings std_value;
278  GxSeqSettings value_storage;
279  sigc::signal<void, const GxSeqSettings*> changed;
280 public:
281  ParameterV(const string& id, GxSeqSettings *v);
283  ~ParameterV();
284  virtual void serializeJSON(gx_system::JsonWriter& jw);
285  sigc::signal<void, const GxSeqSettings*>& signal_changed() { return changed; }
286  static ParameterV<GxSeqSettings> *insert_param(
287  ParamMap &pmap, const string& id, GxSeqSettings *v);
288  bool set(const GxSeqSettings& val) const;
289  const GxSeqSettings& get_value() const { return *value; }
290  virtual void stdJSON_value();
291  virtual bool on_off_value();
292  virtual void writeJSON(gx_system::JsonWriter& jw) const;
293  virtual bool compareJSON_value();
294  virtual void setJSON_value();
295  virtual void readJSON_value(gx_system::JsonParser& jp);
296 };
297 
299 
300 /****************************************************************
301  ** class GxJConvSettings
302  */
303 
305  private:
306  // main jconv setting
307  std::string fIRFile;
308  std::string fIRDir;
309 
310  float fGain; // jconv gain
311  guint fOffset; // offset in IR where to start comvolution
312  guint fLength; // length of the IR to use for convolution
313  guint fDelay; // delay when to apply reverb
314  Gainline gainline;
315  bool fGainCor;
316  void read_gainline(gx_system::JsonParser& jp);
317  inline void setIRDir(string name) { fIRDir = name; }
318  friend class ConvolverAdapter;
320  public:
321  GxJConvSettings();
322  GxJConvSettings& operator=(GxJConvSettings const& jcset);
323  bool operator==(const GxJConvSettings& jcset) const;
324  // getters and setters
325  inline const std::string& getIRFile() const { return fIRFile; }
326  std::string getFullIRPath() const;
327  inline float getGain() const { return fGain; }
328  inline guint getOffset() const { return fOffset; }
329  inline guint getLength() const { return fLength; }
330  inline guint getDelay() const { return fDelay; }
331  inline bool getGainCor() const { return fGainCor; }
332  inline const Gainline& getGainline() const { return gainline; }
333  const std::string& getIRDir() const { return fIRDir; }
334  void setFullIRPath(string name);
335  inline void setIRFile(string name) { fIRFile = name; }
336  inline void setGain(float gain) { fGain = gain; }
337  inline void setGainCor(bool gain) { fGainCor = gain; }
338  inline void setOffset(guint offs) { fOffset = offs; }
339  inline void setLength(guint leng) { fLength = leng; }
340  inline void setDelay(guint del) { fDelay = del; }
341  inline void setGainline(const Gainline& gain) { gainline = gain; }
342 
343  public:
344  void readJSON(gx_system::JsonParser& jp);
345  void writeJSON(gx_system::JsonWriter& w) const;
346 };
347 
348 class ConvolverAdapter;
349 
350 template<>
352 private:
353  const gx_system::PathList *searchpath;
354  const gx_system::PrefixConverter* pfx_conv;
355  GxJConvSettings json_value;
356  GxJConvSettings *value;
357  GxJConvSettings std_value;
358  GxJConvSettings value_storage;
359  sigc::signal<void, const GxJConvSettings*> changed;
360 public:
361  ParameterV(const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
363  ~ParameterV();
364  virtual void serializeJSON(gx_system::JsonWriter& jw);
365  sigc::signal<void, const GxJConvSettings*>& signal_changed() { return changed; }
366  static ParameterV<GxJConvSettings> *insert_param(
367  ParamMap &pmap, const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
368  bool set(const GxJConvSettings& val) const;
369  const GxJConvSettings& get_value() const { return *value; }
370  virtual void stdJSON_value();
371  virtual bool on_off_value();
372  virtual void writeJSON(gx_system::JsonWriter& jw) const;
373  virtual bool compareJSON_value();
374  virtual void setJSON_value();
375  virtual void readJSON_value(gx_system::JsonParser& jp);
376 };
377 
379 
380 
381 /****************************************************************
382  ** class ConvolverAdapter
383  */
384 
385 class ConvolverAdapter: protected PluginDef, public sigc::trackable {
386 protected:
388  boost::mutex activate_mutex;
390  sigc::slot<void> sync;
392  bool activated;
393  // wrapper for the rack order function pointers
394  void change_buffersize(unsigned int size);
396  JConvParameter *jcp;
397 public:
399 public:
400  ConvolverAdapter(EngineControl& engine, sigc::slot<void> sync, ParamMap& param);
401  ~ConvolverAdapter();
402  void restart();
403  bool conv_start();
404  inline const std::string& getIRFile() const { return jcset.getIRFile(); }
405  inline void set_sync(bool val) { conv.set_sync(val); }
406  inline std::string getFullIRPath() const { return jcset.getFullIRPath(); }
407  inline const std::string& getIRDir() const { return jcset.getIRDir(); }
408  bool set(const GxJConvSettings& jcset) const { return jcp->set(jcset); }
409  const GxJConvSettings& get_jcset() const { return jcset; }
410  ParamMap& get_parameter_map() const { return param; }
411 };
412 
413 
414 /****************************************************************
415  ** class ConvolverStereoAdapter
416  */
417 
418 #include "faust/jconv_post.h"
419 #include "faust/jconv_post_mono.h"
420 
422 private:
423  jconv_post::Dsp jc_post;
424  // wrapper for the rack order function pointers
425  static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
426  static int activate(bool start, PluginDef *pdef);
427  static void convolver(int count, float *input0, float *input1,
428  float *output0, float *output1, PluginDef*);
429  static int convolver_register(const ParamReg& reg);
430 public:
431  ConvolverStereoAdapter(EngineControl& engine, sigc::slot<void> sync, ParamMap& param);
433 };
434 
435 
436 /****************************************************************
437  ** class ConvolverMonoAdapter
438  */
439 
441 private:
442  jconv_post_mono::Dsp jc_post_mono;
443  // wrapper for the rack order function pointers
444  static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
445  static int activate(bool start, PluginDef *pdef);
446  static void convolver(int count, float *input, float *output, PluginDef*);
447  static int convolver_register(const ParamReg& reg);
448 public:
449  ConvolverMonoAdapter(EngineControl& engine, sigc::slot<void> sync, ParamMap& param);
451 };
452 
453 
454 /****************************************************************
455  ** class BaseConvolver
456  */
457 
458 
459 class BaseConvolver: protected PluginDef {
460 protected:
462  boost::mutex activate_mutex;
464  sigc::slot<void> sync;
465  bool activated;
466  sigc::connection update_conn;
467  static void init(unsigned int samplingFreq, PluginDef *p);
468  static int activate(bool start, PluginDef *pdef);
469  void change_buffersize(unsigned int);
470  int conv_start();
471  bool check_update_timeout();
472  virtual void check_update() = 0;
473  virtual bool start(bool force = false) = 0;
474 public:
476 public:
477  BaseConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
478  virtual ~BaseConvolver();
479  inline void set_sync(bool val) { conv.set_sync(val); }
480 };
481 
482 /****************************************************************
483  ** class FixedBaseConvolver
484  */
485 
486 
487 class FixedBaseConvolver: protected PluginDef {
488 protected:
490  boost::mutex activate_mutex;
492  sigc::slot<void> sync;
493  bool activated;
494  unsigned int SamplingFreq;
495  unsigned int buffersize;
496  unsigned int bz;
497  sigc::connection update_conn;
498  static void init(unsigned int samplingFreq, PluginDef *p);
499  unsigned int getSamplingFreq() { return SamplingFreq;};
500  static int activate(bool start, PluginDef *pdef);
501  void change_buffersize(unsigned int);
502  int conv_start();
503  bool check_update_timeout();
504  virtual void check_update() = 0;
505  virtual bool start(bool force = false) = 0;
506 public:
508 public:
509  FixedBaseConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
510  virtual ~FixedBaseConvolver();
511  inline void set_sync(bool val) { conv.set_sync(val); }
512 };
513 
514 /****************************************************************
515  ** class CabinetConvolver
516  */
517 
518 #include "faust/cabinet_impulse_former.h"
519 
521 private:
522  int current_cab;
523  float level;
524  int cabinet;
525  float bass;
526  float treble;
527  float sum;
528  value_pair *cab_names;
529  cabinet_impulse_former::Dsp impf;
531  static void run_cab_conf(int count, float *input, float *output, PluginDef*);
532  static int register_cab(const ParamReg& reg);
533  bool do_update();
534  virtual void check_update();
535  virtual bool start(bool force = false);
536  bool cabinet_changed() { return current_cab != cabinet; }
537  void update_cabinet() { current_cab = cabinet; }
538  bool sum_changed() { return std::abs(sum - (level + bass + treble)) > 0.01; }
539  void update_sum() { sum = level + bass + treble; }
540 public:
541  CabinetConvolver(EngineControl& engine, sigc::slot<void> sync,
543  ~CabinetConvolver();
544 };
545 
546 #include "faust/cabinet_impulse_former_st.h"
547 
549 private:
550  int current_cab;
551  float level;
552  int cabinet;
553  float bass;
554  float treble;
555  float sum;
556  value_pair *cab_names;
557  cabinet_impulse_former_st::Dsp impf;
560  static void run_cab_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
561  static int register_cab(const ParamReg& reg);
562  bool do_update();
563  virtual void check_update();
564  virtual bool start(bool force = false);
565  bool cabinet_changed() { return current_cab != cabinet; }
566  void update_cabinet() { current_cab = cabinet; }
567  bool sum_changed() { return fabs(sum - (level + bass + treble)) > 0.01; }
568  void update_sum() { sum = level + bass + treble; }
569 public:
570  CabinetStereoConvolver(EngineControl& engine, sigc::slot<void> sync,
573 };
574 
575 
576 /****************************************************************
577  ** class PreampConvolver
578  */
579 
580 #include "faust/preamp_impulse_former.h"
581 
583 private:
584  int current_pre;
585  float level;
586  int preamp;
587  float bass;
588  float treble;
589  float sum;
590  value_pair *pre_names;
591  preamp_impulse_former::Dsp impf;
593  static void run_pre_conf(int count, float *input, float *output, PluginDef*);
594  static int register_pre(const ParamReg& reg);
595  bool do_update();
596  virtual void check_update();
597  virtual bool start(bool force = false);
598  bool preamp_changed() { return current_pre != preamp; }
599  void update_preamp() { current_pre = preamp; }
600  bool sum_changed() { return std::abs(sum - (level + bass + treble)) > 0.01; }
601  void update_sum() { sum = level + bass + treble; }
602 public:
603  PreampConvolver(EngineControl& engine, sigc::slot<void> sync,
605  ~PreampConvolver();
606 };
607 
608 #include "faust/preamp_impulse_former_st.h"
609 
611 private:
612  int current_pre;
613  float level;
614  int preamp;
615  float bass;
616  float treble;
617  float sum;
618  value_pair *pre_names;
619  preamp_impulse_former_st::Dsp impf;
622  static void run_pre_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
623  static int register_pre(const ParamReg& reg);
624  bool do_update();
625  virtual void check_update();
626  virtual bool start(bool force = false);
627  bool preamp_changed() { return current_pre != preamp; }
628  void update_preamp() { current_pre = preamp; }
629  bool sum_changed() { return fabs(sum - (level + bass + treble)) > 0.01; }
630  void update_sum() { sum = level + bass + treble; }
631 public:
632  PreampStereoConvolver(EngineControl& engine, sigc::slot<void> sync,
635 };
636 
637 /****************************************************************
638  ** class ContrastConvolver
639  */
640 
641 #include "faust/presence_level.h"
642 
644 private:
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();
653  bool do_update();
654  inline bool sum_changed() { return std::abs(sum - level) > 0.01; }
655  virtual bool start(bool force = false);
656 public:
657  ContrastConvolver(EngineControl& engine, sigc::slot<void> sync,
660 };
661 
662 /****************************************************************
663  ** class LV2Features
664  */
665 
666 class LV2Features {
667 private:
668 
669  static LV2_Options_Option gx_options[2];
670  static LV2_Feature gx_options_feature;
671 
672  static LV2_URID lv2_urid_map(LV2_URID_Map_Handle, const char* const uri_);
673  static LV2_Feature gx_urid_map_feature;
674 
675  static uint32_t lv2_uri_to_id(LV2_URI_Map_Callback_Data handle, const char*, const char* uri);
676  static LV2_URI_Map_Feature gx_uri_map;
677  static LV2_Feature gx_uri_map_feature;
678 
679  static const char* lv2_urid_unmap(LV2_URID_Unmap_Handle, const LV2_URID urid);
680  static LV2_Feature gx_urid_unmap_feature;
681  LV2Features() {};
682 
683 public:
685  {
686  static LV2Features instance;
687  return instance;
688  }
689  static LV2_Feature* gx_features[];
690  static LV2_URID_Map gx_urid_map;
691  static LV2_URID_Unmap gx_urid_unmap;
692 
693  LV2Features(LV2Features const&) = delete;
694  void operator=(LV2Features const&) = delete;
695 
696 };
697 
698 /****************************************************************
699  ** class LadspaLoader
700  */
701 
703 
704 struct paradesc: boost::noncopyable {
705  int index;
706  std::string name;
707  float dflt;
708  float low;
709  float up;
710  float step;
712  bool newrow;
715  paradesc(): index(), name(), dflt(), low(), up(), step(), tp(), newrow(), has_caption(true), values() {}
716  ~paradesc();
717  void set_valuelist(const std::vector<std::string>& v);
718  void readJSON(gx_system::JsonParser& jp);
719  void writeJSON(gx_system::JsonWriter& jw);
720 };
721 
722 enum quirkflag { need_activate = 1, no_cleanup = 2, is_lv2 = 4 };
723 
724 class plugdesc {
725 public:
726  std::string path;
727  unsigned int index;
728  unsigned long UniqueID;
729  Glib::ustring Label;
730  Glib::ustring shortname;
731  Glib::ustring category;
732  int quirks; // quirkflag bits
736  Glib::ustring master_label;
737  std::vector<paradesc*> names;
738  std::string id_str;
739 private:
740  plugdesc() {}
741  ~plugdesc();
742  friend class LadspaLoader;
743 public:
744  void readJSON(gx_system::JsonParser& jp);
745  void writeJSON(gx_system::JsonWriter& jw);
746 };
747 
749 public:
750  typedef std::vector<plugdesc*> pluginarray;
751 private:
752  const gx_system::CmdlineOptions& options;
753  pluginarray plugins;
754  LilvWorld* world;
755  const LilvPlugins* lv2_plugins;
756  LilvNode* lv2_AudioPort;
757  LilvNode* lv2_ControlPort;
758  LilvNode* lv2_InputPort;
759  LilvNode* lv2_OutputPort;
760 private:
761  void read_module_config(const std::string& filename, plugdesc *p);
762  void read_module_list(pluginarray& p);
763 public:
764  LadspaLoader(const gx_system::CmdlineOptions& options);
765  ~LadspaLoader();
766  bool load(pluginarray& p);
767  unsigned int size() { return plugins.size(); }
768  PluginDef *create(unsigned int idx) { return create(plugins[idx]); }
769  PluginDef *create(const plugdesc *p);
770  pluginarray::iterator begin() { return plugins.begin(); }
771  pluginarray::iterator end() { return plugins.end(); }
772  pluginarray::iterator find(plugdesc* desc);
773  void set_plugins(pluginarray& new_plugins);
774  void change_plugins(pluginarray& new_plugins);
775  void update_instance(PluginDef *pdef, plugdesc *pdesc);
776  static std::string get_ladspa_filename(unsigned long uid)
777  { return "ladspa"+gx_system::to_string(uid)+".js"; }
778  static std::string get_ladspa_filename(std::string uid_key)
779  { return "ladspa"+uid_key.substr(9)+".js"; }
780  friend class Lv2Dsp;
781 };
782 
783 
784 /****************************************************************
785  ** class Directout
786  */
787 
788 class Directout: public PluginDef {
789 public:
790  float* outdata;
791 private:
792  int fSamplingFreq;
793  int bsize;
794  bool fdfill;
795  EngineControl& engine;
796  sigc::slot<void> sync;
797  void mem_alloc();
798  void mem_free();
799  void init(unsigned int samplingFreq);
800  void compute(int count, float *input0, float *input1, float *output0, float *output1);
801  void change_buffersize(unsigned int size);
802 
803  static void init_static(unsigned int samplingFreq, PluginDef*);
804  static void compute_static(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
805 public:
807  float* get_buffer() {return outdata;};
808  void set_data(bool dfill);
811  Directout( EngineControl& engine, sigc::slot<void> sync);
812  ~Directout();
813 };
814 
815 
816 /****************************************************************
817  ** class LiveLooper
818  */
819 
820 class LiveLooper: public PluginDef {
821 
822 
823 class FileResampler {
824 private:
825  Resampler r_file;
826  int inputRate, outputRate;
827  int last_in_count;
828 public:
829  int setup(int _inputRate, int _outputRate);
830  int run(int count, float *input, float *output);
831  int max_out_count(int in_count) {
832  return static_cast<int>(ceil((in_count*static_cast<double>(outputRate))/inputRate)); }
833 };
834 
835 private:
836  int fSamplingFreq;
837  float gain;
838  float fRec0[2];
839  float gain_out;
840  float fclip1;
841  float fclip2;
842  float fclip3;
843  float fclip4;
844  float fclips1;
845  float fclips2;
846  float fclips3;
847  float fclips4;
848  float fspeed1;
849  float fspeed2;
850  float fspeed3;
851  float fspeed4;
852  float rplay1;
853  float rplay2;
854  float rplay3;
855  float rplay4;
856  float load1;
857  float load2;
858  float load3;
859  float load4;
860  float od1;
861  float od2;
862  float od3;
863  float od4;
864  float fod1;
865  float fod2;
866  float fod3;
867  float fod4;
868  float record1;
869  int iVec0[2];
870  int IOTA1;
871  int IOTA2;
872  int IOTA3;
873  int IOTA4;
874  float IOTAR1;
875  float IOTAR2;
876  float IOTAR3;
877  float IOTAR4;
878  float *tape1;
879  int tape1_size;
880  float fConst0;
881  float fConst1;
882  float fConst2;
883  float reset1;
884  int RecSize1[2];
885  float rectime0;
886  float fRec1[2];
887  float fRec2[2];
888  int iRec3[2];
889  int iRec4[2];
890  float play1;
891  float playh1;
892  float gain1;
893  float record2;
894  int iVec2[2];
895  float *tape2;
896  int tape2_size;
897  float reset2;
898  int RecSize2[2];
899  float rectime1;
900  float fRec6[2];
901  float fRec7[2];
902  int iRec8[2];
903  int iRec9[2];
904  float play2;
905  float playh2;
906  float gain2;
907  float record3;
908  int iVec4[2];
909  float *tape3;
910  int tape3_size;
911  float reset3;
912  int RecSize3[2];
913  float rectime2;
914  float fRec11[2];
915  float fRec12[2];
916  int iRec13[2];
917  int iRec14[2];
918  float play3;
919  float playh3;
920  float gain3;
921  float record4;
922  int iVec6[2];
923  float *tape4;
924  int tape4_size;
925  float reset4;
926  int RecSize4[2];
927  float rectime3;
928  float fRec16[2];
929  float fRec17[2];
930  int iRec18[2];
931  int iRec19[2];
932  float play4;
933  float playh4;
934  float gain4;
935  float play_all;
936  float dout;
937  float* outbuffer;
938  bool save1;
939  bool save2;
940  bool save3;
941  bool save4;
942  bool first1;
943  bool first2;
944  bool first3;
945  bool first4;
946  bool RP1;
947  bool RP2;
948  bool RP3;
949  bool RP4;
950  Glib::ustring preset_name;
951  Glib::ustring load_file1;
952  Glib::ustring load_file2;
953  Glib::ustring load_file3;
954  Glib::ustring load_file4;
955  Glib::ustring cur_name;
956  Glib::ustring loop_dir;
957  bool save_p;
958  ParamMap& param;
959  bool mem_allocated;
960  sigc::slot<void> sync;
961  volatile int ready;
962  FileResampler smp;
963  Directout* d;
964 
965  int do_resample(int inrate, int insize, float *input, int maxsize);
966  int do_mono(int c, int f, float *oIn, float *tape, int n);
967  void play_all_tapes();
968  void mem_alloc();
969  void mem_free();
970  void clear_state_f();
971  int activate(bool start);
972  int load_ui_f(const UiBuilder& b, int form);
973  void init(unsigned int samplingFreq);
974  void compute(int count, float *input0, float *output0);
975  int register_par(const ParamReg& reg);
976  void save_array(std::string name);
977  void load_array(std::string name);
978  void save_to_wave(std::string fname, float *tape, float fSize, int tape_size);
979  int load_from_wave(std::string fname, float **tape, int tape_size);
980  void set_p_state();
981  void load_tape1();
982  void load_tape2();
983  void load_tape3();
984  void load_tape4();
985 
986  static void clear_state_f_static(PluginDef*);
987  static int activate_static(bool start, PluginDef*);
988  static int load_ui_f_static(const UiBuilder& b, int form);
989  static void init_static(unsigned int samplingFreq, PluginDef*);
990  static void compute_static(int count, float *input0, float *output0, PluginDef*);
991  static int register_params_static(const ParamReg& reg);
992  static void del_instance(PluginDef *p);
993 public:
995  LiveLooper(ParamMap& param_, sigc::slot<void> sync, const string& loop_dir_);
996  ~LiveLooper();
997 };
998 
999 
1000 /****************************************************************
1001  ** class SCapture
1002  */
1003 
1004 
1005 class SCapture: public PluginDef {
1006 private:
1007  SNDFILE * recfile;
1008  EngineControl& engine;
1009  int fSamplingFreq;
1010  int channel;
1011  float fcheckbox0;
1012  float fcheckbox1;
1013  float fslider0;
1014  float fbargraph0;
1015  float fRecC0[2];
1016  float fformat;
1017  int IOTA;
1018  int iA;
1019  int savesize;
1020  int filesize;
1021  float *fRec0;
1022  float *fRec1;
1023  float *tape;
1024  sem_t m_trig;
1025  pthread_t m_pthr;
1026  volatile bool keep_stream;
1027  bool mem_allocated;
1028  bool is_wav;
1029  bool err;
1030  float fConst0;
1031  float fRecb0[2];
1032  int iRecb1[2];
1033  float fRecb2[2];
1034  void mem_alloc();
1035  void mem_free();
1036  void clear_state_f();
1037  int activate(bool start);
1038  int load_ui_f(const UiBuilder& b, int form);
1039  void init(unsigned int samplingFreq);
1040  void compute(int count, float *input0, float *output0);
1041  void compute_st(int count, float *input0, float *input1, float *output0, float *output1);
1042  int register_par(const ParamReg& reg);
1043  void save_to_wave(SNDFILE * sf, float *tape, int lSize);
1044  SNDFILE *open_stream(std::string fname);
1045  void close_stream(SNDFILE **sf);
1046  void stop_thread();
1047  void start_thread();
1048  void disc_stream();
1049  inline std::string get_ffilename();
1050 
1051  static void *run_thread(void* p);
1052  static void clear_state_f_static(PluginDef*);
1053  static int activate_static(bool start, PluginDef*);
1054  static const char *glade_def;
1055  static const char *glade_def_st;
1056  static int load_ui_f_static(const UiBuilder& b, int form);
1057  static void init_static(unsigned int samplingFreq, PluginDef*);
1058  static void compute_static(int count, float *input0, float *output0, PluginDef*);
1059  static void compute_static_st(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1060  static int register_params_static(const ParamReg& reg);
1061  static void del_instance(PluginDef *p);
1062 public:
1064  SCapture(EngineControl& engine, int channel_);
1065  ~SCapture();
1066 };
1067 
1068 /****************************************************************
1069  ** class DrumSequencer
1070  */
1071 
1072 #include "faust/drumseq.h"
1073 
1074 class Drumout {
1075 private:
1076  static float* set;
1077  static bool mb;
1078  static float* data;
1079  static Plugin input_drum;
1080  static void outputdrum_compute(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
1081 public:
1082  static void set_plugin(Plugin p);
1083  static void set_data(float* mode, bool ready, float* buf);
1086  Drumout();
1087 };
1088 
1089 
1090 class DrumSequencer: public PluginDef {
1091 private:
1092  int fSamplingFreq;
1093  FAUSTFLOAT position;
1094  FAUSTFLOAT ftact;
1095  FAUSTFLOAT fsec;
1096  FAUSTFLOAT fslidergain;
1097  FAUSTFLOAT fsliderbpm;
1098  FAUSTFLOAT fsliderhum;
1099  drumseq::Dsp drums;
1100 
1101  int counter;
1102  int seq_size;
1103  int bsize;
1104  FAUSTFLOAT step;
1105  FAUSTFLOAT step_orig;
1106  FAUSTFLOAT fSlow1;
1107  FAUSTFLOAT fSlow3;
1108  FAUSTFLOAT fSlow5;
1109  FAUSTFLOAT fSlow7;
1110  FAUSTFLOAT fSlow12;
1111  FAUSTFLOAT fSlow14;
1112  FAUSTFLOAT fSlow16;
1113  FAUSTFLOAT fSlow18;
1114  FAUSTFLOAT fSlow20;
1115  FAUSTFLOAT fSlow22;
1116  std::vector<int> Vectom;
1117  std::vector<int> Vectom1;
1118  std::vector<int> Vectom2;
1119  std::vector<int> Veckick;
1120  std::vector<int> Vecsnare;
1121  std::vector<int> Vechat;
1122 
1123  EngineControl& engine;
1124  bool mem_allocated;
1125  sigc::slot<void> sync;
1126  volatile bool ready;
1127  float *outdata;
1128  ParamMap& param;
1129  GxSeqSettings tomset;
1130  SeqParameter *tomp;
1131  GxSeqSettings tomset1;
1132  SeqParameter *tomp1;
1133  GxSeqSettings tomset2;
1134  SeqParameter *tomp2;
1135  GxSeqSettings snareset;
1136  SeqParameter *snarep;
1137  GxSeqSettings hatset;
1138  SeqParameter *hatp;
1139  GxSeqSettings kickset;
1140  SeqParameter *kickp;
1141 
1142  void mem_alloc();
1143  void mem_free();
1144  void init(unsigned int samplingFreq);
1145  void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
1146  void change_buffersize(unsigned int size);
1147  int register_par(const ParamReg& reg);
1148 
1149  int min_seq_size();
1150  void reset_tom();
1151  void reset_tom1();
1152  void reset_tom2();
1153  void reset_kick();
1154  void reset_hat();
1155  void reset_snare();
1156 
1157  static void init_static(unsigned int samplingFreq, PluginDef*);
1158  static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef*);
1159  static int register_params_static(const ParamReg& reg);
1160  static void del_instance(PluginDef *p);
1161 public:
1163  DrumSequencer(ParamMap& param_, EngineControl& engine, sigc::slot<void> sync);
1164  ~DrumSequencer();
1165 };
1166 
1167 /****************************************************************************
1168 *
1169 * NAME: smbPitchShift.cpp
1170 * VERSION: 1.2
1171 * HOME URL: http://www.dspdimension.com
1172 * KNOWN BUGS: none
1173 *
1174 *
1175 * COPYRIGHT 1999-2009 Stephan M. Bernsee <smb [AT] dspdimension [DOT] com>
1176 *
1177 * Modified for guitarix by Hermann Meyer 2014
1178 *
1179 * The Wide Open License (WOL)
1180 *
1181 * Permission to use, copy, modify, distribute and sell this software and its
1182 * documentation for any purpose is hereby granted without fee, provided that
1183 * the above copyright notice and this license appear in all source copies.
1184 * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
1185 * ANY KIND. See http://www.dspguru.com/wol.htm for more information.
1186 *
1187 *****************************************************************************/
1188 
1189 
1190 #define M_PI 3.14159265358979323846
1191 #define MAX_FRAME_LENGTH 8096
1192 
1193 class smbPitchShift : public PluginDef {
1194 private:
1196  EngineControl& engine;
1197  bool mem_allocated;
1198  sigc::slot<void> sync;
1199  volatile bool ready;
1200  ParamMap& param;
1201  float gInFIFO[MAX_FRAME_LENGTH];
1202  float gOutFIFO[MAX_FRAME_LENGTH];
1203  float *fpb;
1204  float *expect;
1205  float *hanning;
1206  float *hanningd;
1207  float *resampin;
1208  float *resampin2;
1209  float *resampout;
1210  float *indata2;
1211  float gLastPhase[MAX_FRAME_LENGTH/2+1];
1212  float gSumPhase[MAX_FRAME_LENGTH/2+1];
1213  float gOutputAccum[2*MAX_FRAME_LENGTH];
1214  float gAnaFreq[MAX_FRAME_LENGTH];
1215  float gAnaMagn[MAX_FRAME_LENGTH];
1216  float gSynFreq[MAX_FRAME_LENGTH];
1217  float gSynMagn[MAX_FRAME_LENGTH];
1218  float semitones;
1219  float a,b,c,d,l;
1220  float wet;
1221  float dry;
1222  float mpi, mpi1;
1223  float tone;
1224  int octave, osamp, numSampsToResamp, numSampsToProcess, fftFrameSize, sampleRate ;
1225  int latency;
1226  int ai;
1227  int aio;
1228  int ii;
1229  long gRover , gInit ;
1230  double magn, phase, tmp, window, real, imag;
1231  double freqPerBin, freqPerBin1, freqPerBin2, expct;
1232  double fftFrameSize3;
1233  double fftFrameSize4;
1234  double osamp1,osamp2;
1235  long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2;
1236 
1237  fftwf_complex fftw_in[MAX_FRAME_LENGTH], fftw_out[MAX_FRAME_LENGTH];
1238  fftwf_plan ftPlanForward, ftPlanInverse;
1239 
1240  inline int load_ui_f(const UiBuilder& b, int form);
1241  int register_par(const ParamReg& reg);
1242  void change_latency();
1243 
1244  void mem_alloc();
1245  void mem_free();
1246  void clear_state();
1247  int activate(bool start);
1248  bool setParameters( int sampleRate);
1249  void PitchShift(int count, float *indata, float *outdata);
1250  void change_buffersize(unsigned int size);
1251  static int activate_static(bool start, PluginDef*);
1252  static void del_instance(PluginDef *p);
1253  static int registerparam(const ParamReg& reg);
1254  static int load_ui_f_static(const UiBuilder& b, int form);
1255  static void init(unsigned int sampleRate, PluginDef *plugin);
1256  static void compute_static(int count, float *input0, float *output0, PluginDef *p);
1257 
1258 public:
1260  smbPitchShift(ParamMap& param_, EngineControl& engine, sigc::slot<void> sync);
1261  ~smbPitchShift();
1262 };
1263 
1264 
1265 } // namespace gx_engine
ParameterV< GxSeqSettings > SeqParameter
static LV2_URID_Unmap gx_urid_unmap
CmdConnection::msg_type start
Definition: jsonrpc.cpp:257
void setseqline(const std::vector< int > &seq)
Glib::Dispatcher & signal_jack_load_change()
pluginarray::iterator end()
const std::vector< int > & getseqline() const
ParameterV< GxJConvSettings > JConvParameter
void init(int samplingFreq)
const std::string & getIRDir() const
const Gainline & getGainline() const
std::string getFullIRPath() const
void set_jack(gx_jack::GxJack *jack_)
static std::string get_ladspa_filename(std::string uid_key)
std::vector< plugdesc * > pluginarray
bool set(const GxJConvSettings &val) const
const std::string & getIRDir() const
sigc::signal< void, const GxJConvSettings * > & signal_changed()
#define FAUSTFLOAT
const GxJConvSettings & get_jcset() const
const std::string & getIRFile() const
static PluginDef outputdrum
sigc::signal< int, bool > activation
PluginDef * create(unsigned int idx)
static PluginDef outputgate
void compute(int count, float *input0, float *output0)
const std::string & getIRFile() const
static LV2_URID_Map gx_urid_map
std::string to_string(const T &t)
Definition: gx_system.h:529
#define MAX_FRAME_LENGTH
sigc::signal< void, unsigned int > size_change
std::vector< paradesc * > names
const GxJConvSettings & get_value() const
static LV2Features & getInstance()
pluginarray::iterator begin()
void setGainline(const Gainline &gain)
void set_dep_module(Plugin *dep)
Glib::Dispatcher & signal_freq_changed()
sigc::signal< void, const GxSeqSettings * > & signal_changed()
ParamMap & get_parameter_map() const
static std::string get_ladspa_filename(unsigned long uid)
std::string fformat(float value, float step)
Glib::Dispatcher new_freq
const GxSeqSettings & get_value() const
void set_mul_buffer(int a, unsigned int b)