~ubuntu-branches/ubuntu/oneiric/muse/oneiric

« back to all changes in this revision

Viewing changes to muse/plugin.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-11-17 21:43:38 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101117214338-1hvfl7oo2dsqnvrb
Tags: 1.1-0ubuntu1
* New upstream release (LP: #668631)
* Switch to dpkg-source 3.0 (quilt) format
* Switch to dh7 short form
* debian/rules:
  - added --enable-dssi and --enable-osc to conf flags for dssi support
  - added -ljackserver to LDFLAGS to fix a FTBFS because of --as-needed
* debian/control:
  - added build build dependency on liblo-dev and dssi-dev for dssi support
  - bump Standards-version to 3.9.1. No changes required.
* debian/muse.desktop, debian/muse.xpm: dropped as desktop file and icon is
  now shipped upstream.
* fix-desktop-categories.patch: fix Categories tag in upstream desktop file
* 10_es_locale_fix.dpatch: refreshed and converted to quilt as
  fix_es_locale.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include <qmainwindow.h>
16
16
#include <qstring.h>
17
17
#include <qwidget.h>
 
18
#include <qwidgetfactory.h>
18
19
#include <qdialog.h>
19
20
#include <qfileinfo.h>
20
21
#include <qcombobox.h>
24
25
#include "globaldefs.h"
25
26
#include "ctrl.h"
26
27
 
 
28
//#include "stringparam.h"
 
29
 
 
30
#include "config.h"
 
31
 
 
32
#ifdef OSC_SUPPORT
 
33
//class OscIF;
 
34
#include "osc.h"
 
35
#endif
 
36
 
 
37
#ifdef DSSI_SUPPORT
 
38
#include <dssi.h>
 
39
#endif
 
40
 
27
41
class Xml;
28
42
class QWidget;
29
43
// class QLabel;
30
44
class Slider;
31
45
class QListView;
 
46
class QScrollView;
32
47
class QToolButton;
33
48
class DoubleLabel;
34
49
class AudioTrack;
35
50
class MidiController;
36
51
 
37
52
//---------------------------------------------------------
 
53
//   PluginWidgetFactory
 
54
//---------------------------------------------------------
 
55
 
 
56
class PluginWidgetFactory : public QWidgetFactory
 
57
{
 
58
  public:
 
59
    virtual QWidget* createWidget(const QString& className, QWidget* parent, const char* name) const; 
 
60
};
 
61
 
 
62
//---------------------------------------------------------
38
63
//   Plugin
39
64
//---------------------------------------------------------
40
65
 
41
66
class Plugin {
 
67
   protected:
 
68
      void* _handle;
42
69
      int _references;
43
70
      int _instNo;
44
71
      QFileInfo fi;
45
72
      LADSPA_Descriptor_Function ladspa;
46
73
      const LADSPA_Descriptor *plugin;
47
 
      int _inports;
48
 
      int _outports;
 
74
      unsigned long _uniqueID;
 
75
      QString _label;
 
76
      QString _name;
 
77
      QString _maker;
 
78
      QString _copyright;
 
79
      
 
80
      bool _isDssi;
 
81
      #ifdef DSSI_SUPPORT
 
82
      const DSSI_Descriptor* dssi_descr;
 
83
      #endif
 
84
      
 
85
      //LADSPA_PortDescriptor* _portDescriptors;
 
86
      unsigned long _portCount;
 
87
      unsigned long _inports;
 
88
      unsigned long _outports;
 
89
      unsigned long _controlInPorts;
 
90
      unsigned long _controlOutPorts;
 
91
      std::vector<unsigned long> rpIdx; // Port number to control input index. Item is -1 if it's not a control input.
 
92
      
49
93
      bool _inPlaceCapable;
50
94
   
51
95
   public:
52
 
      Plugin(QFileInfo* f,
53
 
         LADSPA_Descriptor_Function df, const LADSPA_Descriptor* d, bool inPlace);
54
 
 
55
 
      QString label() const    { return QString(plugin->Label); }
56
 
      QString name() const     { return QString(plugin->Name); }
57
 
      unsigned long id() const { return plugin->UniqueID; }
58
 
      QString maker() const    { return QString(plugin->Maker); }
59
 
      QString copyright() const { return QString(plugin->Copyright); }
60
 
      QString lib() const      { return fi.baseName(true); }
61
 
      QString path() const     { return fi.dirPath(); }
62
 
      int references() const   { return _references; }
63
 
      int incReferences(int n) { return _references += n; }
64
 
      int instNo()             { return _instNo++;        }
65
 
 
66
 
      LADSPA_Handle instantiate() {
67
 
            return plugin->instantiate(plugin, sampleRate);
68
 
            }
 
96
      Plugin(QFileInfo* f, const LADSPA_Descriptor* d, bool isDssi = false);
 
97
      ~Plugin();
 
98
      
 
99
      QString label() const                        { return _label; }
 
100
      QString name() const                         { return _name; }
 
101
      unsigned long id() const                     { return _uniqueID; }
 
102
      QString maker() const                        { return _maker; }
 
103
      QString copyright() const                    { return _copyright; }
 
104
      QString lib(bool complete = true) const      { return fi.baseName(complete); }
 
105
      QString dirPath(bool complete = true) const  { return fi.dirPath(complete); }
 
106
      QString filePath() const                     { return fi.filePath(); }
 
107
      int references() const                       { return _references; }
 
108
      int incReferences(int);
 
109
      int instNo()                                 { return _instNo++;        }
 
110
 
 
111
      bool isDssiPlugin() const { return _isDssi; }  
 
112
      
 
113
      LADSPA_Handle instantiate(); 
69
114
      void activate(LADSPA_Handle handle) {
70
 
            if (plugin->activate)
 
115
            if (plugin && plugin->activate)
71
116
                  plugin->activate(handle);
72
117
            }
73
118
      void deactivate(LADSPA_Handle handle) {
74
 
            if (plugin->deactivate)
 
119
            if (plugin && plugin->deactivate)
75
120
                  plugin->deactivate(handle);
76
121
            }
77
122
      void cleanup(LADSPA_Handle handle) {
78
 
            if (plugin->cleanup)
 
123
            if (plugin && plugin->cleanup)
79
124
                  plugin->cleanup(handle);
80
125
            }
81
126
      void connectPort(LADSPA_Handle handle, int port, float* value) {
82
 
            plugin->connect_port(handle, port, value);
 
127
            if(plugin)
 
128
              plugin->connect_port(handle, port, value);
83
129
            }
84
130
      void apply(LADSPA_Handle handle, int n) {
85
 
            plugin->run(handle, n);
86
 
            }
87
 
      int ports() { return plugin->PortCount; }
88
 
      double defaultValue(unsigned int port) const;
89
 
      LADSPA_PortDescriptor portd(int k) const {
90
 
            return plugin->PortDescriptors[k];
91
 
            }
92
 
      void range(int i, float*, float*) const;
93
 
      LADSPA_PortRangeHint range(int i) {
 
131
            if(plugin)
 
132
              plugin->run(handle, n);
 
133
            }
 
134
      
 
135
      #ifdef OSC_SUPPORT
 
136
      int oscConfigure(LADSPA_Handle /*handle*/, const char* /*key*/, const char* /*value*/);
 
137
      #endif
 
138
      
 
139
      //int ports() { return plugin ? plugin->PortCount : 0; }
 
140
      unsigned long ports() { return _portCount; }
 
141
      
 
142
      LADSPA_PortDescriptor portd(unsigned long k) const {
 
143
            return plugin ? plugin->PortDescriptors[k] : 0;
 
144
            //return _portDescriptors[k];
 
145
            }
 
146
      
 
147
      LADSPA_PortRangeHint range(unsigned long i) {
 
148
            // FIXME:
 
149
            //return plugin ? plugin->PortRangeHints[i] : 0;
94
150
            return plugin->PortRangeHints[i];
95
151
            }
96
152
 
97
 
      const char* portName(int i) {
98
 
            return plugin->PortNames[i];
 
153
      double defaultValue(unsigned long port) const;
 
154
      void range(unsigned long i, float*, float*) const;
 
155
      
 
156
      const char* portName(unsigned long i) {
 
157
            return plugin ? plugin->PortNames[i] : 0;
99
158
            }
100
 
      int inports() const  { return _inports; }
101
 
      int outports() const { return _outports; }
102
 
      bool inPlaceCapable() const { return _inPlaceCapable; }
 
159
            
 
160
      // Returns (int)-1 if not an input control.   
 
161
      unsigned long port2InCtrl(unsigned long p) { return p >= rpIdx.size() ? (unsigned long)-1 : rpIdx[p]; }   
 
162
      
 
163
      unsigned long inports() const         { return _inports; }
 
164
      unsigned long outports() const        { return _outports; }
 
165
      unsigned long controlInPorts() const  { return _controlInPorts; }
 
166
      unsigned long controlOutPorts() const { return _controlOutPorts; }
 
167
      bool inPlaceCapable() const           { return _inPlaceCapable; }
103
168
      };
104
169
 
105
170
typedef std::list<Plugin>::iterator iPlugin;
110
175
 
111
176
class PluginList : public std::list<Plugin> {
112
177
   public:
113
 
      void add(QFileInfo* fi, LADSPA_Descriptor_Function df,
114
 
         const LADSPA_Descriptor* d, bool inPlaceOk) {
115
 
            push_back(Plugin(fi, df, d, inPlaceOk));
116
 
            }
 
178
      void add(QFileInfo* fi, const LADSPA_Descriptor* d, bool isDssi = false) 
 
179
      {
 
180
        push_back(Plugin(fi, d, isDssi));
 
181
      }
 
182
      
117
183
      Plugin* find(const QString&, const QString&);
118
184
      PluginList() {}
119
185
      };
161
227
 
162
228
class PluginI;
163
229
 
 
230
/*
 
231
class PluginBase 
 
232
{
 
233
   public:
 
234
      bool on() const        { return _on; }
 
235
      void setOn(bool val)   { _on = val; }
 
236
      int pluginID()                { return plugin()->id(); }
 
237
      int id()                      { return _id; }
 
238
      QString pluginLabel() const    { return _plugin->label(); }
 
239
      QString name() const           { return _name; }
 
240
      
 
241
      AudioTrack* track()           { return _track; }
 
242
      
 
243
      void enableController(int i, bool v = true)   { controls[i].enCtrl = v; }
 
244
      bool controllerEnabled(int i) const           { return controls[i].enCtrl; }
 
245
      bool controllerEnabled2(int i) const          { return controls[i].en2Ctrl; }
 
246
      void updateControllers();
 
247
      
 
248
      void writeConfiguration(int level, Xml& xml);
 
249
      bool readConfiguration(Xml& xml, bool readPreset=false);
 
250
      
 
251
      int parameters() const           { return controlPorts; }
 
252
      void setParam(int i, double val) { controls[i].tmpVal = val; }
 
253
      double param(int i) const        { return controls[i].val; }
 
254
      const char* paramName(int i)     { return _plugin->portName(controls[i].idx); }
 
255
      LADSPA_PortRangeHint range(int i) 
 
256
      {
 
257
            return _plugin->range(controls[i].idx);
 
258
      }
 
259
};
 
260
*/
 
261
 
 
262
//---------------------------------------------------------
 
263
//   PluginIBase 
 
264
//---------------------------------------------------------
 
265
 
 
266
class PluginIBase 
 
267
{
 
268
   public:
 
269
      virtual bool on() const = 0;       
 
270
      virtual void setOn(bool /*val*/) = 0;   
 
271
      virtual int pluginID() = 0;
 
272
      virtual int id() = 0;
 
273
      virtual QString pluginLabel() const = 0;  
 
274
      virtual QString name() const = 0;
 
275
      
 
276
      virtual AudioTrack* track() = 0;          
 
277
      
 
278
      virtual void enableController(int /*i*/, bool v = true) = 0; 
 
279
      virtual bool controllerEnabled(int /*i*/) const = 0;          
 
280
      virtual bool controllerEnabled2(int /*i*/) const = 0;          
 
281
      virtual void updateControllers() = 0;
 
282
      
 
283
      virtual void writeConfiguration(int /*level*/, Xml& /*xml*/) = 0;
 
284
      virtual bool readConfiguration(Xml& /*xml*/, bool readPreset=false) = 0;
 
285
      
 
286
      virtual int parameters() const = 0;          
 
287
      virtual void setParam(int /*i*/, double /*val*/) = 0; 
 
288
      virtual double param(int /*i*/) const = 0;        
 
289
      virtual const char* paramName(int /*i*/) = 0;     
 
290
      virtual LADSPA_PortRangeHint range(int /*i*/) = 0; 
 
291
};
 
292
 
164
293
//---------------------------------------------------------
165
294
//   PluginGui
166
295
//---------------------------------------------------------
168
297
class PluginGui : public QMainWindow {
169
298
      Q_OBJECT
170
299
 
171
 
      PluginI* plugin;        // plugin instance
 
300
      //PluginI* plugin;        // plugin instance
 
301
      PluginIBase* plugin;        // plugin instance
 
302
      
172
303
      GuiParam* params;
173
304
      int nobj;               // number of widgets in gw
174
305
      GuiWidgets* gw;
175
306
 
176
307
      QToolButton* onOff;
177
308
      QWidget* mw;            // main widget
 
309
      QScrollView* view;
178
310
 
179
311
      void updateControls();
180
312
 
198
330
      void heartBeat();
199
331
 
200
332
   public:
201
 
      PluginGui(PluginI*);
 
333
      //PluginGui(PluginI*);
 
334
      PluginGui(PluginIBase*);
 
335
      
202
336
      ~PluginGui();
203
337
      void setOn(bool);
204
338
      void updateValues();
212
346
#define AUDIO_IN (LADSPA_PORT_AUDIO  | LADSPA_PORT_INPUT)
213
347
#define AUDIO_OUT (LADSPA_PORT_AUDIO | LADSPA_PORT_OUTPUT)
214
348
 
215
 
class PluginI {
 
349
//class PluginI {
 
350
class PluginI : public PluginIBase {
216
351
      Plugin* _plugin;
217
352
      int channel;
218
353
      int instances;
221
356
 
222
357
      LADSPA_Handle* handle;         // per instance
223
358
      Port* controls;
 
359
      Port* controlsOut;
224
360
 
225
361
      int controlPorts;
 
362
      int controlOutPorts;
226
363
      PluginGui* _gui;
227
364
      bool _on;
228
365
      bool initControlValues;
229
366
      QString _name;
230
367
      QString _label;
231
368
 
 
369
      //#ifdef DSSI_SUPPORT
 
370
      //StringParamMap _stringParamMap;
 
371
      //#endif
 
372
      
 
373
      #ifdef OSC_SUPPORT
 
374
      OscEffectIF _oscif;
 
375
      #endif
 
376
      bool _showNativeGuiPending;
 
377
 
232
378
      void init();
233
379
      void makeGui();
234
 
 
 
380
      
235
381
   public:
236
382
      PluginI();
237
383
      ~PluginI();
244
390
      
245
391
      void setTrack(AudioTrack* t)  { _track = t; }
246
392
      AudioTrack* track()           { return _track; }
 
393
      int pluginID()                { return _plugin->id(); }
247
394
      void setID(int i);
248
395
      int id()                      { return _id; }
249
396
      void updateControllers();
262
409
      
263
410
      void activate();
264
411
      void deactivate();
 
412
      QString pluginLabel() const    { return _plugin->label(); }
265
413
      QString label() const          { return _label; }
266
414
      QString name() const           { return _name; }
267
415
      CtrlValueType valueType() const;
268
416
      QString lib() const            { return _plugin->lib(); }
269
417
 
 
418
      #ifdef OSC_SUPPORT
 
419
      OscEffectIF& oscIF() { return _oscif; }
 
420
      /*
 
421
      int oscConfigure(lo_arg**);
 
422
      int oscControl(lo_arg**);
 
423
      //int oscUpdate(lo_arg**);
 
424
      //int oscExiting(lo_arg**);
 
425
      */
 
426
      
 
427
      int oscControl(unsigned long /*dssiPort*/, float /*val*/);
 
428
      int oscConfigure(const char */*key*/, const char */*val*/);
 
429
      int oscUpdate();
 
430
      //int oscExiting();
 
431
      #endif
 
432
      
270
433
      void writeConfiguration(int level, Xml& xml);
271
434
      bool readConfiguration(Xml& xml, bool readPreset=false);
272
435
      bool loadControl(Xml& xml);
273
436
      bool setControl(const QString& s, double val);
274
437
      void showGui();
275
438
      void showGui(bool);
 
439
      bool isDssiPlugin() const { return _plugin->isDssiPlugin(); }  
 
440
      void showNativeGui();
 
441
      void showNativeGui(bool);
 
442
      bool isShowNativeGuiPending() { return _showNativeGuiPending; }
276
443
      bool guiVisible();
 
444
      bool nativeGuiVisible();
277
445
      int parameters() const           { return controlPorts; }
278
446
      void setParam(int i, double val) { controls[i].tmpVal = val; }
279
447
      double param(int i) const        { return controls[i].val; }
317
485
      QString label(int idx) const;
318
486
      QString name(int idx) const;
319
487
      void showGui(int, bool);
 
488
      bool isDssiPlugin(int) const; 
 
489
      void showNativeGui(int, bool);
320
490
      void deleteGui(int idx);
321
491
      void deleteAllGuis();
322
492
      bool guiVisible(int);
 
493
      bool nativeGuiVisible(int);
323
494
      void apply(int ports, unsigned long nframes, float** buffer);
324
495
      void move(int idx, bool up);
325
496
      bool empty(int idx) const;