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 GxJConvSettings
254  */
255 
257  private:
258  // main jconv setting
259  std::string fIRFile;
260  std::string fIRDir;
261 
262  float fGain; // jconv gain
263  guint fOffset; // offset in IR where to start comvolution
264  guint fLength; // length of the IR to use for convolution
265  guint fDelay; // delay when to apply reverb
266  Gainline gainline;
267  bool fGainCor;
268  void read_gainline(gx_system::JsonParser& jp);
269  inline void setIRDir(string name) { fIRDir = name; }
270  friend class ConvolverAdapter;
272  public:
273  GxJConvSettings();
274  GxJConvSettings& operator=(GxJConvSettings const& jcset);
275  bool operator==(const GxJConvSettings& jcset) const;
276  // getters and setters
277  inline const std::string& getIRFile() const { return fIRFile; }
278  std::string getFullIRPath() const;
279  inline float getGain() const { return fGain; }
280  inline guint getOffset() const { return fOffset; }
281  inline guint getLength() const { return fLength; }
282  inline guint getDelay() const { return fDelay; }
283  inline bool getGainCor() const { return fGainCor; }
284  inline const Gainline& getGainline() const { return gainline; }
285  const std::string& getIRDir() const { return fIRDir; }
286  void setFullIRPath(string name);
287  inline void setIRFile(string name) { fIRFile = name; }
288  inline void setGain(float gain) { fGain = gain; }
289  inline void setGainCor(bool gain) { fGainCor = gain; }
290  inline void setOffset(guint offs) { fOffset = offs; }
291  inline void setLength(guint leng) { fLength = leng; }
292  inline void setDelay(guint del) { fDelay = del; }
293  inline void setGainline(const Gainline& gain) { gainline = gain; }
294 
295  public:
296  void readJSON(gx_system::JsonParser& jp);
297  void writeJSON(gx_system::JsonWriter& w) const;
298 };
299 
300 class ConvolverAdapter;
301 
302 template<>
304 private:
305  const gx_system::PathList *searchpath;
306  const gx_system::PrefixConverter* pfx_conv;
307  GxJConvSettings json_value;
308  GxJConvSettings *value;
309  GxJConvSettings std_value;
310  GxJConvSettings value_storage;
311  sigc::signal<void, const GxJConvSettings*> changed;
312 public:
313  ParameterV(const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
315  ~ParameterV();
316  virtual void serializeJSON(gx_system::JsonWriter& jw);
317  sigc::signal<void, const GxJConvSettings*>& signal_changed() { return changed; }
318  static ParameterV<GxJConvSettings> *insert_param(
319  ParamMap &pmap, const string& id, ConvolverAdapter &conv, GxJConvSettings *v);
320  bool set(const GxJConvSettings& val) const;
321  const GxJConvSettings& get_value() const { return *value; }
322  virtual void stdJSON_value();
323  virtual bool on_off_value();
324  virtual void writeJSON(gx_system::JsonWriter& jw) const;
325  virtual bool compareJSON_value();
326  virtual void setJSON_value();
327  virtual void readJSON_value(gx_system::JsonParser& jp);
328 };
329 
331 
332 
333 /****************************************************************
334  ** class ConvolverAdapter
335  */
336 
337 class ConvolverAdapter: protected PluginDef, public sigc::trackable {
338 protected:
340  boost::mutex activate_mutex;
342  sigc::slot<void> sync;
344  bool activated;
345  // wrapper for the rack order function pointers
346  void change_buffersize(unsigned int size);
348  JConvParameter *jcp;
349 public:
351 public:
352  ConvolverAdapter(EngineControl& engine, sigc::slot<void> sync, ParamMap& param);
353  ~ConvolverAdapter();
354  void restart();
355  bool conv_start();
356  inline const std::string& getIRFile() const { return jcset.getIRFile(); }
357  inline void set_sync(bool val) { conv.set_sync(val); }
358  inline std::string getFullIRPath() const { return jcset.getFullIRPath(); }
359  inline const std::string& getIRDir() const { return jcset.getIRDir(); }
360  bool set(const GxJConvSettings& jcset) const { return jcp->set(jcset); }
361  const GxJConvSettings& get_jcset() const { return jcset; }
362  ParamMap& get_parameter_map() const { return param; }
363 };
364 
365 
366 /****************************************************************
367  ** class ConvolverStereoAdapter
368  */
369 
370 #include "faust/jconv_post.h"
371 #include "faust/jconv_post_mono.h"
372 
374 private:
375  jconv_post::Dsp jc_post;
376  // wrapper for the rack order function pointers
377  static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
378  static int activate(bool start, PluginDef *pdef);
379  static void convolver(int count, float *input0, float *input1,
380  float *output0, float *output1, PluginDef*);
381  static int convolver_register(const ParamReg& reg);
382 public:
383  ConvolverStereoAdapter(EngineControl& engine, sigc::slot<void> sync, ParamMap& param);
385 };
386 
387 
388 /****************************************************************
389  ** class ConvolverMonoAdapter
390  */
391 
393 private:
394  jconv_post_mono::Dsp jc_post_mono;
395  // wrapper for the rack order function pointers
396  static void convolver_init(unsigned int samplingFreq, PluginDef *pdef);
397  static int activate(bool start, PluginDef *pdef);
398  static void convolver(int count, float *input, float *output, PluginDef*);
399  static int convolver_register(const ParamReg& reg);
400 public:
401  ConvolverMonoAdapter(EngineControl& engine, sigc::slot<void> sync, ParamMap& param);
403 };
404 
405 
406 /****************************************************************
407  ** class BaseConvolver
408  */
409 
410 
411 class BaseConvolver: protected PluginDef {
412 protected:
414  boost::mutex activate_mutex;
416  sigc::slot<void> sync;
417  bool activated;
418  sigc::connection update_conn;
419  static void init(unsigned int samplingFreq, PluginDef *p);
420  static int activate(bool start, PluginDef *pdef);
421  void change_buffersize(unsigned int);
422  int conv_start();
423  bool check_update_timeout();
424  virtual void check_update() = 0;
425  virtual bool start(bool force = false) = 0;
426 public:
428 public:
429  BaseConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
430  virtual ~BaseConvolver();
431  inline void set_sync(bool val) { conv.set_sync(val); }
432 };
433 
434 /****************************************************************
435  ** class CabinetConvolver
436  */
437 
438 #include "faust/cabinet_impulse_former.h"
439 
441 private:
442  int current_cab;
443  float level;
444  int cabinet;
445  float bass;
446  float treble;
447  float sum;
448  value_pair *cab_names;
449  cabinet_impulse_former::Dsp impf;
450  static void run_cab_conf(int count, float *input, float *output, PluginDef*);
451  static int register_cab(const ParamReg& reg);
452  bool do_update();
453  virtual void check_update();
454  virtual bool start(bool force = false);
455  bool cabinet_changed() { return current_cab != cabinet; }
456  void update_cabinet() { current_cab = cabinet; }
457  bool sum_changed() { return abs(sum - (level + bass + treble)) > 0.01; }
458  void update_sum() { sum = level + bass + treble; }
459 public:
460  CabinetConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
461  ~CabinetConvolver();
462 };
463 
464 
466 private:
467  int current_cab;
468  float level;
469  int cabinet;
470  float bass;
471  float treble;
472  float sum;
473  value_pair *cab_names;
474  cabinet_impulse_former::Dsp impf;
475  static void run_cab_conf(int count, float *input, float *input1, float *output, float *output1, PluginDef*);
476  static int register_cab(const ParamReg& reg);
477  bool do_update();
478  virtual void check_update();
479  virtual bool start(bool force = false);
480  bool cabinet_changed() { return current_cab != cabinet; }
481  void update_cabinet() { current_cab = cabinet; }
482  bool sum_changed() { return abs(sum - (level + bass + treble)) > 0.01; }
483  void update_sum() { sum = level + bass + treble; }
484 public:
485  CabinetStereoConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
487 };
488 
489 
490 /****************************************************************
491  ** class PreampConvolver
492  */
493 
494 #include "faust/preamp_impulse_former.h"
495 
497 private:
498  int current_pre;
499  float level;
500  int preamp;
501  float bass;
502  float treble;
503  float sum;
504  value_pair *pre_names;
505  preamp_impulse_former::Dsp impf;
506  static void run_pre_conf(int count, float *input, float *output, PluginDef*);
507  static int register_pre(const ParamReg& reg);
508  bool do_update();
509  virtual void check_update();
510  virtual bool start(bool force = false);
511  bool preamp_changed() { return current_pre != preamp; }
512  void update_preamp() { current_pre = preamp; }
513  bool sum_changed() { return abs(sum - (level + bass + treble)) > 0.01; }
514  void update_sum() { sum = level + bass + treble; }
515 public:
516  PreampConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
517  ~PreampConvolver();
518 };
519 
520 /****************************************************************
521  ** class ContrastConvolver
522  */
523 
524 #include "faust/presence_level.h"
525 
527 private:
528  float level;
529  float sum;
530  presence_level::Dsp presl;
531  static void run_contrast(int count, float *input, float *output, PluginDef*);
532  static int register_con(const ParamReg& reg);
533  inline void update_sum() { sum = level; }
534  virtual void check_update();
535  bool do_update();
536  inline bool sum_changed() { return abs(sum - level) > 0.01; }
537  virtual bool start(bool force = false);
538 public:
539  ContrastConvolver(EngineControl& engine, sigc::slot<void> sync, gx_resample::BufferResampler& resamp);
541 };
542 
543 
544 /****************************************************************
545  ** class LadspaLoader
546  */
547 
549 
550 struct paradesc: boost::noncopyable {
551  int index;
552  std::string name;
553  float dflt;
554  float low;
555  float up;
556  float step;
558  bool newrow;
561  paradesc(): index(), name(), dflt(), low(), up(), step(), tp(), newrow(), has_caption(true), values() {}
562  ~paradesc();
563  void set_valuelist(const std::vector<std::string>& v);
564  void readJSON(gx_system::JsonParser& jp);
565  void writeJSON(gx_system::JsonWriter& jw);
566 };
567 
568 enum quirkflag { need_activate = 1, no_cleanup = 2, is_lv2 = 4 };
569 
570 class plugdesc {
571 public:
572  std::string path;
573  unsigned int index;
574  unsigned long UniqueID;
575  Glib::ustring Label;
576  Glib::ustring shortname;
577  Glib::ustring category;
578  int quirks; // quirkflag bits
581  Glib::ustring master_label;
582  std::vector<paradesc*> names;
583  std::string id_str;
584 private:
585  plugdesc() {}
586  ~plugdesc();
587  friend class LadspaLoader;
588 public:
589  void readJSON(gx_system::JsonParser& jp);
590  void writeJSON(gx_system::JsonWriter& jw);
591 };
592 
594 public:
595  typedef std::vector<plugdesc*> pluginarray;
596 private:
597  const gx_system::CmdlineOptions& options;
598  pluginarray plugins;
599  LilvWorld* world;
600  const LilvPlugins* lv2_plugins;
601  LilvNode* lv2_AudioPort;
602  LilvNode* lv2_ControlPort;
603  LilvNode* lv2_InputPort;
604  LilvNode* lv2_OutputPort;
605 private:
606  void read_module_config(const std::string& filename, plugdesc *p);
607  void read_module_list(pluginarray& p);
608 public:
609  LadspaLoader(const gx_system::CmdlineOptions& options);
610  ~LadspaLoader();
611  bool load(pluginarray& p);
612  unsigned int size() { return plugins.size(); }
613  PluginDef *create(unsigned int idx) { return create(plugins[idx]); }
614  PluginDef *create(const plugdesc *p);
615  pluginarray::iterator begin() { return plugins.begin(); }
616  pluginarray::iterator end() { return plugins.end(); }
617  pluginarray::iterator find(plugdesc* desc);
618  void set_plugins(pluginarray& new_plugins);
619  void change_plugins(pluginarray& new_plugins);
620  void update_instance(PluginDef *pdef, plugdesc *pdesc);
621  static std::string get_ladspa_filename(unsigned long uid)
622  { return "ladspa"+gx_system::to_string(uid)+".js"; }
623  static std::string get_ladspa_filename(std::string uid_key)
624  { return "ladspa"+uid_key.substr(9)+".js"; }
625  friend class Lv2Dsp;
626 };
627 
628 
629 /****************************************************************
630  ** class LiveLooper
631  */
632 
633 
634 class LiveLooper: public PluginDef {
635 
636 
637 class FileResampler {
638 private:
639  Resampler r_file;
640  int inputRate, outputRate;
641  int last_in_count;
642 public:
643  int setup(int _inputRate, int _outputRate);
644  int run(int count, float *input, float *output);
645  int max_out_count(int in_count) {
646  return static_cast<int>(ceil((in_count*static_cast<double>(outputRate))/inputRate)); }
647 };
648 
649 private:
650  int fSamplingFreq;
651  float gain;
652  float fRec0[2];
653  float gain_out;
654  float fclip1;
655  float fclip2;
656  float fclip3;
657  float fclip4;
658  float fclips1;
659  float fclips2;
660  float fclips3;
661  float fclips4;
662  float fspeed1;
663  float fspeed2;
664  float fspeed3;
665  float fspeed4;
666  float rplay1;
667  float rplay2;
668  float rplay3;
669  float rplay4;
670  float load1;
671  float load2;
672  float load3;
673  float load4;
674  float record1;
675  int iVec0[2];
676  int IOTA1;
677  int IOTA2;
678  int IOTA3;
679  int IOTA4;
680  float IOTAR1;
681  float IOTAR2;
682  float IOTAR3;
683  float IOTAR4;
684  float *tape1;
685  int tape1_size;
686  float fConst0;
687  float fConst1;
688  float fConst2;
689  float reset1;
690  int RecSize1[2];
691  float rectime0;
692  float fRec1[2];
693  float fRec2[2];
694  int iRec3[2];
695  int iRec4[2];
696  float play1;
697  float playh1;
698  float gain1;
699  float record2;
700  int iVec2[2];
701  float *tape2;
702  int tape2_size;
703  float reset2;
704  int RecSize2[2];
705  float rectime1;
706  float fRec6[2];
707  float fRec7[2];
708  int iRec8[2];
709  int iRec9[2];
710  float play2;
711  float playh2;
712  float gain2;
713  float record3;
714  int iVec4[2];
715  float *tape3;
716  int tape3_size;
717  float reset3;
718  int RecSize3[2];
719  float rectime2;
720  float fRec11[2];
721  float fRec12[2];
722  int iRec13[2];
723  int iRec14[2];
724  float play3;
725  float playh3;
726  float gain3;
727  float record4;
728  int iVec6[2];
729  float *tape4;
730  int tape4_size;
731  float reset4;
732  int RecSize4[2];
733  float rectime3;
734  float fRec16[2];
735  float fRec17[2];
736  int iRec18[2];
737  int iRec19[2];
738  float play4;
739  float playh4;
740  float gain4;
741  float play_all;
742  bool save1;
743  bool save2;
744  bool save3;
745  bool save4;
746  bool RP1;
747  bool RP2;
748  bool RP3;
749  bool RP4;
750  Glib::ustring preset_name;
751  Glib::ustring load_file1;
752  Glib::ustring load_file2;
753  Glib::ustring load_file3;
754  Glib::ustring load_file4;
755  Glib::ustring cur_name;
756  Glib::ustring loop_dir;
757  bool save_p;
758  ParamMap& param;
759  bool mem_allocated;
760  sigc::slot<void> sync;
761  volatile int ready;
762  FileResampler smp;
763 
764  int do_resample(int inrate, int insize, float *input, int maxsize);
765  int do_mono(int c, int f, float *oIn, float *tape, int n);
766  void play_all_tapes();
767  void mem_alloc();
768  void mem_free();
769  void clear_state_f();
770  int activate(bool start);
771  int load_ui_f(const UiBuilder& b, int form);
772  void init(unsigned int samplingFreq);
773  void compute(int count, float *input0, float *output0);
774  int register_par(const ParamReg& reg);
775  void save_array(std::string name);
776  void load_array(std::string name);
777  void save_to_wave(std::string fname, float *tape, float fSize, int tape_size);
778  int load_from_wave(std::string fname, float **tape, int tape_size);
779  void set_p_state();
780  void load_tape1();
781  void load_tape2();
782  void load_tape3();
783  void load_tape4();
784 
785  static void clear_state_f_static(PluginDef*);
786  static int activate_static(bool start, PluginDef*);
787  static int load_ui_f_static(const UiBuilder& b, int form);
788  static void init_static(unsigned int samplingFreq, PluginDef*);
789  static void compute_static(int count, float *input0, float *output0, PluginDef*);
790  static int register_params_static(const ParamReg& reg);
791  static void del_instance(PluginDef *p);
792 public:
794  LiveLooper(ParamMap& param_, sigc::slot<void> sync, const string& loop_dir_);
795  ~LiveLooper();
796 };
797 
798 
799 /****************************************************************
800  ** class SCapture
801  */
802 
803 
804 class SCapture: public PluginDef {
805 private:
806  SNDFILE * recfile;
807  EngineControl& engine;
808  int fSamplingFreq;
809  int channel;
810  float fcheckbox0;
811  float fcheckbox1;
812  float fslider0;
813  float fbargraph0;
814  float fRecC0[2];
815  float fformat;
816  int IOTA;
817  int iA;
818  int savesize;
819  int filesize;
820  float *fRec0;
821  float *fRec1;
822  float *tape;
823  sem_t m_trig;
824  pthread_t m_pthr;
825  volatile bool keep_stream;
826  bool mem_allocated;
827  bool is_wav;
828  bool err;
829  float fConst0;
830  float fRecb0[2];
831  int iRecb1[2];
832  float fRecb2[2];
833  void mem_alloc();
834  void mem_free();
835  void clear_state_f();
836  int activate(bool start);
837  int load_ui_f(const UiBuilder& b, int form);
838  void init(unsigned int samplingFreq);
839  void compute(int count, float *input0, float *output0);
840  void compute_st(int count, float *input0, float *input1, float *output0, float *output1);
841  int register_par(const ParamReg& reg);
842  void save_to_wave(SNDFILE * sf, float *tape, int lSize);
843  SNDFILE *open_stream(std::string fname);
844  void close_stream(SNDFILE **sf);
845  void stop_thread();
846  void start_thread();
847  void disc_stream();
848  inline std::string get_ffilename();
849 
850  static void *run_thread(void* p);
851  static void clear_state_f_static(PluginDef*);
852  static int activate_static(bool start, PluginDef*);
853  static const char *glade_def;
854  static const char *glade_def_st;
855  static int load_ui_f_static(const UiBuilder& b, int form);
856  static void init_static(unsigned int samplingFreq, PluginDef*);
857  static void compute_static(int count, float *input0, float *output0, PluginDef*);
858  static void compute_static_st(int count, float *input0, float *input1, float *output0, float *output1, PluginDef*);
859  static int register_params_static(const ParamReg& reg);
860  static void del_instance(PluginDef *p);
861 public:
863  SCapture(EngineControl& engine, int channel_);
864  ~SCapture();
865 };
866 
867 
868 /****************************************************************************
869 *
870 * NAME: smbPitchShift.cpp
871 * VERSION: 1.2
872 * HOME URL: http://www.dspdimension.com
873 * KNOWN BUGS: none
874 *
875 *
876 * COPYRIGHT 1999-2009 Stephan M. Bernsee <smb [AT] dspdimension [DOT] com>
877 *
878 * Modified for guitarix by Hermann Meyer 2014
879 *
880 * The Wide Open License (WOL)
881 *
882 * Permission to use, copy, modify, distribute and sell this software and its
883 * documentation for any purpose is hereby granted without fee, provided that
884 * the above copyright notice and this license appear in all source copies.
885 * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
886 * ANY KIND. See http://www.dspguru.com/wol.htm for more information.
887 *
888 *****************************************************************************/
889 
890 
891 #define M_PI 3.14159265358979323846
892 #define MAX_FRAME_LENGTH 8096
893 
894 class smbPitchShift : public PluginDef {
895 private:
897  EngineControl& engine;
898  bool mem_allocated;
899  sigc::slot<void> sync;
900  volatile bool ready;
901  ParamMap& param;
902  float gInFIFO[MAX_FRAME_LENGTH];
903  float gOutFIFO[MAX_FRAME_LENGTH];
904  float *fpb;
905  float *expect;
906  float *hanning;
907  float *hanningd;
908  float *resampin;
909  float *resampin2;
910  float *resampout;
911  float *indata2;
912  float gLastPhase[MAX_FRAME_LENGTH/2+1];
913  float gSumPhase[MAX_FRAME_LENGTH/2+1];
914  float gOutputAccum[2*MAX_FRAME_LENGTH];
915  float gAnaFreq[MAX_FRAME_LENGTH];
916  float gAnaMagn[MAX_FRAME_LENGTH];
917  float gSynFreq[MAX_FRAME_LENGTH];
918  float gSynMagn[MAX_FRAME_LENGTH];
919  float semitones;
920  float a,b,c,d,l;
921  float wet;
922  float dry;
923  float mpi, mpi1;
924  float tone;
925  int octave, osamp, numSampsToResamp, numSampsToProcess, fftFrameSize, sampleRate ;
926  int latency;
927  int ai;
928  int aio;
929  int ii;
930  long gRover , gInit ;
931  double magn, phase, tmp, window, real, imag;
932  double freqPerBin, freqPerBin1, freqPerBin2, expct;
933  double fftFrameSize3;
934  double fftFrameSize4;
935  double osamp1,osamp2;
936  long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2;
937 
938  fftwf_complex fftw_in[MAX_FRAME_LENGTH], fftw_out[MAX_FRAME_LENGTH];
939  fftwf_plan ftPlanForward, ftPlanInverse;
940 
941  inline int load_ui_f(const UiBuilder& b, int form);
942  int register_par(const ParamReg& reg);
943  void change_latency();
944 
945  void mem_alloc();
946  void mem_free();
947  void clear_state();
948  int activate(bool start);
949  bool setParameters( int sampleRate);
950  void PitchShift(int count, float *indata, float *outdata);
951  void change_buffersize(unsigned int size);
952  static int activate_static(bool start, PluginDef*);
953  static void del_instance(PluginDef *p);
954  static int registerparam(const ParamReg& reg);
955  static int load_ui_f_static(const UiBuilder& b, int form);
956  static void init(unsigned int sampleRate, PluginDef *plugin);
957  static void compute_static(int count, float *input0, float *output0, PluginDef *p);
958 
959 public:
961  smbPitchShift(ParamMap& param_, EngineControl& engine, sigc::slot<void> sync);
962  ~smbPitchShift();
963 };
964 
965 
966 } // namespace gx_engine
CmdConnection::msg_type start
Definition: jsonrpc.cpp:255
Glib::Dispatcher & signal_jack_load_change()
pluginarray::iterator end()
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()
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:523
#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()
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
void set_mul_buffer(int a, unsigned int b)