1 |
capela |
426 |
// qsamplerDevice.h |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
430 |
Copyright (C) 2005, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
capela |
426 |
|
6 |
|
|
This program is free software; you can redistribute it and/or |
7 |
|
|
modify it under the terms of the GNU General Public License |
8 |
|
|
as published by the Free Software Foundation; either version 2 |
9 |
|
|
of the License, or (at your option) any later version. |
10 |
|
|
|
11 |
|
|
This program is distributed in the hope that it will be useful, |
12 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
GNU General Public License for more details. |
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License |
17 |
|
|
along with this program; if not, write to the Free Software |
18 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
|
|
20 |
|
|
*****************************************************************************/ |
21 |
|
|
|
22 |
|
|
#ifndef __qsamplerDevice_h |
23 |
|
|
#define __qsamplerDevice_h |
24 |
|
|
|
25 |
capela |
429 |
#include <qlistview.h> |
26 |
capela |
426 |
#include <qtable.h> |
27 |
|
|
|
28 |
|
|
#include <lscp/client.h> |
29 |
|
|
#include <lscp/device.h> |
30 |
|
|
|
31 |
|
|
#include "qsamplerOptions.h" |
32 |
|
|
|
33 |
|
|
|
34 |
capela |
430 |
// Special QListViewItem::rtti() unique return value. |
35 |
capela |
429 |
#define QSAMPLER_DEVICE_ITEM 1001 |
36 |
|
|
|
37 |
capela |
463 |
// Early forward declaration. |
38 |
|
|
class qsamplerDevicePort; |
39 |
capela |
429 |
|
40 |
capela |
463 |
|
41 |
capela |
426 |
//------------------------------------------------------------------------- |
42 |
capela |
429 |
// qsamplerDeviceParam - MIDI/Audio Device parameter structure. |
43 |
capela |
426 |
// |
44 |
capela |
429 |
class qsamplerDeviceParam |
45 |
|
|
{ |
46 |
|
|
public: |
47 |
capela |
426 |
|
48 |
capela |
431 |
// Constructor. |
49 |
|
|
qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL, |
50 |
capela |
429 |
const char *pszValue = NULL); |
51 |
capela |
431 |
// Default destructor. |
52 |
|
|
~qsamplerDeviceParam(); |
53 |
capela |
429 |
|
54 |
|
|
// Initializer. |
55 |
|
|
void setParam(lscp_param_info_t *pParamInfo, |
56 |
|
|
const char *pszValue = NULL); |
57 |
|
|
|
58 |
capela |
431 |
// Info structure field members. |
59 |
|
|
lscp_type_t type; |
60 |
|
|
QString description; |
61 |
|
|
bool mandatory; |
62 |
|
|
bool fix; |
63 |
|
|
bool multiplicity; |
64 |
|
|
QStringList depends; |
65 |
|
|
QString defaultv; |
66 |
|
|
QString range_min; |
67 |
|
|
QString range_max; |
68 |
|
|
QStringList possibilities; |
69 |
|
|
// The current parameter value. |
70 |
|
|
QString value; |
71 |
capela |
429 |
}; |
72 |
|
|
|
73 |
capela |
463 |
// Typedef'd parameter QMap. |
74 |
capela |
429 |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
75 |
|
|
|
76 |
capela |
463 |
// Typedef'd device port/channels QptrList. |
77 |
|
|
typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList; |
78 |
capela |
429 |
|
79 |
capela |
463 |
|
80 |
capela |
429 |
//------------------------------------------------------------------------- |
81 |
|
|
// qsamplerDevice - MIDI/Audio Device structure. |
82 |
|
|
// |
83 |
|
|
|
84 |
|
|
class qsamplerDevice |
85 |
capela |
426 |
{ |
86 |
capela |
429 |
public: |
87 |
|
|
|
88 |
capela |
431 |
// We use the same class for MIDI and audio device management |
89 |
capela |
436 |
enum qsamplerDeviceType { None, Midi, Audio }; |
90 |
capela |
429 |
|
91 |
capela |
431 |
// Constructor. |
92 |
|
|
qsamplerDevice(lscp_client_t *pClient, |
93 |
capela |
429 |
qsamplerDeviceType deviceType, int iDeviceID = -1); |
94 |
capela |
431 |
// Default destructor. |
95 |
|
|
~qsamplerDevice(); |
96 |
capela |
429 |
|
97 |
|
|
// Initializer. |
98 |
|
|
void setDevice(lscp_client_t *pClient, |
99 |
|
|
qsamplerDeviceType deviceType, int iDeviceID = -1); |
100 |
capela |
431 |
|
101 |
|
|
// Driver name initializer. |
102 |
|
|
void setDriver(lscp_client_t *pClient, |
103 |
|
|
const QString& sDriverName); |
104 |
|
|
|
105 |
capela |
429 |
// Device property accessors. |
106 |
capela |
431 |
int deviceID() const; |
107 |
|
|
qsamplerDeviceType deviceType() const; |
108 |
capela |
433 |
const QString& deviceTypeName() const; |
109 |
capela |
431 |
const QString& driverName() const; |
110 |
|
|
const QString& deviceName() const; |
111 |
capela |
429 |
|
112 |
capela |
463 |
// Set the proper device parameter value. |
113 |
|
|
void setParam (const QString& sParam, const QString& sValue); |
114 |
|
|
|
115 |
capela |
429 |
// Device parameters accessor. |
116 |
capela |
462 |
const qsamplerDeviceParamMap& params() const; |
117 |
capela |
429 |
|
118 |
capela |
463 |
// Device port/channel list accessor. |
119 |
|
|
qsamplerDevicePortList& ports(); |
120 |
capela |
429 |
|
121 |
capela |
467 |
// Device parameter dependency list refreshner. |
122 |
|
|
int refreshParams(lscp_client_t *pClient); |
123 |
capela |
463 |
// Device port/channel list refreshner. |
124 |
capela |
467 |
int refreshPorts(lscp_client_t *pClient); |
125 |
|
|
// Refresh/set dependencies given that some parameter has changed. |
126 |
|
|
int refreshDepends(lscp_client_t *pClient, const QString& sParam); |
127 |
|
|
|
128 |
capela |
430 |
// Device ids enumerator. |
129 |
capela |
431 |
static int *getDevices(lscp_client_t *pClient, |
130 |
capela |
429 |
qsamplerDeviceType deviceType); |
131 |
|
|
|
132 |
capela |
430 |
// Driver names enumerator. |
133 |
capela |
431 |
static QStringList getDrivers(lscp_client_t *pClient, |
134 |
capela |
430 |
qsamplerDeviceType deviceType); |
135 |
|
|
|
136 |
capela |
429 |
private: |
137 |
|
|
|
138 |
capela |
467 |
// Refresh/set given parameter based on driver supplied dependencies. |
139 |
|
|
int refreshParam(lscp_client_t *pClient, const QString& sParam); |
140 |
|
|
|
141 |
capela |
429 |
// Instance variables. |
142 |
capela |
431 |
int m_iDeviceID; |
143 |
|
|
qsamplerDeviceType m_deviceType; |
144 |
capela |
433 |
QString m_sDeviceType; |
145 |
capela |
431 |
QString m_sDriverName; |
146 |
|
|
QString m_sDeviceName; |
147 |
capela |
429 |
|
148 |
|
|
// Device parameter list. |
149 |
|
|
qsamplerDeviceParamMap m_params; |
150 |
capela |
463 |
|
151 |
|
|
// Device port/channel list. |
152 |
|
|
qsamplerDevicePortList m_ports; |
153 |
capela |
429 |
}; |
154 |
|
|
|
155 |
|
|
|
156 |
|
|
//------------------------------------------------------------------------- |
157 |
capela |
462 |
// qsamplerDevicePort - MIDI/Audio Device port/channel structure. |
158 |
|
|
// |
159 |
|
|
|
160 |
|
|
class qsamplerDevicePort |
161 |
|
|
{ |
162 |
|
|
public: |
163 |
|
|
|
164 |
|
|
// Constructor. |
165 |
|
|
qsamplerDevicePort(lscp_client_t *pClient, |
166 |
|
|
const qsamplerDevice& device, int iPortID); |
167 |
|
|
// Default destructor. |
168 |
|
|
~qsamplerDevicePort(); |
169 |
|
|
|
170 |
|
|
// Initializer. |
171 |
|
|
void setDevicePort(lscp_client_t *pClient, |
172 |
|
|
const qsamplerDevice& device, int iPortID); |
173 |
|
|
|
174 |
|
|
// Device port property accessors. |
175 |
|
|
int portID() const; |
176 |
|
|
const QString& portName() const; |
177 |
|
|
|
178 |
|
|
// Device port parameters accessor. |
179 |
|
|
const qsamplerDeviceParamMap& params() const; |
180 |
|
|
|
181 |
|
|
// Set the proper device port/channel parameter value. |
182 |
|
|
void setParam (const QString& sParam, const QString& sValue); |
183 |
|
|
|
184 |
|
|
private: |
185 |
|
|
|
186 |
|
|
// Instance variables. |
187 |
|
|
int m_iPortID; |
188 |
|
|
QString m_sPortName; |
189 |
|
|
|
190 |
|
|
// Device port parameter list. |
191 |
|
|
qsamplerDeviceParamMap m_params; |
192 |
|
|
}; |
193 |
|
|
|
194 |
|
|
|
195 |
|
|
//------------------------------------------------------------------------- |
196 |
capela |
429 |
// qsamplerDeviceItem - QListView device item. |
197 |
|
|
// |
198 |
|
|
|
199 |
|
|
class qsamplerDeviceItem : public QListViewItem |
200 |
|
|
{ |
201 |
|
|
public: |
202 |
|
|
|
203 |
capela |
431 |
// Constructors. |
204 |
|
|
qsamplerDeviceItem(QListView *pListView, lscp_client_t *pClient, |
205 |
capela |
429 |
qsamplerDevice::qsamplerDeviceType deviceType); |
206 |
capela |
431 |
qsamplerDeviceItem(QListViewItem *pItem, lscp_client_t *pClient, |
207 |
capela |
429 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
208 |
capela |
431 |
// Default destructor. |
209 |
|
|
~qsamplerDeviceItem(); |
210 |
capela |
429 |
|
211 |
capela |
431 |
// Instance accessors. |
212 |
|
|
qsamplerDevice& device(); |
213 |
capela |
429 |
|
214 |
capela |
431 |
// To virtually distinguish between list view items. |
215 |
|
|
virtual int rtti() const; |
216 |
capela |
429 |
|
217 |
|
|
private: |
218 |
|
|
|
219 |
capela |
431 |
// Instance variables. |
220 |
|
|
qsamplerDevice m_device; |
221 |
capela |
429 |
}; |
222 |
|
|
|
223 |
|
|
|
224 |
|
|
//------------------------------------------------------------------------- |
225 |
|
|
// qsamplerDeviceParamTable - Device parameter view table. |
226 |
|
|
// |
227 |
|
|
|
228 |
|
|
class qsamplerDeviceParamTable : public QTable |
229 |
|
|
{ |
230 |
capela |
431 |
Q_OBJECT |
231 |
capela |
426 |
|
232 |
|
|
public: |
233 |
|
|
|
234 |
capela |
431 |
// Constructor. |
235 |
|
|
qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0); |
236 |
|
|
// Default destructor. |
237 |
|
|
~qsamplerDeviceParamTable(); |
238 |
capela |
426 |
|
239 |
capela |
462 |
// Common parameter table renderer. |
240 |
|
|
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
241 |
capela |
426 |
}; |
242 |
|
|
|
243 |
|
|
|
244 |
capela |
442 |
//------------------------------------------------------------------------- |
245 |
|
|
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
246 |
|
|
// |
247 |
|
|
|
248 |
|
|
class qsamplerDeviceParamTableSpinBox : public QTableItem |
249 |
|
|
{ |
250 |
|
|
public: |
251 |
|
|
|
252 |
|
|
// Constructor. |
253 |
capela |
447 |
qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, |
254 |
|
|
const QString& sText); |
255 |
capela |
442 |
|
256 |
|
|
// Public accessors. |
257 |
|
|
void setMinValue(int iMinValue); |
258 |
|
|
void setMaxValue(int iMaxValue); |
259 |
|
|
void setValue(int iValue); |
260 |
|
|
|
261 |
|
|
protected: |
262 |
|
|
|
263 |
|
|
// Virtual implemetations. |
264 |
|
|
QWidget *createEditor() const; |
265 |
|
|
void setContentFromEditor(QWidget *pWidget); |
266 |
|
|
|
267 |
|
|
private: |
268 |
|
|
|
269 |
|
|
// Initial value holders. |
270 |
capela |
447 |
int m_iValue; |
271 |
capela |
442 |
int m_iMinValue; |
272 |
|
|
int m_iMaxValue; |
273 |
|
|
}; |
274 |
|
|
|
275 |
|
|
|
276 |
|
|
//------------------------------------------------------------------------- |
277 |
|
|
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
278 |
|
|
// |
279 |
|
|
|
280 |
|
|
class qsamplerDeviceParamTableEditBox : public QTableItem |
281 |
|
|
{ |
282 |
|
|
public: |
283 |
|
|
|
284 |
|
|
// Constructor. |
285 |
|
|
qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType, |
286 |
|
|
const QString& sText); |
287 |
|
|
|
288 |
|
|
protected: |
289 |
|
|
|
290 |
|
|
// Virtual implemetations. |
291 |
|
|
QWidget *createEditor() const; |
292 |
|
|
void setContentFromEditor(QWidget *pWidget); |
293 |
|
|
}; |
294 |
|
|
|
295 |
|
|
|
296 |
capela |
426 |
#endif // __qsamplerDevice_h |
297 |
|
|
|
298 |
|
|
|
299 |
|
|
// end of qsamplerDevice.h |