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 |
// Flush any pending editing... |
206 |
AudioRoutingTable->flush(); |
207 |
|
208 |
// We'll go for it! |
209 |
if (m_iDirtyCount > 0) { |
210 |
int iErrors = 0; |
211 |
// Are we a new channel? |
212 |
if (!m_pChannel->addChannel()) |
213 |
iErrors++; |
214 |
// Accept Audio driver or device selection... |
215 |
if (m_audioDevices.isEmpty()) { |
216 |
if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) |
217 |
iErrors++; |
218 |
} else { |
219 |
qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem()); |
220 |
if (pDevice == NULL) |
221 |
iErrors++; |
222 |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
223 |
iErrors++; |
224 |
else if (!m_audioRouting.isEmpty()) { |
225 |
// Set the audio route changes... |
226 |
qsamplerChannelRoutingMap::ConstIterator iter; |
227 |
for (iter = m_audioRouting.begin(); |
228 |
iter != m_audioRouting.end(); ++iter) { |
229 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.data())) |
230 |
iErrors++; |
231 |
} |
232 |
} |
233 |
} |
234 |
// Accept MIDI driver or device selection... |
235 |
if (m_midiDevices.isEmpty()) { |
236 |
if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText())) |
237 |
iErrors++; |
238 |
} else { |
239 |
qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem()); |
240 |
if (pDevice == NULL) |
241 |
iErrors++; |
242 |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
243 |
iErrors++; |
244 |
} |
245 |
// MIDI input port number... |
246 |
if (!m_pChannel->setMidiPort(MidiPortSpinBox->value())) |
247 |
iErrors++; |
248 |
// MIDI input channel... |
249 |
if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem())) |
250 |
iErrors++; |
251 |
// Engine name... |
252 |
if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) |
253 |
iErrors++; |
254 |
// Instrument file and index... |
255 |
if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem())) |
256 |
iErrors++; |
257 |
// Show error messages? |
258 |
if (iErrors > 0) |
259 |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
260 |
} |
261 |
|
262 |
// Save default engine name, instrument directory and history... |
263 |
pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true); |
264 |
pOptions->sEngineName = EngineNameComboBox->currentText(); |
265 |
pOptions->sAudioDriver = AudioDriverComboBox->currentText(); |
266 |
pOptions->sMidiDriver = MidiDriverComboBox->currentText(); |
267 |
pOptions->saveComboBoxHistory(InstrumentFileComboBox); |
268 |
|
269 |
// Just go with dialog acceptance. |
270 |
QDialog::accept(); |
271 |
} |
272 |
|
273 |
|
274 |
// Reject settings (Cancel button slot). |
275 |
void qsamplerChannelForm::reject (void) |
276 |
{ |
277 |
bool bReject = true; |
278 |
|
279 |
// Check if there's any pending changes... |
280 |
if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) { |
281 |
switch (QMessageBox::warning(this, |
282 |
QSAMPLER_TITLE ": " + tr("Warning"), |
283 |
tr("Some channel settings have been changed.\n\n" |
284 |
"Do you want to apply the changes?"), |
285 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
286 |
case 0: // Apply... |
287 |
accept(); |
288 |
return; |
289 |
case 1: // Discard |
290 |
break; |
291 |
default: // Cancel. |
292 |
bReject = false; |
293 |
} |
294 |
} |
295 |
|
296 |
if (bReject) |
297 |
QDialog::reject(); |
298 |
} |
299 |
|
300 |
|
301 |
// Browse and open an instrument file. |
302 |
void qsamplerChannelForm::openInstrumentFile (void) |
303 |
{ |
304 |
qsamplerOptions *pOptions = m_pChannel->options(); |
305 |
if (pOptions == NULL) |
306 |
return; |
307 |
|
308 |
// FIXME: the instrument file filters should be restricted, |
309 |
// depending on the current engine. |
310 |
QString sInstrumentFile = QFileDialog::getOpenFileName( |
311 |
pOptions->sInstrumentDir, // Start here. |
312 |
tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files) |
313 |
this, 0, // Parent and name (none) |
314 |
QSAMPLER_TITLE ": " + tr("Instrument files") // Caption. |
315 |
); |
316 |
|
317 |
if (sInstrumentFile.isEmpty()) |
318 |
return; |
319 |
|
320 |
InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
321 |
updateInstrumentName(); |
322 |
} |
323 |
|
324 |
|
325 |
// Refresh the actual instrument name. |
326 |
void qsamplerChannelForm::updateInstrumentName (void) |
327 |
{ |
328 |
qsamplerOptions *pOptions = m_pChannel->options(); |
329 |
if (pOptions == NULL) |
330 |
return; |
331 |
|
332 |
// Finally this better idea would be to use libgig |
333 |
// to retrieve the REAL instrument names. |
334 |
InstrumentNrComboBox->clear(); |
335 |
InstrumentNrComboBox->insertStringList( |
336 |
qsamplerChannel::getInstrumentList( |
337 |
InstrumentFileComboBox->currentText(), |
338 |
pOptions->bInstrumentNames) |
339 |
); |
340 |
|
341 |
optionsChanged(); |
342 |
} |
343 |
|
344 |
// Show device options dialog. |
345 |
void qsamplerChannelForm::setupDevice ( qsamplerDevice *pDevice, |
346 |
qsamplerDevice::qsamplerDeviceType deviceTypeMode, |
347 |
const QString& sDriverName ) |
348 |
{ |
349 |
// Create the device form if not already... |
350 |
if (m_pDeviceForm == NULL) { |
351 |
m_pDeviceForm = new qsamplerDeviceForm(this, 0, |
352 |
WType_Dialog | WShowModal); |
353 |
m_pDeviceForm->setMainForm(m_pChannel->mainForm()); |
354 |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
355 |
this, SLOT(updateDevices())); |
356 |
} |
357 |
|
358 |
// Refresh the device form with selected data. |
359 |
if (m_pDeviceForm) { |
360 |
m_pDeviceForm->setDeviceTypeMode(deviceTypeMode); |
361 |
m_pDeviceForm->setClient(m_pChannel->client()); // -> refreshDevices(); |
362 |
m_pDeviceForm->setDevice(pDevice); |
363 |
m_pDeviceForm->setDriverName(sDriverName); |
364 |
m_pDeviceForm->show(); |
365 |
} |
366 |
} |
367 |
|
368 |
|
369 |
// Refresh MIDI driver item devices. |
370 |
void qsamplerChannelForm::selectMidiDriverItem ( const QString& sMidiDriver ) |
371 |
{ |
372 |
const QString sDriverName = sMidiDriver.upper(); |
373 |
|
374 |
// Save current device id. |
375 |
int iDeviceID = 0; |
376 |
qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem()); |
377 |
if (pDevice) |
378 |
iDeviceID = pDevice->deviceID(); |
379 |
|
380 |
// Clean maplist. |
381 |
MidiDeviceComboBox->clear(); |
382 |
m_midiDevices.clear(); |
383 |
|
384 |
// Populate with the current ones... |
385 |
const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png"); |
386 |
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
387 |
qsamplerDevice::Midi); |
388 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
389 |
pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
390 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
391 |
if (pDevice->driverName().upper() == sDriverName) { |
392 |
MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName()); |
393 |
m_midiDevices.append(pDevice); |
394 |
} else { |
395 |
delete pDevice; |
396 |
} |
397 |
} |
398 |
|
399 |
// Do proper enabling... |
400 |
bool bEnabled = !m_midiDevices.isEmpty(); |
401 |
if (bEnabled) { |
402 |
// Select the previous current device... |
403 |
int iMidiItem = 0; |
404 |
for (pDevice = m_midiDevices.first(); |
405 |
pDevice; |
406 |
pDevice = m_midiDevices.next()) { |
407 |
if (pDevice->deviceID() == iDeviceID) { |
408 |
MidiDeviceComboBox->setCurrentItem(iMidiItem); |
409 |
selectMidiDeviceItem(iMidiItem); |
410 |
break; |
411 |
} |
412 |
iMidiItem++; |
413 |
} |
414 |
} else { |
415 |
MidiDeviceComboBox->insertItem( |
416 |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
417 |
} |
418 |
MidiDeviceTextLabel->setEnabled(bEnabled); |
419 |
MidiDeviceComboBox->setEnabled(bEnabled); |
420 |
} |
421 |
|
422 |
|
423 |
// Refresh MIDI device options slot. |
424 |
void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver ) |
425 |
{ |
426 |
if (m_iDirtySetup > 0) |
427 |
return; |
428 |
|
429 |
selectMidiDriverItem(sMidiDriver); |
430 |
optionsChanged(); |
431 |
} |
432 |
|
433 |
|
434 |
// Select MIDI device item. |
435 |
void qsamplerChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
436 |
{ |
437 |
qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem); |
438 |
if (pDevice) { |
439 |
const qsamplerDeviceParamMap& params = pDevice->params(); |
440 |
int iPorts = params["PORTS"].value.toInt(); |
441 |
MidiPortTextLabel->setEnabled(iPorts > 0); |
442 |
MidiPortSpinBox->setEnabled(iPorts > 0); |
443 |
if (iPorts > 0) |
444 |
MidiPortSpinBox->setMaxValue(iPorts - 1); |
445 |
} |
446 |
} |
447 |
|
448 |
|
449 |
// Select MIDI device options slot. |
450 |
void qsamplerChannelForm::selectMidiDevice ( int iMidiItem ) |
451 |
{ |
452 |
if (m_iDirtySetup > 0) |
453 |
return; |
454 |
|
455 |
selectMidiDeviceItem(iMidiItem); |
456 |
optionsChanged(); |
457 |
} |
458 |
|
459 |
|
460 |
// MIDI device options. |
461 |
void qsamplerChannelForm::setupMidiDevice (void) |
462 |
{ |
463 |
setupDevice(m_midiDevices.at(MidiDeviceComboBox->currentItem()), |
464 |
qsamplerDevice::Midi, MidiDriverComboBox->currentText()); |
465 |
} |
466 |
|
467 |
|
468 |
// Refresh Audio driver item devices. |
469 |
void qsamplerChannelForm::selectAudioDriverItem ( const QString& sAudioDriver ) |
470 |
{ |
471 |
const QString sDriverName = sAudioDriver.upper(); |
472 |
|
473 |
// Save current device id. |
474 |
int iDeviceID = 0; |
475 |
qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem()); |
476 |
if (pDevice) |
477 |
iDeviceID = pDevice->deviceID(); |
478 |
|
479 |
// Clean maplist. |
480 |
AudioDeviceComboBox->clear(); |
481 |
m_audioDevices.clear(); |
482 |
|
483 |
// Populate with the current ones... |
484 |
const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png"); |
485 |
int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(), |
486 |
qsamplerDevice::Audio); |
487 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
488 |
pDevice = new qsamplerDevice(m_pChannel->mainForm(), |
489 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
490 |
if (pDevice->driverName().upper() == sDriverName) { |
491 |
AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName()); |
492 |
m_audioDevices.append(pDevice); |
493 |
} else { |
494 |
delete pDevice; |
495 |
} |
496 |
} |
497 |
|
498 |
// Do proper enabling... |
499 |
bool bEnabled = !m_audioDevices.isEmpty(); |
500 |
if (bEnabled) { |
501 |
// Select the previous current device... |
502 |
int iAudioItem = 0; |
503 |
for (pDevice = m_audioDevices.first(); |
504 |
pDevice; |
505 |
pDevice = m_audioDevices.next()) { |
506 |
if (pDevice->deviceID() == iDeviceID) { |
507 |
AudioDeviceComboBox->setCurrentItem(iAudioItem); |
508 |
selectAudioDeviceItem(iAudioItem); |
509 |
break; |
510 |
} |
511 |
iAudioItem++; |
512 |
} |
513 |
} else { |
514 |
AudioDeviceComboBox->insertItem( |
515 |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
516 |
AudioRoutingTable->setNumRows(0); |
517 |
} |
518 |
AudioDeviceTextLabel->setEnabled(bEnabled); |
519 |
AudioDeviceComboBox->setEnabled(bEnabled); |
520 |
AudioRoutingTable->setEnabled(bEnabled); |
521 |
} |
522 |
|
523 |
|
524 |
// Refresh Audio device options slot. |
525 |
void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver ) |
526 |
{ |
527 |
if (m_iDirtySetup > 0) |
528 |
return; |
529 |
|
530 |
selectAudioDriverItem(sAudioDriver); |
531 |
optionsChanged(); |
532 |
} |
533 |
|
534 |
|
535 |
// Select Audio device item. |
536 |
void qsamplerChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
537 |
{ |
538 |
qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem); |
539 |
if (pDevice) { |
540 |
// Refresh the audio routing table. |
541 |
AudioRoutingTable->refresh(pDevice, m_pChannel->audioRouting()); |
542 |
// Reset routing change map. |
543 |
m_audioRouting.clear(); |
544 |
} |
545 |
} |
546 |
|
547 |
|
548 |
// Select Audio device options slot. |
549 |
void qsamplerChannelForm::selectAudioDevice ( int iAudioItem ) |
550 |
{ |
551 |
if (m_iDirtySetup > 0) |
552 |
return; |
553 |
|
554 |
selectAudioDeviceItem(iAudioItem); |
555 |
optionsChanged(); |
556 |
} |
557 |
|
558 |
|
559 |
// Audio device options. |
560 |
void qsamplerChannelForm::setupAudioDevice (void) |
561 |
{ |
562 |
setupDevice(m_audioDevices.at(AudioDeviceComboBox->currentItem()), |
563 |
qsamplerDevice::Audio, AudioDriverComboBox->currentText()); |
564 |
} |
565 |
|
566 |
|
567 |
// Audio routing change slot. |
568 |
void qsamplerChannelForm::changeAudioRouting ( int iRow, int iCol ) |
569 |
{ |
570 |
if (m_iDirtySetup > 0) |
571 |
return; |
572 |
if (iRow < 0 || iCol < 0) |
573 |
return; |
574 |
|
575 |
// Verify that this is a QComboTableItem (magic rtti == 1) |
576 |
QTableItem *pItem = AudioRoutingTable->item(iRow, iCol); |
577 |
if (pItem == NULL) |
578 |
return; |
579 |
qsamplerChannelRoutingComboBox *pComboItem = |
580 |
static_cast<qsamplerChannelRoutingComboBox*> (pItem); |
581 |
// FIXME: Its not garanteed that we must have |
582 |
// iAudioOut == iRow on all times forth! |
583 |
m_audioRouting[iRow] = pComboItem->currentItem(); |
584 |
|
585 |
// And let's get dirty... |
586 |
optionsChanged(); |
587 |
} |
588 |
|
589 |
|
590 |
// UPdate all device lists slot. |
591 |
void qsamplerChannelForm::updateDevices (void) |
592 |
{ |
593 |
if (m_iDirtySetup > 0) |
594 |
return; |
595 |
|
596 |
selectMidiDriverItem(MidiDriverComboBox->currentText()); |
597 |
selectAudioDriverItem(AudioDriverComboBox->currentText()); |
598 |
optionsChanged(); |
599 |
} |
600 |
|
601 |
|
602 |
// Dirty up settings. |
603 |
void qsamplerChannelForm::optionsChanged (void) |
604 |
{ |
605 |
if (m_iDirtySetup > 0) |
606 |
return; |
607 |
|
608 |
m_iDirtyCount++; |
609 |
stabilizeForm(); |
610 |
} |
611 |
|
612 |
|
613 |
// Stabilize current form state. |
614 |
void qsamplerChannelForm::stabilizeForm (void) |
615 |
{ |
616 |
const QString& sFilename = InstrumentFileComboBox->currentText(); |
617 |
OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists()); |
618 |
} |
619 |
|
620 |
|
621 |
// end of qsamplerChannelForm.ui.h |