summaryrefslogtreecommitdiff
path: root/muse2/muse/osc.h
blob: a0973ac7c652ae52910ed99e40871efcc7e4e8c8 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//=============================================================================
//  MusE
//  Linux Music Editor
//  $Id: osc.h,v 1.0.0.0 2010/04/22 10:05:00 terminator356 Exp $
//
//  Copyright (C) 1999-2011 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
//  as published by the Free Software Foundation; version 2 of
//  the License, or (at your option) any later version.
//
//  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//=============================================================================

#ifndef __OSC_H__
#define __OSC_H__

#include <lo/lo.h>

#include "config.h"
 
#ifdef DSSI_SUPPORT
class DssiSynthIF;
#endif

class QProcess;
class QString;
class PluginI;
class OscIF;

/*
// Keep the OSC fifo small. There may be thousands of controls, and each control needs a fifo.
// Oops, no, if the user keeps adjusting a slider without releasing the mouse button, then all of the 
//  events are sent at once upon releasing the button, meaning there might be thousands of events at once.
#define OSC_FIFO_SIZE 512

//---------------------------------------------------------
//  OscControlValue
//  Item struct for OscGuiControlFifo. 
//---------------------------------------------------------

struct OscControlValue
{
  //int idx;
  float value;
  int frame;    // Added p4.0.15
};

//---------------------------------------------------------
//  OscControlFifo
//  A fifo for each of the OSC controls.
//---------------------------------------------------------

class OscControlFifo
{
      OscControlValue fifo[OSC_FIFO_SIZE];
      volatile int size;
      int wIndex;
      int rIndex;

   public:
      OscControlFifo()  { clear(); }
      bool put(const OscControlValue& event);   // returns true on fifo overflow
      OscControlValue get();
      const OscControlValue& peek(int n = 0);
      void remove();
      bool isEmpty() const { return size == 0; }
      void clear()         { size = 0, wIndex = 0, rIndex = 0; }
      int getSize() const  { return size; }
};
*/

//---------------------------------------------------------
//  OscIF
//  Open Sound Control Interface
//---------------------------------------------------------

/*
class OscIF
{
   private:
      PluginI* _oscPluginI;
      
      #ifdef DSSI_SUPPORT
      DssiSynthIF* _oscSynthIF;
      #endif
      
      QProcess* _oscGuiQProc;
      void* _uiOscTarget;
      char* _uiOscShowPath;
      char* _uiOscControlPath;
      char* _uiOscConfigurePath;
      char* _uiOscProgramPath;
      char* _uiOscPath;
      bool _oscGuiVisible;
   
      OscControlFifo* _oscControlFifos;
      
   public:
      OscIF();
      ~OscIF();
      
      void oscSetPluginI(PluginI*);
      
      #ifdef DSSI_SUPPORT
      void oscSetSynthIF(DssiSynthIF*);
      #endif
      
      int oscUpdate(lo_arg**);    
      int oscProgram(lo_arg**);   
      int oscControl(lo_arg**);   
      int oscExiting(lo_arg**);   
      int oscMidi(lo_arg**);      
      int oscConfigure(lo_arg**); 
   
      bool oscInitGui();
      void oscShowGui(bool);
      bool oscGuiVisible() const;
      OscControlFifo* oscFifo(unsigned long) const;
};
*/ 
 
class OscIF
{
   protected:
      QProcess* _oscGuiQProc;
      void* _uiOscTarget;
      char* _uiOscPath;
      char* _uiOscSampleRatePath;
      char* _uiOscConfigurePath;
      char* _uiOscProgramPath;
      char* _uiOscControlPath;
      char* _uiOscShowPath;
      bool _oscGuiVisible;
   
      //OscControlFifo* _oscControlFifos;
      
      virtual bool oscInitGui(const QString& /*typ*/, const QString& /*baseName*/, const QString& /*name*/, 
                       const QString& /*label*/, const QString& /*filePath*/, const QString& /*guiPath*/);
                       
   public:
      OscIF();
      virtual ~OscIF();
      
      //OscControlFifo* oscFifo(unsigned long) const;
      
      virtual int oscUpdate(lo_arg**);    
      virtual int oscProgram(lo_arg**)   { return 0; }   
      virtual int oscControl(lo_arg**)   { return 0; }    
      virtual int oscExiting(lo_arg**);   
      virtual int oscMidi(lo_arg**)      { return 0; }      
      virtual int oscConfigure(lo_arg**) { return 0; } 
   
      virtual void oscSendProgram(unsigned long /*prog*/, unsigned long /*bank*/);    
      virtual void oscSendControl(unsigned long /*dssiPort*/, float /*val*/);    
      virtual void oscSendConfigure(const char */*key*/, const char */*val*/); 
      
      virtual bool oscInitGui() { return false; }
      virtual void oscShowGui(bool);
      virtual bool oscGuiVisible() const;
};
 
class OscEffectIF : public OscIF
{
   protected:
      PluginI* _oscPluginI;
   
   public:
      OscEffectIF() {}
      //~OscEffectIF();

      void oscSetPluginI(PluginI*);
      
      virtual int oscUpdate(lo_arg**);
      //virtual int oscProgram(lo_arg**);
      virtual int oscControl(lo_arg**);
      //virtual int oscExiting(lo_arg**);
      //virtual int oscMidi(lo_arg**);
      virtual int oscConfigure(lo_arg**);
      
      virtual bool oscInitGui();
};
 
#ifdef DSSI_SUPPORT
class OscDssiIF : public OscIF
{
   protected:
      DssiSynthIF* _oscSynthIF;
      
   public:
      OscDssiIF() {}
      //~OscDssiIF();
      
      void oscSetSynthIF(DssiSynthIF*);
      
      virtual int oscUpdate(lo_arg**);
      virtual int oscProgram(lo_arg**);
      virtual int oscControl(lo_arg**);
      //virtual int oscExiting(lo_arg**);
      virtual int oscMidi(lo_arg**);
      virtual int oscConfigure(lo_arg**);
      
      virtual bool oscInitGui();
};
#endif // DSSI_SUPPORT
 
extern void initOSC();

#endif