summaryrefslogtreecommitdiff
path: root/attic/muse_qt4_evolution/muse/ladspaplugin.h
blob: 4c492813960b548db4fa359e91ae866833ca837d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//=============================================================================
//  MusE
//  Linux Music Editor
//  $Id:$
//
//  Copyright (C) 2006 by Werner Schweer and others
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================

#ifndef __LADSPAPLUGIN_H__
#define __LADSPAPLUGIN_H__

#include "ladspa.h"
#include "plugin.h"

//---------------------------------------------------------
//   LadspaPlugin
//---------------------------------------------------------

class LadspaPlugin : public Plugin {
      LADSPA_Descriptor_Function ladspa;
      const LADSPA_Descriptor* plugin;

   protected:
      int _parameter;
      std::vector<int> pIdx;

      int _inports;
      std::vector<int> iIdx;

      int _outports;
      std::vector<int> oIdx;

      bool _inPlaceCapable;
      friend class LadspaPluginIF;

   public:
      LadspaPlugin(const QFileInfo* f,
         const LADSPA_Descriptor_Function,
         const LADSPA_Descriptor* d);

      virtual QString label() const     { return QString(plugin->Label); }
      virtual QString name() const      { return QString(plugin->Name); }
      virtual unsigned long id() const  { return plugin->UniqueID; }
      virtual QString maker() const     { return QString(plugin->Maker); }
      virtual QString copyright() const { return QString(plugin->Copyright); }

      void* instantiate();
      virtual void range(int i, double*, double*) const;
      virtual int parameter() const { return _parameter;     }
      virtual int inports() const   { return _inports; }
      virtual int outports() const  { return _outports; }

      virtual bool inPlaceCapable() const { return _inPlaceCapable; }
      virtual PluginIF* createPIF(PluginI*);
      const LADSPA_Descriptor* ladspaDescriptor() const { return plugin; }

      virtual bool isLog(int k) const {
            LADSPA_PortRangeHint r = plugin->PortRangeHints[pIdx[k]];
            return LADSPA_IS_HINT_LOGARITHMIC(r.HintDescriptor);
            }
      virtual bool isBool(int k) const {
            return LADSPA_IS_HINT_TOGGLED(plugin->PortRangeHints[pIdx[k]].HintDescriptor);
            }
      virtual bool isInt(int k) const {
            LADSPA_PortRangeHint r = plugin->PortRangeHints[pIdx[k]];
            return LADSPA_IS_HINT_INTEGER(r.HintDescriptor);
            }
      virtual double defaultValue(int) const;
      };

//---------------------------------------------------------
//   LadspaPort
//---------------------------------------------------------

struct LadspaPort {
      float val;
      };

//---------------------------------------------------------
//   LadspaPluginIF
//---------------------------------------------------------

class LadspaPluginIF : public PluginIF {
      const LADSPA_Descriptor* descr;
      LADSPA_Handle handle;         // per instance
      LadspaPlugin* plugin;

      LadspaPort* controls;

   public:
      LadspaPluginIF(PluginI* pi);

      virtual void apply(unsigned nframes, float** src, float** dst);
      virtual void activate();
      virtual void deactivate() {
            if (descr->deactivate)
                  descr->deactivate(handle);
            }
      virtual void cleanup() {
            if (descr->cleanup)
                  descr->cleanup(handle);
            }
      virtual const char* getParameterName(int i) const {
            return plugin->plugin->PortNames[plugin->pIdx[i]];
            }
      virtual void setParam(int i, double val) { controls[i].val = val; }
      virtual float param(int i) const        { return controls[i].val; }
      bool init(Plugin*);
      };

extern float ladspaDefaultValue(const LADSPA_Descriptor* plugin, int k);

#endif