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 |
28 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
29 |
#include "qsamplerInstrument.h" |
#include "qsamplerInstrument.h" |
30 |
|
|
31 |
#include <qvalidator.h> |
#include <QValidator> |
32 |
#include <qmessagebox.h> |
#include <QMessageBox> |
33 |
#include <qfiledialog.h> |
#include <QFileDialog> |
34 |
#include <qfileinfo.h> |
#include <QFileInfo> |
35 |
|
|
36 |
|
#include <QHeaderView> |
37 |
|
|
38 |
|
|
39 |
namespace QSampler { |
namespace QSampler { |
40 |
|
|
41 |
ChannelForm::ChannelForm(QWidget* parent) : QDialog(parent) { |
//------------------------------------------------------------------------- |
42 |
ui.setupUi(this); |
// QSampler::Channelform -- Channel form implementation. |
43 |
|
// |
44 |
|
|
45 |
|
ChannelForm::ChannelForm ( QWidget* pParent ) |
46 |
|
: QDialog(pParent) |
47 |
|
{ |
48 |
|
m_ui.setupUi(this); |
49 |
|
|
50 |
// Initialize locals. |
// Initialize locals. |
51 |
m_pChannel = NULL; |
m_pChannel = NULL; |
53 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
54 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
55 |
|
|
56 |
m_midiDevices.setAutoDelete(true); |
// m_midiDevices.setAutoDelete(true); |
57 |
m_audioDevices.setAutoDelete(true); |
// m_audioDevices.setAutoDelete(true); |
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); |
66 |
|
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); |
71 |
|
#endif |
72 |
|
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
73 |
|
|
74 |
|
// This goes initially hidden, and will be shown |
75 |
|
// on setup() for currently existing channels... |
76 |
|
m_ui.AudioRoutingTable->hide(); |
77 |
|
|
78 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
79 |
adjustSize(); |
adjustSize(); |
80 |
|
|
81 |
QObject::connect(ui.EngineNameComboBox, |
QObject::connect(m_ui.EngineNameComboBox, |
82 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
83 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
84 |
QObject::connect(ui.InstrumentFileComboBox, |
QObject::connect(m_ui.InstrumentFileComboBox, |
85 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
86 |
SLOT(updateInstrumentName())); |
SLOT(updateInstrumentName())); |
87 |
QObject::connect(ui.InstrumentFileToolButton, |
QObject::connect(m_ui.InstrumentFileToolButton, |
88 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
89 |
SLOT(openInstrumentFile())); |
SLOT(openInstrumentFile())); |
90 |
QObject::connect(ui.InstrumentNrComboBox, |
QObject::connect(m_ui.InstrumentNrComboBox, |
91 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
92 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
93 |
QObject::connect(ui.MidiDriverComboBox, |
QObject::connect(m_ui.MidiDriverComboBox, |
94 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
95 |
SLOT(selectMidiDriver(const QString&))); |
SLOT(selectMidiDriver(const QString&))); |
96 |
QObject::connect(ui.MidiDeviceComboBox, |
QObject::connect(m_ui.MidiDeviceComboBox, |
97 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
98 |
SLOT(selectMidiDevice(int))); |
SLOT(selectMidiDevice(int))); |
99 |
QObject::connect(ui.MidiPortSpinBox, |
QObject::connect(m_ui.MidiPortSpinBox, |
100 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
101 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
102 |
QObject::connect(ui.MidiChannelComboBox, |
QObject::connect(m_ui.MidiChannelComboBox, |
103 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
104 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
105 |
QObject::connect(ui.MidiMapComboBox, |
QObject::connect(m_ui.MidiMapComboBox, |
106 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
107 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
108 |
QObject::connect(ui.AudioDriverComboBox, |
QObject::connect(m_ui.AudioDriverComboBox, |
109 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
110 |
SLOT(selectAudioDriver(const QString&))); |
SLOT(selectAudioDriver(const QString&))); |
111 |
QObject::connect(ui.AudioDeviceComboBox, |
QObject::connect(m_ui.AudioDeviceComboBox, |
112 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
113 |
SLOT(selectAudioDevice(int))); |
SLOT(selectAudioDevice(int))); |
114 |
QObject::connect(ui.OkPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
115 |
SIGNAL(clicked()), |
SIGNAL(accepted()), |
116 |
SLOT(accept())); |
SLOT(accept())); |
117 |
QObject::connect(ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
118 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
119 |
SLOT(reject())); |
SLOT(reject())); |
120 |
QObject::connect(ui.MidiDeviceToolButton, |
QObject::connect(m_ui.MidiDeviceToolButton, |
121 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
122 |
SLOT(setupMidiDevice())); |
SLOT(setupMidiDevice())); |
123 |
QObject::connect(ui.AudioDeviceToolButton, |
QObject::connect(m_ui.AudioDeviceToolButton, |
124 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
125 |
SLOT(setupAudioDevice())); |
SLOT(setupAudioDevice())); |
126 |
|
QObject::connect(&m_routingModel, |
127 |
|
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
128 |
|
SLOT(optionsChanged())); |
129 |
|
QObject::connect(&m_routingModel, |
130 |
|
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
131 |
|
SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&))); |
132 |
|
QObject::connect(&m_routingModel, |
133 |
|
SIGNAL(modelReset()), |
134 |
|
SLOT(updateTableCellRenderers())); |
135 |
} |
} |
136 |
|
|
137 |
ChannelForm::~ChannelForm() { |
ChannelForm::~ChannelForm() |
138 |
|
{ |
139 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
140 |
delete m_pDeviceForm; |
delete m_pDeviceForm; |
141 |
m_pDeviceForm = NULL; |
m_pDeviceForm = NULL; |
142 |
|
|
143 |
|
qDeleteAll(m_midiDevices); |
144 |
|
m_midiDevices.clear(); |
145 |
|
|
146 |
|
qDeleteAll(m_audioDevices); |
147 |
|
m_audioDevices.clear(); |
148 |
} |
} |
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 |
setCaption(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. |
167 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
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 |
|
|
178 |
m_iDirtySetup++; |
m_iDirtySetup++; |
179 |
|
|
180 |
// Load combo box history... |
// Load combo box history... |
181 |
pOptions->loadComboBoxHistory(ui.InstrumentFileComboBox); |
pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox); |
|
|
|
|
// Notify.that we've just changed one audio route. |
|
|
QObject::connect(ui.AudioRoutingTable, SIGNAL(valueChanged(int,int)), |
|
|
this, SLOT(changeAudioRouting(int,int))); |
|
182 |
|
|
183 |
// Populate Engines list. |
// Populate Engines list. |
184 |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
185 |
if (ppszEngines) { |
if (ppszEngines) { |
186 |
ui.EngineNameComboBox->clear(); |
m_ui.EngineNameComboBox->clear(); |
187 |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
188 |
ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine])); |
m_ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine])); |
189 |
} |
} |
190 |
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
191 |
|
|
192 |
// Populate Audio output type list. |
// Populate Audio output type list. |
193 |
ui.AudioDriverComboBox->clear(); |
m_ui.AudioDriverComboBox->clear(); |
194 |
ui.AudioDriverComboBox->insertStringList( |
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 |
ui.MidiDriverComboBox->clear(); |
m_ui.MidiDriverComboBox->clear(); |
199 |
ui.MidiDriverComboBox->insertStringList( |
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 |
ui.MidiMapComboBox->clear(); |
m_ui.MidiMapComboBox->clear(); |
204 |
ui.MidiMapComboBox->insertStringList(qsamplerInstrument::getMapNames()); |
m_ui.MidiMapComboBox->insertItems(0, |
205 |
|
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 (ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
217 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
218 |
ui.EngineNameComboBox->addItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
219 |
} |
} |
220 |
ui.EngineNameComboBox->setCurrentIndex( |
m_ui.EngineNameComboBox->setCurrentIndex( |
221 |
ui.EngineNameComboBox->findText(sEngineName, |
m_ui.EngineNameComboBox->findText(sEngineName, |
222 |
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
223 |
|
|
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 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
229 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
230 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
231 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
232 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
233 |
ui.InstrumentNrComboBox->setCurrentItem(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) |
243 |
sMidiDriver = pOptions->sMidiDriver.upper(); |
sMidiDriver = pOptions->sMidiDriver.toUpper(); |
244 |
if (!sMidiDriver.isEmpty()) { |
if (!sMidiDriver.isEmpty()) { |
245 |
if (ui.MidiDriverComboBox->findText(sMidiDriver, |
if (m_ui.MidiDriverComboBox->findText(sMidiDriver, |
246 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
247 |
ui.MidiDriverComboBox->insertItem(sMidiDriver); |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
248 |
} |
} |
249 |
ui.MidiDriverComboBox->setCurrentText(sMidiDriver); |
m_ui.MidiDriverComboBox->setCurrentIndex( |
250 |
|
m_ui.MidiDriverComboBox->findText(sMidiDriver, |
251 |
|
Qt::MatchExactly | Qt::MatchCaseSensitive) |
252 |
|
); |
253 |
} |
} |
254 |
selectMidiDriverItem(sMidiDriver); |
selectMidiDriverItem(sMidiDriver); |
255 |
if (!bNew) |
if (!bNew) { |
256 |
ui.MidiDeviceComboBox->setCurrentText(midiDevice.deviceName()); |
m_ui.MidiDeviceComboBox->setItemText( |
257 |
selectMidiDeviceItem(ui.MidiDeviceComboBox->currentItem()); |
m_ui.MidiDeviceComboBox->currentIndex(), |
258 |
|
midiDevice.deviceName()); |
259 |
|
} |
260 |
|
selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex()); |
261 |
// MIDI input port... |
// MIDI input port... |
262 |
ui.MidiPortSpinBox->setValue(pChannel->midiPort()); |
m_ui.MidiPortSpinBox->setValue(pChannel->midiPort()); |
263 |
// MIDI input channel... |
// MIDI input channel... |
264 |
int iMidiChannel = pChannel->midiChannel(); |
int iMidiChannel = pChannel->midiChannel(); |
265 |
// When new, try to suggest a sensible MIDI channel... |
// When new, try to suggest a sensible MIDI channel... |
266 |
if (iMidiChannel < 0) |
if (iMidiChannel < 0) |
267 |
iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16); |
iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16); |
268 |
ui.MidiChannelComboBox->setCurrentItem(iMidiChannel); |
m_ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel); |
269 |
// MIDI instrument map... |
// MIDI instrument map... |
270 |
int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap()); |
int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap()); |
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 |
ui.MidiMapComboBox->setCurrentText(sMapName); |
m_ui.MidiMapComboBox->setItemText( |
277 |
|
m_ui.MidiMapComboBox->currentIndex(), |
278 |
|
sMapName); |
279 |
|
} |
280 |
// It might be no maps around... |
// It might be no maps around... |
281 |
bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0); |
bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0); |
282 |
ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
283 |
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) |
290 |
sAudioDriver = pOptions->sAudioDriver.upper(); |
sAudioDriver = pOptions->sAudioDriver.toUpper(); |
291 |
if (!sAudioDriver.isEmpty()) { |
if (!sAudioDriver.isEmpty()) { |
292 |
if (ui.AudioDriverComboBox->findText(sAudioDriver, |
if (m_ui.AudioDriverComboBox->findText(sAudioDriver, |
293 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
294 |
ui.AudioDriverComboBox->insertItem(sAudioDriver); |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
295 |
} |
} |
296 |
ui.AudioDriverComboBox->setCurrentText(sAudioDriver); |
m_ui.AudioDriverComboBox->setCurrentIndex( |
297 |
|
m_ui.AudioDriverComboBox->findText(sAudioDriver, |
298 |
|
Qt::MatchExactly | Qt::MatchCaseSensitive) |
299 |
|
); |
300 |
} |
} |
301 |
selectAudioDriverItem(sAudioDriver); |
selectAudioDriverItem(sAudioDriver); |
302 |
if (!bNew) |
if (!bNew) { |
303 |
ui.AudioDeviceComboBox->setCurrentText(audioDevice.deviceName()); |
m_ui.AudioDeviceComboBox->setItemText( |
304 |
selectAudioDeviceItem(ui.AudioDeviceComboBox->currentItem()); |
m_ui.AudioDeviceComboBox->currentIndex(), |
305 |
|
audioDevice.deviceName()); |
306 |
|
} |
307 |
|
selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex()); |
308 |
|
|
309 |
|
// Let the audio routing table see the light, |
310 |
|
// if we're editing an existing sampler channel... |
311 |
|
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 |
|
|
349 |
// Flush any pending editing... |
// Flush any pending editing... |
350 |
//ui.AudioRoutingTable->flush(); |
//m_ui.AudioRoutingTable->flush(); |
351 |
|
|
352 |
// We'll go for it! |
// We'll go for it! |
353 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
357 |
iErrors++; |
iErrors++; |
358 |
// Accept Audio driver or device selection... |
// Accept Audio driver or device selection... |
359 |
if (m_audioDevices.isEmpty()) { |
if (m_audioDevices.isEmpty()) { |
360 |
if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
361 |
iErrors++; |
iErrors++; |
362 |
} else { |
} else { |
363 |
qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
364 |
|
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
365 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
366 |
|
pDevice = m_audioDevices.at(iAudioItem); |
367 |
|
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 (!m_audioRouting.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 = m_audioRouting.begin(); |
for (iter = routingMap.begin(); |
376 |
iter != m_audioRouting.end(); ++iter) { |
iter != routingMap.end(); ++iter) { |
377 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.data())) |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
378 |
iErrors++; |
iErrors++; |
379 |
} |
} |
380 |
} |
} |
381 |
} |
} |
382 |
// Accept MIDI driver or device selection... |
// Accept MIDI driver or device selection... |
383 |
if (m_midiDevices.isEmpty()) { |
if (m_midiDevices.isEmpty()) { |
384 |
if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText())) |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
385 |
iErrors++; |
iErrors++; |
386 |
} else { |
} else { |
387 |
qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
388 |
|
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
389 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
390 |
|
pDevice = m_midiDevices.at(iMidiItem); |
391 |
if (pDevice == NULL) |
if (pDevice == NULL) |
392 |
iErrors++; |
iErrors++; |
393 |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
394 |
iErrors++; |
iErrors++; |
395 |
} |
} |
396 |
// MIDI input port number... |
// MIDI input port number... |
397 |
if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value())) |
if (!m_pChannel->setMidiPort(m_ui.MidiPortSpinBox->value())) |
398 |
iErrors++; |
iErrors++; |
399 |
// MIDI input channel... |
// MIDI input channel... |
400 |
if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentItem())) |
if (!m_pChannel->setMidiChannel(m_ui.MidiChannelComboBox->currentIndex())) |
401 |
iErrors++; |
iErrors++; |
402 |
// Engine name... |
// Engine name... |
403 |
if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText())) |
if (!m_pChannel->loadEngine(m_ui.EngineNameComboBox->currentText())) |
404 |
iErrors++; |
iErrors++; |
405 |
// Instrument file and index... |
// Instrument file and index... |
406 |
const QString& sPath = ui.InstrumentFileComboBox->currentText(); |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
407 |
if (!sPath.isEmpty() && QFileInfo(sPath).exists()) { |
if (!sPath.isEmpty() && QFileInfo(sPath).exists()) { |
408 |
if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentItem())) |
if (!m_pChannel->loadInstrument(sPath, m_ui.InstrumentNrComboBox->currentIndex())) |
409 |
iErrors++; |
iErrors++; |
410 |
} |
} |
411 |
// MIDI intrument map... |
// MIDI intrument map... |
412 |
if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentItem())) |
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... |
422 |
pOptions->sInstrumentDir = QFileInfo(ui.InstrumentFileComboBox->currentText()).dirPath(true); |
pOptions->sInstrumentDir = QFileInfo( |
423 |
pOptions->sEngineName = ui.EngineNameComboBox->currentText(); |
m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath(); |
424 |
pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText(); |
pOptions->sEngineName = m_ui.EngineNameComboBox->currentText(); |
425 |
pOptions->sMidiDriver = ui.MidiDriverComboBox->currentText(); |
pOptions->sAudioDriver = m_ui.AudioDriverComboBox->currentText(); |
426 |
pOptions->iMidiMap = ui.MidiMapComboBox->currentItem(); |
pOptions->sMidiDriver = m_ui.MidiDriverComboBox->currentText(); |
427 |
pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox); |
pOptions->iMidiMap = m_ui.MidiMapComboBox->currentIndex(); |
428 |
|
pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox); |
429 |
|
|
430 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |
431 |
QDialog::accept(); |
QDialog::accept(); |
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 && 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 |
QString sInstrumentFile = QFileDialog::getOpenFileName( |
QStringList filters; |
481 |
pOptions->sInstrumentDir, // Start here. |
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
482 |
tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files) |
if (sEngineName.contains("GIG")) |
483 |
this, 0, // Parent and name (none) |
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
484 |
QSAMPLER_TITLE ": " + tr("Instrument files") // Caption. |
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, |
492 |
|
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
493 |
|
pOptions->sInstrumentDir, // Start here. |
494 |
|
filter // File filter. |
495 |
); |
); |
496 |
|
|
497 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
498 |
return; |
return; |
499 |
|
|
500 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
501 |
updateInstrumentName(); |
updateInstrumentName(); |
502 |
} |
} |
503 |
|
|
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 |
|
|
518 |
// Finally this better idea would be to use libgig |
// Finally this better idea would be to use libgig |
519 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
520 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
521 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
522 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
523 |
ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
524 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
525 |
); |
); |
526 |
|
|
529 |
|
|
530 |
|
|
531 |
// Show device options dialog. |
// Show device options dialog. |
532 |
void ChannelForm::setupDevice ( qsamplerDevice *pDevice, |
void ChannelForm::setupDevice ( Device *pDevice, |
533 |
qsamplerDevice::qsamplerDeviceType deviceTypeMode, |
Device::DeviceType deviceTypeMode, |
534 |
const QString& sDriverName ) |
const QString& sDriverName ) |
535 |
{ |
{ |
536 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
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 |
} |
} |
567 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
568 |
return; |
return; |
569 |
|
|
570 |
const QString sDriverName = sMidiDriver.upper(); |
const QString sDriverName = sMidiDriver.toUpper(); |
571 |
|
|
572 |
// Save current device id. |
// Save current device id. |
573 |
|
// Save current device id. |
574 |
int iDeviceID = 0; |
int iDeviceID = 0; |
575 |
qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
576 |
|
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
577 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
578 |
|
pDevice = m_midiDevices.at(iMidiItem); |
579 |
if (pDevice) |
if (pDevice) |
580 |
iDeviceID = pDevice->deviceID(); |
iDeviceID = pDevice->deviceID(); |
581 |
|
|
582 |
// Clean maplist. |
// Clean maplist. |
583 |
ui.MidiDeviceComboBox->clear(); |
m_ui.MidiDeviceComboBox->clear(); |
584 |
|
qDeleteAll(m_midiDevices); |
585 |
m_midiDevices.clear(); |
m_midiDevices.clear(); |
586 |
|
|
587 |
// Populate with the current ones... |
// Populate with the current ones... |
588 |
const QPixmap midiPixmap(":/qsampler/pixmaps/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().upper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
594 |
ui.MidiDeviceComboBox->insertItem(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; |
603 |
bool bEnabled = !m_midiDevices.isEmpty(); |
bool bEnabled = !m_midiDevices.isEmpty(); |
604 |
if (bEnabled) { |
if (bEnabled) { |
605 |
// Select the previous current device... |
// Select the previous current device... |
606 |
int iMidiItem = 0; |
iMidiItem = 0; |
607 |
for (pDevice = m_midiDevices.first(); |
QListIterator<Device *> iter(m_midiDevices); |
608 |
pDevice; |
while (iter.hasNext()) { |
609 |
pDevice = m_midiDevices.next()) { |
pDevice = iter.next(); |
610 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
611 |
ui.MidiDeviceComboBox->setCurrentItem(iMidiItem); |
m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem); |
612 |
selectMidiDeviceItem(iMidiItem); |
selectMidiDeviceItem(iMidiItem); |
613 |
break; |
break; |
614 |
} |
} |
615 |
iMidiItem++; |
iMidiItem++; |
616 |
} |
} |
617 |
} else { |
} else { |
618 |
ui.MidiDeviceComboBox->insertItem( |
m_ui.MidiDeviceComboBox->insertItem(0, |
619 |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
620 |
} |
} |
621 |
ui.MidiDeviceTextLabel->setEnabled(bEnabled); |
m_ui.MidiDeviceTextLabel->setEnabled(bEnabled); |
622 |
ui.MidiDeviceComboBox->setEnabled(bEnabled); |
m_ui.MidiDeviceComboBox->setEnabled(bEnabled); |
623 |
} |
} |
624 |
|
|
625 |
|
|
637 |
// Select MIDI device item. |
// Select MIDI device item. |
638 |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
639 |
{ |
{ |
640 |
qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem); |
Device *pDevice = NULL; |
641 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
642 |
|
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 |
ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
647 |
ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
648 |
if (iPorts > 0) |
if (iPorts > 0) |
649 |
ui.MidiPortSpinBox->setMaxValue(iPorts - 1); |
m_ui.MidiPortSpinBox->setMaximum(iPorts - 1); |
650 |
} |
} |
651 |
} |
} |
652 |
|
|
665 |
// MIDI device options. |
// MIDI device options. |
666 |
void ChannelForm::setupMidiDevice (void) |
void ChannelForm::setupMidiDevice (void) |
667 |
{ |
{ |
668 |
setupDevice(m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()), |
Device *pDevice = NULL; |
669 |
qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText()); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
670 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
671 |
|
pDevice = m_midiDevices.at(iMidiItem); |
672 |
|
setupDevice(pDevice, |
673 |
|
Device::Midi, m_ui.MidiDriverComboBox->currentText()); |
674 |
} |
} |
675 |
|
|
676 |
|
|
683 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
684 |
return; |
return; |
685 |
|
|
686 |
const QString sDriverName = sAudioDriver.upper(); |
const QString sDriverName = sAudioDriver.toUpper(); |
687 |
|
|
688 |
// Save current device id. |
// Save current device id. |
689 |
int iDeviceID = 0; |
int iDeviceID = 0; |
690 |
qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
691 |
|
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
692 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
693 |
|
pDevice = m_audioDevices.at(iAudioItem); |
694 |
if (pDevice) |
if (pDevice) |
695 |
iDeviceID = pDevice->deviceID(); |
iDeviceID = pDevice->deviceID(); |
696 |
|
|
697 |
// Clean maplist. |
// Clean maplist. |
698 |
ui.AudioDeviceComboBox->clear(); |
m_ui.AudioDeviceComboBox->clear(); |
699 |
|
qDeleteAll(m_audioDevices); |
700 |
m_audioDevices.clear(); |
m_audioDevices.clear(); |
701 |
|
|
702 |
// Populate with the current ones... |
// Populate with the current ones... |
703 |
const QPixmap audioPixmap(":/qsampler/pixmaps/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().upper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
709 |
ui.AudioDeviceComboBox->insertItem(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; |
718 |
bool bEnabled = !m_audioDevices.isEmpty(); |
bool bEnabled = !m_audioDevices.isEmpty(); |
719 |
if (bEnabled) { |
if (bEnabled) { |
720 |
// Select the previous current device... |
// Select the previous current device... |
721 |
int iAudioItem = 0; |
iAudioItem = 0; |
722 |
for (pDevice = m_audioDevices.first(); |
QListIterator<Device *> iter(m_audioDevices); |
723 |
pDevice; |
while (iter.hasNext()) { |
724 |
pDevice = m_audioDevices.next()) { |
pDevice = iter.next(); |
725 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
726 |
ui.AudioDeviceComboBox->setCurrentItem(iAudioItem); |
m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem); |
727 |
selectAudioDeviceItem(iAudioItem); |
selectAudioDeviceItem(iAudioItem); |
728 |
break; |
break; |
729 |
} |
} |
730 |
iAudioItem++; |
iAudioItem++; |
731 |
} |
} |
732 |
} else { |
} else { |
733 |
ui.AudioDeviceComboBox->insertItem( |
m_ui.AudioDeviceComboBox->insertItem(0, |
734 |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
735 |
//ui.AudioRoutingTable->setNumRows(0); |
//m_ui.AudioRoutingTable->setNumRows(0); |
736 |
} |
} |
737 |
ui.AudioDeviceTextLabel->setEnabled(bEnabled); |
m_ui.AudioDeviceTextLabel->setEnabled(bEnabled); |
738 |
ui.AudioDeviceComboBox->setEnabled(bEnabled); |
m_ui.AudioDeviceComboBox->setEnabled(bEnabled); |
739 |
ui.AudioRoutingTable->setEnabled(bEnabled); |
m_ui.AudioRoutingTable->setEnabled(bEnabled); |
740 |
} |
} |
741 |
|
|
742 |
|
|
754 |
// Select Audio device item. |
// Select Audio device item. |
755 |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
756 |
{ |
{ |
757 |
qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem); |
Device *pDevice = NULL; |
758 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
759 |
|
pDevice = m_audioDevices.at(iAudioItem); |
760 |
if (pDevice) { |
if (pDevice) { |
761 |
// Refresh the audio routing table. |
// Refresh the audio routing table. |
762 |
routingModel.refresh(pDevice, m_pChannel->audioRouting()); |
m_routingModel.refresh(pDevice, m_pChannel->audioRouting()); |
763 |
// Reset routing change map. |
// Reset routing change map. |
764 |
m_audioRouting.clear(); |
m_routingModel.clear(); |
765 |
} |
} |
766 |
} |
} |
767 |
|
|
780 |
// Audio device options. |
// Audio device options. |
781 |
void ChannelForm::setupAudioDevice (void) |
void ChannelForm::setupAudioDevice (void) |
782 |
{ |
{ |
783 |
setupDevice(m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()), |
Device *pDevice = NULL; |
784 |
qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText()); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
785 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
786 |
|
pDevice = m_audioDevices.at(iAudioItem); |
787 |
|
setupDevice(pDevice, |
788 |
|
Device::Audio, m_ui.AudioDriverComboBox->currentText()); |
789 |
} |
} |
790 |
|
|
|
|
|
|
// Audio routing change slot. |
|
|
void ChannelForm::changeAudioRouting ( int iRow, int iCol ) |
|
|
{ |
|
|
#if 0 |
|
|
if (m_iDirtySetup > 0) |
|
|
return; |
|
|
if (iRow < 0 || iCol < 0) |
|
|
return; |
|
|
|
|
|
// Verify that this is a QComboTableItem (magic rtti == 1) |
|
|
QTableItem *pItem = ui.AudioRoutingTable->item(iRow, iCol); |
|
|
if (pItem == NULL) |
|
|
return; |
|
|
qsamplerChannelRoutingComboBox *pComboItem = |
|
|
static_cast<qsamplerChannelRoutingComboBox*> (pItem); |
|
|
// FIXME: Its not garanteed that we must have |
|
|
// iAudioOut == iRow on all times forth! |
|
|
m_audioRouting[iRow] = pComboItem->currentItem(); |
|
|
|
|
|
// And let's get dirty... |
|
|
optionsChanged(); |
|
|
#endif |
|
|
} |
|
|
|
|
|
|
|
791 |
// UPdate all device lists slot. |
// UPdate all device lists slot. |
792 |
void ChannelForm::updateDevices (void) |
void ChannelForm::updateDevices (void) |
793 |
{ |
{ |
794 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
795 |
return; |
return; |
796 |
|
|
797 |
selectMidiDriverItem(ui.MidiDriverComboBox->currentText()); |
selectMidiDriverItem(m_ui.MidiDriverComboBox->currentText()); |
798 |
selectAudioDriverItem(ui.AudioDriverComboBox->currentText()); |
selectAudioDriverItem(m_ui.AudioDriverComboBox->currentText()); |
799 |
optionsChanged(); |
optionsChanged(); |
800 |
} |
} |
801 |
|
|
814 |
// Stabilize current form state. |
// Stabilize current form state. |
815 |
void ChannelForm::stabilizeForm (void) |
void ChannelForm::stabilizeForm (void) |
816 |
{ |
{ |
817 |
bool bValid = true; |
const bool bValid = |
818 |
|
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
819 |
|
m_ui.EngineNameComboBox->currentText() |
820 |
|
!= 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 |
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) |
831 |
|
{ |
832 |
|
const int rows = m_routingModel.rowCount(); |
833 |
|
const int cols = m_routingModel.columnCount(); |
834 |
|
updateTableCellRenderers( |
835 |
|
m_routingModel.index(0, 0), |
836 |
|
m_routingModel.index(rows - 1, cols - 1)); |
837 |
} |
} |
838 |
|
|
839 |
|
|
840 |
|
void ChannelForm::updateTableCellRenderers ( |
841 |
|
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
842 |
|
{ |
843 |
|
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
844 |
|
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
845 |
|
const QModelIndex index = m_routingModel.index(r, c); |
846 |
|
m_ui.AudioRoutingTable->openPersistentEditor(index); |
847 |
|
} |
848 |
|
} |
849 |
|
} |
850 |
|
|
851 |
} // namespace QSampler |
} // namespace QSampler |
852 |
|
|
853 |
|
|