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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 961 - (show annotations) (download) (as text)
Sun Dec 3 18:26:13 2006 UTC (12 years ago) by capela
File MIME type: text/x-c++hdr
File size: 8021 byte(s)
- Adding preliminary MIDI instrument mapping support; now
  with an instrument list widget and editing capabilities.

1 // qsamplerDevice.h
2 //
3 /****************************************************************************
4 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
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 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
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 declarations.
38 class qsamplerMainForm;
39 class qsamplerDevicePort;
40
41
42 //-------------------------------------------------------------------------
43 // qsamplerDeviceParam - MIDI/Audio Device parameter structure.
44 //
45 class qsamplerDeviceParam
46 {
47 public:
48
49 // Constructor.
50 qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL,
51 const char *pszValue = NULL);
52 // Default destructor.
53 ~qsamplerDeviceParam();
54
55 // Initializer.
56 void setParam(lscp_param_info_t *pParamInfo,
57 const char *pszValue = NULL);
58
59 // 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 };
73
74 // Typedef'd parameter QMap.
75 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.
83 //
84
85 class qsamplerDevice
86 {
87 public:
88
89 // We use the same class for MIDI and audio device management
90 enum qsamplerDeviceType { None, Midi, Audio };
91
92 // Constructor.
93 qsamplerDevice(qsamplerDeviceType deviceType, int iDeviceID = -1);
94 // Copy constructor.
95 qsamplerDevice(const qsamplerDevice& device);
96 // Default destructor.
97 ~qsamplerDevice();
98
99 // Initializer.
100 void setDevice(qsamplerDeviceType deviceType, int iDeviceID = -1);
101
102 // Driver name initializer.
103 void setDriver(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 // Special device name formatter.
111 QString deviceName() const;
112
113 // Set the proper device parameter value.
114 bool setParam (const QString& sParam, const QString& sValue);
115
116 // Device parameters accessor.
117 const qsamplerDeviceParamMap& params() const;
118
119 // Device port/channel list accessor.
120 qsamplerDevicePortList& ports();
121
122 // Device parameter dependency list refreshner.
123 int refreshParams();
124 // Device port/channel list refreshner.
125 int refreshPorts();
126 // Refresh/set dependencies given that some parameter has changed.
127 int refreshDepends(const QString& sParam);
128
129 // 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 // Device ids enumerator.
141 static int *getDevices(lscp_client_t *pClient,
142 qsamplerDeviceType deviceType);
143
144 // Driver names enumerator.
145 static QStringList getDrivers(lscp_client_t *pClient,
146 qsamplerDeviceType deviceType);
147
148 private:
149
150 // Refresh/set given parameter based on driver supplied dependencies.
151 int refreshParam(const QString& sParam);
152
153 // Main application form reference.
154 qsamplerMainForm *m_pMainForm;
155
156 // Instance variables.
157 int m_iDeviceID;
158 qsamplerDeviceType m_deviceType;
159 QString m_sDeviceType;
160 QString m_sDriverName;
161 QString m_sDeviceName;
162
163 // Device parameter list.
164 qsamplerDeviceParamMap m_params;
165
166 // Device port/channel list.
167 qsamplerDevicePortList m_ports;
168 };
169
170
171 //-------------------------------------------------------------------------
172 // qsamplerDevicePort - MIDI/Audio Device port/channel structure.
173 //
174
175 class qsamplerDevicePort
176 {
177 public:
178
179 // Constructor.
180 qsamplerDevicePort(qsamplerDevice& device, int iPortID);
181 // Default destructor.
182 ~qsamplerDevicePort();
183
184 // Initializer.
185 void setDevicePort(int iPortID);
186
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 bool setParam (const QString& sParam, const QString& sValue);
196
197 private:
198
199 // Device reference.
200 qsamplerDevice& m_device;
201
202 // 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 // qsamplerDeviceItem - QListView device item.
213 //
214
215 class qsamplerDeviceItem : public QListViewItem
216 {
217 public:
218
219 // Constructors.
220 qsamplerDeviceItem(QListView *pListView,
221 qsamplerDevice::qsamplerDeviceType deviceType);
222 qsamplerDeviceItem(QListViewItem *pItem,
223 qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);
224 // Default destructor.
225 ~qsamplerDeviceItem();
226
227 // Instance accessors.
228 qsamplerDevice& device();
229
230 // To virtually distinguish between list view items.
231 virtual int rtti() const;
232
233 private:
234
235 // Instance variables.
236 qsamplerDevice m_device;
237 };
238
239
240 //-------------------------------------------------------------------------
241 // qsamplerDeviceParamTable - Device parameter view table.
242 //
243
244 class qsamplerDeviceParamTable : public QTable
245 {
246 Q_OBJECT
247
248 public:
249
250 // Constructor.
251 qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0);
252 // Default destructor.
253 ~qsamplerDeviceParamTable();
254
255 // Common parameter table renderer.
256 void refresh(const qsamplerDeviceParamMap& params, bool bEditable);
257 };
258
259
260 //-------------------------------------------------------------------------
261 // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.
262 //
263
264 class qsamplerDeviceParamTableSpinBox : public QTableItem
265 {
266 public:
267
268 // Constructor.
269 qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType,
270 const QString& sText);
271
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 int m_iValue;
287 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 #endif // __qsamplerDevice_h
313
314
315 // end of qsamplerDevice.h

  ViewVC Help
Powered by ViewVC