53 |
|
|
54 |
|
|
55 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
56 |
void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel ) |
void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel, bool bNew ) |
57 |
{ |
{ |
58 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
59 |
|
|
87 |
EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
88 |
} |
} |
89 |
else m_pChannel->appendMessagesClient("lscp_get_available_engines"); |
else m_pChannel->appendMessagesClient("lscp_get_available_engines"); |
90 |
/* |
|
91 |
// Populate Audio output type list. |
// Populate Audio output type list. |
92 |
const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client()); |
const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client()); |
93 |
if (ppszAudioDrivers) { |
if (ppszAudioDrivers) { |
105 |
MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]); |
MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]); |
106 |
} |
} |
107 |
else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers"); |
else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers"); |
108 |
*/ |
|
109 |
// Read proper channel information, |
// Read proper channel information, |
110 |
// and populate the channel form fields. |
// and populate the channel form fields. |
111 |
|
|
112 |
// Engine name... |
// Engine name... |
113 |
const QString& sEngineName = pChannel->engineName(); |
QString sEngineName = pChannel->engineName(); |
114 |
if (!sEngineName.isEmpty()) { |
if (sEngineName.isEmpty() && bNew) |
115 |
if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL) |
sEngineName = pOptions->sEngineName; |
116 |
EngineNameComboBox->insertItem(sEngineName); |
if (sEngineName.isEmpty()) |
117 |
EngineNameComboBox->setCurrentText(sEngineName); |
sEngineName = tr("(No engine)"); |
118 |
} |
if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL) |
119 |
|
EngineNameComboBox->insertItem(sEngineName); |
120 |
|
EngineNameComboBox->setCurrentText(sEngineName); |
121 |
// Instrument filename and index... |
// Instrument filename and index... |
122 |
InstrumentFileComboBox->setCurrentText(pChannel->instrumentFile()); |
QString sInstrumentFile = pChannel->instrumentFile(); |
123 |
|
if (sInstrumentFile.isEmpty()) |
124 |
|
sInstrumentFile = tr("(No instrument)"); |
125 |
|
InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
126 |
InstrumentNrSpinBox->setValue(pChannel->instrumentNr()); |
InstrumentNrSpinBox->setValue(pChannel->instrumentNr()); |
127 |
// MIDI input... |
// MIDI input driver... |
128 |
const QString& sMidiDriver = pChannel->midiDriver(); |
QString sMidiDriver = pChannel->midiDriver(); |
129 |
|
if (sMidiDriver.isEmpty() && bNew) |
130 |
|
sMidiDriver = pOptions->sMidiDriver; |
131 |
if (!sMidiDriver.isEmpty()) { |
if (!sMidiDriver.isEmpty()) { |
132 |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
133 |
MidiDriverComboBox->insertItem(sMidiDriver); |
MidiDriverComboBox->insertItem(sMidiDriver); |
134 |
MidiDriverComboBox->setCurrentText(sMidiDriver); |
MidiDriverComboBox->setCurrentText(sMidiDriver); |
135 |
} |
} |
136 |
|
// MIDI input port... |
137 |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
138 |
MidiChannelSpinBox->setValue(pChannel->midiChannel()); |
// MIDI input channel... |
139 |
// Audio output... |
int iMidiChannel = pChannel->midiChannel(); |
140 |
const QString& sAudioDriver = pChannel->audioDriver(); |
if (bNew) |
141 |
|
iMidiChannel = (pChannel->channelID() + 1) % 16; |
142 |
|
MidiChannelComboBox->setCurrentItem(iMidiChannel); |
143 |
|
// Audio output driver... |
144 |
|
QString sAudioDriver = pChannel->audioDriver(); |
145 |
|
if (sAudioDriver.isEmpty() && bNew) |
146 |
|
sAudioDriver = pOptions->sAudioDriver; |
147 |
if (!sAudioDriver.isEmpty()) { |
if (!sAudioDriver.isEmpty()) { |
148 |
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
149 |
AudioDriverComboBox->insertItem(sAudioDriver); |
AudioDriverComboBox->insertItem(sAudioDriver); |
150 |
AudioDriverComboBox->setCurrentText(sAudioDriver); |
AudioDriverComboBox->setCurrentText(sAudioDriver); |
151 |
} |
} |
|
// FIXME: Disable this while we don't know what to do. |
|
|
MidiPortTextLabel->setEnabled(false); |
|
|
MidiPortSpinBox->setEnabled(false); |
|
152 |
// Done. |
// Done. |
153 |
m_iDirtySetup--; |
m_iDirtySetup--; |
154 |
stabilizeForm(); |
stabilizeForm(); |
168 |
// We'll go for it! |
// We'll go for it! |
169 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
170 |
int iErrors = 0; |
int iErrors = 0; |
171 |
// Engine name... |
// Audio output driver type... |
172 |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
173 |
iErrors++; |
iErrors++; |
174 |
// MIDI input driver type... |
// MIDI input driver type... |
175 |
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
178 |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
179 |
iErrors++; |
iErrors++; |
180 |
// MIDI input channel... |
// MIDI input channel... |
181 |
if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value())) |
if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem())) |
182 |
iErrors++; |
iErrors++; |
183 |
// Audio output driver type... |
// Engine name... |
184 |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
185 |
iErrors++; |
iErrors++; |
186 |
// Instrument file and index... |
// Instrument file and index... |
187 |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value())) |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value())) |
191 |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
192 |
} |
} |
193 |
|
|
194 |
// Save default instrument directory and history... |
// Save default engine name, instrument directory and history... |
195 |
pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true); |
pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true); |
196 |
|
pOptions->sEngineName = EngineNameComboBox->currentText(); |
197 |
|
pOptions->sAudioDriver = AudioDriverComboBox->currentText(); |
198 |
|
pOptions->sMidiDriver = MidiDriverComboBox->currentText(); |
199 |
pOptions->saveComboBoxHistory(InstrumentFileComboBox); |
pOptions->saveComboBoxHistory(InstrumentFileComboBox); |
200 |
|
|
201 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |
209 |
bool bReject = true; |
bool bReject = true; |
210 |
|
|
211 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
212 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) { |
213 |
switch (QMessageBox::warning(this, tr("Warning"), |
switch (QMessageBox::warning(this, tr("Warning"), |
214 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
215 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
279 |
// Stabilize current form state. |
// Stabilize current form state. |
280 |
void qsamplerChannelForm::stabilizeForm (void) |
void qsamplerChannelForm::stabilizeForm (void) |
281 |
{ |
{ |
282 |
const QString sFilename = InstrumentFileComboBox->currentText(); |
const QString& sFilename = InstrumentFileComboBox->currentText(); |
283 |
OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists()); |
OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists()); |
284 |
} |
} |
285 |
|
|