1 |
// qsamplerDevice.h |
// qsamplerDevice.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
GNU General Public License for more details. |
GNU General Public License for more details. |
15 |
|
|
16 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
17 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
18 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
|
20 |
*****************************************************************************/ |
*****************************************************************************/ |
21 |
|
|
34 |
// Special QListViewItem::rtti() unique return value. |
// Special QListViewItem::rtti() unique return value. |
35 |
#define QSAMPLER_DEVICE_ITEM 1001 |
#define QSAMPLER_DEVICE_ITEM 1001 |
36 |
|
|
37 |
|
// Early forward declarations. |
38 |
|
class qsamplerMainForm; |
39 |
|
class qsamplerDevicePort; |
40 |
|
|
41 |
|
|
42 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
43 |
// qsamplerDeviceParam - MIDI/Audio Device parameter structure. |
// qsamplerDeviceParam - MIDI/Audio Device parameter structure. |
71 |
QString value; |
QString value; |
72 |
}; |
}; |
73 |
|
|
74 |
// A typedef'd parameter QMap. |
// Typedef'd parameter QMap. |
75 |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap; |
76 |
|
|
77 |
|
// Typedef'd device port/channels QptrList. |
78 |
|
typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList; |
79 |
|
|
80 |
|
|
81 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
82 |
// qsamplerDevice - MIDI/Audio Device structure. |
// qsamplerDevice - MIDI/Audio Device structure. |
87 |
public: |
public: |
88 |
|
|
89 |
// We use the same class for MIDI and audio device management |
// We use the same class for MIDI and audio device management |
90 |
enum qsamplerDeviceType { Midi, Audio }; |
enum qsamplerDeviceType { None, Midi, Audio }; |
91 |
|
|
92 |
// Constructor. |
// Constructor. |
93 |
qsamplerDevice(lscp_client_t *pClient, |
qsamplerDevice(qsamplerMainForm *pMainForm, |
94 |
qsamplerDeviceType deviceType, int iDeviceID = -1); |
qsamplerDeviceType deviceType, int iDeviceID = -1); |
95 |
|
// Copy constructor. |
96 |
|
qsamplerDevice(const qsamplerDevice& device); |
97 |
// Default destructor. |
// Default destructor. |
98 |
~qsamplerDevice(); |
~qsamplerDevice(); |
99 |
|
|
100 |
// Initializer. |
// Initializer. |
101 |
void setDevice(lscp_client_t *pClient, |
void setDevice(qsamplerDeviceType deviceType, int iDeviceID = -1); |
|
qsamplerDeviceType deviceType, int iDeviceID = -1); |
|
102 |
|
|
103 |
// Driver name initializer. |
// Driver name initializer. |
104 |
void setDriver(lscp_client_t *pClient, |
void setDriver(const QString& sDriverName); |
105 |
const QString& sDriverName); |
|
106 |
|
// LSCP client descriptor accessor. |
107 |
|
lscp_client_t *client() const; |
108 |
|
|
109 |
// Device property accessors. |
// Device property accessors. |
110 |
int deviceID() const; |
int deviceID() const; |
111 |
qsamplerDeviceType deviceType() const; |
qsamplerDeviceType deviceType() const; |
112 |
|
const QString& deviceTypeName() const; |
113 |
const QString& driverName() const; |
const QString& driverName() const; |
114 |
const QString& deviceName() const; |
// Special device name formatter. |
115 |
|
QString deviceName() const; |
116 |
|
|
117 |
|
// Set the proper device parameter value. |
118 |
|
bool setParam (const QString& sParam, const QString& sValue); |
119 |
|
|
120 |
// Device parameters accessor. |
// Device parameters accessor. |
121 |
qsamplerDeviceParamMap& params(); |
const qsamplerDeviceParamMap& params() const; |
122 |
|
|
123 |
|
// Device port/channel list accessor. |
124 |
|
qsamplerDevicePortList& ports(); |
125 |
|
|
126 |
// Update/refresh device/driver data. |
// Device parameter dependency list refreshner. |
127 |
void refresh(); |
int refreshParams(); |
128 |
|
// Device port/channel list refreshner. |
129 |
|
int refreshPorts(); |
130 |
|
// Refresh/set dependencies given that some parameter has changed. |
131 |
|
int refreshDepends(const QString& sParam); |
132 |
|
|
133 |
|
// 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 |
// Device ids enumerator. |
// Device ids enumerator. |
145 |
static int *getDevices(lscp_client_t *pClient, |
static int *getDevices(lscp_client_t *pClient, |
151 |
|
|
152 |
private: |
private: |
153 |
|
|
154 |
|
// Refresh/set given parameter based on driver supplied dependencies. |
155 |
|
int refreshParam(const QString& sParam); |
156 |
|
|
157 |
|
// Main application form reference. |
158 |
|
qsamplerMainForm *m_pMainForm; |
159 |
|
|
160 |
// Instance variables. |
// Instance variables. |
161 |
int m_iDeviceID; |
int m_iDeviceID; |
162 |
qsamplerDeviceType m_deviceType; |
qsamplerDeviceType m_deviceType; |
163 |
|
QString m_sDeviceType; |
164 |
QString m_sDriverName; |
QString m_sDriverName; |
165 |
QString m_sDeviceName; |
QString m_sDeviceName; |
166 |
|
|
167 |
// Device parameter list. |
// Device parameter list. |
168 |
qsamplerDeviceParamMap m_params; |
qsamplerDeviceParamMap m_params; |
169 |
|
|
170 |
|
// Device port/channel list. |
171 |
|
qsamplerDevicePortList m_ports; |
172 |
|
}; |
173 |
|
|
174 |
|
|
175 |
|
//------------------------------------------------------------------------- |
176 |
|
// qsamplerDevicePort - MIDI/Audio Device port/channel structure. |
177 |
|
// |
178 |
|
|
179 |
|
class qsamplerDevicePort |
180 |
|
{ |
181 |
|
public: |
182 |
|
|
183 |
|
// Constructor. |
184 |
|
qsamplerDevicePort(qsamplerDevice& device, int iPortID); |
185 |
|
// Default destructor. |
186 |
|
~qsamplerDevicePort(); |
187 |
|
|
188 |
|
// Initializer. |
189 |
|
void setDevicePort(int iPortID); |
190 |
|
|
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 |
|
bool setParam (const QString& sParam, const QString& sValue); |
200 |
|
|
201 |
|
private: |
202 |
|
|
203 |
|
// Device reference. |
204 |
|
qsamplerDevice& m_device; |
205 |
|
|
206 |
|
// Instance variables. |
207 |
|
int m_iPortID; |
208 |
|
QString m_sPortName; |
209 |
|
|
210 |
|
// Device port parameter list. |
211 |
|
qsamplerDeviceParamMap m_params; |
212 |
}; |
}; |
213 |
|
|
214 |
|
|
221 |
public: |
public: |
222 |
|
|
223 |
// Constructors. |
// Constructors. |
224 |
qsamplerDeviceItem(QListView *pListView, lscp_client_t *pClient, |
qsamplerDeviceItem(QListView *pListView, qsamplerMainForm *pMainForm, |
225 |
qsamplerDevice::qsamplerDeviceType deviceType); |
qsamplerDevice::qsamplerDeviceType deviceType); |
226 |
qsamplerDeviceItem(QListViewItem *pItem, lscp_client_t *pClient, |
qsamplerDeviceItem(QListViewItem *pItem, qsamplerMainForm *pMainForm, |
227 |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); |
228 |
// Default destructor. |
// Default destructor. |
229 |
~qsamplerDeviceItem(); |
~qsamplerDeviceItem(); |
256 |
// Default destructor. |
// Default destructor. |
257 |
~qsamplerDeviceParamTable(); |
~qsamplerDeviceParamTable(); |
258 |
|
|
259 |
// Client/device descriptor selector. |
// Common parameter table renderer. |
260 |
void refresh(qsamplerDevice& device); |
void refresh(const qsamplerDeviceParamMap& params, bool bEditable); |
261 |
|
}; |
262 |
|
|
263 |
|
|
264 |
|
//------------------------------------------------------------------------- |
265 |
|
// qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table. |
266 |
|
// |
267 |
|
|
268 |
|
class qsamplerDeviceParamTableSpinBox : public QTableItem |
269 |
|
{ |
270 |
|
public: |
271 |
|
|
272 |
|
// Constructor. |
273 |
|
qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, |
274 |
|
const QString& sText); |
275 |
|
|
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 |
|
int m_iValue; |
291 |
|
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 |
|
|