36 |
void qsamplerDeviceForm::init (void) |
void qsamplerDeviceForm::init (void) |
37 |
{ |
{ |
38 |
// Initialize locals. |
// Initialize locals. |
39 |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
m_pMainForm = NULL; |
40 |
m_pClient = NULL; |
m_pClient = NULL; |
41 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
42 |
|
m_iDirtyCount = 0; |
43 |
m_bNewDevice = false; |
m_bNewDevice = false; |
44 |
m_deviceType = qsamplerDevice::None; |
m_deviceType = qsamplerDevice::None; |
45 |
m_pAudioItems = NULL; |
m_pAudioItems = NULL; |
46 |
m_pMidiItems = NULL; |
m_pMidiItems = NULL; |
47 |
|
// No exclusive mode as default. |
48 |
|
m_deviceTypeMode = qsamplerDevice::None; |
49 |
|
|
50 |
// This an outsider (from designer), but rather important. |
// This an outsider (from designer), but rather important. |
51 |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
53 |
QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)), |
QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)), |
54 |
this, SLOT(changeDevicePortParam(int,int))); |
this, SLOT(changeDevicePortParam(int,int))); |
55 |
|
|
56 |
|
// Initial contents. |
57 |
|
refreshDevices(); |
58 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
59 |
adjustSize(); |
adjustSize(); |
60 |
} |
} |
85 |
|
|
86 |
if (m_pMainForm) |
if (m_pMainForm) |
87 |
m_pMainForm->stabilizeForm(); |
m_pMainForm->stabilizeForm(); |
88 |
|
|
89 |
|
// Signal special whether we changed the device set. |
90 |
|
if (m_iDirtyCount > 0) { |
91 |
|
m_iDirtyCount = 0; |
92 |
|
emit devicesChanged(); |
93 |
|
} |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
// Application main form settler (life depends on it). |
98 |
|
void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm ) |
99 |
|
{ |
100 |
|
m_pMainForm = pMainForm; |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
// Set device type spacial exclusive mode. |
105 |
|
void qsamplerDeviceForm::setDeviceTypeMode ( |
106 |
|
qsamplerDevice::qsamplerDeviceType deviceTypeMode ) |
107 |
|
{ |
108 |
|
// If it has not changed, do nothing. |
109 |
|
if (m_deviceTypeMode == deviceTypeMode) |
110 |
|
return; |
111 |
|
|
112 |
|
m_deviceTypeMode = deviceTypeMode; |
113 |
|
|
114 |
|
// OK. Do a whole refresh around. |
115 |
|
refreshDevices(); |
116 |
} |
} |
117 |
|
|
118 |
|
|
125 |
|
|
126 |
// Set new reference. |
// Set new reference. |
127 |
m_pClient = pClient; |
m_pClient = pClient; |
128 |
|
|
129 |
// OK. Do a whole refresh around. |
// OK. Do a whole refresh around. |
130 |
refreshDevices(); |
refreshDevices(); |
131 |
} |
} |
132 |
|
|
133 |
|
|
134 |
// Create a new device from current table view. |
// Device driver name setup formal initializer. |
135 |
void qsamplerDeviceForm::createDevice (void) |
void qsamplerDeviceForm::setDriverName ( const QString& sDriverName ) |
136 |
{ |
{ |
137 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
if (DriverNameComboBox->listBox()->findItem(sDriverName, |
138 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
Qt::ExactMatch | Qt::CaseSensitive) == NULL) { |
139 |
return; |
DriverNameComboBox->insertItem(sDriverName); |
140 |
|
} |
141 |
|
DriverNameComboBox->setCurrentText(sDriverName); |
142 |
|
} |
143 |
|
|
|
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
|
144 |
|
|
145 |
// Build the parameter list... |
// Set current selected device by type and id. |
146 |
const qsamplerDeviceParamMap& params = device.params(); |
void qsamplerDeviceForm::setDevice ( qsamplerDevice *pDevice ) |
147 |
lscp_param_t *pParams = new lscp_param_t [params.count() + 1]; |
{ |
148 |
int iParam = 0; |
// In case no device is given... |
149 |
qsamplerDeviceParamMap::ConstIterator iter; |
qsamplerDevice::qsamplerDeviceType deviceType = m_deviceTypeMode; |
150 |
for (iter = params.begin(); iter != params.end(); ++iter) { |
if (pDevice) |
151 |
pParams[iParam].key = (char *) iter.key().latin1(); |
deviceType = pDevice->deviceType(); |
|
pParams[iParam].value = (char *) iter.data().value.latin1(); |
|
|
++iParam; |
|
|
} |
|
|
// Null terminated. |
|
|
pParams[iParam].key = NULL; |
|
|
pParams[iParam].value = NULL; |
|
152 |
|
|
153 |
// Now it depends on the device type... |
// Get the device view root item... |
154 |
qsamplerDeviceItem *pRootItem = NULL; |
qsamplerDeviceItem *pRootItem = NULL; |
155 |
int iDeviceID = -1; |
switch (deviceType) { |
|
switch (device.deviceType()) { |
|
156 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
157 |
pRootItem = m_pAudioItems; |
pRootItem = m_pAudioItems; |
|
if ((iDeviceID = ::lscp_create_audio_device(m_pClient, |
|
|
device.driverName().latin1(), pParams)) < 0) |
|
|
m_pMainForm->appendMessagesClient("lscp_create_audio_device"); |
|
158 |
break; |
break; |
159 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
160 |
pRootItem = m_pMidiItems; |
pRootItem = m_pMidiItems; |
|
if ((iDeviceID = ::lscp_create_midi_device(m_pClient, |
|
|
device.driverName().latin1(), pParams)) < 0) |
|
|
m_pMainForm->appendMessagesClient("lscp_create_midi_device"); |
|
161 |
break; |
break; |
162 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
163 |
break; |
break; |
164 |
} |
} |
165 |
|
|
166 |
// Free used parameter array. |
// Is the root present? |
167 |
delete pParams; |
if (pRootItem == NULL) |
168 |
|
return; |
169 |
|
|
170 |
|
// So there's no device huh? |
171 |
|
if (pDevice == NULL) { |
172 |
|
DeviceListView->setSelected(pRootItem, true); |
173 |
|
return; |
174 |
|
} |
175 |
|
|
176 |
// We're on to create the new device item. |
// For each child, test for identity... |
177 |
if (iDeviceID >= 0) { |
qsamplerDeviceItem *pDeviceItem = |
178 |
|
(qsamplerDeviceItem *) pRootItem->firstChild(); |
179 |
|
while (pDeviceItem) { |
180 |
|
// If identities match, select as current device item. |
181 |
|
if (pDeviceItem->device().deviceID() == pDevice->deviceID()) { |
182 |
|
DeviceListView->setSelected(pDeviceItem, true); |
183 |
|
break; |
184 |
|
} |
185 |
|
pDeviceItem = (qsamplerDeviceItem *) pDeviceItem->nextSibling(); |
186 |
|
} |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
// Create a new device from current table view. |
192 |
|
void qsamplerDeviceForm::createDevice (void) |
193 |
|
{ |
194 |
|
if (m_pMainForm == NULL) |
195 |
|
return; |
196 |
|
|
197 |
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
198 |
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
199 |
|
return; |
200 |
|
|
201 |
|
// About a brand new device instance... |
202 |
|
qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device()); |
203 |
|
if (device.createDevice()) { |
204 |
|
// Now it depends on the device type... |
205 |
|
qsamplerDeviceItem *pRootItem = NULL; |
206 |
|
switch (device.deviceType()) { |
207 |
|
case qsamplerDevice::Audio: |
208 |
|
pRootItem = m_pAudioItems; |
209 |
|
break; |
210 |
|
case qsamplerDevice::Midi: |
211 |
|
pRootItem = m_pMidiItems; |
212 |
|
break; |
213 |
|
case qsamplerDevice::None: |
214 |
|
break; |
215 |
|
} |
216 |
// Append the new device item. |
// Append the new device item. |
217 |
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
218 |
m_pClient, device.deviceType(), iDeviceID); |
m_pMainForm, device.deviceType(), device.deviceID()); |
219 |
// Just make it the new selection... |
// Just make it the new selection... |
220 |
DeviceListView->setSelected(pDeviceItem, true); |
DeviceListView->setSelected(pDeviceItem, true); |
|
// Done. |
|
|
m_pMainForm->appendMessages(pDeviceItem->device().deviceName() + ' ' |
|
|
+ tr("created.")); |
|
221 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
222 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
223 |
|
m_iDirtyCount++; |
224 |
} |
} |
225 |
} |
} |
226 |
|
|
228 |
// Delete current device in table view. |
// Delete current device in table view. |
229 |
void qsamplerDeviceForm::deleteDevice (void) |
void qsamplerDeviceForm::deleteDevice (void) |
230 |
{ |
{ |
231 |
|
if (m_pMainForm == NULL) |
232 |
|
return; |
233 |
|
|
234 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
235 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
236 |
return; |
return; |
237 |
|
|
238 |
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
239 |
|
|
240 |
// Prompt user if this is for real... |
// Prompt user if this is for real... |
241 |
qsamplerOptions *pOptions = m_pMainForm->options(); |
qsamplerOptions *pOptions = m_pMainForm->options(); |
242 |
if (pOptions && pOptions->bConfirmRemove) { |
if (pOptions && pOptions->bConfirmRemove) { |
243 |
if (QMessageBox::warning(this, tr("Warning"), |
if (QMessageBox::warning(this, tr("Warning"), |
244 |
tr("Delete %1 device:\n\n" |
tr("Delete device:\n\n" |
245 |
"%2\n\n" |
"%1\n\n" |
246 |
"Are you sure?") |
"Are you sure?") |
|
.arg(device.deviceTypeName()) |
|
247 |
.arg(device.deviceName()), |
.arg(device.deviceName()), |
248 |
tr("OK"), tr("Cancel")) > 0) |
tr("OK"), tr("Cancel")) > 0) |
249 |
return; |
return; |
250 |
} |
} |
251 |
|
|
252 |
// Now it depends on the device type... |
// Go and destroy... |
253 |
lscp_status_t ret = LSCP_FAILED; |
if (device.deleteDevice()) { |
254 |
switch (device.deviceType()) { |
// Remove it from the device view... |
|
case qsamplerDevice::Audio: |
|
|
if ((ret = ::lscp_destroy_audio_device(m_pClient, |
|
|
device.deviceID())) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_destroy_audio_device"); |
|
|
break; |
|
|
case qsamplerDevice::Midi: |
|
|
if ((ret = ::lscp_destroy_midi_device(m_pClient, |
|
|
device.deviceID())) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_destroy_midi_device"); |
|
|
break; |
|
|
case qsamplerDevice::None: |
|
|
break; |
|
|
} |
|
|
|
|
|
// Show result. |
|
|
if (ret == LSCP_OK) { |
|
|
// Show log message before loosing it. |
|
|
m_pMainForm->appendMessages(device.deviceName() + ' ' |
|
|
+ tr("deleted.")); |
|
|
// Done. |
|
255 |
delete pItem; |
delete pItem; |
256 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
257 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
258 |
|
m_iDirtyCount++; |
259 |
} |
} |
260 |
} |
} |
261 |
|
|
263 |
// Refresh all device list and views. |
// Refresh all device list and views. |
264 |
void qsamplerDeviceForm::refreshDevices (void) |
void qsamplerDeviceForm::refreshDevices (void) |
265 |
{ |
{ |
266 |
|
if (m_pMainForm == NULL) |
267 |
|
return; |
268 |
|
|
269 |
// Avoid nested changes. |
// Avoid nested changes. |
270 |
m_iDirtySetup++; |
m_iDirtySetup++; |
271 |
|
|
278 |
if (m_pClient) { |
if (m_pClient) { |
279 |
int *piDeviceIDs; |
int *piDeviceIDs; |
280 |
// Grab and pop Audio devices... |
// Grab and pop Audio devices... |
281 |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
if (m_deviceTypeMode == qsamplerDevice::None || |
282 |
qsamplerDevice::Audio); |
m_deviceTypeMode == qsamplerDevice::Audio) { |
283 |
|
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, |
284 |
|
m_pMainForm, qsamplerDevice::Audio); |
285 |
|
} |
286 |
if (m_pAudioItems) { |
if (m_pAudioItems) { |
|
m_pAudioItems->setText(0, tr("Audio")); |
|
287 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
288 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
289 |
new qsamplerDeviceItem(m_pAudioItems, m_pClient, |
new qsamplerDeviceItem(m_pAudioItems, m_pMainForm, |
290 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
qsamplerDevice::Audio, piDeviceIDs[i]); |
291 |
} |
} |
292 |
m_pAudioItems->setOpen(true); |
m_pAudioItems->setOpen(true); |
293 |
} |
} |
294 |
// Grab and pop MIDI devices... |
// Grab and pop MIDI devices... |
295 |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
if (m_deviceTypeMode == qsamplerDevice::None || |
296 |
qsamplerDevice::Midi); |
m_deviceTypeMode == qsamplerDevice::Midi) { |
297 |
|
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, |
298 |
|
m_pMainForm, qsamplerDevice::Midi); |
299 |
|
} |
300 |
if (m_pMidiItems) { |
if (m_pMidiItems) { |
|
m_pMidiItems->setText(0, tr("MIDI")); |
|
301 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
302 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
303 |
new qsamplerDeviceItem(m_pMidiItems, m_pClient, |
new qsamplerDeviceItem(m_pMidiItems, m_pMainForm, |
304 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
qsamplerDevice::Midi, piDeviceIDs[i]); |
305 |
} |
} |
306 |
m_pMidiItems->setOpen(true); |
m_pMidiItems->setOpen(true); |
334 |
// Driver change is only valid for scratch devices... |
// Driver change is only valid for scratch devices... |
335 |
if (m_bNewDevice) { |
if (m_bNewDevice) { |
336 |
m_iDirtySetup++; |
m_iDirtySetup++; |
337 |
device.setDriver(m_pClient, sDriverName); |
device.setDriver(sDriverName); |
338 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
339 |
m_iDirtySetup--; |
m_iDirtySetup--; |
340 |
// Done. |
// Done. |
358 |
m_deviceType = qsamplerDevice::None; |
m_deviceType = qsamplerDevice::None; |
359 |
DeviceNameTextLabel->setText(QString::null); |
DeviceNameTextLabel->setText(QString::null); |
360 |
DeviceParamTable->setNumRows(0); |
DeviceParamTable->setNumRows(0); |
361 |
|
DevicePortComboBox->clear(); |
362 |
|
DevicePortParamTable->setNumRows(0); |
363 |
DevicePortComboBox->setEnabled(false); |
DevicePortComboBox->setEnabled(false); |
364 |
DevicePortParamTable->setEnabled(false); |
DevicePortParamTable->setEnabled(false); |
365 |
stabilizeForm(); |
stabilizeForm(); |
373 |
m_bNewDevice = (device.deviceID() < 0); |
m_bNewDevice = (device.deviceID() < 0); |
374 |
|
|
375 |
// Fill the device/driver heading... |
// Fill the device/driver heading... |
376 |
QString sPrefix; |
DeviceNameTextLabel->setText(device.deviceName()); |
|
if (!m_bNewDevice) |
|
|
sPrefix += device.deviceTypeName() + ' '; |
|
|
DeviceNameTextLabel->setText(sPrefix + device.deviceName()); |
|
377 |
// The driver combobox is only rebuilt if device type has changed... |
// The driver combobox is only rebuilt if device type has changed... |
378 |
if (device.deviceType() != m_deviceType) { |
if (device.deviceType() != m_deviceType) { |
379 |
DriverNameComboBox->clear(); |
DriverNameComboBox->clear(); |
383 |
} |
} |
384 |
// Do we need a driver name? |
// Do we need a driver name? |
385 |
if (m_bNewDevice || device.driverName().isEmpty()) |
if (m_bNewDevice || device.driverName().isEmpty()) |
386 |
device.setDriver(m_pClient, DriverNameComboBox->currentText()); |
device.setDriver(DriverNameComboBox->currentText()); |
387 |
const QString& sDriverName = device.driverName(); |
setDriverName(device.driverName()); |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
|
|
DriverNameComboBox->insertItem(sDriverName); |
|
|
DriverNameComboBox->setCurrentText(sDriverName); |
|
388 |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
389 |
DriverNameComboBox->setEnabled(m_bNewDevice); |
DriverNameComboBox->setEnabled(m_bNewDevice); |
390 |
// Fill the device parameter table... |
// Fill the device parameter table... |
399 |
QPixmap pixmap; |
QPixmap pixmap; |
400 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
401 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
402 |
pixmap = QPixmap::fromMimeSource("audio2.png"); |
pixmap = QPixmap::fromMimeSource("audio2.png"); |
403 |
break; |
break; |
404 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
405 |
pixmap = QPixmap::fromMimeSource("midi2.png"); |
pixmap = QPixmap::fromMimeSource("midi2.png"); |
406 |
break; |
break; |
407 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
408 |
break; |
break; |
409 |
} |
} |
410 |
qsamplerDevicePortList& ports = device.ports(); |
qsamplerDevicePortList& ports = device.ports(); |
411 |
qsamplerDevicePort *pPort; |
qsamplerDevicePort *pPort; |
412 |
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
413 |
DevicePortComboBox->insertItem(pixmap, |
DevicePortComboBox->insertItem(pixmap, device.deviceTypeName() |
414 |
device.deviceTypeName() + ' ' + pPort->portName()); |
+ ' ' + device.driverName() |
415 |
|
+ ' ' + pPort->portName()); |
416 |
} |
} |
417 |
bool bEnabled = (ports.count() > 0); |
bool bEnabled = (ports.count() > 0); |
418 |
DevicePortComboBox->setEnabled(bEnabled); |
DevicePortComboBox->setEnabled(bEnabled); |
420 |
} |
} |
421 |
// Done. |
// Done. |
422 |
m_iDirtySetup--; |
m_iDirtySetup--; |
423 |
|
|
424 |
// Make the device port/channel selection effective. |
// Make the device port/channel selection effective. |
425 |
selectDevicePort(DevicePortComboBox->currentItem()); |
selectDevicePort(DevicePortComboBox->currentItem()); |
426 |
} |
} |
455 |
// Device parameter value change slot. |
// Device parameter value change slot. |
456 |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
457 |
{ |
{ |
458 |
|
if (m_pMainForm == NULL) |
459 |
|
return; |
460 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
461 |
return; |
return; |
462 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
463 |
return; |
return; |
464 |
|
|
465 |
// |
// |
466 |
// Device parameter change... |
// Device parameter change... |
467 |
// |
// |
472 |
|
|
473 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
474 |
|
|
|
m_iDirtySetup++; |
|
475 |
// Table 1st column has the parameter name; |
// Table 1st column has the parameter name; |
476 |
const QString sParam = DeviceParamTable->text(iRow, 0); |
const QString sParam = DeviceParamTable->text(iRow, 0); |
477 |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
|
|
|
478 |
// Set the local device parameter value. |
// Set the local device parameter value. |
479 |
device.setParam(sParam, sValue); |
if (device.setParam(sParam, sValue)) { |
480 |
|
selectDevice(); |
481 |
// Set proper device parameter, on existing device ... |
} else { |
482 |
if (device.deviceID() >= 0) { |
stabilizeForm(); |
|
// Prepare parameter struct. |
|
|
lscp_param_t param; |
|
|
param.key = (char *) sParam.latin1(); |
|
|
param.value = (char *) sValue.latin1(); |
|
|
// Now it depends on the device type... |
|
|
bool bRefresh = false; |
|
|
lscp_status_t ret = LSCP_FAILED; |
|
|
switch (device.deviceType()) { |
|
|
case qsamplerDevice::Audio: |
|
|
bRefresh = (sParam == "CHANNELS"); |
|
|
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
|
|
device.deviceID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
|
|
break; |
|
|
case qsamplerDevice::Midi: |
|
|
bRefresh = (sParam == "PORTS"); |
|
|
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
|
|
device.deviceID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
|
|
break; |
|
|
case qsamplerDevice::None: |
|
|
break; |
|
|
} |
|
|
// Show result. |
|
|
if (ret == LSCP_OK) { |
|
|
m_pMainForm->appendMessages(device.deviceName() + ' ' |
|
|
+ QString("%1: %2.").arg(sParam).arg(sValue)); |
|
|
// Special care for specific parameter changes... |
|
|
if (bRefresh) |
|
|
device.refresh(m_pClient); |
|
|
} |
|
483 |
} |
} |
|
|
|
|
// Done. |
|
|
m_iDirtySetup--; |
|
|
stabilizeForm(); |
|
484 |
// Main session should be dirtier... |
// Main session should be dirtier... |
485 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
486 |
} |
} |
489 |
// Device port/channel parameter value change slot. |
// Device port/channel parameter value change slot. |
490 |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
491 |
{ |
{ |
492 |
|
if (m_pMainForm == NULL) |
493 |
|
return; |
494 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
495 |
return; |
return; |
496 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
509 |
int iPort = DevicePortComboBox->currentItem(); |
int iPort = DevicePortComboBox->currentItem(); |
510 |
qsamplerDevicePort *pPort = device.ports().at(iPort); |
qsamplerDevicePort *pPort = device.ports().at(iPort); |
511 |
if (pPort == NULL) |
if (pPort == NULL) |
512 |
return; |
return; |
513 |
|
|
|
m_iDirtySetup++; |
|
514 |
// Table 1st column has the parameter name; |
// Table 1st column has the parameter name; |
515 |
const QString sParam = DevicePortParamTable->text(iRow, 0); |
const QString sParam = DevicePortParamTable->text(iRow, 0); |
516 |
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
|
|
|
517 |
// Set the local device port/channel parameter value. |
// Set the local device port/channel parameter value. |
518 |
pPort->setParam(sParam, sValue); |
pPort->setParam(sParam, sValue); |
|
|
|
|
// Set proper device port/channel parameter, if any... |
|
|
if (device.deviceID() >= 0 && pPort->portID() >= 0) { |
|
|
// Prepare parameter struct. |
|
|
lscp_param_t param; |
|
|
param.key = (char *) sParam.latin1(); |
|
|
param.value = (char *) sValue.latin1(); |
|
|
// Now it depends on the device type... |
|
|
lscp_status_t ret = LSCP_FAILED; |
|
|
switch (device.deviceType()) { |
|
|
case qsamplerDevice::Audio: |
|
|
if ((ret = ::lscp_set_audio_channel_param(m_pClient, |
|
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_audio_channel_param"); |
|
|
break; |
|
|
case qsamplerDevice::Midi: |
|
|
if ((ret = ::lscp_set_midi_port_param(m_pClient, |
|
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_midi_port_param"); |
|
|
break; |
|
|
case qsamplerDevice::None: |
|
|
break; |
|
|
} |
|
|
// Show result. |
|
|
if (ret == LSCP_OK) { |
|
|
m_pMainForm->appendMessages(device.deviceName() + ' ' |
|
|
+ pPort->portName() + ' ' |
|
|
+ QString("%1: %2.").arg(sParam).arg(sValue)); |
|
|
} |
|
|
} |
|
|
|
|
519 |
// Done. |
// Done. |
|
m_iDirtySetup--; |
|
520 |
stabilizeForm(); |
stabilizeForm(); |
521 |
// Main session should be dirtier... |
// Main session should be dirtier... |
522 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
527 |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
528 |
{ |
{ |
529 |
int iItemID; |
int iItemID; |
530 |
|
|
531 |
// Build the device context menu... |
// Build the device context menu... |
532 |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
533 |
|
|
534 |
bool bClient = (m_pClient != NULL); |
bool bClient = (m_pClient != NULL); |
535 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
536 |
iItemID = pContextMenu->insertItem( |
iItemID = pContextMenu->insertItem( |
546 |
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
547 |
tr("&Refresh"), this, SLOT(refreshDevices())); |
tr("&Refresh"), this, SLOT(refreshDevices())); |
548 |
pContextMenu->setItemEnabled(iItemID, bClient); |
pContextMenu->setItemEnabled(iItemID, bClient); |
549 |
|
|
550 |
pContextMenu->exec(pos); |
pContextMenu->exec(pos); |
551 |
|
|
552 |
delete pContextMenu; |
delete pContextMenu; |
553 |
} |
} |
554 |
|
|
570 |
|
|
571 |
|
|
572 |
// end of qsamplerDeviceForm.ui.h |
// end of qsamplerDeviceForm.ui.h |
|
|
|
|
|
|
|
|
|