107 |
qsamplerDevice::qsamplerDevice ( lscp_client_t *pClient, |
qsamplerDevice::qsamplerDevice ( lscp_client_t *pClient, |
108 |
qsamplerDeviceType deviceType, int iDeviceID ) |
qsamplerDeviceType deviceType, int iDeviceID ) |
109 |
{ |
{ |
110 |
|
m_ports.setAutoDelete(true); |
111 |
|
|
112 |
setDevice(pClient, deviceType, iDeviceID); |
setDevice(pClient, deviceType, iDeviceID); |
113 |
} |
} |
114 |
|
|
125 |
// Device id and type should be always set. |
// Device id and type should be always set. |
126 |
m_iDeviceID = iDeviceID; |
m_iDeviceID = iDeviceID; |
127 |
m_deviceType = deviceType; |
m_deviceType = deviceType; |
128 |
|
|
129 |
|
// Reset device parameters and ports anyway. |
130 |
|
m_params.clear(); |
131 |
|
m_ports.clear(); |
132 |
|
|
133 |
// Retrieve device info, if any. |
// Retrieve device info, if any. |
134 |
lscp_device_info_t *pDeviceInfo = NULL; |
lscp_device_info_t *pDeviceInfo = NULL; |
159 |
+ QObject::tr("Device %1").arg(m_iDeviceID); |
+ QObject::tr("Device %1").arg(m_iDeviceID); |
160 |
|
|
161 |
// Grab device parameters... |
// Grab device parameters... |
|
m_params.clear(); |
|
162 |
for (int i = 0; pDeviceInfo->params && pDeviceInfo->params[i].key; i++) { |
for (int i = 0; pDeviceInfo->params && pDeviceInfo->params[i].key; i++) { |
163 |
const char *pszParam = pDeviceInfo->params[i].key; |
const QString sParam = pDeviceInfo->params[i].key; |
164 |
lscp_param_info_t *pParamInfo = NULL; |
lscp_param_info_t *pParamInfo = NULL; |
165 |
switch (deviceType) { |
switch (deviceType) { |
166 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
167 |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
168 |
m_sDriverName.latin1(), pszParam, NULL); |
m_sDriverName.latin1(), sParam.latin1(), NULL); |
169 |
break; |
break; |
170 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
171 |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
172 |
m_sDriverName.latin1(), pszParam, NULL); |
m_sDriverName.latin1(), sParam.latin1(), NULL); |
173 |
break; |
break; |
174 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
175 |
break; |
break; |
176 |
} |
} |
177 |
if (pParamInfo) { |
if (pParamInfo) { |
178 |
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, |
m_params[sParam.upper()] = qsamplerDeviceParam(pParamInfo, |
179 |
pDeviceInfo->params[i].value); |
pDeviceInfo->params[i].value); |
180 |
} |
} |
181 |
} |
} |
182 |
|
|
183 |
|
// Grab port/channel list... |
184 |
|
refresh(pClient); |
185 |
} |
} |
186 |
|
|
187 |
|
|
193 |
if (m_sDriverName == sDriverName) |
if (m_sDriverName == sDriverName) |
194 |
return; |
return; |
195 |
|
|
196 |
|
// Reset device parameters and ports anyway. |
197 |
|
m_params.clear(); |
198 |
|
m_ports.clear(); |
199 |
|
|
200 |
// Retrieve driver info, if any. |
// Retrieve driver info, if any. |
201 |
lscp_driver_info_t *pDriverInfo = NULL; |
lscp_driver_info_t *pDriverInfo = NULL; |
202 |
switch (m_deviceType) { |
switch (m_deviceType) { |
220 |
m_sDriverName = sDriverName; |
m_sDriverName = sDriverName; |
221 |
|
|
222 |
// Grab driver parameters... |
// Grab driver parameters... |
|
m_params.clear(); |
|
223 |
for (int i = 0; pDriverInfo->parameters && pDriverInfo->parameters[i]; i++) { |
for (int i = 0; pDriverInfo->parameters && pDriverInfo->parameters[i]; i++) { |
224 |
const char *pszParam = pDriverInfo->parameters[i]; |
const QString sParam = pDriverInfo->parameters[i]; |
225 |
lscp_param_info_t *pParamInfo = NULL; |
lscp_param_info_t *pParamInfo = NULL; |
226 |
switch (m_deviceType) { |
switch (m_deviceType) { |
227 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
228 |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
229 |
sDriverName.latin1(), pszParam, NULL); |
sDriverName.latin1(), sParam.latin1(), NULL); |
230 |
break; |
break; |
231 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
232 |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
233 |
sDriverName.latin1(), pszParam, NULL); |
sDriverName.latin1(), sParam.latin1(), NULL); |
234 |
break; |
break; |
235 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
236 |
break; |
break; |
237 |
} |
} |
238 |
if (pParamInfo) |
if (pParamInfo) { |
239 |
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, pParamInfo->defaultv); |
m_params[sParam.upper()] = qsamplerDeviceParam(pParamInfo, |
240 |
|
pParamInfo->defaultv); |
241 |
|
} |
242 |
} |
} |
243 |
} |
} |
244 |
|
|
269 |
return m_sDeviceName; |
return m_sDeviceName; |
270 |
} |
} |
271 |
|
|
272 |
|
|
273 |
|
// Set the proper device parameter value. |
274 |
|
void qsamplerDevice::setParam ( const QString& sParam, |
275 |
|
const QString& sValue ) |
276 |
|
{ |
277 |
|
m_params[sParam.upper()].value = sValue; |
278 |
|
} |
279 |
|
|
280 |
|
|
281 |
// Device parameter accessor. |
// Device parameter accessor. |
282 |
const qsamplerDeviceParamMap& qsamplerDevice::params (void) const |
const qsamplerDeviceParamMap& qsamplerDevice::params (void) const |
283 |
{ |
{ |
285 |
} |
} |
286 |
|
|
287 |
|
|
288 |
// Set the proper device parameter value. |
// Device port/channel list accessor. |
289 |
void qsamplerDevice::setParam ( const QString& sParam, |
qsamplerDevicePortList& qsamplerDevice::ports (void) |
290 |
const QString& sValue ) |
{ |
291 |
|
return m_ports; |
292 |
|
} |
293 |
|
|
294 |
|
|
295 |
|
// Device port/channel list refreshner. |
296 |
|
void qsamplerDevice::refresh ( lscp_client_t *pClient ) |
297 |
{ |
{ |
298 |
m_params[sParam].value = sValue; |
// Port/channel count determination... |
299 |
|
int iPorts = 0; |
300 |
|
switch (m_deviceType) { |
301 |
|
case qsamplerDevice::Audio: |
302 |
|
iPorts = m_params["CHANNELS"].value.toInt(); |
303 |
|
break; |
304 |
|
case qsamplerDevice::Midi: |
305 |
|
iPorts = m_params["PORTS"].value.toInt(); |
306 |
|
break; |
307 |
|
case qsamplerDevice::None: |
308 |
|
break; |
309 |
|
} |
310 |
|
|
311 |
|
// Retrieve port/channel information... |
312 |
|
m_ports.clear(); |
313 |
|
for (int iPort = 0; iPort < iPorts; iPort++) |
314 |
|
m_ports.append(new qsamplerDevicePort(pClient, *this, iPort)); |
315 |
} |
} |
316 |
|
|
317 |
|
|
383 |
// Device port id should be always set. |
// Device port id should be always set. |
384 |
m_iPortID = iPortID; |
m_iPortID = iPortID; |
385 |
|
|
386 |
|
// Reset port parameters anyway. |
387 |
|
m_params.clear(); |
388 |
|
|
389 |
// Retrieve device port/channel info, if any. |
// Retrieve device port/channel info, if any. |
390 |
|
QString sPrefix = device.driverName() + ' '; |
391 |
lscp_device_port_info_t *pPortInfo = NULL; |
lscp_device_port_info_t *pPortInfo = NULL; |
392 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
393 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
394 |
|
sPrefix += QObject::tr("Channel"); |
395 |
pPortInfo = ::lscp_get_audio_channel_info(pClient, device.deviceID(), iPortID); |
pPortInfo = ::lscp_get_audio_channel_info(pClient, device.deviceID(), iPortID); |
396 |
break; |
break; |
397 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
398 |
|
sPrefix += QObject::tr("Port"); |
399 |
pPortInfo = ::lscp_get_midi_port_info(pClient, device.deviceID(), iPortID); |
pPortInfo = ::lscp_get_midi_port_info(pClient, device.deviceID(), iPortID); |
400 |
break; |
break; |
401 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
409 |
} |
} |
410 |
|
|
411 |
// Set device port/channel properties... |
// Set device port/channel properties... |
412 |
m_sPortName = pPortInfo->name; |
sPrefix += " %1:"; |
413 |
|
m_sPortName = sPrefix.arg(m_iPortID) + ' ' + pPortInfo->name; |
414 |
|
|
415 |
// Grab device port/channel parameters... |
// Grab device port/channel parameters... |
416 |
m_params.clear(); |
m_params.clear(); |
417 |
for (int i = 0; pPortInfo->params && pPortInfo->params[i].key; i++) { |
for (int i = 0; pPortInfo->params && pPortInfo->params[i].key; i++) { |
418 |
const char *pszParam = pPortInfo->params[i].key; |
const QString sParam = pPortInfo->params[i].key; |
419 |
lscp_param_info_t *pParamInfo = NULL; |
lscp_param_info_t *pParamInfo = NULL; |
420 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
421 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
422 |
pParamInfo = ::lscp_get_audio_channel_param_info(pClient, |
pParamInfo = ::lscp_get_audio_channel_param_info(pClient, |
423 |
device.deviceID(), iPortID, pszParam); |
device.deviceID(), iPortID, sParam.latin1()); |
424 |
break; |
break; |
425 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
426 |
pParamInfo = ::lscp_get_midi_port_param_info(pClient, |
pParamInfo = ::lscp_get_midi_port_param_info(pClient, |
427 |
device.deviceID(), iPortID, pszParam); |
device.deviceID(), iPortID, sParam.latin1()); |
428 |
break; |
break; |
429 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
430 |
break; |
break; |
431 |
} |
} |
432 |
if (pParamInfo) { |
if (pParamInfo) { |
433 |
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, |
m_params[sParam.upper()] = qsamplerDeviceParam(pParamInfo, |
434 |
pPortInfo->params[i].value); |
pPortInfo->params[i].value); |
435 |
} |
} |
436 |
} |
} |
459 |
void qsamplerDevicePort::setParam ( const QString& sParam, |
void qsamplerDevicePort::setParam ( const QString& sParam, |
460 |
const QString& sValue ) |
const QString& sValue ) |
461 |
{ |
{ |
462 |
m_params[sParam].value = sValue; |
m_params[sParam.upper()].value = sValue; |
463 |
} |
} |
464 |
|
|
465 |
|
|
579 |
QTable::setText(iRow, 1, param.description); |
QTable::setText(iRow, 1, param.description); |
580 |
if (param.type == LSCP_TYPE_BOOL) { |
if (param.type == LSCP_TYPE_BOOL) { |
581 |
QStringList opts; |
QStringList opts; |
582 |
opts.append(tr("False")); |
opts.append(tr("false")); |
583 |
opts.append(tr("True")); |
opts.append(tr("true")); |
584 |
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
585 |
pComboItem->setCurrentItem(param.value.lower() == "true" ? 1 : 0); |
pComboItem->setCurrentItem(param.value.lower() == "true" ? 1 : 0); |
586 |
pComboItem->setEnabled(bEnabled); |
pComboItem->setEnabled(bEnabled); |