1 |
// qsamplerChannelForm.cpp |
// qsamplerChannelForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
38 |
|
|
39 |
namespace QSampler { |
namespace QSampler { |
40 |
|
|
41 |
|
//------------------------------------------------------------------------- |
42 |
|
// QSampler::Channelform -- Channel form implementation. |
43 |
|
// |
44 |
|
|
45 |
ChannelForm::ChannelForm ( QWidget* pParent ) |
ChannelForm::ChannelForm ( QWidget* pParent ) |
46 |
: QDialog(pParent) |
: QDialog(pParent) |
47 |
{ |
{ |
64 |
|
|
65 |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
66 |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
67 |
|
#if QT_VERSION < 0x050000 |
68 |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
69 |
|
#endif |
70 |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
71 |
|
|
72 |
// This goes initially hidden, and will be shown |
// This goes initially hidden, and will be shown |
109 |
QObject::connect(m_ui.AudioDeviceComboBox, |
QObject::connect(m_ui.AudioDeviceComboBox, |
110 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
111 |
SLOT(selectAudioDevice(int))); |
SLOT(selectAudioDevice(int))); |
112 |
QObject::connect(m_ui.OkPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
113 |
SIGNAL(clicked()), |
SIGNAL(accepted()), |
114 |
SLOT(accept())); |
SLOT(accept())); |
115 |
QObject::connect(m_ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
116 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
117 |
SLOT(reject())); |
SLOT(reject())); |
118 |
QObject::connect(m_ui.MidiDeviceToolButton, |
QObject::connect(m_ui.MidiDeviceToolButton, |
119 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
147 |
|
|
148 |
|
|
149 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
150 |
void ChannelForm::setup ( qsamplerChannel *pChannel ) |
void ChannelForm::setup ( Channel *pChannel ) |
151 |
{ |
{ |
152 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
153 |
|
|
158 |
return; |
return; |
159 |
|
|
160 |
// It can be a brand new channel, remember? |
// It can be a brand new channel, remember? |
161 |
bool bNew = (m_pChannel->channelID() < 0); |
const bool bNew = (m_pChannel->channelID() < 0); |
162 |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
163 |
|
|
164 |
// Check if we're up and connected. |
// Check if we're up and connected. |
168 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
169 |
return; |
return; |
170 |
|
|
171 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
172 |
if (pOptions == NULL) |
if (pOptions == NULL) |
173 |
return; |
return; |
174 |
|
|
190 |
// Populate Audio output type list. |
// Populate Audio output type list. |
191 |
m_ui.AudioDriverComboBox->clear(); |
m_ui.AudioDriverComboBox->clear(); |
192 |
m_ui.AudioDriverComboBox->insertItems(0, |
m_ui.AudioDriverComboBox->insertItems(0, |
193 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio)); |
Device::getDrivers(pMainForm->client(), Device::Audio)); |
194 |
|
|
195 |
// Populate MIDI input type list. |
// Populate MIDI input type list. |
196 |
m_ui.MidiDriverComboBox->clear(); |
m_ui.MidiDriverComboBox->clear(); |
197 |
m_ui.MidiDriverComboBox->insertItems(0, |
m_ui.MidiDriverComboBox->insertItems(0, |
198 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi)); |
Device::getDrivers(pMainForm->client(), Device::Midi)); |
199 |
|
|
200 |
// Populate Maps list. |
// Populate Maps list. |
201 |
m_ui.MidiMapComboBox->clear(); |
m_ui.MidiMapComboBox->clear(); |
202 |
m_ui.MidiMapComboBox->insertItems(0, |
m_ui.MidiMapComboBox->insertItems(0, |
203 |
qsamplerInstrument::getMapNames()); |
Instrument::getMapNames()); |
204 |
|
|
205 |
// Read proper channel information, |
// Read proper channel information, |
206 |
// and populate the channel form fields. |
// and populate the channel form fields. |
210 |
if (sEngineName.isEmpty() || bNew) |
if (sEngineName.isEmpty() || bNew) |
211 |
sEngineName = pOptions->sEngineName; |
sEngineName = pOptions->sEngineName; |
212 |
if (sEngineName.isEmpty()) |
if (sEngineName.isEmpty()) |
213 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = Channel::noEngineName(); |
214 |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
215 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
216 |
m_ui.EngineNameComboBox->addItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
222 |
// Instrument filename and index... |
// Instrument filename and index... |
223 |
QString sInstrumentFile = pChannel->instrumentFile(); |
QString sInstrumentFile = pChannel->instrumentFile(); |
224 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
225 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = Channel::noInstrumentName(); |
226 |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
227 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
228 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
229 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
230 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
231 |
int iInstrumentNr = pChannel->instrumentNr(); |
int iInstrumentNr = pChannel->instrumentNr(); |
232 |
if (iInstrumentNr < 0) |
if (iInstrumentNr < 0) |
234 |
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
235 |
|
|
236 |
// MIDI input device... |
// MIDI input device... |
237 |
qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice()); |
Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
238 |
// MIDI input driver... |
// MIDI input driver... |
239 |
QString sMidiDriver = midiDevice.driverName(); |
QString sMidiDriver = midiDevice.driverName(); |
240 |
if (sMidiDriver.isEmpty() || bNew) |
if (sMidiDriver.isEmpty() || bNew) |
244 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
245 |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
246 |
} |
} |
247 |
m_ui.MidiDriverComboBox->setItemText( |
m_ui.MidiDriverComboBox->setCurrentIndex( |
248 |
m_ui.MidiDriverComboBox->currentIndex(), |
m_ui.MidiDriverComboBox->findText(sMidiDriver, |
249 |
sMidiDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
250 |
|
); |
251 |
} |
} |
252 |
selectMidiDriverItem(sMidiDriver); |
selectMidiDriverItem(sMidiDriver); |
253 |
if (!bNew) { |
if (!bNew) { |
269 |
// When new, try to suggest a sensible MIDI map... |
// When new, try to suggest a sensible MIDI map... |
270 |
if (iMidiMap < 0) |
if (iMidiMap < 0) |
271 |
iMidiMap = 0; |
iMidiMap = 0; |
272 |
const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap); |
const QString& sMapName = Instrument::getMapName(iMidiMap); |
273 |
if (!sMapName.isEmpty()) { |
if (!sMapName.isEmpty()) { |
274 |
m_ui.MidiMapComboBox->setItemText( |
m_ui.MidiMapComboBox->setItemText( |
275 |
m_ui.MidiMapComboBox->currentIndex(), |
m_ui.MidiMapComboBox->currentIndex(), |
281 |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
282 |
|
|
283 |
// Audio output device... |
// Audio output device... |
284 |
qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice()); |
Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
285 |
// Audio output driver... |
// Audio output driver... |
286 |
QString sAudioDriver = audioDevice.driverName(); |
QString sAudioDriver = audioDevice.driverName(); |
287 |
if (sAudioDriver.isEmpty() || bNew) |
if (sAudioDriver.isEmpty() || bNew) |
291 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
292 |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
293 |
} |
} |
294 |
m_ui.AudioDriverComboBox->setItemText( |
m_ui.AudioDriverComboBox->setCurrentIndex( |
295 |
m_ui.AudioDriverComboBox->currentIndex(), |
m_ui.AudioDriverComboBox->findText(sAudioDriver, |
296 |
sAudioDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
297 |
|
); |
298 |
} |
} |
299 |
selectAudioDriverItem(sAudioDriver); |
selectAudioDriverItem(sAudioDriver); |
300 |
if (!bNew) { |
if (!bNew) { |
308 |
// if we're editing an existing sampler channel... |
// if we're editing an existing sampler channel... |
309 |
m_ui.AudioRoutingTable->setVisible(!bNew); |
m_ui.AudioRoutingTable->setVisible(!bNew); |
310 |
|
|
311 |
|
const QString sInstrumentNrToolTip = |
312 |
|
(pOptions->bInstrumentNames) ? |
313 |
|
"Select an instrument of the file" : |
314 |
|
"You might want to enable instrument name retrieval in the " |
315 |
|
"settings dialog"; |
316 |
|
m_ui.InstrumentNrComboBox->setToolTip( |
317 |
|
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
318 |
|
); |
319 |
|
|
320 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
321 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
322 |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
/* if (sEngineName != Channel::noEngineName() && |
323 |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
sInstrumentFile != Channel::noInstrumentName()) |
324 |
m_iDirtyCount++; */ |
m_iDirtyCount++; */ |
325 |
// Done. |
// Done. |
326 |
m_iDirtySetup--; |
m_iDirtySetup--; |
340 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
341 |
return; |
return; |
342 |
|
|
343 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
344 |
if (pOptions == NULL) |
if (pOptions == NULL) |
345 |
return; |
return; |
346 |
|
|
358 |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
359 |
iErrors++; |
iErrors++; |
360 |
} else { |
} else { |
361 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
362 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
363 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
364 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
365 |
qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap(); |
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
366 |
if (pDevice == NULL) |
if (pDevice == NULL) |
367 |
iErrors++; |
iErrors++; |
368 |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
369 |
iErrors++; |
iErrors++; |
370 |
else if (!routingMap.isEmpty()) { |
else if (!routingMap.isEmpty()) { |
371 |
// Set the audio route changes... |
// Set the audio route changes... |
372 |
qsamplerChannelRoutingMap::ConstIterator iter; |
ChannelRoutingMap::ConstIterator iter; |
373 |
for (iter = routingMap.begin(); |
for (iter = routingMap.begin(); |
374 |
iter != routingMap.end(); ++iter) { |
iter != routingMap.end(); ++iter) { |
375 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
382 |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
383 |
iErrors++; |
iErrors++; |
384 |
} else { |
} else { |
385 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
386 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
387 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
388 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
436 |
bool bReject = true; |
bool bReject = true; |
437 |
|
|
438 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
439 |
if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) { |
if (m_iDirtyCount > 0) { |
440 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
441 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
442 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
443 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
444 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
445 |
case 0: // Apply... |
QMessageBox::Discard | |
446 |
|
QMessageBox::Cancel)) { |
447 |
|
case QMessageBox::Apply: |
448 |
accept(); |
accept(); |
449 |
return; |
return; |
450 |
case 1: // Discard |
case QMessageBox::Discard: |
451 |
break; |
break; |
452 |
default: // Cancel. |
default: // Cancel. |
453 |
bReject = false; |
bReject = false; |
469 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
470 |
return; |
return; |
471 |
|
|
472 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
473 |
if (pOptions == NULL) |
if (pOptions == NULL) |
474 |
return; |
return; |
475 |
|
|
476 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
477 |
// depending on the current engine. |
// depending on the current engine. |
478 |
|
QStringList filters; |
479 |
|
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
480 |
|
if (sEngineName.contains("GIG")) |
481 |
|
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
482 |
|
if (sEngineName.contains("SFZ")) |
483 |
|
filters << tr("SFZ Instrument files") + " (*.sfz)"; |
484 |
|
if (sEngineName.contains("SF2")) |
485 |
|
filters << tr("SF2 Instrument files") + " (*.sf2)"; |
486 |
|
filters << tr("All files") + " (*.*)"; |
487 |
|
const QString& filter = filters.join(";;"); |
488 |
|
|
489 |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
490 |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
491 |
pOptions->sInstrumentDir, // Start here. |
pOptions->sInstrumentDir, // Start here. |
492 |
tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) |
filter // File filter. |
493 |
); |
); |
494 |
|
|
495 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
509 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
510 |
return; |
return; |
511 |
|
|
512 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
513 |
if (pOptions == NULL) |
if (pOptions == NULL) |
514 |
return; |
return; |
515 |
|
|
517 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
518 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
519 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
520 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
521 |
m_ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
522 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
523 |
); |
); |
527 |
|
|
528 |
|
|
529 |
// Show device options dialog. |
// Show device options dialog. |
530 |
void ChannelForm::setupDevice ( qsamplerDevice *pDevice, |
void ChannelForm::setupDevice ( Device *pDevice, |
531 |
qsamplerDevice::DeviceType deviceTypeMode, |
Device::DeviceType deviceTypeMode, |
532 |
const QString& sDriverName ) |
const QString& sDriverName ) |
533 |
{ |
{ |
|
if (pDevice == NULL) |
|
|
return; |
|
|
|
|
534 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
535 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
536 |
return; |
return; |
570 |
// Save current device id. |
// Save current device id. |
571 |
// Save current device id. |
// Save current device id. |
572 |
int iDeviceID = 0; |
int iDeviceID = 0; |
573 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
574 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
575 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
576 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
583 |
m_midiDevices.clear(); |
m_midiDevices.clear(); |
584 |
|
|
585 |
// Populate with the current ones... |
// Populate with the current ones... |
586 |
const QPixmap midiPixmap(":/icons/midi2.png"); |
const QPixmap midiPixmap(":/images/midi2.png"); |
587 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
588 |
qsamplerDevice::Midi); |
Device::Midi); |
589 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
590 |
pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]); |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
591 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
592 |
m_ui.MidiDeviceComboBox->insertItem(0, |
m_ui.MidiDeviceComboBox->insertItem(0, |
593 |
midiPixmap, pDevice->deviceName()); |
midiPixmap, pDevice->deviceName()); |
602 |
if (bEnabled) { |
if (bEnabled) { |
603 |
// Select the previous current device... |
// Select the previous current device... |
604 |
iMidiItem = 0; |
iMidiItem = 0; |
605 |
QListIterator<qsamplerDevice *> iter(m_midiDevices); |
QListIterator<Device *> iter(m_midiDevices); |
606 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
607 |
pDevice = iter.next(); |
pDevice = iter.next(); |
608 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
635 |
// Select MIDI device item. |
// Select MIDI device item. |
636 |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
637 |
{ |
{ |
638 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
639 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
640 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
641 |
if (pDevice) { |
if (pDevice) { |
642 |
const qsamplerDeviceParamMap& params = pDevice->params(); |
const DeviceParamMap& params = pDevice->params(); |
643 |
int iPorts = params["PORTS"].value.toInt(); |
int iPorts = params["PORTS"].value.toInt(); |
644 |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
645 |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
663 |
// MIDI device options. |
// MIDI device options. |
664 |
void ChannelForm::setupMidiDevice (void) |
void ChannelForm::setupMidiDevice (void) |
665 |
{ |
{ |
666 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
667 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
668 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
669 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
670 |
setupDevice(pDevice, |
setupDevice(pDevice, |
671 |
qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText()); |
Device::Midi, m_ui.MidiDriverComboBox->currentText()); |
672 |
} |
} |
673 |
|
|
674 |
|
|
685 |
|
|
686 |
// Save current device id. |
// Save current device id. |
687 |
int iDeviceID = 0; |
int iDeviceID = 0; |
688 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
689 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
690 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
691 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
698 |
m_audioDevices.clear(); |
m_audioDevices.clear(); |
699 |
|
|
700 |
// Populate with the current ones... |
// Populate with the current ones... |
701 |
const QPixmap audioPixmap(":/icons/audio2.png"); |
const QPixmap audioPixmap(":/images/audio2.png"); |
702 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
703 |
qsamplerDevice::Audio); |
Device::Audio); |
704 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
705 |
pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]); |
pDevice = new Device(Device::Audio, piDeviceIDs[i]); |
706 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
707 |
m_ui.AudioDeviceComboBox->insertItem(0, |
m_ui.AudioDeviceComboBox->insertItem(0, |
708 |
audioPixmap, pDevice->deviceName()); |
audioPixmap, pDevice->deviceName()); |
717 |
if (bEnabled) { |
if (bEnabled) { |
718 |
// Select the previous current device... |
// Select the previous current device... |
719 |
iAudioItem = 0; |
iAudioItem = 0; |
720 |
QListIterator<qsamplerDevice *> iter(m_audioDevices); |
QListIterator<Device *> iter(m_audioDevices); |
721 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
722 |
pDevice = iter.next(); |
pDevice = iter.next(); |
723 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
752 |
// Select Audio device item. |
// Select Audio device item. |
753 |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
754 |
{ |
{ |
755 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
756 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
757 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
758 |
if (pDevice) { |
if (pDevice) { |
778 |
// Audio device options. |
// Audio device options. |
779 |
void ChannelForm::setupAudioDevice (void) |
void ChannelForm::setupAudioDevice (void) |
780 |
{ |
{ |
781 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
782 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
783 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
784 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
785 |
setupDevice(pDevice, |
setupDevice(pDevice, |
786 |
qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText()); |
Device::Audio, m_ui.AudioDriverComboBox->currentText()); |
787 |
} |
} |
788 |
|
|
789 |
// UPdate all device lists slot. |
// UPdate all device lists slot. |
815 |
const bool bValid = |
const bool bValid = |
816 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
817 |
m_ui.EngineNameComboBox->currentText() |
m_ui.EngineNameComboBox->currentText() |
818 |
!= qsamplerChannel::noEngineName(); |
!= Channel::noEngineName(); |
819 |
#if 0 |
#if 0 |
820 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
821 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
822 |
#endif |
#endif |
823 |
m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
m_ui.DialogButtonBox->button( |
824 |
|
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
825 |
} |
} |
826 |
|
|
827 |
|
|