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 |
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 |
484 |
qsamplerDevice(qsamplerMainForm *pMainForm, |
94 |
capela |
429 |
qsamplerDeviceType deviceType, int iDeviceID = -1); |
95 |
capela |
484 |
// Copy constructor. |
96 |
|
|
qsamplerDevice(const qsamplerDevice& device); |
97 |
capela |
431 |
// Default destructor. |
98 |
|
|
~qsamplerDevice(); |
99 |
capela |
429 |
|
100 |
|
|
// Initializer. |
101 |
capela |
484 |
void setDevice(qsamplerDeviceType deviceType, int iDeviceID = -1); |
102 |
capela |
431 |
|
103 |
|
|
// Driver name initializer. |
104 |
capela |
484 |
void setDriver(const QString& sDriverName); |
105 |
capela |
431 |
|
106 |
capela |
484 |
// LSCP client descriptor accessor. |
107 |
|
|
lscp_client_t *client() const; |
108 |
|
|
|
109 |
capela |
429 |
// Device property accessors. |
110 |
capela |
431 |
int deviceID() const; |
111 |
|
|
qsamplerDeviceType deviceType() const; |
112 |
capela |
433 |
const QString& deviceTypeName() const; |
113 |
capela |
431 |
const QString& driverName() const; |
114 |
capela |
484 |
// Special device name formatter. |
115 |
|
|
QString deviceName() const; |
116 |
capela |
429 |
|
117 |
capela |
463 |
// Set the proper device parameter value. |
118 |
capela |
484 |
bool setParam (const QString& sParam, const QString& sValue); |
119 |
capela |
463 |
|
120 |
capela |
429 |
// Device parameters accessor. |
121 |
capela |
462 |
const qsamplerDeviceParamMap& params() const; |
122 |
capela |
429 |
|
123 |
capela |
463 |
// Device port/channel list accessor. |
124 |
|
|
qsamplerDevicePortList& ports(); |
125 |
capela |
429 |
|
126 |
capela |
467 |
// Device parameter dependency list refreshner. |
127 |
capela |
484 |
int refreshParams(); |
128 |
capela |
463 |
// Device port/channel list refreshner. |
129 |
capela |
484 |
int refreshPorts(); |
130 |
capela |
467 |
// Refresh/set dependencies given that some parameter has changed. |
131 |
capela |
484 |
int refreshDepends(const QString& sParam); |
132 |
capela |
467 |
|
133 |
capela |
484 |
// Create/destroy device methods. |
134 |
|
|
bool createDevice(); |
135 |
|
|
bool deleteDevice(); |
136 |
|
|
|
137 |
|
|
// Message logging methods (brainlessly mapped to main form's). |
138 |
|
|
void appendMessages (const QString& s) const; |
139 |
|
|
void appendMessagesColor (const QString& s, const QString & c) const; |
140 |
|
|
void appendMessagesText (const QString& s) const; |
141 |
|
|
void appendMessagesError (const QString& s) const; |
142 |
|
|
void appendMessagesClient (const QString& s) const; |
143 |
|
|
|
144 |
capela |
430 |
// Device ids enumerator. |
145 |
capela |
431 |
static int *getDevices(lscp_client_t *pClient, |
146 |
capela |
429 |
qsamplerDeviceType deviceType); |
147 |
|
|
|
148 |
capela |
430 |
// Driver names enumerator. |
149 |
capela |
431 |
static QStringList getDrivers(lscp_client_t *pClient, |
150 |
capela |
430 |
qsamplerDeviceType deviceType); |
151 |
|
|
|
152 |
capela |
429 |
private: |
153 |
|
|
|
154 |
capela |
467 |
// Refresh/set given parameter based on driver supplied dependencies. |
155 |
capela |
484 |
int refreshParam(const QString& sParam); |
156 |
capela |
467 |
|
157 |
capela |
484 |
// Main application form reference. |
158 |
|
|
qsamplerMainForm *m_pMainForm; |
159 |
|
|
|
160 |
capela |
429 |
// Instance variables. |
161 |
capela |
431 |
int m_iDeviceID; |
162 |
|
|
qsamplerDeviceType m_deviceType; |
163 |
capela |
433 |
QString m_sDeviceType; |
164 |
capela |
431 |
QString m_sDriverName; |
165 |
|
|
QString m_sDeviceName; |
166 |
capela |
429 |
|
167 |
|
|
// Device parameter list. |
168 |
|
|
qsamplerDeviceParamMap m_params; |
169 |
capela |
463 |
|
170 |
|
|
// Device port/channel list. |
171 |
|
|
qsamplerDevicePortList m_ports; |
172 |
capela |
429 |
}; |
173 |
|
|
|
174 |
|
|
|
175 |
|
|
//------------------------------------------------------------------------- |
176 |
capela |
462 |
// qsamplerDevicePort - MIDI/Audio Device port/channel structure. |
177 |
|
|
// |
178 |
|
|
|
179 |
|
|
class qsamplerDevicePort |
180 |
|
|
{ |
181 |
|
|
public: |
182 |
|
|
|
183 |
|
|
// Constructor. |
184 |
capela |
484 |
qsamplerDevicePort(qsamplerDevice& device, int iPortID); |
185 |
capela |
462 |
// Default destructor. |
186 |
|
|
~qsamplerDevicePort(); |
187 |
|
|
|
188 |
|
|
// Initializer. |
189 |
capela |
484 |
void setDevicePort(int iPortID); |
190 |
capela |
462 |
|
191 |
|
|
// Device port property accessors. |
192 |
|
|
int portID() const; |
193 |
|
|
const QString& portName() const; |
194 |
|
|
|
195 |
|
|
// Device port parameters accessor. |
196 |
|
|
const qsamplerDeviceParamMap& params() const; |
197 |
|
|
|
198 |
|
|
// Set the proper device port/channel parameter value. |
199 |
capela |
484 |
bool setParam (const QString& sParam, const QString& sValue); |
200 |
capela |
462 |
|
201 |
|
|
private: |
202 |
|
|
|
203 |
capela |
484 |
// Device reference. |
204 |
|
|
qsamplerDevice& m_device; |
205 |
|
|
|
206 |
capela |
462 |
// Instance variables. |
207 |
|
|
int m_iPortID; |
208 |
|
|
QString m_sPortName; |
209 |
|
|
|
210 |
|
|
// Device port parameter list. |
211 |
|
|
qsamplerDeviceParamMap m_params; |
212 |
|
|
}; |
213 |
|
|
|
214 |
|
|
|
215 |
|
|
//------------------------------------------------------------------------- |
216 |
capela |
429 |
// qsamplerDeviceItem - QListView device item. |
217 |
|
|
// |
218 |
|
|
|
219 |
|
|
class qsamplerDeviceItem : public QListViewItem |
220 |
|
|
{ |
221 |
|
|
public: |
222 |
|
|
|
223 |
capela |
431 |
// Constructors. |
224 |
capela |
484 |
qsamplerDeviceItem(QListView *pListView, qsamplerMainForm *pMainForm, |
225 |
capela |
429 |
qsamplerDevice::qsamplerDeviceType deviceType); |
226 |
capela |
484 |
qsamplerDeviceItem(QListViewItem *pItem, qsamplerMainForm *pMainForm, |
227 |
capela |
429 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
228 |
capela |
431 |
// Default destructor. |
229 |
|
|
~qsamplerDeviceItem(); |
230 |
capela |
429 |
|
231 |
capela |
431 |
// Instance accessors. |
232 |
|
|
qsamplerDevice& device(); |
233 |
capela |
429 |
|
234 |
capela |
431 |
// To virtually distinguish between list view items. |
235 |
|
|
virtual int rtti() const; |
236 |
capela |
429 |
|
237 |
|
|
private: |
238 |
|
|
|
239 |
capela |
431 |
// Instance variables. |
240 |
|
|
qsamplerDevice m_device; |
241 |
capela |
429 |
}; |
242 |
|
|
|
243 |
|
|
|
244 |
|
|
//------------------------------------------------------------------------- |
245 |
|
|
// qsamplerDeviceParamTable - Device parameter view table. |
246 |
|
|
// |
247 |
|
|
|
248 |
|
|
class qsamplerDeviceParamTable : public QTable |
249 |
|
|
{ |
250 |
capela |
431 |
Q_OBJECT |
251 |
capela |
426 |
|
252 |
|
|
public: |
253 |
|
|
|
254 |
capela |
431 |
// Constructor. |
255 |
|
|
qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0); |
256 |
|
|
// Default destructor. |
257 |
|
|
~qsamplerDeviceParamTable(); |
258 |
capela |
426 |
|
259 |
capela |
462 |
// Common parameter table renderer. |
260 |
|
|
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
261 |
capela |
426 |
}; |
262 |
|
|
|
263 |
|
|
|
264 |
capela |
442 |
//------------------------------------------------------------------------- |
265 |
|
|
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
266 |
|
|
// |
267 |
|
|
|
268 |
|
|
class qsamplerDeviceParamTableSpinBox : public QTableItem |
269 |
|
|
{ |
270 |
|
|
public: |
271 |
|
|
|
272 |
|
|
// Constructor. |
273 |
capela |
447 |
qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, |
274 |
|
|
const QString& sText); |
275 |
capela |
442 |
|
276 |
|
|
// Public accessors. |
277 |
|
|
void setMinValue(int iMinValue); |
278 |
|
|
void setMaxValue(int iMaxValue); |
279 |
|
|
void setValue(int iValue); |
280 |
|
|
|
281 |
|
|
protected: |
282 |
|
|
|
283 |
|
|
// Virtual implemetations. |
284 |
|
|
QWidget *createEditor() const; |
285 |
|
|
void setContentFromEditor(QWidget *pWidget); |
286 |
|
|
|
287 |
|
|
private: |
288 |
|
|
|
289 |
|
|
// Initial value holders. |
290 |
capela |
447 |
int m_iValue; |
291 |
capela |
442 |
int m_iMinValue; |
292 |
|
|
int m_iMaxValue; |
293 |
|
|
}; |
294 |
|
|
|
295 |
|
|
|
296 |
|
|
//------------------------------------------------------------------------- |
297 |
|
|
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
298 |
|
|
// |
299 |
|
|
|
300 |
|
|
class qsamplerDeviceParamTableEditBox : public QTableItem |
301 |
|
|
{ |
302 |
|
|
public: |
303 |
|
|
|
304 |
|
|
// Constructor. |
305 |
|
|
qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType, |
306 |
|
|
const QString& sText); |
307 |
|
|
|
308 |
|
|
protected: |
309 |
|
|
|
310 |
|
|
// Virtual implemetations. |
311 |
|
|
QWidget *createEditor() const; |
312 |
|
|
void setContentFromEditor(QWidget *pWidget); |
313 |
|
|
}; |
314 |
|
|
|
315 |
|
|
|
316 |
capela |
426 |
#endif // __qsamplerDevice_h |
317 |
|
|
|
318 |
|
|
|
319 |
|
|
// end of qsamplerDevice.h |