50 |
|
|
51 |
|
|
52 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
53 |
void qsamplerChannelForm::setup ( qsamplerChannel *pChannel, bool bNew ) |
void qsamplerChannelForm::setup ( qsamplerChannel *pChannel ) |
54 |
{ |
{ |
55 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
56 |
|
|
60 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
61 |
return; |
return; |
62 |
|
|
63 |
setCaption(tr("Channel %1").arg(m_pChannel->channelID())); |
// It can be a brand new channel, remember? |
64 |
|
bool bNew = (m_pChannel->channelID() < 0); |
65 |
|
setCaption(m_pChannel->channelName()); |
66 |
|
|
67 |
// Check if we're up and connected. |
// Check if we're up and connected. |
68 |
if (m_pChannel->client() == NULL) |
if (m_pChannel->client() == NULL) |
122 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
123 |
sInstrumentFile = tr("(No instrument)"); |
sInstrumentFile = tr("(No instrument)"); |
124 |
InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
125 |
InstrumentNrSpinBox->setValue(pChannel->instrumentNr()); |
InstrumentNrComboBox->clear(); |
126 |
|
InstrumentNrComboBox->insertStringList(qsamplerChannel::getInstrumentList(sInstrumentFile)); |
127 |
|
InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); |
128 |
// MIDI input driver... |
// MIDI input driver... |
129 |
QString sMidiDriver = pChannel->midiDriver(); |
QString sMidiDriver = pChannel->midiDriver(); |
130 |
if (sMidiDriver.isEmpty() && bNew) |
if (sMidiDriver.isEmpty() || bNew) |
131 |
sMidiDriver = pOptions->sMidiDriver; |
sMidiDriver = pOptions->sMidiDriver; |
132 |
if (!sMidiDriver.isEmpty()) { |
if (!sMidiDriver.isEmpty()) { |
133 |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
138 |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
139 |
// MIDI input channel... |
// MIDI input channel... |
140 |
int iMidiChannel = pChannel->midiChannel(); |
int iMidiChannel = pChannel->midiChannel(); |
141 |
if (bNew) |
// When new, try to suggest a sensible MIDI channel... |
142 |
iMidiChannel = (pChannel->channelID() + 1) % 16; |
if (iMidiChannel < 0) |
143 |
|
iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16); |
144 |
MidiChannelComboBox->setCurrentItem(iMidiChannel); |
MidiChannelComboBox->setCurrentItem(iMidiChannel); |
145 |
// Audio output driver... |
// Audio output driver... |
146 |
QString sAudioDriver = pChannel->audioDriver(); |
QString sAudioDriver = pChannel->audioDriver(); |
147 |
if (sAudioDriver.isEmpty() && bNew) |
if (sAudioDriver.isEmpty() || bNew) |
148 |
sAudioDriver = pOptions->sAudioDriver; |
sAudioDriver = pOptions->sAudioDriver; |
149 |
if (!sAudioDriver.isEmpty()) { |
if (!sAudioDriver.isEmpty()) { |
150 |
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
170 |
// We'll go for it! |
// We'll go for it! |
171 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
172 |
int iErrors = 0; |
int iErrors = 0; |
173 |
|
// Are we a new channel? |
174 |
|
if (!m_pChannel->addChannel()) |
175 |
|
iErrors++; |
176 |
// Audio output driver type... |
// Audio output driver type... |
177 |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
178 |
iErrors++; |
iErrors++; |
189 |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
190 |
iErrors++; |
iErrors++; |
191 |
// Instrument file and index... |
// Instrument file and index... |
192 |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value())) |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem())) |
193 |
iErrors++; |
iErrors++; |
194 |
// Show error messages? |
// Show error messages? |
195 |
if (iErrors > 0) |
if (iErrors > 0) |
260 |
// Refresh the actual instrument name. |
// Refresh the actual instrument name. |
261 |
void qsamplerChannelForm::updateInstrumentName (void) |
void qsamplerChannelForm::updateInstrumentName (void) |
262 |
{ |
{ |
263 |
// FIXME: A better idea would be to use libgig |
// Finally this better idea would be to use libgig |
264 |
// to retrieve the REAL instrument name. |
// to retrieve the REAL instrument names. |
265 |
InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName() |
InstrumentNrComboBox->clear(); |
266 |
+ " [" + QString::number(InstrumentNrSpinBox->value()) + "]"); |
InstrumentNrComboBox->insertStringList( |
267 |
|
qsamplerChannel::getInstrumentList(InstrumentFileComboBox->currentText()) |
268 |
|
); |
269 |
|
|
270 |
optionsChanged(); |
optionsChanged(); |
271 |
} |
} |