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
676  Glib::ustring master_label;
677  std::vector<paradesc*> names;
678  std::string id_str;
679 private:
680  plugdesc() {}
681  ~plugdesc();
682  friend class LadspaLoader;
683 public:
684  void readJSON(gx_system::JsonParser& jp);
685  void writeJSON(gx_system::JsonWriter& jw);
686 };
687 
689 public:
690  typedef std::vector<plugdesc*> pluginarray;
691 private:
692  const gx_system::CmdlineOptions& options;
693  pluginarray plugins;
694  LilvWorld* world;
695  const LilvPlugins* lv2_plugins;
696  LilvNode* lv2_AudioPort;
697  LilvNode* lv2_ControlPort;
698  LilvNode* lv2_InputPort;
699  LilvNode* lv2_OutputPort;
700 private:
701  void read_module_config(const std::string& filename, plugdesc *p);
702  void read_module_list(pluginarray& p);
703 public:
704  LadspaLoader(const gx_system::CmdlineOptions& options);
705  ~LadspaLoader();
706  bool load(pluginarray& p);
707  unsigned int size() { return plugins.size(); }
708  PluginDef *create(unsigned int idx) { return create(plugins[idx]); }
709  PluginDef *create(const plugdesc *p);
710  pluginarray::iterator begin() { return plugins.begin(); }
711  pluginarray::iterator end() { return plugins.end(); }
712  pluginarray::iterator find(plugdesc* desc);
713  void set_plugins(pluginarray& new_plugins);
714  void change_plugins(pluginarray& new_plugins);
715  void update_instance(PluginDef *pdef, plugdesc *pdesc);
716  static std::string get_ladspa_filename(unsigned long uid)
717  { return "ladspa"+gx_system::to_string(uid)+".js"; }
718  static std::string get_ladspa_filename(std::string uid_key)
719  { return "ladspa"+uid_key.substr(9)+".js"; }
720  friend class Lv2Dsp;
721 };
722 
723 
724 /****************************************************************
725  ** class LiveLooper
726  */
727 
728 
729 class LiveLooper: public PluginDef {
730 
731 
732 class FileResampler {
733 private:
734  Resampler r_file;
735  int inputRate, outputRate;
736  int last_in_count;
737 public:
738  int setup(int _inputRate, int _outputRate);
739  int run(int count, float *input, float *output);
740  int max_out_count(int in_count) {
741  return static_cast<int>(ceil((in_count*static_cast<double>(outputRate))/inputRate)); }
742 };
743 
744 private:
745  int fSamplingFreq;
746  float gain;
747  float fRec0[2];
748  float gain_out;
749  float fclip1;
750  float fclip2;
751  float fclip3;
752  float fclip4;
753  float fclips1;
754  float fclips2;
755  float fclips3;
756  float fclips4;
757  float fspeed1;
758  float fspeed2;
759  float fspeed3;
760  float fspeed4;
761  float rplay1;
762  float rplay2;
763  float rplay3;
764  float rplay4;
765  float load1;
766  float load2;
767  float load3;
768  float load4;
769  float record1;
770  int iVec0[2];
771  int IOTA1;
772  int IOTA2;
773  int IOTA3;
774  int IOTA4;
775  float IOTAR1;
776  float IOTAR2;
777  float IOTAR3;
778  float IOTAR4;
779  float *tape1;
780  int tape1_size;
781  float fConst0;
782  float fConst1;
783  float fConst2;
784  float reset1;
785  int RecSize1[2];
786  float rectime0;
787  float fRec1[2];
788  float fRec2[2];
789  int iRec3[2];
790  int iRec4[2];
791  float play1;
792  float playh1;
793  float gain1;
794  float record2;
795  int iVec2[2];
796  float *tape2;
797  int tape2_size;
798  float reset2;
799  int RecSize2[2];
800  float rectime1;
801  float fRec6[2];
802  float fRec7[2];
803  int iRec8[2];
804  int iRec9[2];
805  float play2;
806  float playh2;
807  float gain2;
808  float record3;
809  int iVec4[2];
810  float *tape3;
811  int tape3_size;
812  float reset3;
813  int RecSize3[2];
814  float rectime2;
815  float fRec11[2];
816  float fRec12[2];
817  int iRec13[2];
818  int iRec14[2];
819  float play3;
820  float playh3;
821  float gain3;
822  float record4;
823  int iVec6[2];
824  float *tape4;
825  int tape4_size;
826  float reset4;
827  int RecSize4[2];
828  float rectime3;
829  float fRec16[2];
830  float fRec17[2];
831  int iRec18[2];
832  int iRec19[2];
833  float play4;
834  float playh4;
835  float gain4;
836  float play_all;
837  bool save1;
838  bool save2;
839  bool save3;
840  bool save4;
841  bool RP1;
842  bool RP2;
843  bool RP3;
844  bool RP4;
845  Glib::ustring preset_name;
846  Glib::ustring load_file1;
847  Glib::ustring load_file2;
848  Glib::ustring load_file3;
849  Glib::ustring load_file4;
850  Glib::ustring cur_name;
851  Glib::ustring loop_dir;
852  bool save_p;
853  ParamMap& param;
854  bool mem_allocated;
855  sigc::slot<void> sync;
856  volatile int ready;
857  FileResampler smp;
858 
859  int do_resample(int inrate, int insize, float *input, int maxsize);
860  int do_mono(int c, int f, float *oIn, float *tape, int n);
861  void play_all_tapes();
862  void mem_alloc();
863  void mem_free();
864  void clear_state_f();
865  int activate(bool start);
866  int load_ui_f(const UiBuilder& b, int form);
867  void init(unsigned int samplingFreq);
868  void compute(int count, float *input0, float *output0);
869  int register_par(const ParamReg& reg);
870  void save_array(std::string name);
871  void load_array(std::string name);
872  void save_to_wave(std::string fname, float *tape, float fSize, int tape_size);
873  int load_from_wave(std::string fname, float **tape, int tape_size);
874  void set_p_state();
875  void load_tape1();
876  void load_tape2();
877  void load_tape3();
878  void load_tape4();
879 
880  static void clear_state_f_static(PluginDef*);
881  static int activate_static(bool start, PluginDef*);
882  static int load_ui_f_static(const UiBuilder& b, int form);
883  static void init_static(unsigned int samplingFreq, PluginDef*);
884  static void compute_static(int count, float *input0, float *output0, PluginDef*);
885  static int register_params_static(const ParamReg& reg);
886  static void del_instance(PluginDef *p);
887 public:
889  LiveLooper(ParamMap& param_, sigc::slot<void> sync, const string& loop_dir_);
890  ~LiveLooper();
891 };
892 
893 
894 /****************************************************************
895  ** class SCapture
896  */
897 
898 
899 class SCapture: public PluginDef {
900 private:
901  SNDFILE * recfile;
902  EngineControl& engine;
903  int fSamplingFreq;
904  int channel;
905  float fcheckbox0;
906  float fcheckbox1;
907  float fslider0;
908  float fbargraph0;
909  float fRecC0[2];
910  float fformat;
911  int IOTA;
912  int iA;
913  int savesize;
914  int filesize;
915  float *fRec0;
916  float *fRec1;
917  float *tape;
918  sem_t m_trig;
919  pthread_t m_pthr;
920  volatile bool keep_stream;
921  bool mem_allocated;
922  bool is_wav;
923  bool err;
924  float fConst0;
925  float fRecb0[2];
926  int iRecb1[2];
927  float fRecb2[2];
928  void mem_alloc();
929  void mem_free();
930  void clear_state_f();
931  int activate(bool start);
932  int load_ui_f(const UiBuilder& b, int form);
933  void init(unsigned int samplingFreq);
934  void compute(int count, float *input0, float *output0);
935  void compute_st(int count, float *input0, float *input1, float *output0, float *output1);
936  int register_par(const ParamReg& reg);
937  void save_to_wave(SNDFILE * sf, float *tape, int lSize);
938  SNDFILE *open_stream(std::string fname);
939  void close_stream(SNDFILE **sf);
940  void stop_thread();
941  void start_thread();
942  void disc_stream();
943  inline std::string get_ffilename();
944 
945  static void *run_thread(void* p);
946  static void clear_state_f_static(PluginDef*);
947  static int activate_static(bool start, PluginDef*);
948  static const char *glade_def;
949  static const char *glade_def_st;
950  static int load_ui_f_static(const UiBuilder& b, int form);
951  static void init_static(unsigned int samplingFreq, PluginDef*);
952  static void compute_static(int count, float *input0, float *output0, PluginDef*);
953  static void compute_static_st(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
954  static int register_params_static(const ParamReg& reg);
955  static void del_instance(PluginDef *p);
956 public:
958  SCapture(EngineControl& engine, int channel_);
959  ~SCapture();
960 };
961 
962 /****************************************************************
963  ** class DrumSequencer
964  */
965 
966 
967 class DrumSequencer: public PluginDef {
968 private:
969  int fSamplingFreq;
970  FAUSTFLOAT position;
971  FAUSTFLOAT ftact;
972  FAUSTFLOAT fsec;
973  FAUSTFLOAT fslidergain;
974  FAUSTFLOAT fsliderbpm;
975  FAUSTFLOAT fslidersnare;
976  double fRecout[2];
977  int iVec0[2];
978  double fRec0[2];
979  int iConst0;
980  double fConst1;
981  double fConst2;
982  double fVec1[2];
983  double fRec3[2];
984  int iRec1[2];
985  double fConst3;
986  double fConst4;
987  double fRec2[2];
988  double fConst5;
989  double fConst6;
990  double fConst7;
991  double fRec4[2];
992  double fConst8;
993  double fRec5[2];
994  double fVec2[2];
995  int iRec6[2];
996  double fConst9;
997  double fRec7[2];
998  double fConst10;
999  double fConst11;
1000  double fConst12;
1001  double fRec8[2];
1002  double fConst13;
1003  double fRec9[2];
1004  double fConst14;
1005  double fConst15;
1006  double fConst16;
1007  double fConst17;
1008  double fConst18;
1009  int iRec12[2];
1010  double fConst19;
1011  double fConst20;
1012  double fConst21;
1013  double fRec11[2];
1014  double fRec10[3];
1015  int iRec13[2];
1016  double fConst22;
1017  double fRec14[2];
1018  double fConst23;
1019  double fConst24;
1020  double fConst25;
1021  double fConst26;
1022  double fConst27;
1023  double fConst28;
1024  double fConst29;
1025  double fConst30;
1026  double fConst31;
1027  double fConst32;
1028  double fRec16[2];
1029  double fRec15[3];
1030  double fConst33;
1031  int iRec17[2];
1032  double fConst34;
1033  double fRec18[2];
1034  FAUSTFLOAT fsliderhat;
1035  double fRec19[2];
1036  double fConst35;
1037  double fVec3[2];
1038  double fRec20[2];
1039  double fConst36;
1040  double fConst37;
1041  double fRec25[2];
1042  double fVec4[2];
1043  int IOTA;
1044  double fVec5[64];
1045  double fConst38;
1046  int iConst39;
1047  int iConst40;
1048  int iConst41;
1049  double fConst42;
1050  double fConst43;
1051  double fConst44;
1052  double fConst45;
1053  double fConst46;
1054  double fRec26[2];
1055  double fConst47;
1056  double fRec27[2];
1057  double fConst48;
1058  double fConst49;
1059  double fRec23[2];
1060  double fRec24[2];
1061  double fConst50;
1062  double fConst51;
1063  double fConst52;
1064  double fRec30[2];
1065  double fConst53;
1066  double fRec31[2];
1067  double fConst54;
1068  double fRec28[2];
1069  double fRec29[2];
1070  double fConst55;
1071  double fConst56;
1072  double fConst57;
1073  double fRec34[2];
1074  double fConst58;
1075  double fRec35[2];
1076  double fConst59;
1077  double fRec32[2];
1078  double fRec33[2];
1079  double fConst60;
1080  double fConst61;
1081  double fConst62;
1082  double fRec38[2];
1083  double fConst63;
1084  double fRec39[2];
1085  double fConst64;
1086  double fRec36[2];
1087  double fRec37[2];
1088  double fVec6[2];
1089  double fRec22[2];
1090  double fRec21[3];
1091  double fConst65;
1092  double fRec42[2];
1093  int iRec40[2];
1094  double fConst66;
1095  double fConst67;
1096  double fRec41[2];
1097  double fConst68;
1098  double fConst69;
1099  double fRec43[3];
1100  FAUSTFLOAT fsliderkick;
1101  double fRec44[2];
1102  double fConst70;
1103  double fVec7[2];
1104  double fRec45[2];
1105  double fConst71;
1106  double fConst72;
1107  double fConst73;
1108  double fConst74;
1109  double fConst75;
1110  double fConst76;
1111  double fConst77;
1112  double fConst78;
1113  double fConst79;
1114  double fConst80;
1115  double fRec49[2];
1116  double fRec48[3];
1117  double fConst81;
1118  double fVec8[2];
1119  double fRec47[2];
1120  double fRec46[3];
1121  double fConst82;
1122  double fRec52[2];
1123  int iRec50[2];
1124  double fConst83;
1125  double fConst84;
1126  double fRec51[2];
1127  double fConst85;
1128  double fConst86;
1129  double fConst87;
1130  double fConst88;
1131  double fConst89;
1132  double fConst90;
1133  double fConst91;
1134  double fConst92;
1135  double fRec57[2];
1136  double fConst93;
1137  double fRec58[2];
1138  double fConst94;
1139  double fRec59[2];
1140  double fRec55[2];
1141  double fRec56[2];
1142  double fConst95;
1143  double fConst96;
1144  double fConst97;
1145  double fRec54[2];
1146  double fRec53[3];
1147  double fRec62[2];
1148  int iRec60[2];
1149  double fConst98;
1150  double fRec61[2];
1151  FAUSTFLOAT fslidertom;
1152  double fRec63[2];
1153  double fVec9[2];
1154  double fRec66[2];
1155  int iRec64[2];
1156  double fConst99;
1157  double fRec65[2];
1158  double fConst100;
1159  double fConst101;
1160  double fConst102;
1161  double fRec67[2];
1162  double fConst103;
1163  double fRec68[2];
1164  double fConst104;
1165  double fConst105;
1166  double fConst106;
1167  double fRec69[2];
1168  double fConst107;
1169  double fRec70[2];
1170  double fConst108;
1171  double fConst109;
1172  double fConst110;
1173  double fRec73[2];
1174  double fConst111;
1175  double fRec74[2];
1176  double fConst112;
1177  double fRec75[2];
1178  double fConst113;
1179  double fVec10[2];
1180  double fConst114;
1181  double fRec71[2];
1182  double fRec72[2];
1183  int iRec76[2];
1184  double fRec77[2];
1185  int counter;
1186  int step;
1187  int seq_size;
1188  double fSlow1;
1189  double fSlow3;
1190  double fSlow5;
1191  double fSlow7;
1192  std::vector<int> Vectom;
1193  std::vector<int> Veckick;
1194  std::vector<int> Vecsnare;
1195  std::vector<int> Vechat;
1196 
1197  ParamMap& param;
1198  GxSeqSettings tomset;
1199  SeqParameter *tomp;
1200  GxSeqSettings snareset;
1201  SeqParameter *snarep;
1202  GxSeqSettings hatset;
1203  SeqParameter *hatp;
1204  GxSeqSettings kickset;
1205  SeqParameter *kickp;
1206  void clear_state_f();
1207  void init(unsigned int samplingFreq);
1208  void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
1209  int register_par(const ParamReg& reg);
1210  int min_seq_size();
1211  void reset_tom();
1212  void reset_kick();
1213  void reset_hat();
1214  void reset_snare();
1215 
1216  static void clear_state_f_static(PluginDef*);
1217  static void init_static(unsigned int samplingFreq, PluginDef*);
1218  static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef*);
1219  static int register_params_static(const ParamReg& reg);
1220  static void del_instance(PluginDef *p);
1221 public:
1223  DrumSequencer(ParamMap& param_);
1224  ~DrumSequencer();
1225 };
1226 
1227 /****************************************************************************
1228 *
1229 * NAME: smbPitchShift.cpp
1230 * VERSION: 1.2
1231 * HOME URL: http://www.dspdimension.com
1232 * KNOWN BUGS: none
1233 *
1234 *
1235 * COPYRIGHT 1999-2009 Stephan M. Bernsee <smb [AT] dspdimension [DOT] com>
1236 *
1237 * Modified for guitarix by Hermann Meyer 2014
1238 *
1239 * The Wide Open License (WOL)
1240 *
1241 * Permission to use, copy, modify, distribute and sell this software and its
1242 * documentation for any purpose is hereby granted without fee, provided that
1243 * the above copyright notice and this license appear in all source copies.
1244 * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
1245 * ANY KIND. See http://www.dspguru.com/wol.htm for more information.
1246 *
1247 *****************************************************************************/
1248 
1249 
1250 #define M_PI 3.14159265358979323846
1251 #define MAX_FRAME_LENGTH 8096
1252 
1253 class smbPitchShift : public PluginDef {
1254 private:
1256  EngineControl& engine;
1257  bool mem_allocated;
1258  sigc::slot<void> sync;
1259  volatile bool ready;
1260  ParamMap& param;
1261  float gInFIFO[MAX_FRAME_LENGTH];
1262  float gOutFIFO[MAX_FRAME_LENGTH];
1263  float *fpb;
1264  float *expect;
1265  float *hanning;
1266  float *hanningd;
1267  float *resampin;
1268  float *resampin2;
1269  float *resampout;
1270  float *indata2;
1271  float gLastPhase[MAX_FRAME_LENGTH/2+1];
1272  float gSumPhase[MAX_FRAME_LENGTH/2+1];
1273  float gOutputAccum[2*MAX_FRAME_LENGTH];
1274  float gAnaFreq[MAX_FRAME_LENGTH];
1275  float gAnaMagn[MAX_FRAME_LENGTH];
1276  float gSynFreq[MAX_FRAME_LENGTH];
1277  float gSynMagn[MAX_FRAME_LENGTH];
1278  float semitones;
1279  float a,b,c,d,l;
1280  float wet;
1281  float dry;
1282  float mpi, mpi1;
1283  float tone;
1284  int octave, osamp, numSampsToResamp, numSampsToProcess, fftFrameSize, sampleRate ;
1285  int latency;
1286  int ai;
1287  int aio;
1288  int ii;
1289  long gRover , gInit ;
1290  double magn, phase, tmp, window, real, imag;
1291  double freqPerBin, freqPerBin1, freqPerBin2, expct;
1292  double fftFrameSize3;
1293  double fftFrameSize4;
1294  double osamp1,osamp2;
1295  long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2;
1296 
1297  fftwf_complex fftw_in[MAX_FRAME_LENGTH], fftw_out[MAX_FRAME_LENGTH];
1298  fftwf_plan ftPlanForward, ftPlanInverse;
1299 
1300  inline int load_ui_f(const UiBuilder& b, int form);
1301  int register_par(const ParamReg& reg);
1302  void change_latency();
1303 
1304  void mem_alloc();
1305  void mem_free();
1306  void clear_state();
1307  int activate(bool start);
1308  bool setParameters( int sampleRate);
1309  void PitchShift(int count, float *indata, float *outdata);
1310  void change_buffersize(unsigned int size);
1311  static int activate_static(bool start, PluginDef*);
1312  static void del_instance(PluginDef *p);
1313  static int registerparam(const ParamReg& reg);
1314  static int load_ui_f_static(const UiBuilder& b, int form);
1315  static void init(unsigned int sampleRate, PluginDef *plugin);
1316  static void compute_static(int count, float *input0, float *output0, PluginDef *p);
1317 
1318 public:
1320  smbPitchShift(ParamMap& param_, EngineControl& engine, sigc::slot<void> sync);
1321  ~smbPitchShift();
1322 };
1323 
1324 
1325 } // 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)