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