1 |
// qsamplerChannelForm.cpp |
// qsamplerChannelForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2016, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 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 |
58 |
|
|
59 |
m_pDeviceForm = NULL; |
m_pDeviceForm = NULL; |
60 |
|
|
61 |
int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4; |
const int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4; |
62 |
m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight); |
m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight); |
63 |
m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); |
m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); |
64 |
|
|
82 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
83 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
84 |
QObject::connect(m_ui.InstrumentFileComboBox, |
QObject::connect(m_ui.InstrumentFileComboBox, |
85 |
|
SIGNAL(editTextChanged(const QString&)), |
86 |
|
SLOT(updateInstrumentName())); |
87 |
|
QObject::connect(m_ui.InstrumentFileComboBox, |
88 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
89 |
SLOT(updateInstrumentName())); |
SLOT(updateInstrumentName())); |
90 |
QObject::connect(m_ui.InstrumentFileToolButton, |
QObject::connect(m_ui.InstrumentFileToolButton, |
126 |
QObject::connect(m_ui.AudioDeviceToolButton, |
QObject::connect(m_ui.AudioDeviceToolButton, |
127 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
128 |
SLOT(setupAudioDevice())); |
SLOT(setupAudioDevice())); |
129 |
|
|
130 |
QObject::connect(&m_routingModel, |
QObject::connect(&m_routingModel, |
131 |
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
132 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
183 |
|
|
184 |
// Load combo box history... |
// Load combo box history... |
185 |
pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox); |
pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox); |
186 |
|
// Remove non-existant instrument file-paths... |
187 |
|
int i = m_ui.InstrumentFileComboBox->count() - 1; |
188 |
|
while (i >= 0) { |
189 |
|
const QString& sInstrumentFile |
190 |
|
= m_ui.InstrumentFileComboBox->itemText(i); |
191 |
|
if (sInstrumentFile.isEmpty() |
192 |
|
|| !QFileInfo(sInstrumentFile).exists()) |
193 |
|
m_ui.InstrumentFileComboBox->removeItem(i); |
194 |
|
else --i; |
195 |
|
} |
196 |
|
|
197 |
// Populate Engines list. |
// Populate Engines list. |
198 |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
250 |
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
251 |
|
|
252 |
// MIDI input device... |
// MIDI input device... |
253 |
Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
const Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
254 |
// MIDI input driver... |
// MIDI input driver... |
255 |
QString sMidiDriver = midiDevice.driverName(); |
QString sMidiDriver = midiDevice.driverName(); |
256 |
if (sMidiDriver.isEmpty() || bNew) |
if (sMidiDriver.isEmpty() || bNew) |
292 |
sMapName); |
sMapName); |
293 |
} |
} |
294 |
// It might be no maps around... |
// It might be no maps around... |
295 |
bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0); |
const bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0); |
296 |
m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
297 |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
298 |
|
|
299 |
// Audio output device... |
// Audio output device... |
300 |
Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
const Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
301 |
// Audio output driver... |
// Audio output driver... |
302 |
QString sAudioDriver = audioDevice.driverName(); |
QString sAudioDriver = audioDevice.driverName(); |
303 |
if (sAudioDriver.isEmpty() || bNew) |
if (sAudioDriver.isEmpty() || bNew) |
333 |
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
334 |
); |
); |
335 |
|
|
336 |
|
#if 0 |
337 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
338 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
339 |
/* if (sEngineName != Channel::noEngineName() && |
if (sEngineName != Channel::noEngineName() && |
340 |
sInstrumentFile != Channel::noInstrumentName()) |
sInstrumentFile != Channel::noInstrumentName()) |
341 |
m_iDirtyCount++; */ |
m_iDirtyCount++; |
342 |
|
#endif |
343 |
|
|
344 |
// Done. |
// Done. |
345 |
m_iDirtySetup--; |
m_iDirtySetup--; |
346 |
stabilizeForm(); |
stabilizeForm(); |
378 |
iErrors++; |
iErrors++; |
379 |
} else { |
} else { |
380 |
Device *pDevice = NULL; |
Device *pDevice = NULL; |
381 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
382 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
383 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
384 |
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
402 |
iErrors++; |
iErrors++; |
403 |
} else { |
} else { |
404 |
Device *pDevice = NULL; |
Device *pDevice = NULL; |
405 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
406 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
407 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
408 |
if (pDevice == NULL) |
if (pDevice == NULL) |
587 |
const QString sDriverName = sMidiDriver.toUpper(); |
const QString sDriverName = sMidiDriver.toUpper(); |
588 |
|
|
589 |
// Save current device id. |
// Save current device id. |
|
// Save current device id. |
|
590 |
int iDeviceID = 0; |
int iDeviceID = 0; |
591 |
Device *pDevice = NULL; |
Device *pDevice = NULL; |
592 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
602 |
|
|
603 |
// Populate with the current ones... |
// Populate with the current ones... |
604 |
const QPixmap midiPixmap(":/images/midi2.png"); |
const QPixmap midiPixmap(":/images/midi2.png"); |
605 |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), Device::Midi); |
|
Device::Midi); |
|
606 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
607 |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
608 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
615 |
} |
} |
616 |
|
|
617 |
// Do proper enabling... |
// Do proper enabling... |
618 |
bool bEnabled = !m_midiDevices.isEmpty(); |
const bool bEnabled = !m_midiDevices.isEmpty(); |
619 |
if (bEnabled) { |
if (bEnabled) { |
620 |
// Select the previous current device... |
// Select the previous current device... |
621 |
iMidiItem = 0; |
iMidiItem = 0; |
657 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
658 |
if (pDevice) { |
if (pDevice) { |
659 |
const DeviceParamMap& params = pDevice->params(); |
const DeviceParamMap& params = pDevice->params(); |
660 |
int iPorts = params["PORTS"].value.toInt(); |
const int iPorts = params["PORTS"].value.toInt(); |
661 |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
662 |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
663 |
if (iPorts > 0) |
if (iPorts > 0) |
681 |
void ChannelForm::setupMidiDevice (void) |
void ChannelForm::setupMidiDevice (void) |
682 |
{ |
{ |
683 |
Device *pDevice = NULL; |
Device *pDevice = NULL; |
684 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
const int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
685 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
686 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
687 |
setupDevice(pDevice, |
setupDevice(pDevice, |
730 |
} |
} |
731 |
|
|
732 |
// Do proper enabling... |
// Do proper enabling... |
733 |
bool bEnabled = !m_audioDevices.isEmpty(); |
const bool bEnabled = !m_audioDevices.isEmpty(); |
734 |
if (bEnabled) { |
if (bEnabled) { |
735 |
// Select the previous current device... |
// Select the previous current device... |
736 |
iAudioItem = 0; |
iAudioItem = 0; |
796 |
void ChannelForm::setupAudioDevice (void) |
void ChannelForm::setupAudioDevice (void) |
797 |
{ |
{ |
798 |
Device *pDevice = NULL; |
Device *pDevice = NULL; |
799 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
const int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
800 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
801 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
802 |
setupDevice(pDevice, |
setupDevice(pDevice, |
829 |
// Stabilize current form state. |
// Stabilize current form state. |
830 |
void ChannelForm::stabilizeForm (void) |
void ChannelForm::stabilizeForm (void) |
831 |
{ |
{ |
832 |
const bool bValid = |
bool bValid = m_ui.EngineNameComboBox->currentIndex() >= 0 && |
833 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
m_ui.EngineNameComboBox->currentText() != Channel::noEngineName(); |
834 |
m_ui.EngineNameComboBox->currentText() |
|
835 |
!= Channel::noEngineName(); |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
|
#if 0 |
|
|
const QString& sPath = InstrumentFileComboBox->currentText(); |
|
836 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
837 |
#endif |
|
838 |
m_ui.DialogButtonBox->button( |
m_ui.DialogButtonBox->button( |
839 |
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
840 |
} |
} |