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 |
{ |
{ |
145 |
|
|
146 |
|
|
147 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
148 |
void ChannelForm::setup ( qsamplerChannel *pChannel ) |
void ChannelForm::setup ( Channel *pChannel ) |
149 |
{ |
{ |
150 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
151 |
|
|
166 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
167 |
return; |
return; |
168 |
|
|
169 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
170 |
if (pOptions == NULL) |
if (pOptions == NULL) |
171 |
return; |
return; |
172 |
|
|
188 |
// Populate Audio output type list. |
// Populate Audio output type list. |
189 |
m_ui.AudioDriverComboBox->clear(); |
m_ui.AudioDriverComboBox->clear(); |
190 |
m_ui.AudioDriverComboBox->insertItems(0, |
m_ui.AudioDriverComboBox->insertItems(0, |
191 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio)); |
Device::getDrivers(pMainForm->client(), Device::Audio)); |
192 |
|
|
193 |
// Populate MIDI input type list. |
// Populate MIDI input type list. |
194 |
m_ui.MidiDriverComboBox->clear(); |
m_ui.MidiDriverComboBox->clear(); |
195 |
m_ui.MidiDriverComboBox->insertItems(0, |
m_ui.MidiDriverComboBox->insertItems(0, |
196 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi)); |
Device::getDrivers(pMainForm->client(), Device::Midi)); |
197 |
|
|
198 |
// Populate Maps list. |
// Populate Maps list. |
199 |
m_ui.MidiMapComboBox->clear(); |
m_ui.MidiMapComboBox->clear(); |
200 |
m_ui.MidiMapComboBox->insertItems(0, |
m_ui.MidiMapComboBox->insertItems(0, |
201 |
qsamplerInstrument::getMapNames()); |
Instrument::getMapNames()); |
202 |
|
|
203 |
// Read proper channel information, |
// Read proper channel information, |
204 |
// and populate the channel form fields. |
// and populate the channel form fields. |
208 |
if (sEngineName.isEmpty() || bNew) |
if (sEngineName.isEmpty() || bNew) |
209 |
sEngineName = pOptions->sEngineName; |
sEngineName = pOptions->sEngineName; |
210 |
if (sEngineName.isEmpty()) |
if (sEngineName.isEmpty()) |
211 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = Channel::noEngineName(); |
212 |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
213 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
214 |
m_ui.EngineNameComboBox->addItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
220 |
// Instrument filename and index... |
// Instrument filename and index... |
221 |
QString sInstrumentFile = pChannel->instrumentFile(); |
QString sInstrumentFile = pChannel->instrumentFile(); |
222 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
223 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = Channel::noInstrumentName(); |
224 |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
225 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
226 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
227 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
228 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
229 |
int iInstrumentNr = pChannel->instrumentNr(); |
int iInstrumentNr = pChannel->instrumentNr(); |
230 |
if (iInstrumentNr < 0) |
if (iInstrumentNr < 0) |
232 |
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
233 |
|
|
234 |
// MIDI input device... |
// MIDI input device... |
235 |
qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice()); |
Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
236 |
// MIDI input driver... |
// MIDI input driver... |
237 |
QString sMidiDriver = midiDevice.driverName(); |
QString sMidiDriver = midiDevice.driverName(); |
238 |
if (sMidiDriver.isEmpty() || bNew) |
if (sMidiDriver.isEmpty() || bNew) |
266 |
// When new, try to suggest a sensible MIDI map... |
// When new, try to suggest a sensible MIDI map... |
267 |
if (iMidiMap < 0) |
if (iMidiMap < 0) |
268 |
iMidiMap = 0; |
iMidiMap = 0; |
269 |
const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap); |
const QString& sMapName = Instrument::getMapName(iMidiMap); |
270 |
if (!sMapName.isEmpty()) { |
if (!sMapName.isEmpty()) { |
271 |
m_ui.MidiMapComboBox->setItemText( |
m_ui.MidiMapComboBox->setItemText( |
272 |
m_ui.MidiMapComboBox->currentIndex(), |
m_ui.MidiMapComboBox->currentIndex(), |
278 |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
279 |
|
|
280 |
// Audio output device... |
// Audio output device... |
281 |
qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice()); |
Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
282 |
// Audio output driver... |
// Audio output driver... |
283 |
QString sAudioDriver = audioDevice.driverName(); |
QString sAudioDriver = audioDevice.driverName(); |
284 |
if (sAudioDriver.isEmpty() || bNew) |
if (sAudioDriver.isEmpty() || bNew) |
315 |
|
|
316 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
317 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
318 |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
/* if (sEngineName != Channel::noEngineName() && |
319 |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
sInstrumentFile != Channel::noInstrumentName()) |
320 |
m_iDirtyCount++; */ |
m_iDirtyCount++; */ |
321 |
// Done. |
// Done. |
322 |
m_iDirtySetup--; |
m_iDirtySetup--; |
336 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
337 |
return; |
return; |
338 |
|
|
339 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
340 |
if (pOptions == NULL) |
if (pOptions == NULL) |
341 |
return; |
return; |
342 |
|
|
354 |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
355 |
iErrors++; |
iErrors++; |
356 |
} else { |
} else { |
357 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
358 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
359 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
360 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
361 |
qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap(); |
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
362 |
if (pDevice == NULL) |
if (pDevice == NULL) |
363 |
iErrors++; |
iErrors++; |
364 |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
365 |
iErrors++; |
iErrors++; |
366 |
else if (!routingMap.isEmpty()) { |
else if (!routingMap.isEmpty()) { |
367 |
// Set the audio route changes... |
// Set the audio route changes... |
368 |
qsamplerChannelRoutingMap::ConstIterator iter; |
ChannelRoutingMap::ConstIterator iter; |
369 |
for (iter = routingMap.begin(); |
for (iter = routingMap.begin(); |
370 |
iter != routingMap.end(); ++iter) { |
iter != routingMap.end(); ++iter) { |
371 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
378 |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
379 |
iErrors++; |
iErrors++; |
380 |
} else { |
} else { |
381 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
382 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
383 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
384 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
463 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
464 |
return; |
return; |
465 |
|
|
466 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
467 |
if (pOptions == NULL) |
if (pOptions == NULL) |
468 |
return; |
return; |
469 |
|
|
492 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
493 |
return; |
return; |
494 |
|
|
495 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
496 |
if (pOptions == NULL) |
if (pOptions == NULL) |
497 |
return; |
return; |
498 |
|
|
500 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
501 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
502 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
503 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
504 |
m_ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
505 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
506 |
); |
); |
510 |
|
|
511 |
|
|
512 |
// Show device options dialog. |
// Show device options dialog. |
513 |
void ChannelForm::setupDevice ( qsamplerDevice *pDevice, |
void ChannelForm::setupDevice ( Device *pDevice, |
514 |
qsamplerDevice::DeviceType deviceTypeMode, |
Device::DeviceType deviceTypeMode, |
515 |
const QString& sDriverName ) |
const QString& sDriverName ) |
516 |
{ |
{ |
517 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
553 |
// Save current device id. |
// Save current device id. |
554 |
// Save current device id. |
// Save current device id. |
555 |
int iDeviceID = 0; |
int iDeviceID = 0; |
556 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
557 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
558 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
559 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
567 |
|
|
568 |
// Populate with the current ones... |
// Populate with the current ones... |
569 |
const QPixmap midiPixmap(":/icons/midi2.png"); |
const QPixmap midiPixmap(":/icons/midi2.png"); |
570 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
571 |
qsamplerDevice::Midi); |
Device::Midi); |
572 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
573 |
pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]); |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
574 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
575 |
m_ui.MidiDeviceComboBox->insertItem(0, |
m_ui.MidiDeviceComboBox->insertItem(0, |
576 |
midiPixmap, pDevice->deviceName()); |
midiPixmap, pDevice->deviceName()); |
585 |
if (bEnabled) { |
if (bEnabled) { |
586 |
// Select the previous current device... |
// Select the previous current device... |
587 |
iMidiItem = 0; |
iMidiItem = 0; |
588 |
QListIterator<qsamplerDevice *> iter(m_midiDevices); |
QListIterator<Device *> iter(m_midiDevices); |
589 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
590 |
pDevice = iter.next(); |
pDevice = iter.next(); |
591 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
618 |
// Select MIDI device item. |
// Select MIDI device item. |
619 |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
620 |
{ |
{ |
621 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
622 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
623 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
624 |
if (pDevice) { |
if (pDevice) { |
625 |
const qsamplerDeviceParamMap& params = pDevice->params(); |
const DeviceParamMap& params = pDevice->params(); |
626 |
int iPorts = params["PORTS"].value.toInt(); |
int iPorts = params["PORTS"].value.toInt(); |
627 |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
628 |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
646 |
// MIDI device options. |
// MIDI device options. |
647 |
void ChannelForm::setupMidiDevice (void) |
void ChannelForm::setupMidiDevice (void) |
648 |
{ |
{ |
649 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
650 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
651 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
652 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
653 |
setupDevice(pDevice, |
setupDevice(pDevice, |
654 |
qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText()); |
Device::Midi, m_ui.MidiDriverComboBox->currentText()); |
655 |
} |
} |
656 |
|
|
657 |
|
|
668 |
|
|
669 |
// Save current device id. |
// Save current device id. |
670 |
int iDeviceID = 0; |
int iDeviceID = 0; |
671 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
672 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
673 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
674 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
682 |
|
|
683 |
// Populate with the current ones... |
// Populate with the current ones... |
684 |
const QPixmap audioPixmap(":/icons/audio2.png"); |
const QPixmap audioPixmap(":/icons/audio2.png"); |
685 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
686 |
qsamplerDevice::Audio); |
Device::Audio); |
687 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
688 |
pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]); |
pDevice = new Device(Device::Audio, piDeviceIDs[i]); |
689 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
690 |
m_ui.AudioDeviceComboBox->insertItem(0, |
m_ui.AudioDeviceComboBox->insertItem(0, |
691 |
audioPixmap, pDevice->deviceName()); |
audioPixmap, pDevice->deviceName()); |
700 |
if (bEnabled) { |
if (bEnabled) { |
701 |
// Select the previous current device... |
// Select the previous current device... |
702 |
iAudioItem = 0; |
iAudioItem = 0; |
703 |
QListIterator<qsamplerDevice *> iter(m_audioDevices); |
QListIterator<Device *> iter(m_audioDevices); |
704 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
705 |
pDevice = iter.next(); |
pDevice = iter.next(); |
706 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
735 |
// Select Audio device item. |
// Select Audio device item. |
736 |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
737 |
{ |
{ |
738 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
739 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
740 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
741 |
if (pDevice) { |
if (pDevice) { |
761 |
// Audio device options. |
// Audio device options. |
762 |
void ChannelForm::setupAudioDevice (void) |
void ChannelForm::setupAudioDevice (void) |
763 |
{ |
{ |
764 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
765 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
766 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
767 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
768 |
setupDevice(pDevice, |
setupDevice(pDevice, |
769 |
qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText()); |
Device::Audio, m_ui.AudioDriverComboBox->currentText()); |
770 |
} |
} |
771 |
|
|
772 |
// UPdate all device lists slot. |
// UPdate all device lists slot. |
798 |
const bool bValid = |
const bool bValid = |
799 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
800 |
m_ui.EngineNameComboBox->currentText() |
m_ui.EngineNameComboBox->currentText() |
801 |
!= qsamplerChannel::noEngineName(); |
!= Channel::noEngineName(); |
802 |
#if 0 |
#if 0 |
803 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
804 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |