1 |
// qsamplerChannelForm.ui.h |
2 |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
5 |
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 |
8 |
modify it under the terms of the GNU General Public License |
9 |
as published by the Free Software Foundation; either version 2 |
10 |
of the License, or (at your option) any later version. |
11 |
|
12 |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License |
18 |
along with this program; if not, write to the Free Software |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 |
|
21 |
*****************************************************************************/ |
22 |
|
23 |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerDeviceForm.h" |
25 |
|
26 |
#include <qvalidator.h> |
27 |
#include <qmessagebox.h> |
28 |
#include <qfiledialog.h> |
29 |
#include <qfileinfo.h> |
30 |
#include <qlistbox.h> |
31 |
|
32 |
|
33 |
// Kind of constructor. |
34 |
void qsamplerChannelForm::init (void) |
35 |
{ |
36 |
// Initialize locals. |
37 |
m_pChannel = NULL; |
38 |
|
39 |
m_iDirtySetup = 0; |
40 |
m_iDirtyCount = 0; |
41 |
|
42 |
m_midiDevices.setAutoDelete(true); |
43 |
m_audioDevices.setAutoDelete(true); |
44 |
|
45 |
m_pDeviceForm = NULL; |
46 |
|
47 |
// Try to restore normal window positioning. |
48 |
adjustSize(); |
49 |
} |
50 |
|
51 |
|
52 |
// Kind of destructor. |
53 |
void qsamplerChannelForm::destroy (void) |
54 |
{ |
55 |
if (m_pDeviceForm) |
56 |
delete m_pDeviceForm; |
57 |
m_pDeviceForm = NULL; |
58 |
} |
59 |
|
60 |
|
61 |
// Channel dialog setup formal initializer. |
62 |
void qsamplerChannelForm::setup ( qsamplerChannel *pChannel ) |
63 |
{ |
64 |
m_pChannel = pChannel; |
65 |
|
66 |
m_iDirtySetup = 0; |
67 |
m_iDirtyCount = 0; |
68 |
|
69 |
if (m_pChannel == NULL) |
70 |
return; |
71 |
|
72 |
// It can be a brand new channel, remember? |
73 |
bool bNew = (m_pChannel->channelID() < 0); |
74 |
setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
75 |
|
76 |
// Check if we're up and connected. |
77 |
if (m_pChannel->client() == NULL) |
78 |
return; |
79 |
|
80 |
qsamplerOptions *pOptions = m_pChannel->options(); |
81 |
if (pOptions == NULL) |
82 |
return; |
83 |
|
84 |
// Avoid nested changes. |
85 |
m_iDirtySetup++; |
86 |
|
87 |
// Load combo box history... |
88 |
pOptions->loadComboBoxHistory(InstrumentFileComboBox); |
89 |
|
90 |
// Notify.that we've just changed one audio route. |
91 |
QObject::connect(AudioRoutingTable, SIGNAL(valueChanged(int,int)), |
92 |
this, SLOT(changeAudioRouting(int,int))); |
93 |
|
94 |
// Populate Engines list. |
95 |
const char **ppszEngines = ::lscp_list_available_engines(m_pChannel->client()); |
96 |
if (ppszEngines) { |
97 |
EngineNameComboBox->clear(); |
98 |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
99 |
EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
100 |
} |
101 |
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
102 |
|
103 |
// Populate Audio output type list. |
104 |
AudioDriverComboBox->clear(); |
105 |
AudioDriverComboBox->insertStringList( |
106 |
qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio)); |
107 |
|
108 |
// Populate MIDI input type list. |
109 |
MidiDriverComboBox->clear(); |
110 |
MidiDriverComboBox->insertStringList( |
111 |
qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi)); |
112 |
|
113 |
// Read proper channel information, |
114 |
// and populate the channel form fields. |
115 |
|
116 |
// Engine name... |
117 |
QString sEngineName = pChannel->engineName(); |
118 |
if (sEngineName.isEmpty() || bNew) |
119 |
sEngineName = pOptions->sEngineName; |
120 |
if (sEngineName.isEmpty()) |
121 |
sEngineName = qsamplerChannel::noEngineName(); |
122 |
if (EngineNameComboBox->listBox()->findItem(sEngineName, |
123 |
Qt::ExactMatch | Qt::CaseSensitive) == NULL) { |
124 |
EngineNameComboBox->insertItem(sEngineName); |
125 |
} |
126 |
EngineNameComboBox->setCurrentText(sEngineName); |
127 |
// Instrument filename and index... |
128 |
QString sInstrumentFile = pChannel->instrumentFile(); |
129 |
if (sInstrumentFile.isEmpty()) |
130 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
131 |
InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
132 |
InstrumentNrComboBox->clear(); |
133 |
InstrumentNrComboBox->insertStringList( |
134 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
135 |
pOptions->bInstrumentNames)); |
136 |
InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); |
137 |
|
138 |
// MIDI input device... |
139 |
qsamplerDevice midiDevice(m_pChannel->mainForm(), |
140 |
qsamplerDevice::Midi, m_pChannel->midiDevice()); |
141 |
// MIDI input driver... |
142 |
QString sMidiDriver = midiDevice.driverName(); |
143 |
if (sMidiDriver.isEmpty() || bNew) |
144 |
sMidiDriver = pOptions->sMidiDriver.upper(); |
145 |
if (!sMidiDriver.isEmpty()) { |
146 |
if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, |
147 |
Qt::ExactMatch | Qt::CaseSensitive) == NULL) { |
148 |
MidiDriverComboBox->insertItem(sMidiDriver); |
149 |
} |
150 |
MidiDriverComboBox->setCurrentText(sMidiDriver); |
151 |
} |
152 |
selectMidiDriverItem(sMidiDriver); |
153 |
if (!bNew) |
154 |
MidiDeviceComboBox->setCurrentText(midiDevice.deviceName()); |
155 |
selectMidiDeviceItem(MidiDeviceComboBox->currentItem()); |
156 |
// MIDI input port... |
157 |
MidiPortSpinBox->setValue(pChannel->midiPort()); |
158 |
// MIDI input channel... |
159 |
int iMidiChannel = pChannel->midiChannel(); |
160 |
// When new, try to suggest a sensible MIDI channel... |
161 |
if (iMidiChannel < 0) |
162 |
iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16); |
163 |
MidiChannelComboBox->setCurrentItem(iMidiChannel); |
164 |
|
165 |
// Audio output device... |
166 |
qsamplerDevice audioDevice(m_pChannel->mainForm(), |
167 |
qsamplerDevice::Audio, m_pChannel->audioDevice()); |
168 |
// Audio output driver... |
169 |
QString sAudioDriver = audioDevice.driverName(); |
170 |
if (sAudioDriver.isEmpty() || bNew) |
171 |
sAudioDriver = pOptions->sAudioDriver.upper(); |
172 |
if (!sAudioDriver.isEmpty()) { |
173 |
if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, |
174 |
Qt::ExactMatch | Qt::CaseSensitive) == NULL) { |
175 |
AudioDriverComboBox->insertItem(sAudioDriver); |
176 |
} |
177 |
AudioDriverComboBox->setCurrentText(sAudioDriver); |
178 |
} |
179 |
selectAudioDriverItem(sAudioDriver); |
180 |
if (!bNew) |
181 |
AudioDeviceComboBox->setCurrentText(audioDevice.deviceName()); |
182 |
selectAudioDeviceItem(AudioDeviceComboBox->currentItem()); |
183 |
|
184 |
// As convenient, make it ready on stabilizeForm() for |
185 |
// prompt acceptance, if we got the minimum required... |
186 |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
187 |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
188 |
m_iDirtyCount++; */ |
189 |
// Done. |
190 |
m_iDirtySetup--; |
191 |
stabilizeForm(); |
192 |
} |
193 |
|
194 |
|
195 |
// Accept settings (OK button slot). |
196 |
void qsamplerChannelForm::accept (void) |
197 |
{ |
198 |
if (m_pChannel == NULL) |
199 |
return; |
200 |
|
201 |
qsamplerOptions *pOptions = m_pChannel->options(); |
202 |
if (pOptions == NULL) |
203 |
return; |
204 |
|
205 |
// We'll go for it! |
206 |
if (m_iDirtyCount > 0) { |
207 |
int iErrors = 0; |
208 |
// Are we a new channel? |
209 |
if (!m_pChannel->addChannel()) |
210 |
iErrors++; |
211 |
// Accept Audio driver or device selection... |
212 |
if (m_audioDevices.isEmpty()) { |
213 |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
214 |
iErrors++; |
215 |
} else { |
216 |
qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem()); |
217 |
if (pDevice == NULL) |
218 |
iErrors++; |
219 |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
220 |
iErrors++; |
221 |
else if (!m_audioRouting.isEmpty()) { |
222 |
// Set the audio route changes... |
223 |
qsamplerChannelRoutingMap::ConstIterator iter; |
224 |
for (iter = m_audioRouting.begin(); |
225 |
iter != m_audioRouting.end(); ++iter) { |
226 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.data())) |
227 |
iErrors++; |
228 |
} |
229 |
} |
230 |
} |
231 |
// Accept MIDI driver or device selection... |
232 |
if (m_midiDevices.isEmpty()) { |
233 |
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
234 |
iErrors++; |
235 |
} else { |
236 |
qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem()); |
237 |
if (pDevice == NULL) |
238 |
iErrors++; |
239 |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
240 |
iErrors++; |
241 |
} |
242 |
// MIDI input port number... |
243 |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
244 |
iErrors++; |
245 |
// MIDI input channel... |
246 |
if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem())) |
247 |
iErrors++; |
248 |
// Engine name... |
249 |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
250 |
iErrors++; |
251 |
// Instrument file and index... |
252 |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem())) |
253 |
iErrors++; |
254 |
// Show error messages? |
255 |
if (iErrors > 0) |
256 |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
257 |
} |
258 |
|
259 |
// Save default engine name, instrument directory and history... |
260 |
pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true); |
261 |
pOptions->sEngineName = EngineNameComboBox->currentText(); |
262 |
pOptions->sAudioDriver = AudioDriverComboBox->currentText(); |
263 |
pOptions->sMidiDriver = MidiDriverComboBox->currentText(); |
264 |
pOptions->saveComboBoxHistory(InstrumentFileComboBox); |
265 |
|
266 |
// Just go with dialog acceptance. |
267 |
QDialog::accept(); |
268 |
} |
269 |
|
270 |
|
271 |
// Reject settings (Cancel button slot). |
272 |
void qsamplerChannelForm::reject (void) |
273 |
{ |
274 |
bool bReject = true; |
275 |
|
276 |
// Check if there's any pending changes... |
277 |
if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) { |
278 |
switch (QMessageBox::warning(this, |
279 |
QSAMPLER_TITLE ": " + tr("Warning"), |
280 |
tr("Some channel settings have been changed.\n\n" |
281 |
"Do you want to apply the changes?"), |
282 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
283 |
case 0: // Apply... |
284 |
accept(); |
285 |
return; |
286 |
case 1: // Discard |
287 |
break; |
288 |
default: // Cancel. |
289 |
bReject = false; |
290 |
} |
291 |
} |
292 |
|
293 |
if (bReject) |
294 |
QDialog::reject(); |
295 |
} |
296 |
|
297 |
|
298 |
// Browse and open an instrument file. |
299 |
void qsamplerChannelForm::openInstrumentFile (void) |
300 |
{ |
301 |
qsamplerOptions *pOptions = m_pChannel->options(); |
302 |
if (pOptions == NULL) |
303 |
return; |
304 |
|
305 |
// FIXME: the instrument file filters should be restricted, |
306 |
// depending on the current engine. |
307 |
QString sInstrumentFile = QFileDialog::getOpenFileName( |
308 |
pOptions->sInstrumentDir, // Start here. |
309 |
tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files) |
310 |
this, 0, // Parent and name (none) |
311 |
QSAMPLER_TITLE ": " + tr("Instrument files") // Caption. |
312 |
); |
313 |
|
314 |
if (sInstrumentFile.isEmpty()) |
315 |
return; |
316 |
|
317 |
InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
318 |
updateInstrumentName(); |
319 |
} |
320 |
|
321 |
|
322 |
// Refresh the actual instrument name. |
323 |
void qsamplerChannelForm::updateInstrumentName (void) |
324 |
{ |
325 |
qsamplerOptions *pOptions = m_pChannel->options(); |
326 |
if (pOptions == NULL) |
327 |
return; |
328 |
|
329 |
// Finally this better idea would be to use libgig |
330 |
// to retrieve the REAL instrument names. |
331 |
InstrumentNrComboBox->clear(); |
332 |
InstrumentNrComboBox->insertStringList( |
333 |
qsamplerChannel::getInstrumentList( |
334 |
InstrumentFileComboBox->currentText(), |
335 |
pOptions->bInstrumentNames) |
336 |
); |
337 |
|
338 |
optionsChanged(); |
339 |
} |
340 |
|
341 |
// Show device options dialog. |
342 |
void qsamplerChannelForm::setupDevice ( qsamplerDevice *pDevice, |
343 |
qsamplerDevice::qsamplerDeviceType deviceTypeMode, |
344 |
const QString& sDriverName ) |
345 |
{ |
346 |
// Create the device form if not already... |
347 |
if (m_pDeviceForm == NULL) { |
348 |
m_pDeviceForm = new qsamplerDeviceForm(this, 0, |
349 |
WType_Dialog | WShowModal); |
350 |
m_pDeviceForm->setMainForm(m_pChannel->mainForm()); |
351 |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
352 |
this, SLOT(updateDevices())); |
353 |
} |
354 |
|
355 |
// Refresh the device form with selected data. |
356 |
if (m_pDeviceForm) { |
357 |
m_pDeviceForm->setDeviceTypeMode(deviceTypeMode); |
358 |
m_pDeviceForm->setClient(m_pChannel->client()); // -> refreshDevices(); |
359 |
m_pDeviceForm->setDevice(pDevice); |
360 |
m_pDeviceForm->setDriverName(sDriverName); |
361 |
m_pDeviceForm->show(); |
362 |
} |
363 |
} |
364 |
|
365 |
|
366 |
// Refresh MIDI driver item devices. |
367 |
void qsamplerChannelForm::selectMidiDriverItem ( const QString& sMidiDriver ) |
368 |
{ |
369 |
const QString sDriverName = sMidiDriver.upper(); |
370 |
|
371 |
// Save current device id. |
372 |
int iDeviceID = 0; |
373 |
qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem()); |
374 |
if (pDevice) |
375 |
iDeviceID = pDevice->deviceID(); |
376 |
|
377 |
// Clean maplist. |
378 |
MidiDeviceComboBox->clear(); |
379 |
m_midiDevices.clear(); |
380 |
|
381 |
// Populate with the current ones... |
382 |
const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png"); |
383 |
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
384 |
qsamplerDevice::Midi); |
385 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
386 |
pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
387 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
388 |
if (pDevice->driverName().upper() == sDriverName) { |
389 |
MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName()); |
390 |
m_midiDevices.append(pDevice); |
391 |
} else { |
392 |
delete pDevice; |
393 |
} |
394 |
} |
395 |
|
396 |
// Do proper enabling... |
397 |
bool bEnabled = !m_midiDevices.isEmpty(); |
398 |
if (bEnabled) { |
399 |
// Select the previous current device... |
400 |
int iMidiItem = 0; |
401 |
for (pDevice = m_midiDevices.first(); |
402 |
pDevice; |
403 |
pDevice = m_midiDevices.next()) { |
404 |
if (pDevice->deviceID() == iDeviceID) { |
405 |
MidiDeviceComboBox->setCurrentItem(iMidiItem); |
406 |
selectMidiDeviceItem(iMidiItem); |
407 |
break; |
408 |
} |
409 |
iMidiItem++; |
410 |
} |
411 |
} else { |
412 |
MidiDeviceComboBox->insertItem( |
413 |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
414 |
} |
415 |
MidiDeviceTextLabel->setEnabled(bEnabled); |
416 |
MidiDeviceComboBox->setEnabled(bEnabled); |
417 |
} |
418 |
|
419 |
|
420 |
// Refresh MIDI device options slot. |
421 |
void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver ) |
422 |
{ |
423 |
if (m_iDirtySetup > 0) |
424 |
return; |
425 |
|
426 |
selectMidiDriverItem(sMidiDriver); |
427 |
optionsChanged(); |
428 |
} |
429 |
|
430 |
|
431 |
// Select MIDI device item. |
432 |
void qsamplerChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
433 |
{ |
434 |
qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem); |
435 |
if (pDevice) { |
436 |
const qsamplerDeviceParamMap& params = pDevice->params(); |
437 |
int iPorts = params["PORTS"].value.toInt(); |
438 |
MidiPortTextLabel->setEnabled(iPorts > 0); |
439 |
MidiPortSpinBox->setEnabled(iPorts > 0); |
440 |
if (iPorts > 0) |
441 |
MidiPortSpinBox->setMaxValue(iPorts - 1); |
442 |
} |
443 |
} |
444 |
|
445 |
|
446 |
// Select MIDI device options slot. |
447 |
void qsamplerChannelForm::selectMidiDevice ( int iMidiItem ) |
448 |
{ |
449 |
if (m_iDirtySetup > 0) |
450 |
return; |
451 |
|
452 |
selectMidiDeviceItem(iMidiItem); |
453 |
optionsChanged(); |
454 |
} |
455 |
|
456 |
|
457 |
// MIDI device options. |
458 |
void qsamplerChannelForm::setupMidiDevice (void) |
459 |
{ |
460 |
setupDevice(m_midiDevices.at(MidiDeviceComboBox->currentItem()), |
461 |
qsamplerDevice::Midi, MidiDriverComboBox->currentText()); |
462 |
} |
463 |
|
464 |
|
465 |
// Refresh Audio driver item devices. |
466 |
void qsamplerChannelForm::selectAudioDriverItem ( const QString& sAudioDriver ) |
467 |
{ |
468 |
const QString sDriverName = sAudioDriver.upper(); |
469 |
|
470 |
// Save current device id. |
471 |
int iDeviceID = 0; |
472 |
qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem()); |
473 |
if (pDevice) |
474 |
iDeviceID = pDevice->deviceID(); |
475 |
|
476 |
// Clean maplist. |
477 |
AudioDeviceComboBox->clear(); |
478 |
m_audioDevices.clear(); |
479 |
|
480 |
// Populate with the current ones... |
481 |
const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png"); |
482 |
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
483 |
qsamplerDevice::Audio); |
484 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
485 |
pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
486 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
487 |
if (pDevice->driverName().upper() == sDriverName) { |
488 |
AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName()); |
489 |
m_audioDevices.append(pDevice); |
490 |
} else { |
491 |
delete pDevice; |
492 |
} |
493 |
} |
494 |
|
495 |
// Do proper enabling... |
496 |
bool bEnabled = !m_audioDevices.isEmpty(); |
497 |
if (bEnabled) { |
498 |
// Select the previous current device... |
499 |
int iAudioItem = 0; |
500 |
for (pDevice = m_audioDevices.first(); |
501 |
pDevice; |
502 |
pDevice = m_audioDevices.next()) { |
503 |
if (pDevice->deviceID() == iDeviceID) { |
504 |
AudioDeviceComboBox->setCurrentItem(iAudioItem); |
505 |
selectAudioDeviceItem(iAudioItem); |
506 |
break; |
507 |
} |
508 |
iAudioItem++; |
509 |
} |
510 |
} else { |
511 |
AudioDeviceComboBox->insertItem( |
512 |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
513 |
AudioRoutingTable->setNumRows(0); |
514 |
} |
515 |
AudioDeviceTextLabel->setEnabled(bEnabled); |
516 |
AudioDeviceComboBox->setEnabled(bEnabled); |
517 |
AudioRoutingTable->setEnabled(bEnabled); |
518 |
} |
519 |
|
520 |
|
521 |
// Refresh Audio device options slot. |
522 |
void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver ) |
523 |
{ |
524 |
if (m_iDirtySetup > 0) |
525 |
return; |
526 |
|
527 |
selectAudioDriverItem(sAudioDriver); |
528 |
optionsChanged(); |
529 |
} |
530 |
|
531 |
|
532 |
// Select Audio device item. |
533 |
void qsamplerChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
534 |
{ |
535 |
qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem); |
536 |
if (pDevice) { |
537 |
// Refresh the audio routing table. |
538 |
AudioRoutingTable->refresh(pDevice, m_pChannel->audioRouting()); |
539 |
// Reset routing change map. |
540 |
m_audioRouting.clear(); |
541 |
} |
542 |
} |
543 |
|
544 |
|
545 |
// Select Audio device options slot. |
546 |
void qsamplerChannelForm::selectAudioDevice ( int iAudioItem ) |
547 |
{ |
548 |
if (m_iDirtySetup > 0) |
549 |
return; |
550 |
|
551 |
selectAudioDeviceItem(iAudioItem); |
552 |
optionsChanged(); |
553 |
} |
554 |
|
555 |
|
556 |
// Audio device options. |
557 |
void qsamplerChannelForm::setupAudioDevice (void) |
558 |
{ |
559 |
setupDevice(m_audioDevices.at(AudioDeviceComboBox->currentItem()), |
560 |
qsamplerDevice::Audio, AudioDriverComboBox->currentText()); |
561 |
} |
562 |
|
563 |
|
564 |
// Audio routing change slot. |
565 |
void qsamplerChannelForm::changeAudioRouting ( int iRow, int iCol ) |
566 |
{ |
567 |
if (m_iDirtySetup > 0) |
568 |
return; |
569 |
if (iRow < 0 || iCol < 0) |
570 |
return; |
571 |
|
572 |
// Verify that this is a QComboTableItem (magic rtti == 1) |
573 |
QTableItem *pItem = AudioRoutingTable->item(iRow, iCol); |
574 |
if (pItem == NULL) |
575 |
return; |
576 |
qsamplerChannelRoutingComboBox *pComboItem = |
577 |
static_cast<qsamplerChannelRoutingComboBox*> (pItem); |
578 |
// FIXME: Its not garanteed that we must have |
579 |
// iAudioOut == iRow on all times forth! |
580 |
m_audioRouting[iRow] = pComboItem->currentItem(); |
581 |
|
582 |
// And let's get dirty... |
583 |
optionsChanged(); |
584 |
} |
585 |
|
586 |
|
587 |
// UPdate all device lists slot. |
588 |
void qsamplerChannelForm::updateDevices (void) |
589 |
{ |
590 |
if (m_iDirtySetup > 0) |
591 |
return; |
592 |
|
593 |
selectMidiDriverItem(MidiDriverComboBox->currentText()); |
594 |
selectAudioDriverItem(AudioDriverComboBox->currentText()); |
595 |
optionsChanged(); |
596 |
} |
597 |
|
598 |
|
599 |
// Dirty up settings. |
600 |
void qsamplerChannelForm::optionsChanged (void) |
601 |
{ |
602 |
if (m_iDirtySetup > 0) |
603 |
return; |
604 |
|
605 |
m_iDirtyCount++; |
606 |
stabilizeForm(); |
607 |
} |
608 |
|
609 |
|
610 |
// Stabilize current form state. |
611 |
void qsamplerChannelForm::stabilizeForm (void) |
612 |
{ |
613 |
const QString& sFilename = InstrumentFileComboBox->currentText(); |
614 |
OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists()); |
615 |
} |
616 |
|
617 |
|
618 |
// end of qsamplerChannelForm.ui.h |