/[svn]/qsampler/trunk/src/qsamplerDevice.h
ViewVC logotype

Contents of /qsampler/trunk/src/qsamplerDevice.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 467 - (show annotations) (download) (as text)
Tue Mar 15 23:54:14 2005 UTC (19 years ago) by capela
File MIME type: text/x-c++hdr
File size: 7649 byte(s)
Device port/channel configuration refreshing fix.

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 parameter dependency list refreshner.
122 int refreshParams(lscp_client_t *pClient);
123 // Device port/channel list refreshner.
124 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 // Device ids enumerator.
129 static int *getDevices(lscp_client_t *pClient,
130 qsamplerDeviceType deviceType);
131
132 // Driver names enumerator.
133 static QStringList getDrivers(lscp_client_t *pClient,
134 qsamplerDeviceType deviceType);
135
136 private:
137
138 // Refresh/set given parameter based on driver supplied dependencies.
139 int refreshParam(lscp_client_t *pClient, const QString& sParam);
140
141 // Instance variables.
142 int m_iDeviceID;
143 qsamplerDeviceType m_deviceType;
144 QString m_sDeviceType;
145 QString m_sDriverName;
146 QString m_sDeviceName;
147
148 // Device parameter list.
149 qsamplerDeviceParamMap m_params;
150
151 // Device port/channel list.
152 qsamplerDevicePortList m_ports;
153 };
154
155
156 //-------------------------------------------------------------------------
157 // 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 // qsamplerDeviceItem - QListView device item.
197 //
198
199 class qsamplerDeviceItem : public QListViewItem
200 {
201 public:
202
203 // Constructors.
204 qsamplerDeviceItem(QListView *pListView, lscp_client_t *pClient,
205 qsamplerDevice::qsamplerDeviceType deviceType);
206 qsamplerDeviceItem(QListViewItem *pItem, lscp_client_t *pClient,
207 qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);
208 // Default destructor.
209 ~qsamplerDeviceItem();
210
211 // Instance accessors.
212 qsamplerDevice& device();
213
214 // To virtually distinguish between list view items.
215 virtual int rtti() const;
216
217 private:
218
219 // Instance variables.
220 qsamplerDevice m_device;
221 };
222
223
224 //-------------------------------------------------------------------------
225 // qsamplerDeviceParamTable - Device parameter view table.
226 //
227
228 class qsamplerDeviceParamTable : public QTable
229 {
230 Q_OBJECT
231
232 public:
233
234 // Constructor.
235 qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0);
236 // Default destructor.
237 ~qsamplerDeviceParamTable();
238
239 // Common parameter table renderer.
240 void refresh(const qsamplerDeviceParamMap& params, bool bEditable);
241 };
242
243
244 //-------------------------------------------------------------------------
245 // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.
246 //
247
248 class qsamplerDeviceParamTableSpinBox : public QTableItem
249 {
250 public:
251
252 // Constructor.
253 qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType,
254 const QString& sText);
255
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 int m_iValue;
271 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 #endif // __qsamplerDevice_h
297
298
299 // end of qsamplerDevice.h

  ViewVC Help
Powered by ViewVC