2 |
// |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
/**************************************************************************** |
5 |
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
26 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
27 |
#include <qlistbox.h> |
#include <qlistbox.h> |
28 |
|
|
29 |
#include "qsamplerOptions.h" |
#include "qsamplerDeviceForm.h" |
|
#include "qsamplerChannelStrip.h" |
|
30 |
|
|
31 |
#include "config.h" |
#include "config.h" |
32 |
|
|
40 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
41 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
42 |
|
|
43 |
|
m_midiDevices.setAutoDelete(true); |
44 |
|
m_audioDevices.setAutoDelete(true); |
45 |
|
|
46 |
|
m_pDeviceForm = NULL; |
47 |
|
|
48 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
49 |
adjustSize(); |
adjustSize(); |
50 |
} |
} |
53 |
// Kind of destructor. |
// Kind of destructor. |
54 |
void qsamplerChannelForm::destroy (void) |
void qsamplerChannelForm::destroy (void) |
55 |
{ |
{ |
56 |
|
if (m_pDeviceForm) |
57 |
|
delete m_pDeviceForm; |
58 |
|
m_pDeviceForm = NULL; |
59 |
} |
} |
60 |
|
|
61 |
|
|
62 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
63 |
void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel ) |
void qsamplerChannelForm::setup ( qsamplerChannel *pChannel ) |
64 |
{ |
{ |
65 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
66 |
|
|
70 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
71 |
return; |
return; |
72 |
|
|
73 |
setCaption(m_pChannel->caption()); |
// It can be a brand new channel, remember? |
74 |
|
bool bNew = (m_pChannel->channelID() < 0); |
75 |
|
setCaption(m_pChannel->channelName()); |
76 |
|
|
77 |
// Check if we're up and connected. |
// Check if we're up and connected. |
78 |
if (m_pChannel->client() == NULL) |
if (m_pChannel->client() == NULL) |
96 |
EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
97 |
} |
} |
98 |
else m_pChannel->appendMessagesClient("lscp_get_available_engines"); |
else m_pChannel->appendMessagesClient("lscp_get_available_engines"); |
99 |
/* |
|
100 |
// Populate Audio output type list. |
// Populate Audio output type list. |
101 |
const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client()); |
AudioDriverComboBox->clear(); |
102 |
if (ppszAudioDrivers) { |
AudioDriverComboBox->insertStringList( |
103 |
AudioDriverComboBox->clear(); |
qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio)); |
|
for (int iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++) |
|
|
AudioDriverComboBox->insertItem(ppszAudioDrivers[iAudioDriver]); |
|
|
} |
|
|
else m_pChannel->appendMessagesClient("lscp_get_available_audio_drivers"); |
|
104 |
|
|
105 |
// Populate MIDI input type list. |
// Populate MIDI input type list. |
106 |
const char **ppszMidiDrivers = ::lscp_get_available_midi_drivers(m_pChannel->client()); |
MidiDriverComboBox->clear(); |
107 |
if (ppszMidiDrivers) { |
MidiDriverComboBox->insertStringList( |
108 |
MidiDriverComboBox->clear(); |
qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi)); |
109 |
for (int iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++) |
|
|
MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]); |
|
|
} |
|
|
else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers"); |
|
|
*/ |
|
110 |
// Read proper channel information, |
// Read proper channel information, |
111 |
// and populate the channel form fields. |
// and populate the channel form fields. |
112 |
|
|
113 |
// Engine name... |
// Engine name... |
114 |
const QString& sEngineName = pChannel->engineName(); |
QString sEngineName = pChannel->engineName(); |
115 |
if (!sEngineName.isEmpty()) { |
if (sEngineName.isEmpty() || bNew) |
116 |
if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL) |
sEngineName = pOptions->sEngineName; |
117 |
EngineNameComboBox->insertItem(sEngineName); |
if (sEngineName.isEmpty()) |
118 |
EngineNameComboBox->setCurrentText(sEngineName); |
sEngineName = qsamplerChannel::noEngineName(); |
119 |
} |
if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL) |
120 |
|
EngineNameComboBox->insertItem(sEngineName); |
121 |
|
EngineNameComboBox->setCurrentText(sEngineName); |
122 |
// Instrument filename and index... |
// Instrument filename and index... |
123 |
InstrumentFileComboBox->setCurrentText(pChannel->instrumentFile()); |
QString sInstrumentFile = pChannel->instrumentFile(); |
124 |
InstrumentNrSpinBox->setValue(pChannel->instrumentNr()); |
if (sInstrumentFile.isEmpty()) |
125 |
// MIDI input... |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
126 |
const QString& sMidiDriver = pChannel->midiDriver(); |
InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
127 |
if (!sMidiDriver.isEmpty()) { |
InstrumentNrComboBox->clear(); |
128 |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
InstrumentNrComboBox->insertStringList( |
129 |
MidiDriverComboBox->insertItem(sMidiDriver); |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
130 |
MidiDriverComboBox->setCurrentText(sMidiDriver); |
pOptions->bInstrumentNames)); |
131 |
} |
InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); |
132 |
|
|
133 |
|
// MIDI input device... |
134 |
|
qsamplerDevice midiDevice(m_pChannel->mainForm(), |
135 |
|
qsamplerDevice::Midi, m_pChannel->midiDevice()); |
136 |
|
// MIDI input driver... |
137 |
|
QString sMidiDriver = midiDevice.driverName(); |
138 |
|
if (sMidiDriver.isEmpty() || bNew) |
139 |
|
sMidiDriver = pOptions->sMidiDriver; |
140 |
|
if (!sMidiDriver.isEmpty()) { |
141 |
|
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) |
142 |
|
MidiDriverComboBox->insertItem(sMidiDriver); |
143 |
|
MidiDriverComboBox->setCurrentText(sMidiDriver); |
144 |
|
} |
145 |
|
selectMidiDriverItem(sMidiDriver); |
146 |
|
if (!bNew) |
147 |
|
MidiDeviceComboBox->setCurrentText(midiDevice.deviceName()); |
148 |
|
selectMidiDeviceItem(MidiDeviceComboBox->currentItem()); |
149 |
|
// MIDI input port... |
150 |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
151 |
MidiChannelSpinBox->setValue(pChannel->midiChannel()); |
// MIDI input channel... |
152 |
// Audio output... |
int iMidiChannel = pChannel->midiChannel(); |
153 |
const QString& sAudioDriver = pChannel->audioDriver(); |
// When new, try to suggest a sensible MIDI channel... |
154 |
if (!sAudioDriver.isEmpty()) { |
if (iMidiChannel < 0) |
155 |
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16); |
156 |
AudioDriverComboBox->insertItem(sAudioDriver); |
MidiChannelComboBox->setCurrentItem(iMidiChannel); |
157 |
AudioDriverComboBox->setCurrentText(sAudioDriver); |
|
158 |
} |
// Audio output device... |
159 |
// FIXME: Disable this while we don't know what to do. |
qsamplerDevice audioDevice(m_pChannel->mainForm(), |
160 |
MidiPortTextLabel->setEnabled(false); |
qsamplerDevice::Audio, m_pChannel->audioDevice()); |
161 |
MidiPortSpinBox->setEnabled(false); |
// Audio output driver... |
162 |
|
QString sAudioDriver = audioDevice.driverName(); |
163 |
|
if (sAudioDriver.isEmpty() || bNew) |
164 |
|
sAudioDriver = pOptions->sAudioDriver; |
165 |
|
if (!sAudioDriver.isEmpty()) { |
166 |
|
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) |
167 |
|
AudioDriverComboBox->insertItem(sAudioDriver); |
168 |
|
AudioDriverComboBox->setCurrentText(sAudioDriver); |
169 |
|
} |
170 |
|
selectAudioDriverItem(sAudioDriver); |
171 |
|
if (!bNew) |
172 |
|
AudioDeviceComboBox->setCurrentText(audioDevice.deviceName()); |
173 |
|
selectAudioDeviceItem(AudioDeviceComboBox->currentItem()); |
174 |
|
|
175 |
|
// As convenient, make it ready on stabilizeForm() for |
176 |
|
// prompt acceptance, if we got the minimum required... |
177 |
|
if (sEngineName != qsamplerChannel::noEngineName() && |
178 |
|
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
179 |
|
m_iDirtyCount++; |
180 |
// Done. |
// Done. |
181 |
m_iDirtySetup--; |
m_iDirtySetup--; |
182 |
stabilizeForm(); |
stabilizeForm(); |
196 |
// We'll go for it! |
// We'll go for it! |
197 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
198 |
int iErrors = 0; |
int iErrors = 0; |
199 |
// Engine name... |
// Are we a new channel? |
200 |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
if (!m_pChannel->addChannel()) |
|
iErrors++; |
|
|
// MIDI input driver type... |
|
|
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
|
201 |
iErrors++; |
iErrors++; |
202 |
|
// Accept Audio driver or device selection... |
203 |
|
if (m_audioDevices.isEmpty()) { |
204 |
|
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
205 |
|
iErrors++; |
206 |
|
} else { |
207 |
|
qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem()); |
208 |
|
if (pDevice == NULL) |
209 |
|
iErrors++; |
210 |
|
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
211 |
|
iErrors++; |
212 |
|
} |
213 |
|
// Accept MIDI driver or device selection... |
214 |
|
if (m_midiDevices.isEmpty()) { |
215 |
|
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
216 |
|
iErrors++; |
217 |
|
} else { |
218 |
|
qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem()); |
219 |
|
if (pDevice == NULL) |
220 |
|
iErrors++; |
221 |
|
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
222 |
|
iErrors++; |
223 |
|
} |
224 |
// MIDI input port number... |
// MIDI input port number... |
225 |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
226 |
iErrors++; |
iErrors++; |
227 |
// MIDI input channel... |
// MIDI input channel... |
228 |
if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value())) |
if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem())) |
229 |
iErrors++; |
iErrors++; |
230 |
// Audio output driver type... |
// Engine name... |
231 |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
232 |
iErrors++; |
iErrors++; |
233 |
// Instrument file and index... |
// Instrument file and index... |
234 |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value())) |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem())) |
235 |
iErrors++; |
iErrors++; |
236 |
// Show error messages? |
// Show error messages? |
237 |
if (iErrors > 0) |
if (iErrors > 0) |
238 |
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.")); |
239 |
} |
} |
240 |
|
|
241 |
// Save default instrument directory and history... |
// Save default engine name, instrument directory and history... |
242 |
pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true); |
pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true); |
243 |
|
pOptions->sEngineName = EngineNameComboBox->currentText(); |
244 |
|
pOptions->sAudioDriver = AudioDriverComboBox->currentText(); |
245 |
|
pOptions->sMidiDriver = MidiDriverComboBox->currentText(); |
246 |
pOptions->saveComboBoxHistory(InstrumentFileComboBox); |
pOptions->saveComboBoxHistory(InstrumentFileComboBox); |
247 |
|
|
248 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |
256 |
bool bReject = true; |
bool bReject = true; |
257 |
|
|
258 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
259 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) { |
260 |
switch (QMessageBox::warning(this, tr("Warning"), |
switch (QMessageBox::warning(this, tr("Warning"), |
261 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
262 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
302 |
// Refresh the actual instrument name. |
// Refresh the actual instrument name. |
303 |
void qsamplerChannelForm::updateInstrumentName (void) |
void qsamplerChannelForm::updateInstrumentName (void) |
304 |
{ |
{ |
305 |
// FIXME: A better idea would be to use libgig |
qsamplerOptions *pOptions = m_pChannel->options(); |
306 |
// to retrieve the REAL instrument name. |
if (pOptions == NULL) |
307 |
InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName() |
return; |
308 |
+ " [" + QString::number(InstrumentNrSpinBox->value()) + "]"); |
|
309 |
|
// Finally this better idea would be to use libgig |
310 |
|
// to retrieve the REAL instrument names. |
311 |
|
InstrumentNrComboBox->clear(); |
312 |
|
InstrumentNrComboBox->insertStringList( |
313 |
|
qsamplerChannel::getInstrumentList( |
314 |
|
InstrumentFileComboBox->currentText(), |
315 |
|
pOptions->bInstrumentNames) |
316 |
|
); |
317 |
|
|
318 |
optionsChanged(); |
optionsChanged(); |
319 |
} |
} |
320 |
|
|
321 |
|
// Show device options dialog. |
322 |
|
void qsamplerChannelForm::setupDevice ( qsamplerDevice *pDevice ) |
323 |
|
{ |
324 |
|
// Create the device form if not already... |
325 |
|
if (m_pDeviceForm == NULL) { |
326 |
|
m_pDeviceForm = new qsamplerDeviceForm(this, 0, |
327 |
|
WType_Dialog | WShowModal); |
328 |
|
m_pDeviceForm->setMainForm(m_pChannel->mainForm()); |
329 |
|
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
330 |
|
this, SLOT(updateDevices())); |
331 |
|
} |
332 |
|
|
333 |
|
// Refresh the device form with selected data. |
334 |
|
if (m_pDeviceForm) { |
335 |
|
m_pDeviceForm->setClient(m_pChannel->client()); // <-- refreshDevices(). |
336 |
|
if (pDevice) |
337 |
|
m_pDeviceForm->setDevice(pDevice->deviceType(), pDevice->deviceID()); |
338 |
|
m_pDeviceForm->show(); |
339 |
|
} |
340 |
|
} |
341 |
|
|
342 |
|
|
343 |
|
// Refresh MIDI driver item devices. |
344 |
|
void qsamplerChannelForm::selectMidiDriverItem ( const QString& sMidiDriver ) |
345 |
|
{ |
346 |
|
const QString sDriverName = sMidiDriver.upper(); |
347 |
|
|
348 |
|
// Save current device id. |
349 |
|
int iDeviceID = -1; |
350 |
|
qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem()); |
351 |
|
if (pDevice) |
352 |
|
iDeviceID = pDevice->deviceID(); |
353 |
|
|
354 |
|
// Clean maplist. |
355 |
|
MidiDeviceComboBox->clear(); |
356 |
|
m_midiDevices.clear(); |
357 |
|
|
358 |
|
// Populate with the current ones... |
359 |
|
const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png"); |
360 |
|
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
361 |
|
qsamplerDevice::Midi); |
362 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
363 |
|
pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
364 |
|
qsamplerDevice::Midi, piDeviceIDs[i]); |
365 |
|
if (pDevice->driverName().upper() == sDriverName) { |
366 |
|
MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName()); |
367 |
|
m_midiDevices.append(pDevice); |
368 |
|
} else { |
369 |
|
delete pDevice; |
370 |
|
} |
371 |
|
} |
372 |
|
|
373 |
|
// Do proper enabling... |
374 |
|
bool bEnabled = !m_midiDevices.isEmpty(); |
375 |
|
if (!bEnabled) |
376 |
|
MidiDeviceComboBox->insertItem(tr("(New MIDI device)")); |
377 |
|
else if (iDeviceID >= 0) { |
378 |
|
// Select the previous current device... |
379 |
|
int iMidiItem = 0; |
380 |
|
for (pDevice = m_midiDevices.first(); |
381 |
|
pDevice; |
382 |
|
pDevice = m_midiDevices.next()) { |
383 |
|
if (pDevice->deviceID() == iDeviceID) { |
384 |
|
MidiDeviceComboBox->setCurrentItem(iMidiItem); |
385 |
|
// selectMidiDeviceItem(iMidiItem); |
386 |
|
break; |
387 |
|
} |
388 |
|
iMidiItem++; |
389 |
|
} |
390 |
|
} |
391 |
|
MidiDeviceTextLabel->setEnabled(bEnabled); |
392 |
|
MidiDeviceComboBox->setEnabled(bEnabled); |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
|
// Refresh MIDI device options slot. |
397 |
|
void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver ) |
398 |
|
{ |
399 |
|
if (m_iDirtySetup > 0) |
400 |
|
return; |
401 |
|
|
402 |
|
selectMidiDriverItem(sMidiDriver); |
403 |
|
optionsChanged(); |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
// Select MIDI device item. |
408 |
|
void qsamplerChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
409 |
|
{ |
410 |
|
qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem); |
411 |
|
if (pDevice) { |
412 |
|
const qsamplerDeviceParamMap& params = pDevice->params(); |
413 |
|
int iPorts = params["PORTS"].value.toInt(); |
414 |
|
MidiPortTextLabel->setEnabled(iPorts > 0); |
415 |
|
MidiPortSpinBox->setEnabled(iPorts > 0); |
416 |
|
if (iPorts > 0) |
417 |
|
MidiPortSpinBox->setMaxValue(iPorts - 1); |
418 |
|
} |
419 |
|
} |
420 |
|
|
421 |
|
|
422 |
|
// Select MIDI device options slot. |
423 |
|
void qsamplerChannelForm::selectMidiDevice ( int iMidiItem ) |
424 |
|
{ |
425 |
|
if (m_iDirtySetup > 0) |
426 |
|
return; |
427 |
|
|
428 |
|
selectMidiDeviceItem(iMidiItem); |
429 |
|
optionsChanged(); |
430 |
|
} |
431 |
|
|
432 |
|
|
433 |
|
// MIDI device options. |
434 |
|
void qsamplerChannelForm::setupMidiDevice (void) |
435 |
|
{ |
436 |
|
setupDevice(m_midiDevices.at(MidiDeviceComboBox->currentItem())); |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
|
// Refresh Audio driver item devices. |
441 |
|
void qsamplerChannelForm::selectAudioDriverItem ( const QString& sAudioDriver ) |
442 |
|
{ |
443 |
|
const QString sDriverName = sAudioDriver.upper(); |
444 |
|
|
445 |
|
// Save current device id. |
446 |
|
int iDeviceID = -1; |
447 |
|
qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem()); |
448 |
|
if (pDevice) |
449 |
|
iDeviceID = pDevice->deviceID(); |
450 |
|
|
451 |
|
// Clean maplist. |
452 |
|
AudioDeviceComboBox->clear(); |
453 |
|
m_audioDevices.clear(); |
454 |
|
|
455 |
|
// Populate with the current ones... |
456 |
|
const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png"); |
457 |
|
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
458 |
|
qsamplerDevice::Audio); |
459 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
460 |
|
pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
461 |
|
qsamplerDevice::Audio, piDeviceIDs[i]); |
462 |
|
if (pDevice->driverName().upper() == sDriverName) { |
463 |
|
AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName()); |
464 |
|
m_audioDevices.append(pDevice); |
465 |
|
} else { |
466 |
|
delete pDevice; |
467 |
|
} |
468 |
|
} |
469 |
|
|
470 |
|
// Do proper enabling... |
471 |
|
bool bEnabled = !m_audioDevices.isEmpty(); |
472 |
|
if (!bEnabled) |
473 |
|
AudioDeviceComboBox->insertItem(tr("(New Audio device)")); |
474 |
|
else if (iDeviceID >= 0) { |
475 |
|
// Select the previous current device... |
476 |
|
int iAudioItem = 0; |
477 |
|
for (pDevice = m_audioDevices.first(); |
478 |
|
pDevice; |
479 |
|
pDevice = m_audioDevices.next()) { |
480 |
|
if (pDevice->deviceID() == iDeviceID) { |
481 |
|
AudioDeviceComboBox->setCurrentItem(iAudioItem); |
482 |
|
// selectAudioDeviceItem(iAudioItem); |
483 |
|
break; |
484 |
|
} |
485 |
|
iAudioItem++; |
486 |
|
} |
487 |
|
} |
488 |
|
AudioDeviceTextLabel->setEnabled(bEnabled); |
489 |
|
AudioDeviceComboBox->setEnabled(bEnabled); |
490 |
|
} |
491 |
|
|
492 |
|
|
493 |
|
// Refresh Audio device options slot. |
494 |
|
void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver ) |
495 |
|
{ |
496 |
|
if (m_iDirtySetup > 0) |
497 |
|
return; |
498 |
|
|
499 |
|
selectAudioDriverItem(sAudioDriver); |
500 |
|
optionsChanged(); |
501 |
|
} |
502 |
|
|
503 |
|
|
504 |
|
// Select Audio device item. |
505 |
|
void qsamplerChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
506 |
|
{ |
507 |
|
qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem); |
508 |
|
if (pDevice) { |
509 |
|
// Is there anything to do here? |
510 |
|
} |
511 |
|
} |
512 |
|
|
513 |
|
|
514 |
|
// Select Audio device options slot. |
515 |
|
void qsamplerChannelForm::selectAudioDevice ( int iAudioItem ) |
516 |
|
{ |
517 |
|
if (m_iDirtySetup > 0) |
518 |
|
return; |
519 |
|
|
520 |
|
selectAudioDeviceItem(iAudioItem); |
521 |
|
optionsChanged(); |
522 |
|
} |
523 |
|
|
524 |
|
|
525 |
|
// Audio device options. |
526 |
|
void qsamplerChannelForm::setupAudioDevice (void) |
527 |
|
{ |
528 |
|
setupDevice(m_audioDevices.at(AudioDeviceComboBox->currentItem())); |
529 |
|
} |
530 |
|
|
531 |
|
|
532 |
|
// UPdate all device lists slot. |
533 |
|
void qsamplerChannelForm::updateDevices (void) |
534 |
|
{ |
535 |
|
if (m_iDirtySetup > 0) |
536 |
|
return; |
537 |
|
|
538 |
|
selectMidiDriverItem(MidiDriverComboBox->currentText()); |
539 |
|
selectAudioDriverItem(AudioDriverComboBox->currentText()); |
540 |
|
optionsChanged(); |
541 |
|
} |
542 |
|
|
543 |
|
|
544 |
// Dirty up settings. |
// Dirty up settings. |
555 |
// Stabilize current form state. |
// Stabilize current form state. |
556 |
void qsamplerChannelForm::stabilizeForm (void) |
void qsamplerChannelForm::stabilizeForm (void) |
557 |
{ |
{ |
558 |
const QString sFilename = InstrumentFileComboBox->currentText(); |
const QString& sFilename = InstrumentFileComboBox->currentText(); |
559 |
OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists()); |
OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists()); |
560 |
} |
} |
561 |
|
|