1 |
|
// qsamplerChannelForm.cpp |
2 |
|
// |
3 |
|
/**************************************************************************** |
4 |
|
Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
|
This program is free software; you can redistribute it and/or |
8 |
|
modify it under the terms of the GNU General Public License |
9 |
|
as published by the Free Software Foundation; either version 2 |
10 |
|
of the License, or (at your option) any later version. |
11 |
|
|
12 |
|
This program is distributed in the hope that it will be useful, |
13 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
GNU General Public License for more details. |
16 |
|
|
17 |
|
You should have received a copy of the GNU General Public License along |
18 |
|
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
|
*****************************************************************************/ |
22 |
|
|
23 |
#include "qsamplerChannelForm.h" |
#include "qsamplerChannelForm.h" |
24 |
|
|
25 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
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()->setResizeMode(0, QHeaderView::Stretch); |
69 |
|
#endif |
70 |
|
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
71 |
|
|
72 |
|
// This goes initially hidden, and will be shown |
73 |
|
// on setup() for currently existing channels... |
74 |
|
m_ui.AudioRoutingTable->hide(); |
75 |
|
|
76 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
77 |
adjustSize(); |
adjustSize(); |
78 |
|
|
79 |
|
QObject::connect(m_ui.EngineNameComboBox, |
80 |
|
SIGNAL(activated(int)), |
81 |
|
SLOT(optionsChanged())); |
82 |
|
QObject::connect(m_ui.InstrumentFileComboBox, |
83 |
|
SIGNAL(activated(const QString&)), |
84 |
|
SLOT(updateInstrumentName())); |
85 |
|
QObject::connect(m_ui.InstrumentFileToolButton, |
86 |
|
SIGNAL(clicked()), |
87 |
|
SLOT(openInstrumentFile())); |
88 |
|
QObject::connect(m_ui.InstrumentNrComboBox, |
89 |
|
SIGNAL(activated(int)), |
90 |
|
SLOT(optionsChanged())); |
91 |
|
QObject::connect(m_ui.MidiDriverComboBox, |
92 |
|
SIGNAL(activated(const QString&)), |
93 |
|
SLOT(selectMidiDriver(const QString&))); |
94 |
|
QObject::connect(m_ui.MidiDeviceComboBox, |
95 |
|
SIGNAL(activated(int)), |
96 |
|
SLOT(selectMidiDevice(int))); |
97 |
|
QObject::connect(m_ui.MidiPortSpinBox, |
98 |
|
SIGNAL(valueChanged(int)), |
99 |
|
SLOT(optionsChanged())); |
100 |
|
QObject::connect(m_ui.MidiChannelComboBox, |
101 |
|
SIGNAL(activated(int)), |
102 |
|
SLOT(optionsChanged())); |
103 |
|
QObject::connect(m_ui.MidiMapComboBox, |
104 |
|
SIGNAL(activated(int)), |
105 |
|
SLOT(optionsChanged())); |
106 |
|
QObject::connect(m_ui.AudioDriverComboBox, |
107 |
|
SIGNAL(activated(const QString&)), |
108 |
|
SLOT(selectAudioDriver(const QString&))); |
109 |
|
QObject::connect(m_ui.AudioDeviceComboBox, |
110 |
|
SIGNAL(activated(int)), |
111 |
|
SLOT(selectAudioDevice(int))); |
112 |
|
QObject::connect(m_ui.DialogButtonBox, |
113 |
|
SIGNAL(accepted()), |
114 |
|
SLOT(accept())); |
115 |
|
QObject::connect(m_ui.DialogButtonBox, |
116 |
|
SIGNAL(rejected()), |
117 |
|
SLOT(reject())); |
118 |
|
QObject::connect(m_ui.MidiDeviceToolButton, |
119 |
|
SIGNAL(clicked()), |
120 |
|
SLOT(setupMidiDevice())); |
121 |
|
QObject::connect(m_ui.AudioDeviceToolButton, |
122 |
|
SIGNAL(clicked()), |
123 |
|
SLOT(setupAudioDevice())); |
124 |
|
QObject::connect(&m_routingModel, |
125 |
|
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
126 |
|
SLOT(optionsChanged())); |
127 |
|
QObject::connect(&m_routingModel, |
128 |
|
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
129 |
|
SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&))); |
130 |
|
QObject::connect(&m_routingModel, |
131 |
|
SIGNAL(modelReset()), |
132 |
|
SLOT(updateTableCellRenderers())); |
133 |
} |
} |
134 |
|
|
135 |
ChannelForm::~ChannelForm() { |
ChannelForm::~ChannelForm() |
136 |
|
{ |
137 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
138 |
delete m_pDeviceForm; |
delete m_pDeviceForm; |
139 |
m_pDeviceForm = NULL; |
m_pDeviceForm = NULL; |
140 |
|
|
141 |
|
qDeleteAll(m_midiDevices); |
142 |
|
m_midiDevices.clear(); |
143 |
|
|
144 |
|
qDeleteAll(m_audioDevices); |
145 |
|
m_audioDevices.clear(); |
146 |
} |
} |
147 |
|
|
148 |
|
|
149 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
150 |
void ChannelForm::setup ( qsamplerChannel *pChannel ) |
void ChannelForm::setup ( Channel *pChannel ) |
151 |
{ |
{ |
152 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
153 |
|
|
158 |
return; |
return; |
159 |
|
|
160 |
// It can be a brand new channel, remember? |
// It can be a brand new channel, remember? |
161 |
bool bNew = (m_pChannel->channelID() < 0); |
const bool bNew = (m_pChannel->channelID() < 0); |
162 |
setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
163 |
|
|
164 |
// Check if we're up and connected. |
// Check if we're up and connected. |
165 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
168 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
169 |
return; |
return; |
170 |
|
|
171 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
172 |
if (pOptions == NULL) |
if (pOptions == NULL) |
173 |
return; |
return; |
174 |
|
|
176 |
m_iDirtySetup++; |
m_iDirtySetup++; |
177 |
|
|
178 |
// Load combo box history... |
// Load combo box history... |
179 |
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))); |
|
180 |
|
|
181 |
// Populate Engines list. |
// Populate Engines list. |
182 |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
183 |
if (ppszEngines) { |
if (ppszEngines) { |
184 |
ui.EngineNameComboBox->clear(); |
m_ui.EngineNameComboBox->clear(); |
185 |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
186 |
ui.EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
m_ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine])); |
187 |
} |
} |
188 |
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
189 |
|
|
190 |
// Populate Audio output type list. |
// Populate Audio output type list. |
191 |
ui.AudioDriverComboBox->clear(); |
m_ui.AudioDriverComboBox->clear(); |
192 |
ui.AudioDriverComboBox->insertStringList( |
m_ui.AudioDriverComboBox->insertItems(0, |
193 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio)); |
Device::getDrivers(pMainForm->client(), Device::Audio)); |
194 |
|
|
195 |
// Populate MIDI input type list. |
// Populate MIDI input type list. |
196 |
ui.MidiDriverComboBox->clear(); |
m_ui.MidiDriverComboBox->clear(); |
197 |
ui.MidiDriverComboBox->insertStringList( |
m_ui.MidiDriverComboBox->insertItems(0, |
198 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi)); |
Device::getDrivers(pMainForm->client(), Device::Midi)); |
199 |
|
|
200 |
// Populate Maps list. |
// Populate Maps list. |
201 |
ui.MidiMapComboBox->clear(); |
m_ui.MidiMapComboBox->clear(); |
202 |
ui.MidiMapComboBox->insertStringList(qsamplerInstrument::getMapNames()); |
m_ui.MidiMapComboBox->insertItems(0, |
203 |
|
Instrument::getMapNames()); |
204 |
|
|
205 |
// Read proper channel information, |
// Read proper channel information, |
206 |
// and populate the channel form fields. |
// and populate the channel form fields. |
210 |
if (sEngineName.isEmpty() || bNew) |
if (sEngineName.isEmpty() || bNew) |
211 |
sEngineName = pOptions->sEngineName; |
sEngineName = pOptions->sEngineName; |
212 |
if (sEngineName.isEmpty()) |
if (sEngineName.isEmpty()) |
213 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = Channel::noEngineName(); |
214 |
if (ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
215 |
Qt::MatchExactly | Qt::MatchCaseSensitive) == 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
216 |
ui.EngineNameComboBox->insertItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
217 |
} |
} |
218 |
ui.EngineNameComboBox->setCurrentText(sEngineName); |
m_ui.EngineNameComboBox->setCurrentIndex( |
219 |
|
m_ui.EngineNameComboBox->findText(sEngineName, |
220 |
|
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
221 |
|
|
222 |
// Instrument filename and index... |
// Instrument filename and index... |
223 |
QString sInstrumentFile = pChannel->instrumentFile(); |
QString sInstrumentFile = pChannel->instrumentFile(); |
224 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
225 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = Channel::noInstrumentName(); |
226 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
227 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
228 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
229 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
230 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
231 |
ui.InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); |
int iInstrumentNr = pChannel->instrumentNr(); |
232 |
|
if (iInstrumentNr < 0) |
233 |
|
iInstrumentNr = 0; |
234 |
|
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
235 |
|
|
236 |
// MIDI input device... |
// MIDI input device... |
237 |
qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice()); |
Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
238 |
// MIDI input driver... |
// MIDI input driver... |
239 |
QString sMidiDriver = midiDevice.driverName(); |
QString sMidiDriver = midiDevice.driverName(); |
240 |
if (sMidiDriver.isEmpty() || bNew) |
if (sMidiDriver.isEmpty() || bNew) |
241 |
sMidiDriver = pOptions->sMidiDriver.upper(); |
sMidiDriver = pOptions->sMidiDriver.toUpper(); |
242 |
if (!sMidiDriver.isEmpty()) { |
if (!sMidiDriver.isEmpty()) { |
243 |
if (ui.MidiDriverComboBox->findText(sMidiDriver, |
if (m_ui.MidiDriverComboBox->findText(sMidiDriver, |
244 |
Qt::MatchExactly | Qt::MatchCaseSensitive) == 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
245 |
ui.MidiDriverComboBox->insertItem(sMidiDriver); |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
246 |
} |
} |
247 |
ui.MidiDriverComboBox->setCurrentText(sMidiDriver); |
m_ui.MidiDriverComboBox->setCurrentIndex( |
248 |
|
m_ui.MidiDriverComboBox->findText(sMidiDriver, |
249 |
|
Qt::MatchExactly | Qt::MatchCaseSensitive) |
250 |
|
); |
251 |
} |
} |
252 |
selectMidiDriverItem(sMidiDriver); |
selectMidiDriverItem(sMidiDriver); |
253 |
if (!bNew) |
if (!bNew) { |
254 |
ui.MidiDeviceComboBox->setCurrentText(midiDevice.deviceName()); |
m_ui.MidiDeviceComboBox->setItemText( |
255 |
selectMidiDeviceItem(ui.MidiDeviceComboBox->currentItem()); |
m_ui.MidiDeviceComboBox->currentIndex(), |
256 |
|
midiDevice.deviceName()); |
257 |
|
} |
258 |
|
selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex()); |
259 |
// MIDI input port... |
// MIDI input port... |
260 |
ui.MidiPortSpinBox->setValue(pChannel->midiPort()); |
m_ui.MidiPortSpinBox->setValue(pChannel->midiPort()); |
261 |
// MIDI input channel... |
// MIDI input channel... |
262 |
int iMidiChannel = pChannel->midiChannel(); |
int iMidiChannel = pChannel->midiChannel(); |
263 |
// When new, try to suggest a sensible MIDI channel... |
// When new, try to suggest a sensible MIDI channel... |
264 |
if (iMidiChannel < 0) |
if (iMidiChannel < 0) |
265 |
iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16); |
iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16); |
266 |
ui.MidiChannelComboBox->setCurrentItem(iMidiChannel); |
m_ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel); |
267 |
// MIDI instrument map... |
// MIDI instrument map... |
268 |
int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap()); |
int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap()); |
269 |
// When new, try to suggest a sensible MIDI map... |
// When new, try to suggest a sensible MIDI map... |
270 |
if (iMidiMap < 0) |
if (iMidiMap < 0) |
271 |
iMidiMap = 0; |
iMidiMap = 0; |
272 |
const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap); |
const QString& sMapName = Instrument::getMapName(iMidiMap); |
273 |
if (!sMapName.isEmpty()) |
if (!sMapName.isEmpty()) { |
274 |
ui.MidiMapComboBox->setCurrentText(sMapName); |
m_ui.MidiMapComboBox->setItemText( |
275 |
|
m_ui.MidiMapComboBox->currentIndex(), |
276 |
|
sMapName); |
277 |
|
} |
278 |
// It might be no maps around... |
// It might be no maps around... |
279 |
bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0); |
bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0); |
280 |
ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
281 |
ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
282 |
|
|
283 |
// Audio output device... |
// Audio output device... |
284 |
qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice()); |
Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
285 |
// Audio output driver... |
// Audio output driver... |
286 |
QString sAudioDriver = audioDevice.driverName(); |
QString sAudioDriver = audioDevice.driverName(); |
287 |
if (sAudioDriver.isEmpty() || bNew) |
if (sAudioDriver.isEmpty() || bNew) |
288 |
sAudioDriver = pOptions->sAudioDriver.upper(); |
sAudioDriver = pOptions->sAudioDriver.toUpper(); |
289 |
if (!sAudioDriver.isEmpty()) { |
if (!sAudioDriver.isEmpty()) { |
290 |
if (ui.AudioDriverComboBox->findText(sAudioDriver, |
if (m_ui.AudioDriverComboBox->findText(sAudioDriver, |
291 |
Qt::MatchExactly | Qt::MatchCaseSensitive) == 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
292 |
ui.AudioDriverComboBox->insertItem(sAudioDriver); |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
293 |
} |
} |
294 |
ui.AudioDriverComboBox->setCurrentText(sAudioDriver); |
m_ui.AudioDriverComboBox->setCurrentIndex( |
295 |
|
m_ui.AudioDriverComboBox->findText(sAudioDriver, |
296 |
|
Qt::MatchExactly | Qt::MatchCaseSensitive) |
297 |
|
); |
298 |
} |
} |
299 |
selectAudioDriverItem(sAudioDriver); |
selectAudioDriverItem(sAudioDriver); |
300 |
if (!bNew) |
if (!bNew) { |
301 |
ui.AudioDeviceComboBox->setCurrentText(audioDevice.deviceName()); |
m_ui.AudioDeviceComboBox->setItemText( |
302 |
selectAudioDeviceItem(ui.AudioDeviceComboBox->currentItem()); |
m_ui.AudioDeviceComboBox->currentIndex(), |
303 |
|
audioDevice.deviceName()); |
304 |
|
} |
305 |
|
selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex()); |
306 |
|
|
307 |
|
// Let the audio routing table see the light, |
308 |
|
// if we're editing an existing sampler channel... |
309 |
|
m_ui.AudioRoutingTable->setVisible(!bNew); |
310 |
|
|
311 |
|
const QString sInstrumentNrToolTip = |
312 |
|
(pOptions->bInstrumentNames) ? |
313 |
|
"Select an instrument of the file" : |
314 |
|
"You might want to enable instrument name retrieval in the " |
315 |
|
"settings dialog"; |
316 |
|
m_ui.InstrumentNrComboBox->setToolTip( |
317 |
|
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
318 |
|
); |
319 |
|
|
320 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
321 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
322 |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
/* if (sEngineName != Channel::noEngineName() && |
323 |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
sInstrumentFile != Channel::noInstrumentName()) |
324 |
m_iDirtyCount++; */ |
m_iDirtyCount++; */ |
325 |
// Done. |
// Done. |
326 |
m_iDirtySetup--; |
m_iDirtySetup--; |
340 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
341 |
return; |
return; |
342 |
|
|
343 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
344 |
if (pOptions == NULL) |
if (pOptions == NULL) |
345 |
return; |
return; |
346 |
|
|
347 |
// Flush any pending editing... |
// Flush any pending editing... |
348 |
//ui.AudioRoutingTable->flush(); |
//m_ui.AudioRoutingTable->flush(); |
349 |
|
|
350 |
// We'll go for it! |
// We'll go for it! |
351 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
355 |
iErrors++; |
iErrors++; |
356 |
// Accept Audio driver or device selection... |
// Accept Audio driver or device selection... |
357 |
if (m_audioDevices.isEmpty()) { |
if (m_audioDevices.isEmpty()) { |
358 |
if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
359 |
iErrors++; |
iErrors++; |
360 |
} else { |
} else { |
361 |
qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
362 |
|
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
363 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
364 |
|
pDevice = m_audioDevices.at(iAudioItem); |
365 |
|
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
366 |
if (pDevice == NULL) |
if (pDevice == NULL) |
367 |
iErrors++; |
iErrors++; |
368 |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
369 |
iErrors++; |
iErrors++; |
370 |
else if (!m_audioRouting.isEmpty()) { |
else if (!routingMap.isEmpty()) { |
371 |
// Set the audio route changes... |
// Set the audio route changes... |
372 |
qsamplerChannelRoutingMap::ConstIterator iter; |
ChannelRoutingMap::ConstIterator iter; |
373 |
for (iter = m_audioRouting.begin(); |
for (iter = routingMap.begin(); |
374 |
iter != m_audioRouting.end(); ++iter) { |
iter != routingMap.end(); ++iter) { |
375 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.data())) |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
376 |
iErrors++; |
iErrors++; |
377 |
} |
} |
378 |
} |
} |
379 |
} |
} |
380 |
// Accept MIDI driver or device selection... |
// Accept MIDI driver or device selection... |
381 |
if (m_midiDevices.isEmpty()) { |
if (m_midiDevices.isEmpty()) { |
382 |
if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText())) |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
383 |
iErrors++; |
iErrors++; |
384 |
} else { |
} else { |
385 |
qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
386 |
|
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
387 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
388 |
|
pDevice = m_midiDevices.at(iMidiItem); |
389 |
if (pDevice == NULL) |
if (pDevice == NULL) |
390 |
iErrors++; |
iErrors++; |
391 |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
392 |
iErrors++; |
iErrors++; |
393 |
} |
} |
394 |
// MIDI input port number... |
// MIDI input port number... |
395 |
if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value())) |
if (!m_pChannel->setMidiPort(m_ui.MidiPortSpinBox->value())) |
396 |
iErrors++; |
iErrors++; |
397 |
// MIDI input channel... |
// MIDI input channel... |
398 |
if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentItem())) |
if (!m_pChannel->setMidiChannel(m_ui.MidiChannelComboBox->currentIndex())) |
399 |
iErrors++; |
iErrors++; |
400 |
// Engine name... |
// Engine name... |
401 |
if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText())) |
if (!m_pChannel->loadEngine(m_ui.EngineNameComboBox->currentText())) |
402 |
iErrors++; |
iErrors++; |
403 |
// Instrument file and index... |
// Instrument file and index... |
404 |
const QString& sPath = ui.InstrumentFileComboBox->currentText(); |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
405 |
if (!sPath.isEmpty() && QFileInfo(sPath).exists()) { |
if (!sPath.isEmpty() && QFileInfo(sPath).exists()) { |
406 |
if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentItem())) |
if (!m_pChannel->loadInstrument(sPath, m_ui.InstrumentNrComboBox->currentIndex())) |
407 |
iErrors++; |
iErrors++; |
408 |
} |
} |
409 |
// MIDI intrument map... |
// MIDI intrument map... |
410 |
if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentItem())) |
if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex())) |
411 |
iErrors++; |
iErrors++; |
412 |
// Show error messages? |
// Show error messages? |
413 |
if (iErrors > 0) |
if (iErrors > 0) { |
414 |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
m_pChannel->appendMessagesError( |
415 |
|
tr("Some channel settings could not be set.\n\nSorry.")); |
416 |
|
} |
417 |
} |
} |
418 |
|
|
419 |
// Save default engine name, instrument directory and history... |
// Save default engine name, instrument directory and history... |
420 |
pOptions->sInstrumentDir = QFileInfo(ui.InstrumentFileComboBox->currentText()).dirPath(true); |
pOptions->sInstrumentDir = QFileInfo( |
421 |
pOptions->sEngineName = ui.EngineNameComboBox->currentText(); |
m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath(); |
422 |
pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText(); |
pOptions->sEngineName = m_ui.EngineNameComboBox->currentText(); |
423 |
pOptions->sMidiDriver = ui.MidiDriverComboBox->currentText(); |
pOptions->sAudioDriver = m_ui.AudioDriverComboBox->currentText(); |
424 |
pOptions->iMidiMap = ui.MidiMapComboBox->currentItem(); |
pOptions->sMidiDriver = m_ui.MidiDriverComboBox->currentText(); |
425 |
pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox); |
pOptions->iMidiMap = m_ui.MidiMapComboBox->currentIndex(); |
426 |
|
pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox); |
427 |
|
|
428 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |
429 |
QDialog::accept(); |
QDialog::accept(); |
436 |
bool bReject = true; |
bool bReject = true; |
437 |
|
|
438 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
439 |
if (m_iDirtyCount > 0 && ui.OkPushButton->isEnabled()) { |
if (m_iDirtyCount > 0) { |
440 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
441 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
442 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
443 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
444 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
445 |
case 0: // Apply... |
QMessageBox::Discard | |
446 |
|
QMessageBox::Cancel)) { |
447 |
|
case QMessageBox::Apply: |
448 |
accept(); |
accept(); |
449 |
return; |
return; |
450 |
case 1: // Discard |
case QMessageBox::Discard: |
451 |
break; |
break; |
452 |
default: // Cancel. |
default: // Cancel. |
453 |
bReject = false; |
bReject = false; |
469 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
470 |
return; |
return; |
471 |
|
|
472 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
473 |
if (pOptions == NULL) |
if (pOptions == NULL) |
474 |
return; |
return; |
475 |
|
|
476 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
477 |
// depending on the current engine. |
// depending on the current engine. |
478 |
QString sInstrumentFile = QFileDialog::getOpenFileName( |
QStringList filters; |
479 |
pOptions->sInstrumentDir, // Start here. |
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
480 |
tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files) |
if (sEngineName.contains("GIG")) |
481 |
this, 0, // Parent and name (none) |
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
482 |
QSAMPLER_TITLE ": " + tr("Instrument files") // Caption. |
if (sEngineName.contains("SFZ")) |
483 |
|
filters << tr("SFZ Instrument files") + " (*.sfz)"; |
484 |
|
if (sEngineName.contains("SF2")) |
485 |
|
filters << tr("SF2 Instrument files") + " (*.sf2)"; |
486 |
|
filters << tr("All files") + " (*.*)"; |
487 |
|
const QString& filter = filters.join(";;"); |
488 |
|
|
489 |
|
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
490 |
|
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
491 |
|
pOptions->sInstrumentDir, // Start here. |
492 |
|
filter // File filter. |
493 |
); |
); |
494 |
|
|
495 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
496 |
return; |
return; |
497 |
|
|
498 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
499 |
updateInstrumentName(); |
updateInstrumentName(); |
500 |
} |
} |
501 |
|
|
509 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
510 |
return; |
return; |
511 |
|
|
512 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
513 |
if (pOptions == NULL) |
if (pOptions == NULL) |
514 |
return; |
return; |
515 |
|
|
516 |
// Finally this better idea would be to use libgig |
// Finally this better idea would be to use libgig |
517 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
518 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
519 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
520 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
521 |
ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
522 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
523 |
); |
); |
524 |
|
|
527 |
|
|
528 |
|
|
529 |
// Show device options dialog. |
// Show device options dialog. |
530 |
void ChannelForm::setupDevice ( qsamplerDevice *pDevice, |
void ChannelForm::setupDevice ( Device *pDevice, |
531 |
qsamplerDevice::qsamplerDeviceType deviceTypeMode, |
Device::DeviceType deviceTypeMode, |
532 |
const QString& sDriverName ) |
const QString& sDriverName ) |
533 |
{ |
{ |
534 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
540 |
// Create the device form if not already... |
// Create the device form if not already... |
541 |
if (m_pDeviceForm == NULL) { |
if (m_pDeviceForm == NULL) { |
542 |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
543 |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
544 |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
545 |
this, SLOT(updateDevices())); |
this, SLOT(updateDevices())); |
546 |
} |
} |
565 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
566 |
return; |
return; |
567 |
|
|
568 |
const QString sDriverName = sMidiDriver.upper(); |
const QString sDriverName = sMidiDriver.toUpper(); |
569 |
|
|
570 |
// Save current device id. |
// Save current device id. |
571 |
|
// Save current device id. |
572 |
int iDeviceID = 0; |
int iDeviceID = 0; |
573 |
qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
574 |
|
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
575 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
576 |
|
pDevice = m_midiDevices.at(iMidiItem); |
577 |
if (pDevice) |
if (pDevice) |
578 |
iDeviceID = pDevice->deviceID(); |
iDeviceID = pDevice->deviceID(); |
579 |
|
|
580 |
// Clean maplist. |
// Clean maplist. |
581 |
ui.MidiDeviceComboBox->clear(); |
m_ui.MidiDeviceComboBox->clear(); |
582 |
|
qDeleteAll(m_midiDevices); |
583 |
m_midiDevices.clear(); |
m_midiDevices.clear(); |
584 |
|
|
585 |
// Populate with the current ones... |
// Populate with the current ones... |
586 |
const QPixmap midiPixmap(":/qsampler/pixmaps/midi2.png"); |
const QPixmap midiPixmap(":/images/midi2.png"); |
587 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
588 |
qsamplerDevice::Midi); |
Device::Midi); |
589 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
590 |
pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]); |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
591 |
if (pDevice->driverName().upper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
592 |
ui.MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName()); |
m_ui.MidiDeviceComboBox->insertItem(0, |
593 |
|
midiPixmap, pDevice->deviceName()); |
594 |
m_midiDevices.append(pDevice); |
m_midiDevices.append(pDevice); |
595 |
} else { |
} else { |
596 |
delete pDevice; |
delete pDevice; |
601 |
bool bEnabled = !m_midiDevices.isEmpty(); |
bool bEnabled = !m_midiDevices.isEmpty(); |
602 |
if (bEnabled) { |
if (bEnabled) { |
603 |
// Select the previous current device... |
// Select the previous current device... |
604 |
int iMidiItem = 0; |
iMidiItem = 0; |
605 |
for (pDevice = m_midiDevices.first(); |
QListIterator<Device *> iter(m_midiDevices); |
606 |
pDevice; |
while (iter.hasNext()) { |
607 |
pDevice = m_midiDevices.next()) { |
pDevice = iter.next(); |
608 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
609 |
ui.MidiDeviceComboBox->setCurrentItem(iMidiItem); |
m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem); |
610 |
selectMidiDeviceItem(iMidiItem); |
selectMidiDeviceItem(iMidiItem); |
611 |
break; |
break; |
612 |
} |
} |
613 |
iMidiItem++; |
iMidiItem++; |
614 |
} |
} |
615 |
} else { |
} else { |
616 |
ui.MidiDeviceComboBox->insertItem( |
m_ui.MidiDeviceComboBox->insertItem(0, |
617 |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
618 |
} |
} |
619 |
ui.MidiDeviceTextLabel->setEnabled(bEnabled); |
m_ui.MidiDeviceTextLabel->setEnabled(bEnabled); |
620 |
ui.MidiDeviceComboBox->setEnabled(bEnabled); |
m_ui.MidiDeviceComboBox->setEnabled(bEnabled); |
621 |
} |
} |
622 |
|
|
623 |
|
|
635 |
// Select MIDI device item. |
// Select MIDI device item. |
636 |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
637 |
{ |
{ |
638 |
qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem); |
Device *pDevice = NULL; |
639 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
640 |
|
pDevice = m_midiDevices.at(iMidiItem); |
641 |
if (pDevice) { |
if (pDevice) { |
642 |
const qsamplerDeviceParamMap& params = pDevice->params(); |
const DeviceParamMap& params = pDevice->params(); |
643 |
int iPorts = params["PORTS"].value.toInt(); |
int iPorts = params["PORTS"].value.toInt(); |
644 |
ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
645 |
ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
646 |
if (iPorts > 0) |
if (iPorts > 0) |
647 |
ui.MidiPortSpinBox->setMaxValue(iPorts - 1); |
m_ui.MidiPortSpinBox->setMaximum(iPorts - 1); |
648 |
} |
} |
649 |
} |
} |
650 |
|
|
663 |
// MIDI device options. |
// MIDI device options. |
664 |
void ChannelForm::setupMidiDevice (void) |
void ChannelForm::setupMidiDevice (void) |
665 |
{ |
{ |
666 |
setupDevice(m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()), |
Device *pDevice = NULL; |
667 |
qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText()); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
668 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
669 |
|
pDevice = m_midiDevices.at(iMidiItem); |
670 |
|
setupDevice(pDevice, |
671 |
|
Device::Midi, m_ui.MidiDriverComboBox->currentText()); |
672 |
} |
} |
673 |
|
|
674 |
|
|
681 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
682 |
return; |
return; |
683 |
|
|
684 |
const QString sDriverName = sAudioDriver.upper(); |
const QString sDriverName = sAudioDriver.toUpper(); |
685 |
|
|
686 |
// Save current device id. |
// Save current device id. |
687 |
int iDeviceID = 0; |
int iDeviceID = 0; |
688 |
qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
689 |
|
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
690 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
691 |
|
pDevice = m_audioDevices.at(iAudioItem); |
692 |
if (pDevice) |
if (pDevice) |
693 |
iDeviceID = pDevice->deviceID(); |
iDeviceID = pDevice->deviceID(); |
694 |
|
|
695 |
// Clean maplist. |
// Clean maplist. |
696 |
ui.AudioDeviceComboBox->clear(); |
m_ui.AudioDeviceComboBox->clear(); |
697 |
|
qDeleteAll(m_audioDevices); |
698 |
m_audioDevices.clear(); |
m_audioDevices.clear(); |
699 |
|
|
700 |
// Populate with the current ones... |
// Populate with the current ones... |
701 |
const QPixmap audioPixmap(":/qsampler/pixmaps/audio2.png"); |
const QPixmap audioPixmap(":/images/audio2.png"); |
702 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
703 |
qsamplerDevice::Audio); |
Device::Audio); |
704 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
705 |
pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]); |
pDevice = new Device(Device::Audio, piDeviceIDs[i]); |
706 |
if (pDevice->driverName().upper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
707 |
ui.AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName()); |
m_ui.AudioDeviceComboBox->insertItem(0, |
708 |
|
audioPixmap, pDevice->deviceName()); |
709 |
m_audioDevices.append(pDevice); |
m_audioDevices.append(pDevice); |
710 |
} else { |
} else { |
711 |
delete pDevice; |
delete pDevice; |
716 |
bool bEnabled = !m_audioDevices.isEmpty(); |
bool bEnabled = !m_audioDevices.isEmpty(); |
717 |
if (bEnabled) { |
if (bEnabled) { |
718 |
// Select the previous current device... |
// Select the previous current device... |
719 |
int iAudioItem = 0; |
iAudioItem = 0; |
720 |
for (pDevice = m_audioDevices.first(); |
QListIterator<Device *> iter(m_audioDevices); |
721 |
pDevice; |
while (iter.hasNext()) { |
722 |
pDevice = m_audioDevices.next()) { |
pDevice = iter.next(); |
723 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
724 |
ui.AudioDeviceComboBox->setCurrentItem(iAudioItem); |
m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem); |
725 |
selectAudioDeviceItem(iAudioItem); |
selectAudioDeviceItem(iAudioItem); |
726 |
break; |
break; |
727 |
} |
} |
728 |
iAudioItem++; |
iAudioItem++; |
729 |
} |
} |
730 |
} else { |
} else { |
731 |
ui.AudioDeviceComboBox->insertItem( |
m_ui.AudioDeviceComboBox->insertItem(0, |
732 |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
733 |
//ui.AudioRoutingTable->setNumRows(0); |
//m_ui.AudioRoutingTable->setNumRows(0); |
734 |
} |
} |
735 |
ui.AudioDeviceTextLabel->setEnabled(bEnabled); |
m_ui.AudioDeviceTextLabel->setEnabled(bEnabled); |
736 |
ui.AudioDeviceComboBox->setEnabled(bEnabled); |
m_ui.AudioDeviceComboBox->setEnabled(bEnabled); |
737 |
ui.AudioRoutingTable->setEnabled(bEnabled); |
m_ui.AudioRoutingTable->setEnabled(bEnabled); |
738 |
} |
} |
739 |
|
|
740 |
|
|
752 |
// Select Audio device item. |
// Select Audio device item. |
753 |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
754 |
{ |
{ |
755 |
qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem); |
Device *pDevice = NULL; |
756 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
757 |
|
pDevice = m_audioDevices.at(iAudioItem); |
758 |
if (pDevice) { |
if (pDevice) { |
759 |
// Refresh the audio routing table. |
// Refresh the audio routing table. |
760 |
routingModel.refresh(pDevice, m_pChannel->audioRouting()); |
m_routingModel.refresh(pDevice, m_pChannel->audioRouting()); |
761 |
// Reset routing change map. |
// Reset routing change map. |
762 |
m_audioRouting.clear(); |
m_routingModel.clear(); |
763 |
} |
} |
764 |
} |
} |
765 |
|
|
778 |
// Audio device options. |
// Audio device options. |
779 |
void ChannelForm::setupAudioDevice (void) |
void ChannelForm::setupAudioDevice (void) |
780 |
{ |
{ |
781 |
setupDevice(m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()), |
Device *pDevice = NULL; |
782 |
qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText()); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
783 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
784 |
|
pDevice = m_audioDevices.at(iAudioItem); |
785 |
|
setupDevice(pDevice, |
786 |
|
Device::Audio, m_ui.AudioDriverComboBox->currentText()); |
787 |
} |
} |
788 |
|
|
|
|
|
|
// 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 |
|
|
} |
|
|
|
|
|
|
|
789 |
// UPdate all device lists slot. |
// UPdate all device lists slot. |
790 |
void ChannelForm::updateDevices (void) |
void ChannelForm::updateDevices (void) |
791 |
{ |
{ |
792 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
793 |
return; |
return; |
794 |
|
|
795 |
selectMidiDriverItem(ui.MidiDriverComboBox->currentText()); |
selectMidiDriverItem(m_ui.MidiDriverComboBox->currentText()); |
796 |
selectAudioDriverItem(ui.AudioDriverComboBox->currentText()); |
selectAudioDriverItem(m_ui.AudioDriverComboBox->currentText()); |
797 |
optionsChanged(); |
optionsChanged(); |
798 |
} |
} |
799 |
|
|
812 |
// Stabilize current form state. |
// Stabilize current form state. |
813 |
void ChannelForm::stabilizeForm (void) |
void ChannelForm::stabilizeForm (void) |
814 |
{ |
{ |
815 |
bool bValid = true; |
const bool bValid = |
816 |
|
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
817 |
|
m_ui.EngineNameComboBox->currentText() |
818 |
|
!= Channel::noEngineName(); |
819 |
#if 0 |
#if 0 |
820 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
821 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
822 |
#endif |
#endif |
823 |
ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
m_ui.DialogButtonBox->button( |
824 |
|
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
825 |
|
} |
826 |
|
|
827 |
|
|
828 |
|
void ChannelForm::updateTableCellRenderers (void) |
829 |
|
{ |
830 |
|
const int rows = m_routingModel.rowCount(); |
831 |
|
const int cols = m_routingModel.columnCount(); |
832 |
|
updateTableCellRenderers( |
833 |
|
m_routingModel.index(0, 0), |
834 |
|
m_routingModel.index(rows - 1, cols - 1)); |
835 |
} |
} |
836 |
|
|
837 |
|
|
838 |
|
void ChannelForm::updateTableCellRenderers ( |
839 |
|
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
840 |
|
{ |
841 |
|
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
842 |
|
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
843 |
|
const QModelIndex index = m_routingModel.index(r, c); |
844 |
|
m_ui.AudioRoutingTable->openPersistentEditor(index); |
845 |
|
} |
846 |
|
} |
847 |
|
} |
848 |
|
|
849 |
} // namespace QSampler |
} // namespace QSampler |
850 |
|
|
851 |
|
|
852 |
|
// end of qsamplerChannelForm.cpp |