summaryrefslogtreecommitdiff
path: root/muse2/synti/fluidsynth/fluidsynthgui.h
blob: 373a2343902b2415497ef21878f8e44fb983bac0 (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
218
219
220
221
222
223
224
225
226
227
228
229
/*
 * MusE FLUID Synth softsynth plugin
 *
 * Copyright (C) 2004 Mathias Lundgren (lunar_shuttle@users.sourcforge.net)
 *
 * $Id: fluidsynthgui.h,v 1.10.2.3 2009/02/02 21:38:02 terminator356 Exp $
 *
 */

#ifndef __MUSE_FLUIDSYNTHGUI_H__
#define __MUSE_FLUIDSYNTHGUI_H__

#include "ui_fluidsynthguibase.h"
#include "libsynti/gui.h"
#include <list>

class QDialog;
class QTreeWidgetItem;

struct FluidChannel;
#define FS_DEBUG 0 //Turn on/off debug
/*
#include <list>
#include <string>
#include <qscrollview.h>

#include <qevent.h>
#include <qmenubar.h>
#include <qsocketnotifier.h>
#include <alsa/asoundlib.h>
#include <qlistview.h>
#include <qheader.h>
#include "muse/debug.h"
*/

#define FS_MAX_NR_OF_CHANNELS          16
#define FS_UNSPECIFIED_FONT           126
#define FS_UNSPECIFIED_ID             127
#define FS_UNSPECIFIED_PRESET         129
#define FS_CHANNEL_COL                  0
#define FS_ID_COL                       0
#define FS_SFNAME_COL                   1
#define FS_SF_ID_COL                    1
#define FS_DRUM_CHANNEL_COL             2

#define FS_SFDATALEN                    1
#define FS_VERSION_MAJOR                0
#define FS_VERSION_MINOR                4
//#define FS_INIT_DATA_HEADER_SIZE        4
#define FS_INIT_DATA_HEADER_SIZE        6    // Including MFG + synth IDs
#define FS_INIT_CHANNEL_SECTION       255

// Predefined init-values for fluidsynth
#define FS_PREDEF_VOLUME               0.063
#define FS_PREDEF_REVERB_LEVEL         0.125
#define FS_PREDEF_REVERB_ROOMSIZE      0.125
#define FS_PREDEF_REVERB_DAMPING       0.3
#define FS_PREDEF_REVERB_WIDTH         0.125
#define FS_PREDEF_CHORUS_NUM           3
#define FS_PREDEF_CHORUS_TYPE          1
#define FS_PREDEF_CHORUS_SPEED         0.5
#define FS_PREDEF_CHORUS_DEPTH         0.3
#define FS_PREDEF_CHORUS_LEVEL         0.5
typedef unsigned char byte;


/*


#define MUSE_FLUID_UNSPECIFIED_CHANNEL	127


#define MUSE_FLUID_UNSPECIFIED_LASTDIR	127
*/

//Various messages the gui and the client uses to communicate
enum {
      FS_LASTDIR_CHANGE = 1,
      FS_PUSH_FONT
      };

enum {
      //FS_GAIN_SET,
      FS_SEND_SOUNDFONTDATA = 4,
      FS_SEND_CHANNELINFO, //Used by synth to send info about all channels, on init
      FS_SOUNDFONT_CHANNEL_SET,
      FS_SOUNDFONT_POP,
      FS_SEND_DRUMCHANNELINFO, //Used by synth to send drumchannel status about all channels, on init
      FS_DRUMCHANNEL_SET //Used by gui to set drumchannel status for specific channel
      };

enum
      {
      FS_DUMP_INFO = 240,
      FS_ERROR,
      FS_INIT_DATA
      };
/*
enum {
      MUSE_FLUID_REVERB = 100,
      MUSE_FLUID_REVERB_ROOMSIZE,
      MUSE_FLUID_REVERB_DAMPING,
      MUSE_FLUID_REVERB_WIDTH,
      MUSE_FLUID_REVERB_LEVEL,
      MUSE_FLUID_CHORUS,
      MUSE_FLUID_CHORUS_NUMBER,
      MUSE_FLUID_CHORUS_TYPE,
      MUSE_FLUID_CHORUS_SPEED,
      MUSE_FLUID_CHORUS_DEPTH,
      MUSE_FLUID_CHORUS_LEVEL,
      MUSE_FLUID_GAIN,
      MUSE_FLUID_SOUNDFONT,
      MUSE_FLUID_STRING,
      MUSE_FLUID_STRING_END
      };

enum {
      MUSE_FLUID_CLIENT_SEND_PARAMETER = 33,
      MUSE_FLUID_CLIENT_SEND_SOUNDFONTS,
      MUSE_FLUID_PARAMETER_GET,
      MUSE_FLUID_PARAMETER_REVERB,
      MUSE_FLUID_PARAMETER_CHORUS,

      MUSE_FLUID_GAIN_GET,
      MUSE_FLUID_SOUNDFONT_PUSH,
      MUSE_FLUID_SOUNDFONT_POP,

      MUSE_FLUID_CLIENT_SEND_ERROR = 44,
      MUSE_FLUID_SOUNDFONT_LOAD,
      ,
      MUSE_FLUID_CLIENT_RESTORE_CHANNELDATA,
      MUSE_FLUID_CLIENT_INIT_PARAMS,
      MUSE_FLUID_CLIENT_LASTDIR_CHANGE,

      MUSE_FLUID_GUI_REQ_SOUNDFONTS = 60,
      MUSE_FLUID_GUI_REQ_FXPARAMETER_SET,
      MUSE_FLUID_GUI_REQ_FXPARAMETER_GET,
      MUSE_FLUID_GUI_SEND_ERROR,
      MUSE_FLUID_GUI_LASTDIR_CHANGE
      };
*/

struct FluidGuiSoundFont
      {
      QString filename;
      QString name;
      byte id;
      };

//---------------------------------------------------------
//   FluidSynthGui
//---------------------------------------------------------

class FluidSynthGui : public QDialog, public Ui::FLUIDSynthGuiBase, public MessGui
   {
   Q_OBJECT
   private:
      virtual void processEvent(const MidiPlayEvent& ev);
      void sendLastdir(QString);
      void sendLoadFont(QString);
      void sendChannelChange(byte font_id, byte channel);
      void sendDrumChannelChange(byte onoff, byte channel);
      void updateSoundfontListView();
      void updateChannelListView();

      QString getSoundFontName(int id);
      int getSoundFontId(QString q);
      QString lastdir;
      std::list<FluidGuiSoundFont> stack;
      byte channels[FS_MAX_NR_OF_CHANNELS]; //Array of bytes, for mapping soundfonts to individual channels
      byte drumchannels[FS_MAX_NR_OF_CHANNELS]; // Array of bytes for setting channels to drumchannels or not (equiv to midichan 10)

      int currentlySelectedFont; //Font currently selected in sfListView. -1 if none selected

/*
      unsigned _smallH;
      unsigned _bigH;
      QSocketNotifier * _notifier;
      bool sendParameterChange (int, const char *, int);
      void setParameter (int, const char *, double);
      void requestAllParameters ();
      void dbgMsg(const char*);
      bool sendParameterRequest(int, const char *);
      //void dealWithSysex (unsigned char const * data, int datalen);






*/
   private slots:
      void loadClicked();
      void readMessage(int);
      void changeGain(int);
      void dumpInfo();
      void channelItemClicked(QTableWidgetItem* item);
      void toggleReverb(bool);
      void changeReverbLevel (int);
      void changeReverbRoomSize(int val);
      void changeReverbWidth(int val);
      void changeReverbDamping(int val);
      void toggleChorus(bool);
      void changeChorusNumber(int);
      void changeChorusType(int);
      void changeChorusSpeed(int);
      void changeChorusDepth(int);
      void changeChorusLevel(int);

      void popClicked();
      void sfItemClicked(QTreeWidgetItem* item, int);
      /*
      void readData(int);




      */

   public:
//      virtual void sysexReceived (const unsigned char *, int);
//    virtual void controllerReceived(int, int, int);

      FluidSynthGui();
      ~FluidSynthGui();
};


#endif /* __MUSE_FLUIDSYNTHGUI_H__ */