1 |
capela |
426 |
// qsamplerDevice.h |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
920 |
Copyright (C) 2004-2006, 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 |
capela |
920 |
You should have received a copy of the GNU General Public License along |
17 |
|
|
with this program; if not, write to the Free Software Foundation, Inc., |
18 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
capela |
426 |
|
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 |
484 |
// Early forward declarations. |
38 |
|
|
class qsamplerMainForm; |
39 |
capela |
463 |
class qsamplerDevicePort; |
40 |
capela |
429 |
|
41 |
capela |
463 |
|
42 |
capela |
426 |
//------------------------------------------------------------------------- |
43 |
capela |
429 |
// qsamplerDeviceParam - MIDI/Audio Device parameter structure. |
44 |
capela |
426 |
// |
45 |
capela |
429 |
class qsamplerDeviceParam |
46 |
|
|
{ |
47 |
|
|
public: |
48 |
capela |
426 |
|
49 |
capela |
431 |
// Constructor. |
50 |
|
|
qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL, |
51 |
capela |
429 |
const char *pszValue = NULL); |
52 |
capela |
431 |
// Default destructor. |
53 |
|
|
~qsamplerDeviceParam(); |
54 |
capela |
429 |
|
55 |
|
|
// Initializer. |
56 |
|
|
void setParam(lscp_param_info_t *pParamInfo, |
57 |
|
|
const char *pszValue = NULL); |
58 |
|
|
|
59 |
capela |
431 |
// Info structure field members. |
60 |
|
|
lscp_type_t type; |
61 |
|
|
QString description; |
62 |
|
|
bool mandatory; |
63 |
|
|
bool fix; |
64 |
|
|
bool multiplicity; |
65 |
|
|
QStringList depends; |
66 |
|
|
QString defaultv; |
67 |
|
|
QString range_min; |
68 |
|
|
QString range_max; |
69 |
|
|
QStringList possibilities; |
70 |
|
|
// The current parameter value. |
71 |
|
|
QString value; |
72 |
capela |
429 |
}; |
73 |
|
|
|
74 |
capela |
463 |
// Typedef'd parameter QMap. |
75 |
capela |
429 |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
76 |
|
|
|
77 |
capela |
463 |
// Typedef'd device port/channels QptrList. |
78 |
|
|
typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList; |
79 |
capela |
429 |
|
80 |
capela |
463 |
|
81 |
capela |
429 |
//------------------------------------------------------------------------- |
82 |
|
|
// qsamplerDevice - MIDI/Audio Device structure. |
83 |
|
|
// |
84 |
|
|
|
85 |
|
|
class qsamplerDevice |
86 |
capela |
426 |
{ |
87 |
capela |
429 |
public: |
88 |
|
|
|
89 |
capela |
431 |
// We use the same class for MIDI and audio device management |
90 |
capela |
436 |
enum qsamplerDeviceType { None, Midi, Audio }; |
91 |
capela |
429 |
|
92 |
capela |
431 |
// Constructor. |
93 |
capela |
961 |
qsamplerDevice(qsamplerDeviceType deviceType, int iDeviceID = -1); |
94 |
capela |
484 |
// Copy constructor. |
95 |
|
|
qsamplerDevice(const qsamplerDevice& device); |
96 |
capela |
431 |
// Default destructor. |
97 |
|
|
~qsamplerDevice(); |
98 |
capela |
429 |
|
99 |
|
|
// Initializer. |
100 |
capela |
484 |
void setDevice(qsamplerDeviceType deviceType, int iDeviceID = -1); |
101 |
capela |
431 |
|
102 |
|
|
// Driver name initializer. |
103 |
capela |
484 |
void setDriver(const QString& sDriverName); |
104 |
capela |
431 |
|
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 |
capela |
484 |
// Special device name formatter. |
111 |
|
|
QString deviceName() const; |
112 |
capela |
429 |
|
113 |
capela |
463 |
// Set the proper device parameter value. |
114 |
capela |
484 |
bool setParam (const QString& sParam, const QString& sValue); |
115 |
capela |
463 |
|
116 |
capela |
429 |
// Device parameters accessor. |
117 |
capela |
462 |
const qsamplerDeviceParamMap& params() const; |
118 |
capela |
429 |
|
119 |
capela |
463 |
// Device port/channel list accessor. |
120 |
|
|
qsamplerDevicePortList& ports(); |
121 |
capela |
429 |
|
122 |
capela |
467 |
// Device parameter dependency list refreshner. |
123 |
capela |
484 |
int refreshParams(); |
124 |
capela |
463 |
// Device port/channel list refreshner. |
125 |
capela |
484 |
int refreshPorts(); |
126 |
capela |
467 |
// Refresh/set dependencies given that some parameter has changed. |
127 |
capela |
484 |
int refreshDepends(const QString& sParam); |
128 |
capela |
467 |
|
129 |
capela |
484 |
// Create/destroy device methods. |
130 |
|
|
bool createDevice(); |
131 |
|
|
bool deleteDevice(); |
132 |
|
|
|
133 |
|
|
// Message logging methods (brainlessly mapped to main form's). |
134 |
|
|
void appendMessages (const QString& s) const; |
135 |
|
|
void appendMessagesColor (const QString& s, const QString & c) const; |
136 |
|
|
void appendMessagesText (const QString& s) const; |
137 |
|
|
void appendMessagesError (const QString& s) const; |
138 |
|
|
void appendMessagesClient (const QString& s) const; |
139 |
|
|
|
140 |
capela |
430 |
// Device ids enumerator. |
141 |
capela |
431 |
static int *getDevices(lscp_client_t *pClient, |
142 |
capela |
429 |
qsamplerDeviceType deviceType); |
143 |
|
|
|
144 |
capela |
430 |
// Driver names enumerator. |
145 |
capela |
431 |
static QStringList getDrivers(lscp_client_t *pClient, |
146 |
capela |
430 |
qsamplerDeviceType deviceType); |
147 |
|
|
|
148 |
capela |
429 |
private: |
149 |
|
|
|
150 |
capela |
467 |
// Refresh/set given parameter based on driver supplied dependencies. |
151 |
capela |
484 |
int refreshParam(const QString& sParam); |
152 |
capela |
467 |
|
153 |
capela |
484 |
// Main application form reference. |
154 |
|
|
qsamplerMainForm *m_pMainForm; |
155 |
|
|
|
156 |
capela |
429 |
// Instance variables. |
157 |
capela |
431 |
int m_iDeviceID; |
158 |
|
|
qsamplerDeviceType m_deviceType; |
159 |
capela |
433 |
QString m_sDeviceType; |
160 |
capela |
431 |
QString m_sDriverName; |
161 |
|
|
QString m_sDeviceName; |
162 |
capela |
429 |
|
163 |
|
|
// Device parameter list. |
164 |
|
|
qsamplerDeviceParamMap m_params; |
165 |
capela |
492 |
|
166 |
capela |
463 |
// Device port/channel list. |
167 |
|
|
qsamplerDevicePortList m_ports; |
168 |
capela |
429 |
}; |
169 |
|
|
|
170 |
|
|
|
171 |
|
|
//------------------------------------------------------------------------- |
172 |
capela |
462 |
// qsamplerDevicePort - MIDI/Audio Device port/channel structure. |
173 |
|
|
// |
174 |
|
|
|
175 |
|
|
class qsamplerDevicePort |
176 |
|
|
{ |
177 |
|
|
public: |
178 |
|
|
|
179 |
|
|
// Constructor. |
180 |
capela |
484 |
qsamplerDevicePort(qsamplerDevice& device, int iPortID); |
181 |
capela |
462 |
// Default destructor. |
182 |
|
|
~qsamplerDevicePort(); |
183 |
|
|
|
184 |
|
|
// Initializer. |
185 |
capela |
484 |
void setDevicePort(int iPortID); |
186 |
capela |
462 |
|
187 |
|
|
// Device port property accessors. |
188 |
|
|
int portID() const; |
189 |
|
|
const QString& portName() const; |
190 |
|
|
|
191 |
|
|
// Device port parameters accessor. |
192 |
|
|
const qsamplerDeviceParamMap& params() const; |
193 |
|
|
|
194 |
|
|
// Set the proper device port/channel parameter value. |
195 |
capela |
484 |
bool setParam (const QString& sParam, const QString& sValue); |
196 |
capela |
462 |
|
197 |
|
|
private: |
198 |
|
|
|
199 |
capela |
484 |
// Device reference. |
200 |
|
|
qsamplerDevice& m_device; |
201 |
capela |
492 |
|
202 |
capela |
462 |
// Instance variables. |
203 |
|
|
int m_iPortID; |
204 |
|
|
QString m_sPortName; |
205 |
|
|
|
206 |
|
|
// Device port parameter list. |
207 |
|
|
qsamplerDeviceParamMap m_params; |
208 |
|
|
}; |
209 |
|
|
|
210 |
|
|
|
211 |
|
|
//------------------------------------------------------------------------- |
212 |
capela |
429 |
// qsamplerDeviceItem - QListView device item. |
213 |
|
|
// |
214 |
|
|
|
215 |
|
|
class qsamplerDeviceItem : public QListViewItem |
216 |
|
|
{ |
217 |
|
|
public: |
218 |
|
|
|
219 |
capela |
431 |
// Constructors. |
220 |
capela |
961 |
qsamplerDeviceItem(QListView *pListView, |
221 |
capela |
429 |
qsamplerDevice::qsamplerDeviceType deviceType); |
222 |
capela |
961 |
qsamplerDeviceItem(QListViewItem *pItem, |
223 |
capela |
429 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
224 |
capela |
431 |
// Default destructor. |
225 |
|
|
~qsamplerDeviceItem(); |
226 |
capela |
429 |
|
227 |
capela |
431 |
// Instance accessors. |
228 |
|
|
qsamplerDevice& device(); |
229 |
capela |
429 |
|
230 |
capela |
431 |
// To virtually distinguish between list view items. |
231 |
|
|
virtual int rtti() const; |
232 |
capela |
429 |
|
233 |
|
|
private: |
234 |
|
|
|
235 |
capela |
431 |
// Instance variables. |
236 |
|
|
qsamplerDevice m_device; |
237 |
capela |
429 |
}; |
238 |
|
|
|
239 |
|
|
|
240 |
|
|
//------------------------------------------------------------------------- |
241 |
|
|
// qsamplerDeviceParamTable - Device parameter view table. |
242 |
|
|
// |
243 |
|
|
|
244 |
|
|
class qsamplerDeviceParamTable : public QTable |
245 |
|
|
{ |
246 |
capela |
431 |
Q_OBJECT |
247 |
capela |
426 |
|
248 |
|
|
public: |
249 |
|
|
|
250 |
capela |
431 |
// Constructor. |
251 |
|
|
qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0); |
252 |
|
|
// Default destructor. |
253 |
|
|
~qsamplerDeviceParamTable(); |
254 |
capela |
426 |
|
255 |
capela |
462 |
// Common parameter table renderer. |
256 |
|
|
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
257 |
capela |
426 |
}; |
258 |
|
|
|
259 |
|
|
|
260 |
capela |
442 |
//------------------------------------------------------------------------- |
261 |
|
|
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
262 |
|
|
// |
263 |
|
|
|
264 |
|
|
class qsamplerDeviceParamTableSpinBox : public QTableItem |
265 |
|
|
{ |
266 |
|
|
public: |
267 |
|
|
|
268 |
|
|
// Constructor. |
269 |
capela |
447 |
qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, |
270 |
|
|
const QString& sText); |
271 |
capela |
442 |
|
272 |
|
|
// Public accessors. |
273 |
|
|
void setMinValue(int iMinValue); |
274 |
|
|
void setMaxValue(int iMaxValue); |
275 |
|
|
void setValue(int iValue); |
276 |
|
|
|
277 |
|
|
protected: |
278 |
|
|
|
279 |
|
|
// Virtual implemetations. |
280 |
|
|
QWidget *createEditor() const; |
281 |
|
|
void setContentFromEditor(QWidget *pWidget); |
282 |
|
|
|
283 |
|
|
private: |
284 |
|
|
|
285 |
|
|
// Initial value holders. |
286 |
capela |
447 |
int m_iValue; |
287 |
capela |
442 |
int m_iMinValue; |
288 |
|
|
int m_iMaxValue; |
289 |
|
|
}; |
290 |
|
|
|
291 |
|
|
|
292 |
|
|
//------------------------------------------------------------------------- |
293 |
|
|
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
294 |
|
|
// |
295 |
|
|
|
296 |
|
|
class qsamplerDeviceParamTableEditBox : public QTableItem |
297 |
|
|
{ |
298 |
|
|
public: |
299 |
|
|
|
300 |
|
|
// Constructor. |
301 |
|
|
qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType, |
302 |
|
|
const QString& sText); |
303 |
|
|
|
304 |
|
|
protected: |
305 |
|
|
|
306 |
|
|
// Virtual implemetations. |
307 |
|
|
QWidget *createEditor() const; |
308 |
|
|
void setContentFromEditor(QWidget *pWidget); |
309 |
|
|
}; |
310 |
|
|
|
311 |
|
|
|
312 |
capela |
426 |
#endif // __qsamplerDevice_h |
313 |
|
|
|
314 |
|
|
|
315 |
|
|
// end of qsamplerDevice.h |