1 |
// qsamplerChannelForm.cpp |
// qsamplerChannelForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
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 |
38 |
|
|
39 |
namespace QSampler { |
namespace QSampler { |
40 |
|
|
41 |
|
//------------------------------------------------------------------------- |
42 |
|
// QSampler::Channelform -- Channel form implementation. |
43 |
|
// |
44 |
|
|
45 |
ChannelForm::ChannelForm ( QWidget* pParent ) |
ChannelForm::ChannelForm ( QWidget* pParent ) |
46 |
: QDialog(pParent) |
: QDialog(pParent) |
47 |
{ |
{ |
48 |
m_ui.setupUi(this); |
m_ui.setupUi(this); |
49 |
|
|
50 |
// Initialize locals. |
// Initialize locals. |
51 |
m_pChannel = NULL; |
m_pChannel = NULL; |
58 |
|
|
59 |
m_pDeviceForm = NULL; |
m_pDeviceForm = NULL; |
60 |
|
|
61 |
|
int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4; |
62 |
|
m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight); |
63 |
|
m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); |
64 |
|
|
65 |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
66 |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
67 |
|
#if QT_VERSION >= 0x050000 |
68 |
|
m_ui.AudioRoutingTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); |
69 |
|
else |
70 |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
71 |
|
#endif |
72 |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
73 |
|
|
74 |
// This goes initially hidden, and will be shown |
// This goes initially hidden, and will be shown |
75 |
// on setup() for currently existing channels... |
// on setup() for currently existing channels... |
76 |
m_ui.AudioRoutingTable->hide(); |
m_ui.AudioRoutingTable->hide(); |
77 |
|
|
78 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
111 |
QObject::connect(m_ui.AudioDeviceComboBox, |
QObject::connect(m_ui.AudioDeviceComboBox, |
112 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
113 |
SLOT(selectAudioDevice(int))); |
SLOT(selectAudioDevice(int))); |
114 |
QObject::connect(m_ui.OkPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
115 |
SIGNAL(clicked()), |
SIGNAL(accepted()), |
116 |
SLOT(accept())); |
SLOT(accept())); |
117 |
QObject::connect(m_ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
118 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
119 |
SLOT(reject())); |
SLOT(reject())); |
120 |
QObject::connect(m_ui.MidiDeviceToolButton, |
QObject::connect(m_ui.MidiDeviceToolButton, |
121 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
149 |
|
|
150 |
|
|
151 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
152 |
void ChannelForm::setup ( qsamplerChannel *pChannel ) |
void ChannelForm::setup ( Channel *pChannel ) |
153 |
{ |
{ |
154 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
155 |
|
|
160 |
return; |
return; |
161 |
|
|
162 |
// It can be a brand new channel, remember? |
// It can be a brand new channel, remember? |
163 |
bool bNew = (m_pChannel->channelID() < 0); |
const bool bNew = (m_pChannel->channelID() < 0); |
164 |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
165 |
|
|
166 |
// Check if we're up and connected. |
// Check if we're up and connected. |
170 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
171 |
return; |
return; |
172 |
|
|
173 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
174 |
if (pOptions == NULL) |
if (pOptions == NULL) |
175 |
return; |
return; |
176 |
|
|
192 |
// Populate Audio output type list. |
// Populate Audio output type list. |
193 |
m_ui.AudioDriverComboBox->clear(); |
m_ui.AudioDriverComboBox->clear(); |
194 |
m_ui.AudioDriverComboBox->insertItems(0, |
m_ui.AudioDriverComboBox->insertItems(0, |
195 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio)); |
Device::getDrivers(pMainForm->client(), Device::Audio)); |
196 |
|
|
197 |
// Populate MIDI input type list. |
// Populate MIDI input type list. |
198 |
m_ui.MidiDriverComboBox->clear(); |
m_ui.MidiDriverComboBox->clear(); |
199 |
m_ui.MidiDriverComboBox->insertItems(0, |
m_ui.MidiDriverComboBox->insertItems(0, |
200 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi)); |
Device::getDrivers(pMainForm->client(), Device::Midi)); |
201 |
|
|
202 |
// Populate Maps list. |
// Populate Maps list. |
203 |
m_ui.MidiMapComboBox->clear(); |
m_ui.MidiMapComboBox->clear(); |
204 |
m_ui.MidiMapComboBox->insertItems(0, |
m_ui.MidiMapComboBox->insertItems(0, |
205 |
qsamplerInstrument::getMapNames()); |
Instrument::getMapNames()); |
206 |
|
|
207 |
// Read proper channel information, |
// Read proper channel information, |
208 |
// and populate the channel form fields. |
// and populate the channel form fields. |
212 |
if (sEngineName.isEmpty() || bNew) |
if (sEngineName.isEmpty() || bNew) |
213 |
sEngineName = pOptions->sEngineName; |
sEngineName = pOptions->sEngineName; |
214 |
if (sEngineName.isEmpty()) |
if (sEngineName.isEmpty()) |
215 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = Channel::noEngineName(); |
216 |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
217 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
218 |
m_ui.EngineNameComboBox->addItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
224 |
// Instrument filename and index... |
// Instrument filename and index... |
225 |
QString sInstrumentFile = pChannel->instrumentFile(); |
QString sInstrumentFile = pChannel->instrumentFile(); |
226 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
227 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = Channel::noInstrumentName(); |
228 |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
229 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
230 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
231 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
232 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
233 |
m_ui.InstrumentNrComboBox->setCurrentIndex(pChannel->instrumentNr()); |
int iInstrumentNr = pChannel->instrumentNr(); |
234 |
|
if (iInstrumentNr < 0) |
235 |
|
iInstrumentNr = 0; |
236 |
|
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
237 |
|
|
238 |
// MIDI input device... |
// MIDI input device... |
239 |
qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice()); |
Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
240 |
// MIDI input driver... |
// MIDI input driver... |
241 |
QString sMidiDriver = midiDevice.driverName(); |
QString sMidiDriver = midiDevice.driverName(); |
242 |
if (sMidiDriver.isEmpty() || bNew) |
if (sMidiDriver.isEmpty() || bNew) |
246 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
247 |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
248 |
} |
} |
249 |
m_ui.MidiDriverComboBox->setItemText( |
m_ui.MidiDriverComboBox->setCurrentIndex( |
250 |
m_ui.MidiDriverComboBox->currentIndex(), |
m_ui.MidiDriverComboBox->findText(sMidiDriver, |
251 |
sMidiDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
252 |
|
); |
253 |
} |
} |
254 |
selectMidiDriverItem(sMidiDriver); |
selectMidiDriverItem(sMidiDriver); |
255 |
if (!bNew) { |
if (!bNew) { |
271 |
// When new, try to suggest a sensible MIDI map... |
// When new, try to suggest a sensible MIDI map... |
272 |
if (iMidiMap < 0) |
if (iMidiMap < 0) |
273 |
iMidiMap = 0; |
iMidiMap = 0; |
274 |
const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap); |
const QString& sMapName = Instrument::getMapName(iMidiMap); |
275 |
if (!sMapName.isEmpty()) { |
if (!sMapName.isEmpty()) { |
276 |
m_ui.MidiMapComboBox->setItemText( |
m_ui.MidiMapComboBox->setItemText( |
277 |
m_ui.MidiMapComboBox->currentIndex(), |
m_ui.MidiMapComboBox->currentIndex(), |
283 |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
284 |
|
|
285 |
// Audio output device... |
// Audio output device... |
286 |
qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice()); |
Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
287 |
// Audio output driver... |
// Audio output driver... |
288 |
QString sAudioDriver = audioDevice.driverName(); |
QString sAudioDriver = audioDevice.driverName(); |
289 |
if (sAudioDriver.isEmpty() || bNew) |
if (sAudioDriver.isEmpty() || bNew) |
293 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
294 |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
295 |
} |
} |
296 |
m_ui.AudioDriverComboBox->setItemText( |
m_ui.AudioDriverComboBox->setCurrentIndex( |
297 |
m_ui.AudioDriverComboBox->currentIndex(), |
m_ui.AudioDriverComboBox->findText(sAudioDriver, |
298 |
sAudioDriver); |
Qt::MatchExactly | Qt::MatchCaseSensitive) |
299 |
|
); |
300 |
} |
} |
301 |
selectAudioDriverItem(sAudioDriver); |
selectAudioDriverItem(sAudioDriver); |
302 |
if (!bNew) { |
if (!bNew) { |
310 |
// if we're editing an existing sampler channel... |
// if we're editing an existing sampler channel... |
311 |
m_ui.AudioRoutingTable->setVisible(!bNew); |
m_ui.AudioRoutingTable->setVisible(!bNew); |
312 |
|
|
313 |
|
const QString sInstrumentNrToolTip = |
314 |
|
(pOptions->bInstrumentNames) ? |
315 |
|
"Select an instrument of the file" : |
316 |
|
"You might want to enable instrument name retrieval in the " |
317 |
|
"settings dialog"; |
318 |
|
m_ui.InstrumentNrComboBox->setToolTip( |
319 |
|
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
320 |
|
); |
321 |
|
|
322 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
323 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
324 |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
/* if (sEngineName != Channel::noEngineName() && |
325 |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
sInstrumentFile != Channel::noInstrumentName()) |
326 |
m_iDirtyCount++; */ |
m_iDirtyCount++; */ |
327 |
// Done. |
// Done. |
328 |
m_iDirtySetup--; |
m_iDirtySetup--; |
342 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
343 |
return; |
return; |
344 |
|
|
345 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
346 |
if (pOptions == NULL) |
if (pOptions == NULL) |
347 |
return; |
return; |
348 |
|
|
360 |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
361 |
iErrors++; |
iErrors++; |
362 |
} else { |
} else { |
363 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
364 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
365 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
366 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
367 |
qsamplerChannelRoutingMap routingMap = m_routingModel.routingMap(); |
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
368 |
if (pDevice == NULL) |
if (pDevice == NULL) |
369 |
iErrors++; |
iErrors++; |
370 |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
371 |
iErrors++; |
iErrors++; |
372 |
else if (!routingMap.isEmpty()) { |
else if (!routingMap.isEmpty()) { |
373 |
// Set the audio route changes... |
// Set the audio route changes... |
374 |
qsamplerChannelRoutingMap::ConstIterator iter; |
ChannelRoutingMap::ConstIterator iter; |
375 |
for (iter = routingMap.begin(); |
for (iter = routingMap.begin(); |
376 |
iter != routingMap.end(); ++iter) { |
iter != routingMap.end(); ++iter) { |
377 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
384 |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
385 |
iErrors++; |
iErrors++; |
386 |
} else { |
} else { |
387 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
388 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
389 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
390 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
412 |
if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex())) |
if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex())) |
413 |
iErrors++; |
iErrors++; |
414 |
// Show error messages? |
// Show error messages? |
415 |
if (iErrors > 0) |
if (iErrors > 0) { |
416 |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
m_pChannel->appendMessagesError( |
417 |
|
tr("Some channel settings could not be set.\n\nSorry.")); |
418 |
|
} |
419 |
} |
} |
420 |
|
|
421 |
// Save default engine name, instrument directory and history... |
// Save default engine name, instrument directory and history... |
438 |
bool bReject = true; |
bool bReject = true; |
439 |
|
|
440 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
441 |
if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) { |
if (m_iDirtyCount > 0) { |
442 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
443 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
444 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
445 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
446 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
447 |
case 0: // Apply... |
QMessageBox::Discard | |
448 |
|
QMessageBox::Cancel)) { |
449 |
|
case QMessageBox::Apply: |
450 |
accept(); |
accept(); |
451 |
return; |
return; |
452 |
case 1: // Discard |
case QMessageBox::Discard: |
453 |
break; |
break; |
454 |
default: // Cancel. |
default: // Cancel. |
455 |
bReject = false; |
bReject = false; |
471 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
472 |
return; |
return; |
473 |
|
|
474 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
475 |
if (pOptions == NULL) |
if (pOptions == NULL) |
476 |
return; |
return; |
477 |
|
|
478 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
479 |
// depending on the current engine. |
// depending on the current engine. |
480 |
|
QStringList filters; |
481 |
|
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
482 |
|
if (sEngineName.contains("GIG")) |
483 |
|
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
484 |
|
if (sEngineName.contains("SFZ")) |
485 |
|
filters << tr("SFZ Instrument files") + " (*.sfz)"; |
486 |
|
if (sEngineName.contains("SF2")) |
487 |
|
filters << tr("SF2 Instrument files") + " (*.sf2)"; |
488 |
|
filters << tr("All files") + " (*.*)"; |
489 |
|
const QString& filter = filters.join(";;"); |
490 |
|
|
491 |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
492 |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
493 |
pOptions->sInstrumentDir, // Start here. |
pOptions->sInstrumentDir, // Start here. |
494 |
tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) |
filter // File filter. |
495 |
); |
); |
496 |
|
|
497 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
511 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
512 |
return; |
return; |
513 |
|
|
514 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
515 |
if (pOptions == NULL) |
if (pOptions == NULL) |
516 |
return; |
return; |
517 |
|
|
519 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
520 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
521 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
522 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
523 |
m_ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
524 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
525 |
); |
); |
529 |
|
|
530 |
|
|
531 |
// Show device options dialog. |
// Show device options dialog. |
532 |
void ChannelForm::setupDevice ( qsamplerDevice *pDevice, |
void ChannelForm::setupDevice ( Device *pDevice, |
533 |
qsamplerDevice::DeviceType deviceTypeMode, |
Device::DeviceType deviceTypeMode, |
534 |
const QString& sDriverName ) |
const QString& sDriverName ) |
535 |
{ |
{ |
|
if (pDevice == NULL) |
|
|
return; |
|
|
|
|
536 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
537 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
538 |
return; |
return; |
542 |
// Create the device form if not already... |
// Create the device form if not already... |
543 |
if (m_pDeviceForm == NULL) { |
if (m_pDeviceForm == NULL) { |
544 |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
545 |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
546 |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
547 |
this, SLOT(updateDevices())); |
this, SLOT(updateDevices())); |
548 |
} |
} |
572 |
// Save current device id. |
// Save current device id. |
573 |
// Save current device id. |
// Save current device id. |
574 |
int iDeviceID = 0; |
int iDeviceID = 0; |
575 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
576 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
577 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
578 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
585 |
m_midiDevices.clear(); |
m_midiDevices.clear(); |
586 |
|
|
587 |
// Populate with the current ones... |
// Populate with the current ones... |
588 |
const QPixmap midiPixmap(":/icons/midi2.png"); |
const QPixmap midiPixmap(":/images/midi2.png"); |
589 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
590 |
qsamplerDevice::Midi); |
Device::Midi); |
591 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
592 |
pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]); |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
593 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
594 |
m_ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName()); |
m_ui.MidiDeviceComboBox->insertItem(0, |
595 |
|
midiPixmap, pDevice->deviceName()); |
596 |
m_midiDevices.append(pDevice); |
m_midiDevices.append(pDevice); |
597 |
} else { |
} else { |
598 |
delete pDevice; |
delete pDevice; |
604 |
if (bEnabled) { |
if (bEnabled) { |
605 |
// Select the previous current device... |
// Select the previous current device... |
606 |
iMidiItem = 0; |
iMidiItem = 0; |
607 |
QListIterator<qsamplerDevice *> iter(m_midiDevices); |
QListIterator<Device *> iter(m_midiDevices); |
608 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
609 |
pDevice = iter.next(); |
pDevice = iter.next(); |
610 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
637 |
// Select MIDI device item. |
// Select MIDI device item. |
638 |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
639 |
{ |
{ |
640 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
641 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
642 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
643 |
if (pDevice) { |
if (pDevice) { |
644 |
const qsamplerDeviceParamMap& params = pDevice->params(); |
const DeviceParamMap& params = pDevice->params(); |
645 |
int iPorts = params["PORTS"].value.toInt(); |
int iPorts = params["PORTS"].value.toInt(); |
646 |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
647 |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
665 |
// MIDI device options. |
// MIDI device options. |
666 |
void ChannelForm::setupMidiDevice (void) |
void ChannelForm::setupMidiDevice (void) |
667 |
{ |
{ |
668 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
669 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
670 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
671 |
pDevice = m_midiDevices.at(iMidiItem); |
pDevice = m_midiDevices.at(iMidiItem); |
672 |
setupDevice(pDevice, |
setupDevice(pDevice, |
673 |
qsamplerDevice::Midi, m_ui.MidiDriverComboBox->currentText()); |
Device::Midi, m_ui.MidiDriverComboBox->currentText()); |
674 |
} |
} |
675 |
|
|
676 |
|
|
687 |
|
|
688 |
// Save current device id. |
// Save current device id. |
689 |
int iDeviceID = 0; |
int iDeviceID = 0; |
690 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
691 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
692 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
693 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
700 |
m_audioDevices.clear(); |
m_audioDevices.clear(); |
701 |
|
|
702 |
// Populate with the current ones... |
// Populate with the current ones... |
703 |
const QPixmap audioPixmap(":/icons/audio2.png"); |
const QPixmap audioPixmap(":/images/audio2.png"); |
704 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
705 |
qsamplerDevice::Audio); |
Device::Audio); |
706 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
707 |
pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]); |
pDevice = new Device(Device::Audio, piDeviceIDs[i]); |
708 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
709 |
m_ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName()); |
m_ui.AudioDeviceComboBox->insertItem(0, |
710 |
|
audioPixmap, pDevice->deviceName()); |
711 |
m_audioDevices.append(pDevice); |
m_audioDevices.append(pDevice); |
712 |
} else { |
} else { |
713 |
delete pDevice; |
delete pDevice; |
719 |
if (bEnabled) { |
if (bEnabled) { |
720 |
// Select the previous current device... |
// Select the previous current device... |
721 |
iAudioItem = 0; |
iAudioItem = 0; |
722 |
QListIterator<qsamplerDevice *> iter(m_audioDevices); |
QListIterator<Device *> iter(m_audioDevices); |
723 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
724 |
pDevice = iter.next(); |
pDevice = iter.next(); |
725 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
754 |
// Select Audio device item. |
// Select Audio device item. |
755 |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
756 |
{ |
{ |
757 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
758 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
759 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
760 |
if (pDevice) { |
if (pDevice) { |
780 |
// Audio device options. |
// Audio device options. |
781 |
void ChannelForm::setupAudioDevice (void) |
void ChannelForm::setupAudioDevice (void) |
782 |
{ |
{ |
783 |
qsamplerDevice *pDevice = NULL; |
Device *pDevice = NULL; |
784 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
785 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
786 |
pDevice = m_audioDevices.at(iAudioItem); |
pDevice = m_audioDevices.at(iAudioItem); |
787 |
setupDevice(pDevice, |
setupDevice(pDevice, |
788 |
qsamplerDevice::Audio, m_ui.AudioDriverComboBox->currentText()); |
Device::Audio, m_ui.AudioDriverComboBox->currentText()); |
789 |
} |
} |
790 |
|
|
791 |
// UPdate all device lists slot. |
// UPdate all device lists slot. |
816 |
{ |
{ |
817 |
const bool bValid = |
const bool bValid = |
818 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
819 |
m_ui.EngineNameComboBox->currentText() != |
m_ui.EngineNameComboBox->currentText() |
820 |
qsamplerChannel::noEngineName(); |
!= Channel::noEngineName(); |
821 |
#if 0 |
#if 0 |
822 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
823 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
824 |
#endif |
#endif |
825 |
m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
m_ui.DialogButtonBox->button( |
826 |
|
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
827 |
} |
} |
828 |
|
|
829 |
|
|
830 |
void ChannelForm::updateTableCellRenderers (void) |
void ChannelForm::updateTableCellRenderers (void) |
831 |
{ |
{ |
832 |
const int rows = m_routingModel.rowCount(); |
const int rows = m_routingModel.rowCount(); |
833 |
const int cols = m_routingModel.columnCount(); |
const int cols = m_routingModel.columnCount(); |
834 |
updateTableCellRenderers( |
updateTableCellRenderers( |
835 |
m_routingModel.index(0, 0), |
m_routingModel.index(0, 0), |
836 |
m_routingModel.index(rows - 1, cols - 1)); |
m_routingModel.index(rows - 1, cols - 1)); |
837 |
} |
} |
840 |
void ChannelForm::updateTableCellRenderers ( |
void ChannelForm::updateTableCellRenderers ( |
841 |
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
842 |
{ |
{ |
843 |
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
844 |
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
845 |
const QModelIndex index = m_routingModel.index(r, c); |
const QModelIndex index = m_routingModel.index(r, c); |
846 |
m_ui.AudioRoutingTable->openPersistentEditor(index); |
m_ui.AudioRoutingTable->openPersistentEditor(index); |
847 |
} |
} |
848 |
} |
} |
849 |
} |
} |
850 |
|
|
851 |
} // namespace QSampler |
} // namespace QSampler |