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