26 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
27 |
#include <qlistbox.h> |
#include <qlistbox.h> |
28 |
|
|
|
#include "qsamplerDevice.h" |
|
|
|
|
29 |
#include "config.h" |
#include "config.h" |
30 |
|
|
31 |
|
|
38 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
39 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
40 |
|
|
41 |
|
m_midiDevices.setAutoDelete(true); |
42 |
|
m_audioDevices.setAutoDelete(true); |
43 |
|
|
44 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
45 |
adjustSize(); |
adjustSize(); |
46 |
} |
} |
122 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
123 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
124 |
InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); |
InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); |
125 |
|
|
126 |
|
// MIDI input device... |
127 |
|
qsamplerDevice midiDevice(m_pChannel->mainForm(), |
128 |
|
qsamplerDevice::Midi, m_pChannel->midiDevice()); |
129 |
// MIDI input driver... |
// MIDI input driver... |
130 |
QString sMidiDriver = pChannel->midiDriver(); |
QString sMidiDriver = midiDevice.driverName(); |
131 |
if (sMidiDriver.isEmpty() || bNew) |
if (sMidiDriver.isEmpty() || bNew) |
132 |
sMidiDriver = pOptions->sMidiDriver; |
sMidiDriver = pOptions->sMidiDriver; |
133 |
if (!sMidiDriver.isEmpty()) { |
if (!sMidiDriver.isEmpty()) { |
134 |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
135 |
MidiDriverComboBox->insertItem(sMidiDriver); |
MidiDriverComboBox->insertItem(sMidiDriver); |
136 |
MidiDriverComboBox->setCurrentText(sMidiDriver); |
MidiDriverComboBox->setCurrentText(sMidiDriver); |
137 |
} |
} |
138 |
|
selectMidiDriver(sMidiDriver); |
139 |
|
if (!bNew) |
140 |
|
MidiDeviceComboBox->setCurrentText(midiDevice.deviceName()); |
141 |
|
selectMidiDevice(MidiDeviceComboBox->currentItem()); |
142 |
// MIDI input port... |
// MIDI input port... |
143 |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
144 |
// MIDI input channel... |
// MIDI input channel... |
147 |
if (iMidiChannel < 0) |
if (iMidiChannel < 0) |
148 |
iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16); |
iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16); |
149 |
MidiChannelComboBox->setCurrentItem(iMidiChannel); |
MidiChannelComboBox->setCurrentItem(iMidiChannel); |
150 |
// Audio output driver... |
|
151 |
QString sAudioDriver = pChannel->audioDriver(); |
// Audio output device... |
152 |
if (sAudioDriver.isEmpty() || bNew) |
qsamplerDevice audioDevice(m_pChannel->mainForm(), |
153 |
sAudioDriver = pOptions->sAudioDriver; |
qsamplerDevice::Audio, m_pChannel->audioDevice()); |
154 |
if (!sAudioDriver.isEmpty()) { |
// Audio output driver... |
155 |
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
QString sAudioDriver = audioDevice.driverName(); |
156 |
AudioDriverComboBox->insertItem(sAudioDriver); |
if (sAudioDriver.isEmpty() || bNew) |
157 |
AudioDriverComboBox->setCurrentText(sAudioDriver); |
sAudioDriver = pOptions->sAudioDriver; |
158 |
} |
if (!sAudioDriver.isEmpty()) { |
159 |
|
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
160 |
|
AudioDriverComboBox->insertItem(sAudioDriver); |
161 |
|
AudioDriverComboBox->setCurrentText(sAudioDriver); |
162 |
|
} |
163 |
|
selectAudioDriver(sAudioDriver); |
164 |
|
if (!bNew) |
165 |
|
AudioDeviceComboBox->setCurrentText(audioDevice.deviceName()); |
166 |
|
selectAudioDevice(AudioDeviceComboBox->currentItem()); |
167 |
|
|
168 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
169 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
170 |
if (sEngineName != qsamplerChannel::noEngineName() && |
if (sEngineName != qsamplerChannel::noEngineName() && |
171 |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
172 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
// FIXME: These are better leave diabled... |
|
|
MidiPortTextLabel->setEnabled(false); |
|
|
MidiPortSpinBox->setEnabled(false); |
|
173 |
// Done. |
// Done. |
174 |
m_iDirtySetup--; |
m_iDirtySetup--; |
175 |
stabilizeForm(); |
stabilizeForm(); |
192 |
// Are we a new channel? |
// Are we a new channel? |
193 |
if (!m_pChannel->addChannel()) |
if (!m_pChannel->addChannel()) |
194 |
iErrors++; |
iErrors++; |
195 |
// Audio output driver type... |
// Accept Audio driver or device selection... |
196 |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
if (m_audioDevices.isEmpty()) { |
197 |
iErrors++; |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
198 |
// MIDI input driver type... |
iErrors++; |
199 |
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
} else { |
200 |
iErrors++; |
qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem()); |
201 |
|
if (pDevice == NULL) |
202 |
|
iErrors++; |
203 |
|
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
204 |
|
iErrors++; |
205 |
|
} |
206 |
|
// Accept MIDI driver or device selection... |
207 |
|
if (m_midiDevices.isEmpty()) { |
208 |
|
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
209 |
|
iErrors++; |
210 |
|
} else { |
211 |
|
qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem()); |
212 |
|
if (pDevice == NULL) |
213 |
|
iErrors++; |
214 |
|
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
215 |
|
iErrors++; |
216 |
|
} |
217 |
// MIDI input port number... |
// MIDI input port number... |
218 |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
219 |
iErrors++; |
iErrors++; |
312 |
} |
} |
313 |
|
|
314 |
|
|
315 |
|
// Refresh MIDI device options. |
316 |
|
void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver ) |
317 |
|
{ |
318 |
|
const QString sDriverName = sMidiDriver.upper(); |
319 |
|
|
320 |
|
MidiDeviceComboBox->clear(); |
321 |
|
m_audioDevices.clear(); |
322 |
|
|
323 |
|
const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png"); |
324 |
|
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
325 |
|
qsamplerDevice::Midi); |
326 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
327 |
|
qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
328 |
|
qsamplerDevice::Midi, piDeviceIDs[i]); |
329 |
|
if (pDevice->driverName().upper() == sDriverName) { |
330 |
|
MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName()); |
331 |
|
m_midiDevices.append(pDevice); |
332 |
|
} else { |
333 |
|
delete pDevice; |
334 |
|
} |
335 |
|
} |
336 |
|
|
337 |
|
bool bEnabled = !m_midiDevices.isEmpty(); |
338 |
|
if (!bEnabled) |
339 |
|
MidiDeviceComboBox->insertItem(tr("(New MIDI device)")); |
340 |
|
MidiDeviceTextLabel->setEnabled(bEnabled); |
341 |
|
MidiDeviceComboBox->setEnabled(bEnabled); |
342 |
|
optionsChanged(); |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
// Select MIDI device options. |
347 |
|
void qsamplerChannelForm::selectMidiDevice ( int iMidiItem ) |
348 |
|
{ |
349 |
|
qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem); |
350 |
|
if (pDevice) { |
351 |
|
const qsamplerDeviceParamMap& params = pDevice->params(); |
352 |
|
int iPorts = params["PORTS"].value.toInt(); |
353 |
|
MidiPortTextLabel->setEnabled(iPorts > 0); |
354 |
|
MidiPortSpinBox->setEnabled(iPorts > 0); |
355 |
|
if (iPorts > 0) |
356 |
|
MidiPortSpinBox->setMaxValue(iPorts - 1); |
357 |
|
} |
358 |
|
optionsChanged(); |
359 |
|
} |
360 |
|
|
361 |
|
|
362 |
|
// Refresh Audio device options. |
363 |
|
void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver ) |
364 |
|
{ |
365 |
|
const QString sDriverName = sAudioDriver.upper(); |
366 |
|
|
367 |
|
AudioDeviceComboBox->clear(); |
368 |
|
m_audioDevices.clear(); |
369 |
|
|
370 |
|
const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png"); |
371 |
|
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
372 |
|
qsamplerDevice::Audio); |
373 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
374 |
|
qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
375 |
|
qsamplerDevice::Audio, piDeviceIDs[i]); |
376 |
|
if (pDevice->driverName().upper() == sDriverName) { |
377 |
|
AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName()); |
378 |
|
m_audioDevices.append(pDevice); |
379 |
|
} else { |
380 |
|
delete pDevice; |
381 |
|
} |
382 |
|
} |
383 |
|
|
384 |
|
bool bEnabled = !m_audioDevices.isEmpty(); |
385 |
|
if (!bEnabled) |
386 |
|
AudioDeviceComboBox->insertItem(tr("(New Audio device)")); |
387 |
|
AudioDeviceTextLabel->setEnabled(bEnabled); |
388 |
|
AudioDeviceComboBox->setEnabled(bEnabled); |
389 |
|
optionsChanged(); |
390 |
|
} |
391 |
|
|
392 |
|
|
393 |
|
// Select Audio device options. |
394 |
|
void qsamplerChannelForm::selectAudioDevice ( int iAudioItem ) |
395 |
|
{ |
396 |
|
qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem); |
397 |
|
if (pDevice) { |
398 |
|
// Is there anything to do here? |
399 |
|
} |
400 |
|
optionsChanged(); |
401 |
|
} |
402 |
|
|
403 |
|
|
404 |
// Dirty up settings. |
// Dirty up settings. |
405 |
void qsamplerChannelForm::optionsChanged (void) |
void qsamplerChannelForm::optionsChanged (void) |