28 |
|
|
29 |
|
|
30 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
31 |
// qsamplerDeviceParameterTable - Device parameter view table. |
// qsamplerDeviceParam - MIDI/Audio Device parameter structure. |
32 |
|
// |
33 |
|
|
34 |
|
// Constructors. |
35 |
|
qsamplerDeviceParam::qsamplerDeviceParam ( lscp_param_info_t *pParamInfo, |
36 |
|
const char *pszValue ) |
37 |
|
{ |
38 |
|
setParam(pParamInfo, pszValue); |
39 |
|
} |
40 |
|
|
41 |
|
|
42 |
|
// Default destructor. |
43 |
|
qsamplerDeviceParam::~qsamplerDeviceParam (void) |
44 |
|
{ |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
// Initializer. |
49 |
|
void qsamplerDeviceParam::setParam ( lscp_param_info_t *pParamInfo, |
50 |
|
const char *pszValue ) |
51 |
|
{ |
52 |
|
if (pParamInfo == NULL) |
53 |
|
return; |
54 |
|
|
55 |
|
// Info structure field members. |
56 |
|
|
57 |
|
type = pParamInfo->type; |
58 |
|
|
59 |
|
if (pParamInfo->description) |
60 |
|
description = pParamInfo->description; |
61 |
|
else |
62 |
|
description = QString::null; |
63 |
|
|
64 |
|
mandatory = (bool) pParamInfo->multiplicity; |
65 |
|
fix = (bool) pParamInfo->fix; |
66 |
|
multiplicity = (bool) pParamInfo->multiplicity; |
67 |
|
|
68 |
|
depends.clear(); |
69 |
|
for (int i = 0; pParamInfo->depends && pParamInfo->depends[i]; i++) |
70 |
|
depends.append(pParamInfo->depends[i]); |
71 |
|
|
72 |
|
if (pParamInfo->defaultv) |
73 |
|
defaultv = pParamInfo->defaultv; |
74 |
|
else |
75 |
|
defaultv = QString::null; |
76 |
|
|
77 |
|
if (pParamInfo->range_min) |
78 |
|
range_min = pParamInfo->range_min; |
79 |
|
else |
80 |
|
range_min = QString::null; |
81 |
|
|
82 |
|
if (pParamInfo->range_max) |
83 |
|
range_max = pParamInfo->range_max; |
84 |
|
else |
85 |
|
range_max = QString::null; |
86 |
|
|
87 |
|
possibilities.clear(); |
88 |
|
for (int i = 0; pParamInfo->possibilities && pParamInfo->possibilities[i]; i++) |
89 |
|
possibilities.append(pParamInfo->possibilities[i]); |
90 |
|
|
91 |
|
// The current parameter value. |
92 |
|
if (pszValue) |
93 |
|
value = pszValue; |
94 |
|
else |
95 |
|
value = QString::null; |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
//------------------------------------------------------------------------- |
100 |
|
// qsamplerDevice - MIDI/Audio Device structure. |
101 |
|
// |
102 |
|
|
103 |
|
// Constructor. |
104 |
|
qsamplerDevice::qsamplerDevice ( lscp_client_t *pClient, |
105 |
|
qsamplerDeviceType deviceType, int iDeviceID ) |
106 |
|
{ |
107 |
|
setDevice(pClient, deviceType, iDeviceID); |
108 |
|
} |
109 |
|
|
110 |
|
// Default destructor. |
111 |
|
qsamplerDevice::~qsamplerDevice (void) |
112 |
|
{ |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
// Initializer. |
117 |
|
void qsamplerDevice::setDevice ( lscp_client_t *pClient, |
118 |
|
qsamplerDeviceType deviceType, int iDeviceID ) |
119 |
|
{ |
120 |
|
if (pClient == NULL || iDeviceID < 0) |
121 |
|
return; |
122 |
|
|
123 |
|
lscp_device_info_t *pDeviceInfo = NULL; |
124 |
|
switch (deviceType) { |
125 |
|
case qsamplerDevice::Audio: |
126 |
|
m_sDeviceName = QObject::tr("Audio"); |
127 |
|
pDeviceInfo = ::lscp_get_audio_device_info(pClient, iDeviceID); |
128 |
|
break; |
129 |
|
case qsamplerDevice::Midi: |
130 |
|
m_sDeviceName = QObject::tr("MIDI"); |
131 |
|
pDeviceInfo = ::lscp_get_midi_device_info(pClient, iDeviceID); |
132 |
|
break; |
133 |
|
} |
134 |
|
if (pDeviceInfo == NULL) |
135 |
|
return; |
136 |
|
|
137 |
|
// Device properties... |
138 |
|
m_iDeviceID = iDeviceID; |
139 |
|
m_deviceType = deviceType; |
140 |
|
m_sDriverName = pDeviceInfo->driver; |
141 |
|
|
142 |
|
// Complete fake device name... |
143 |
|
m_sDeviceName += ' ' + m_sDriverName + ' '; |
144 |
|
m_sDeviceName += QObject::tr("Device %1").arg(m_iDeviceID); |
145 |
|
|
146 |
|
// Grab device/driver parameters... |
147 |
|
m_params.clear(); |
148 |
|
for (int i = 0; pDeviceInfo->params && pDeviceInfo->params[i].key; i++) { |
149 |
|
const char *pszParam = pDeviceInfo->params[i].key; |
150 |
|
lscp_param_info_t *pParamInfo = NULL; |
151 |
|
switch (deviceType) { |
152 |
|
case qsamplerDevice::Audio: |
153 |
|
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
154 |
|
m_sDriverName.latin1(), pszParam, NULL); |
155 |
|
break; |
156 |
|
case qsamplerDevice::Midi: |
157 |
|
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
158 |
|
m_sDriverName.latin1(), pszParam, NULL); |
159 |
|
break; |
160 |
|
} |
161 |
|
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, pDeviceInfo->params[i].value); |
162 |
|
} |
163 |
|
} |
164 |
|
|
165 |
|
|
166 |
|
// Device property accessors. |
167 |
|
int qsamplerDevice::deviceID (void) const |
168 |
|
{ |
169 |
|
return m_iDeviceID; |
170 |
|
} |
171 |
|
|
172 |
|
qsamplerDevice::qsamplerDeviceType qsamplerDevice::deviceType (void) const |
173 |
|
{ |
174 |
|
return m_deviceType; |
175 |
|
} |
176 |
|
|
177 |
|
const QString& qsamplerDevice::driverName (void) const |
178 |
|
{ |
179 |
|
return m_sDriverName; |
180 |
|
} |
181 |
|
|
182 |
|
const QString& qsamplerDevice::deviceName (void) const |
183 |
|
{ |
184 |
|
return m_sDeviceName; |
185 |
|
} |
186 |
|
|
187 |
|
// Device parameter accessor. |
188 |
|
qsamplerDeviceParamMap& qsamplerDevice::params (void) |
189 |
|
{ |
190 |
|
return m_params; |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
// Update/refresh device/driver data. |
195 |
|
void qsamplerDevice::refresh (void) |
196 |
|
{ |
197 |
|
} |
198 |
|
|
199 |
|
// Device enumerator. |
200 |
|
int *qsamplerDevice::getDevices ( lscp_client_t *pClient, |
201 |
|
qsamplerDeviceType deviceType ) |
202 |
|
{ |
203 |
|
int *piDeviceIDs = NULL; |
204 |
|
switch (deviceType) { |
205 |
|
case qsamplerDevice::Audio: |
206 |
|
piDeviceIDs = ::lscp_list_audio_devices(pClient); |
207 |
|
break; |
208 |
|
case qsamplerDevice::Midi: |
209 |
|
piDeviceIDs = ::lscp_list_midi_devices(pClient); |
210 |
|
break; |
211 |
|
} |
212 |
|
return piDeviceIDs; |
213 |
|
} |
214 |
|
|
215 |
|
//------------------------------------------------------------------------- |
216 |
|
// qsamplerDeviceItem - QListView device item. |
217 |
|
// |
218 |
|
|
219 |
|
// Constructors. |
220 |
|
qsamplerDeviceItem::qsamplerDeviceItem ( QListView *pListView, lscp_client_t *pClient, |
221 |
|
qsamplerDevice::qsamplerDeviceType deviceType ) |
222 |
|
: QListViewItem(pListView), m_device(pClient, deviceType) |
223 |
|
{ |
224 |
|
switch(m_device.deviceType()) { |
225 |
|
case qsamplerDevice::Audio: |
226 |
|
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio1.png")); |
227 |
|
QListViewItem::setText(0, QObject::tr("Audio devices")); |
228 |
|
break; |
229 |
|
case qsamplerDevice::Midi: |
230 |
|
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi1.png")); |
231 |
|
QListViewItem::setText(0, QObject::tr("MIDI devices")); |
232 |
|
break; |
233 |
|
} |
234 |
|
} |
235 |
|
|
236 |
|
qsamplerDeviceItem::qsamplerDeviceItem ( QListViewItem *pItem, lscp_client_t *pClient, |
237 |
|
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
238 |
|
: QListViewItem(pItem), m_device(pClient, deviceType, iDeviceID) |
239 |
|
{ |
240 |
|
switch(m_device.deviceType()) { |
241 |
|
case qsamplerDevice::Audio: |
242 |
|
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio2.png")); |
243 |
|
break; |
244 |
|
case qsamplerDevice::Midi: |
245 |
|
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi2.png")); |
246 |
|
break; |
247 |
|
} |
248 |
|
|
249 |
|
QListViewItem::setText(0, m_device.deviceName()); |
250 |
|
} |
251 |
|
|
252 |
|
// Default destructor. |
253 |
|
qsamplerDeviceItem::~qsamplerDeviceItem (void) |
254 |
|
{ |
255 |
|
} |
256 |
|
|
257 |
|
// Instance accessors. |
258 |
|
const qsamplerDevice& qsamplerDeviceItem::device (void) |
259 |
|
{ |
260 |
|
return m_device; |
261 |
|
} |
262 |
|
|
263 |
|
// To virtually distinguish between list view items. |
264 |
|
int qsamplerDeviceItem::rtti() const |
265 |
|
{ |
266 |
|
return QSAMPLER_DEVICE_ITEM; |
267 |
|
} |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
//------------------------------------------------------------------------- |
272 |
|
// qsamplerDeviceParamTable - Device parameter view table. |
273 |
// |
// |
274 |
|
|
275 |
// Constructor. |
// Constructor. |
276 |
qsamplerDeviceParameterTable::qsamplerDeviceParameterTable ( QWidget *pParent, const char *pszName ) |
qsamplerDeviceParamTable::qsamplerDeviceParamTable ( QWidget *pParent, const char *pszName ) |
277 |
: QTable(pParent, pszName) |
: QTable(pParent, pszName) |
278 |
{ |
{ |
279 |
m_pClient = NULL; |
m_pClient = NULL; |
280 |
|
m_iDeviceID = -1; |
281 |
|
|
282 |
// Set fixed number of columns. |
// Set fixed number of columns. |
283 |
QTable::setNumCols(5); |
QTable::setNumCols(3); |
284 |
QTable::setShowGrid(false); |
QTable::setShowGrid(false); |
285 |
QTable::setSorting(false); |
QTable::setSorting(false); |
286 |
QTable::setFocusStyle(QTable::FollowStyle); |
QTable::setFocusStyle(QTable::FollowStyle); |
290 |
QTable::setLeftMargin(0); |
QTable::setLeftMargin(0); |
291 |
// Initialize the fixed table column headings. |
// Initialize the fixed table column headings. |
292 |
QHeader *pHeader = QTable::horizontalHeader(); |
QHeader *pHeader = QTable::horizontalHeader(); |
293 |
pHeader->setLabel(0, tr("Name")); |
pHeader->setLabel(0, tr("Parameter")); |
294 |
pHeader->setLabel(1, tr("Description")); |
pHeader->setLabel(1, tr("Description")); |
295 |
pHeader->setLabel(2, tr("Type")); |
pHeader->setLabel(2, tr("Value")); |
|
pHeader->setLabel(3, tr("Value")); |
|
|
pHeader->setLabel(4, tr("Default")); |
|
296 |
// Set read-onlyness of each column |
// Set read-onlyness of each column |
297 |
QTable::setColumnReadOnly(0, true); |
QTable::setColumnReadOnly(0, true); |
298 |
QTable::setColumnReadOnly(1, true); |
QTable::setColumnReadOnly(1, true); |
299 |
QTable::setColumnReadOnly(2, true); |
// QTable::setColumnReadOnly(2, true); -- of course not. |
|
/* QTable::setColumnReadOnly(2, true); -- of course not. */ |
|
|
QTable::setColumnReadOnly(4, true); |
|
300 |
} |
} |
301 |
|
|
302 |
// Default destructor. |
// Default destructor. |
303 |
qsamplerDeviceParameterTable::~qsamplerDeviceParameterTable (void) |
qsamplerDeviceParamTable::~qsamplerDeviceParamTable (void) |
304 |
{ |
{ |
305 |
} |
} |
306 |
|
|
307 |
|
|
308 |
// The client descriptor property accessors. |
// Client/device descriptor selector. |
309 |
void qsamplerDeviceParameterTable::setClient ( lscp_client_t *pClient ) |
void qsamplerDeviceParamTable::setDevice ( lscp_client_t *pClient, |
310 |
|
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
311 |
{ |
{ |
312 |
|
if (m_pClient |
313 |
|
&& m_pClient == pClient |
314 |
|
&& m_deviceType == deviceType |
315 |
|
&& m_iDeviceID == iDeviceID) |
316 |
|
return; |
317 |
|
|
318 |
m_pClient = pClient; |
m_pClient = pClient; |
319 |
|
m_deviceType = deviceType; |
320 |
|
m_iDeviceID = iDeviceID; |
321 |
|
|
322 |
|
refresh(); |
323 |
} |
} |
324 |
|
|
325 |
lscp_client_t *qsamplerDeviceParameterTable::client (void) |
|
326 |
|
// Client/device descriptor accessors. |
327 |
|
lscp_client_t *qsamplerDeviceParamTable::client (void) |
328 |
{ |
{ |
329 |
return m_pClient; |
return m_pClient; |
330 |
} |
} |
331 |
|
|
332 |
|
int qsamplerDeviceParamTable::deviceID (void) |
333 |
|
{ |
334 |
|
return m_iDeviceID; |
335 |
|
} |
336 |
|
|
337 |
|
|
338 |
|
// The main table refresher. |
339 |
|
void qsamplerDeviceParamTable::refresh (void) |
340 |
|
{ |
341 |
|
// Always (re)start it empty. |
342 |
|
QTable::setNumRows(0); |
343 |
|
|
344 |
|
if (m_pClient == NULL) |
345 |
|
return; |
346 |
|
|
347 |
|
// Construct the local device object here. |
348 |
|
qsamplerDevice device(m_pClient, m_deviceType, m_iDeviceID); |
349 |
|
|
350 |
|
|
351 |
|
// Now fill the parameter table... |
352 |
|
QHeader *pHeader = QTable::verticalHeader(); |
353 |
|
qsamplerDeviceParamMap& params = device.params(); |
354 |
|
QTable::insertRows(0, params.count()); |
355 |
|
int iRow = 0; |
356 |
|
qsamplerDeviceParamMap::Iterator iter; |
357 |
|
for (iter = params.begin(); iter != params.end(); ++iter) { |
358 |
|
QTable::setText(iRow, 0, iter.key()); |
359 |
|
QTable::setText(iRow, 1, iter.data().description); |
360 |
|
QTable::setText(iRow, 2, iter.data().value); |
361 |
|
++iRow; |
362 |
|
} |
363 |
|
|
364 |
|
// Adjust optimal column width. |
365 |
|
for (int iCol = 0; iCol < QTable::numCols(); iCol++) |
366 |
|
QTable::adjustColumn(iCol); |
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
// end of qsamplerDevice.cpp |
// end of qsamplerDevice.cpp |