1 |
// qsamplerDevice.h |
2 |
// |
3 |
/**************************************************************************** |
4 |
Copyright (C) 2005, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
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 |
#include <qlistview.h> |
26 |
#include <qtable.h> |
27 |
|
28 |
#include <lscp/client.h> |
29 |
#include <lscp/device.h> |
30 |
|
31 |
#include "qsamplerOptions.h" |
32 |
|
33 |
|
34 |
// Special QListViewItem::rtti() unique return value. |
35 |
#define QSAMPLER_DEVICE_ITEM 1001 |
36 |
|
37 |
// Early forward declaration. |
38 |
class qsamplerDevicePort; |
39 |
|
40 |
|
41 |
//------------------------------------------------------------------------- |
42 |
// qsamplerDeviceParam - MIDI/Audio Device parameter structure. |
43 |
// |
44 |
class qsamplerDeviceParam |
45 |
{ |
46 |
public: |
47 |
|
48 |
// Constructor. |
49 |
qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL, |
50 |
const char *pszValue = NULL); |
51 |
// Default destructor. |
52 |
~qsamplerDeviceParam(); |
53 |
|
54 |
// Initializer. |
55 |
void setParam(lscp_param_info_t *pParamInfo, |
56 |
const char *pszValue = NULL); |
57 |
|
58 |
// 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 |
}; |
72 |
|
73 |
// Typedef'd parameter QMap. |
74 |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
75 |
|
76 |
// Typedef'd device port/channels QptrList. |
77 |
typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList; |
78 |
|
79 |
|
80 |
//------------------------------------------------------------------------- |
81 |
// qsamplerDevice - MIDI/Audio Device structure. |
82 |
// |
83 |
|
84 |
class qsamplerDevice |
85 |
{ |
86 |
public: |
87 |
|
88 |
// We use the same class for MIDI and audio device management |
89 |
enum qsamplerDeviceType { None, Midi, Audio }; |
90 |
|
91 |
// Constructor. |
92 |
qsamplerDevice(lscp_client_t *pClient, |
93 |
qsamplerDeviceType deviceType, int iDeviceID = -1); |
94 |
// Default destructor. |
95 |
~qsamplerDevice(); |
96 |
|
97 |
// Initializer. |
98 |
void setDevice(lscp_client_t *pClient, |
99 |
qsamplerDeviceType deviceType, int iDeviceID = -1); |
100 |
|
101 |
// Driver name initializer. |
102 |
void setDriver(lscp_client_t *pClient, |
103 |
const QString& sDriverName); |
104 |
|
105 |
// Device property accessors. |
106 |
int deviceID() const; |
107 |
qsamplerDeviceType deviceType() const; |
108 |
const QString& deviceTypeName() const; |
109 |
const QString& driverName() const; |
110 |
const QString& deviceName() const; |
111 |
|
112 |
// Set the proper device parameter value. |
113 |
void setParam (const QString& sParam, const QString& sValue); |
114 |
|
115 |
// Device parameters accessor. |
116 |
const qsamplerDeviceParamMap& params() const; |
117 |
|
118 |
// Device port/channel list accessor. |
119 |
qsamplerDevicePortList& ports(); |
120 |
|
121 |
// Device port/channel list refreshner. |
122 |
void refresh(lscp_client_t *pClient); |
123 |
|
124 |
// Device ids enumerator. |
125 |
static int *getDevices(lscp_client_t *pClient, |
126 |
qsamplerDeviceType deviceType); |
127 |
|
128 |
// Driver names enumerator. |
129 |
static QStringList getDrivers(lscp_client_t *pClient, |
130 |
qsamplerDeviceType deviceType); |
131 |
|
132 |
private: |
133 |
|
134 |
// Instance variables. |
135 |
int m_iDeviceID; |
136 |
qsamplerDeviceType m_deviceType; |
137 |
QString m_sDeviceType; |
138 |
QString m_sDriverName; |
139 |
QString m_sDeviceName; |
140 |
|
141 |
// Device parameter list. |
142 |
qsamplerDeviceParamMap m_params; |
143 |
|
144 |
// Device port/channel list. |
145 |
qsamplerDevicePortList m_ports; |
146 |
}; |
147 |
|
148 |
|
149 |
//------------------------------------------------------------------------- |
150 |
// qsamplerDevicePort - MIDI/Audio Device port/channel structure. |
151 |
// |
152 |
|
153 |
class qsamplerDevicePort |
154 |
{ |
155 |
public: |
156 |
|
157 |
// Constructor. |
158 |
qsamplerDevicePort(lscp_client_t *pClient, |
159 |
const qsamplerDevice& device, int iPortID); |
160 |
// Default destructor. |
161 |
~qsamplerDevicePort(); |
162 |
|
163 |
// Initializer. |
164 |
void setDevicePort(lscp_client_t *pClient, |
165 |
const qsamplerDevice& device, int iPortID); |
166 |
|
167 |
// Device port property accessors. |
168 |
int portID() const; |
169 |
const QString& portName() const; |
170 |
|
171 |
// Device port parameters accessor. |
172 |
const qsamplerDeviceParamMap& params() const; |
173 |
|
174 |
// Set the proper device port/channel parameter value. |
175 |
void setParam (const QString& sParam, const QString& sValue); |
176 |
|
177 |
private: |
178 |
|
179 |
// Instance variables. |
180 |
int m_iPortID; |
181 |
QString m_sPortName; |
182 |
|
183 |
// Device port parameter list. |
184 |
qsamplerDeviceParamMap m_params; |
185 |
}; |
186 |
|
187 |
|
188 |
//------------------------------------------------------------------------- |
189 |
// qsamplerDeviceItem - QListView device item. |
190 |
// |
191 |
|
192 |
class qsamplerDeviceItem : public QListViewItem |
193 |
{ |
194 |
public: |
195 |
|
196 |
// Constructors. |
197 |
qsamplerDeviceItem(QListView *pListView, lscp_client_t *pClient, |
198 |
qsamplerDevice::qsamplerDeviceType deviceType); |
199 |
qsamplerDeviceItem(QListViewItem *pItem, lscp_client_t *pClient, |
200 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
201 |
// Default destructor. |
202 |
~qsamplerDeviceItem(); |
203 |
|
204 |
// Instance accessors. |
205 |
qsamplerDevice& device(); |
206 |
|
207 |
// To virtually distinguish between list view items. |
208 |
virtual int rtti() const; |
209 |
|
210 |
private: |
211 |
|
212 |
// Instance variables. |
213 |
qsamplerDevice m_device; |
214 |
}; |
215 |
|
216 |
|
217 |
//------------------------------------------------------------------------- |
218 |
// qsamplerDeviceParamTable - Device parameter view table. |
219 |
// |
220 |
|
221 |
class qsamplerDeviceParamTable : public QTable |
222 |
{ |
223 |
Q_OBJECT |
224 |
|
225 |
public: |
226 |
|
227 |
// Constructor. |
228 |
qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0); |
229 |
// Default destructor. |
230 |
~qsamplerDeviceParamTable(); |
231 |
|
232 |
// Common parameter table renderer. |
233 |
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
234 |
}; |
235 |
|
236 |
|
237 |
//------------------------------------------------------------------------- |
238 |
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
239 |
// |
240 |
|
241 |
class qsamplerDeviceParamTableSpinBox : public QTableItem |
242 |
{ |
243 |
public: |
244 |
|
245 |
// Constructor. |
246 |
qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, |
247 |
const QString& sText); |
248 |
|
249 |
// Public accessors. |
250 |
void setMinValue(int iMinValue); |
251 |
void setMaxValue(int iMaxValue); |
252 |
void setValue(int iValue); |
253 |
|
254 |
protected: |
255 |
|
256 |
// Virtual implemetations. |
257 |
QWidget *createEditor() const; |
258 |
void setContentFromEditor(QWidget *pWidget); |
259 |
|
260 |
private: |
261 |
|
262 |
// Initial value holders. |
263 |
int m_iValue; |
264 |
int m_iMinValue; |
265 |
int m_iMaxValue; |
266 |
}; |
267 |
|
268 |
|
269 |
//------------------------------------------------------------------------- |
270 |
// qsamplerDeviceParamTableEditBox - Custom edit box for parameter table. |
271 |
// |
272 |
|
273 |
class qsamplerDeviceParamTableEditBox : public QTableItem |
274 |
{ |
275 |
public: |
276 |
|
277 |
// Constructor. |
278 |
qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType, |
279 |
const QString& sText); |
280 |
|
281 |
protected: |
282 |
|
283 |
// Virtual implemetations. |
284 |
QWidget *createEditor() const; |
285 |
void setContentFromEditor(QWidget *pWidget); |
286 |
}; |
287 |
|
288 |
|
289 |
#endif // __qsamplerDevice_h |
290 |
|
291 |
|
292 |
// end of qsamplerDevice.h |