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 |
|
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
68 |
|
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
69 |
|
|
70 |
|
// This goes initially hidden, and will be shown |
71 |
|
// on setup() for currently existing channels... |
72 |
|
m_ui.AudioRoutingTable->hide(); |
73 |
|
|
74 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
75 |
adjustSize(); |
adjustSize(); |
76 |
|
|
77 |
QObject::connect(ui.EngineNameComboBox, |
QObject::connect(m_ui.EngineNameComboBox, |
78 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
79 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
80 |
QObject::connect(ui.InstrumentFileComboBox, |
QObject::connect(m_ui.InstrumentFileComboBox, |
81 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
82 |
SLOT(updateInstrumentName())); |
SLOT(updateInstrumentName())); |
83 |
QObject::connect(ui.InstrumentFileToolButton, |
QObject::connect(m_ui.InstrumentFileToolButton, |
84 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
85 |
SLOT(openInstrumentFile())); |
SLOT(openInstrumentFile())); |
86 |
QObject::connect(ui.InstrumentNrComboBox, |
QObject::connect(m_ui.InstrumentNrComboBox, |
87 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
88 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
89 |
QObject::connect(ui.MidiDriverComboBox, |
QObject::connect(m_ui.MidiDriverComboBox, |
90 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
91 |
SLOT(selectMidiDriver(const QString&))); |
SLOT(selectMidiDriver(const QString&))); |
92 |
QObject::connect(ui.MidiDeviceComboBox, |
QObject::connect(m_ui.MidiDeviceComboBox, |
93 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
94 |
SLOT(selectMidiDevice(int))); |
SLOT(selectMidiDevice(int))); |
95 |
QObject::connect(ui.MidiPortSpinBox, |
QObject::connect(m_ui.MidiPortSpinBox, |
96 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
97 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
98 |
QObject::connect(ui.MidiChannelComboBox, |
QObject::connect(m_ui.MidiChannelComboBox, |
99 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
100 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
101 |
QObject::connect(ui.MidiMapComboBox, |
QObject::connect(m_ui.MidiMapComboBox, |
102 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
103 |
SLOT(optionsChanged())); |
SLOT(optionsChanged())); |
104 |
QObject::connect(ui.AudioDriverComboBox, |
QObject::connect(m_ui.AudioDriverComboBox, |
105 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
106 |
SLOT(selectAudioDriver(const QString&))); |
SLOT(selectAudioDriver(const QString&))); |
107 |
QObject::connect(ui.AudioDeviceComboBox, |
QObject::connect(m_ui.AudioDeviceComboBox, |
108 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
109 |
SLOT(selectAudioDevice(int))); |
SLOT(selectAudioDevice(int))); |
110 |
QObject::connect(ui.OkPushButton, |
QObject::connect(m_ui.OkPushButton, |
111 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
112 |
SLOT(accept())); |
SLOT(accept())); |
113 |
QObject::connect(ui.CancelPushButton, |
QObject::connect(m_ui.CancelPushButton, |
114 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
115 |
SLOT(reject())); |
SLOT(reject())); |
116 |
QObject::connect(ui.MidiDeviceToolButton, |
QObject::connect(m_ui.MidiDeviceToolButton, |
117 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
118 |
SLOT(setupMidiDevice())); |
SLOT(setupMidiDevice())); |
119 |
QObject::connect(ui.AudioDeviceToolButton, |
QObject::connect(m_ui.AudioDeviceToolButton, |
120 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
121 |
SLOT(setupAudioDevice())); |
SLOT(setupAudioDevice())); |
122 |
|
QObject::connect(&m_routingModel, |
123 |
|
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
124 |
|
SLOT(optionsChanged())); |
125 |
|
QObject::connect(&m_routingModel, |
126 |
|
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
127 |
|
SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&))); |
128 |
|
QObject::connect(&m_routingModel, |
129 |
|
SIGNAL(modelReset()), |
130 |
|
SLOT(updateTableCellRenderers())); |
131 |
} |
} |
132 |
|
|
133 |
ChannelForm::~ChannelForm() { |
ChannelForm::~ChannelForm() |
134 |
|
{ |
135 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
136 |
delete m_pDeviceForm; |
delete m_pDeviceForm; |
137 |
m_pDeviceForm = NULL; |
m_pDeviceForm = NULL; |
138 |
|
|
139 |
|
qDeleteAll(m_midiDevices); |
140 |
|
m_midiDevices.clear(); |
141 |
|
|
142 |
|
qDeleteAll(m_audioDevices); |
143 |
|
m_audioDevices.clear(); |
144 |
} |
} |
145 |
|
|
146 |
|
|
147 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
148 |
void ChannelForm::setup ( qsamplerChannel *pChannel ) |
void ChannelForm::setup ( Channel *pChannel ) |
149 |
{ |
{ |
150 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
151 |
|
|
157 |
|
|
158 |
// It can be a brand new channel, remember? |
// It can be a brand new channel, remember? |
159 |
bool bNew = (m_pChannel->channelID() < 0); |
bool bNew = (m_pChannel->channelID() < 0); |
160 |
setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
161 |
|
|
162 |
// Check if we're up and connected. |
// Check if we're up and connected. |
163 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
166 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
167 |
return; |
return; |
168 |
|
|
169 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
170 |
if (pOptions == NULL) |
if (pOptions == NULL) |
171 |
return; |
return; |
172 |
|
|
174 |
m_iDirtySetup++; |
m_iDirtySetup++; |
175 |
|
|
176 |
// Load combo box history... |
// Load combo box history... |
177 |
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))); |
|
178 |
|
|
179 |
// Populate Engines list. |
// Populate Engines list. |
180 |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
181 |
if (ppszEngines) { |
if (ppszEngines) { |
182 |
ui.EngineNameComboBox->clear(); |
m_ui.EngineNameComboBox->clear(); |
183 |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
184 |
ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine])); |
m_ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine])); |
185 |
} |
} |
186 |
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
187 |
|
|
188 |
// Populate Audio output type list. |
// Populate Audio output type list. |
189 |
ui.AudioDriverComboBox->clear(); |
m_ui.AudioDriverComboBox->clear(); |
190 |
ui.AudioDriverComboBox->insertStringList( |
m_ui.AudioDriverComboBox->insertItems(0, |
191 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Audio)); |
Device::getDrivers(pMainForm->client(), Device::Audio)); |
192 |
|
|
193 |
// Populate MIDI input type list. |
// Populate MIDI input type list. |
194 |
ui.MidiDriverComboBox->clear(); |
m_ui.MidiDriverComboBox->clear(); |
195 |
ui.MidiDriverComboBox->insertStringList( |
m_ui.MidiDriverComboBox->insertItems(0, |
196 |
qsamplerDevice::getDrivers(pMainForm->client(), qsamplerDevice::Midi)); |
Device::getDrivers(pMainForm->client(), Device::Midi)); |
197 |
|
|
198 |
// Populate Maps list. |
// Populate Maps list. |
199 |
ui.MidiMapComboBox->clear(); |
m_ui.MidiMapComboBox->clear(); |
200 |
ui.MidiMapComboBox->insertStringList(qsamplerInstrument::getMapNames()); |
m_ui.MidiMapComboBox->insertItems(0, |
201 |
|
Instrument::getMapNames()); |
202 |
|
|
203 |
// Read proper channel information, |
// Read proper channel information, |
204 |
// and populate the channel form fields. |
// and populate the channel form fields. |
208 |
if (sEngineName.isEmpty() || bNew) |
if (sEngineName.isEmpty() || bNew) |
209 |
sEngineName = pOptions->sEngineName; |
sEngineName = pOptions->sEngineName; |
210 |
if (sEngineName.isEmpty()) |
if (sEngineName.isEmpty()) |
211 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = Channel::noEngineName(); |
212 |
if (ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
213 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
214 |
ui.EngineNameComboBox->addItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
215 |
} |
} |
216 |
ui.EngineNameComboBox->setCurrentIndex( |
m_ui.EngineNameComboBox->setCurrentIndex( |
217 |
ui.EngineNameComboBox->findText(sEngineName, |
m_ui.EngineNameComboBox->findText(sEngineName, |
218 |
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
219 |
|
|
220 |
// Instrument filename and index... |
// Instrument filename and index... |
221 |
QString sInstrumentFile = pChannel->instrumentFile(); |
QString sInstrumentFile = pChannel->instrumentFile(); |
222 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
223 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = Channel::noInstrumentName(); |
224 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
225 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
226 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
227 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
228 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
229 |
ui.InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); |
int iInstrumentNr = pChannel->instrumentNr(); |
230 |
|
if (iInstrumentNr < 0) |
231 |
|
iInstrumentNr = 0; |
232 |
|
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
233 |
|
|
234 |
// MIDI input device... |
// MIDI input device... |
235 |
qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice()); |
Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
236 |
// MIDI input driver... |
// MIDI input driver... |
237 |
QString sMidiDriver = midiDevice.driverName(); |
QString sMidiDriver = midiDevice.driverName(); |
238 |
if (sMidiDriver.isEmpty() || bNew) |
if (sMidiDriver.isEmpty() || bNew) |
239 |
sMidiDriver = pOptions->sMidiDriver.upper(); |
sMidiDriver = pOptions->sMidiDriver.toUpper(); |
240 |
if (!sMidiDriver.isEmpty()) { |
if (!sMidiDriver.isEmpty()) { |
241 |
if (ui.MidiDriverComboBox->findText(sMidiDriver, |
if (m_ui.MidiDriverComboBox->findText(sMidiDriver, |
242 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
243 |
ui.MidiDriverComboBox->insertItem(sMidiDriver); |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
244 |
} |
} |
245 |
ui.MidiDriverComboBox->setCurrentText(sMidiDriver); |
m_ui.MidiDriverComboBox->setItemText( |
246 |
|
m_ui.MidiDriverComboBox->currentIndex(), |
247 |
|
sMidiDriver); |
248 |
} |
} |
249 |
selectMidiDriverItem(sMidiDriver); |
selectMidiDriverItem(sMidiDriver); |
250 |
if (!bNew) |
if (!bNew) { |
251 |
ui.MidiDeviceComboBox->setCurrentText(midiDevice.deviceName()); |
m_ui.MidiDeviceComboBox->setItemText( |
252 |
selectMidiDeviceItem(ui.MidiDeviceComboBox->currentItem()); |
m_ui.MidiDeviceComboBox->currentIndex(), |
253 |
|
midiDevice.deviceName()); |
254 |
|
} |
255 |
|
selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex()); |
256 |
// MIDI input port... |
// MIDI input port... |
257 |
ui.MidiPortSpinBox->setValue(pChannel->midiPort()); |
m_ui.MidiPortSpinBox->setValue(pChannel->midiPort()); |
258 |
// MIDI input channel... |
// MIDI input channel... |
259 |
int iMidiChannel = pChannel->midiChannel(); |
int iMidiChannel = pChannel->midiChannel(); |
260 |
// When new, try to suggest a sensible MIDI channel... |
// When new, try to suggest a sensible MIDI channel... |
261 |
if (iMidiChannel < 0) |
if (iMidiChannel < 0) |
262 |
iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16); |
iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16); |
263 |
ui.MidiChannelComboBox->setCurrentItem(iMidiChannel); |
m_ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel); |
264 |
// MIDI instrument map... |
// MIDI instrument map... |
265 |
int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap()); |
int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap()); |
266 |
// When new, try to suggest a sensible MIDI map... |
// When new, try to suggest a sensible MIDI map... |
267 |
if (iMidiMap < 0) |
if (iMidiMap < 0) |
268 |
iMidiMap = 0; |
iMidiMap = 0; |
269 |
const QString& sMapName = qsamplerInstrument::getMapName(iMidiMap); |
const QString& sMapName = Instrument::getMapName(iMidiMap); |
270 |
if (!sMapName.isEmpty()) |
if (!sMapName.isEmpty()) { |
271 |
ui.MidiMapComboBox->setCurrentText(sMapName); |
m_ui.MidiMapComboBox->setItemText( |
272 |
|
m_ui.MidiMapComboBox->currentIndex(), |
273 |
|
sMapName); |
274 |
|
} |
275 |
// It might be no maps around... |
// It might be no maps around... |
276 |
bool bMidiMapEnabled = (ui.MidiMapComboBox->count() > 0); |
bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0); |
277 |
ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
278 |
ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
279 |
|
|
280 |
// Audio output device... |
// Audio output device... |
281 |
qsamplerDevice audioDevice(qsamplerDevice::Audio, m_pChannel->audioDevice()); |
Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
282 |
// Audio output driver... |
// Audio output driver... |
283 |
QString sAudioDriver = audioDevice.driverName(); |
QString sAudioDriver = audioDevice.driverName(); |
284 |
if (sAudioDriver.isEmpty() || bNew) |
if (sAudioDriver.isEmpty() || bNew) |
285 |
sAudioDriver = pOptions->sAudioDriver.upper(); |
sAudioDriver = pOptions->sAudioDriver.toUpper(); |
286 |
if (!sAudioDriver.isEmpty()) { |
if (!sAudioDriver.isEmpty()) { |
287 |
if (ui.AudioDriverComboBox->findText(sAudioDriver, |
if (m_ui.AudioDriverComboBox->findText(sAudioDriver, |
288 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
289 |
ui.AudioDriverComboBox->insertItem(sAudioDriver); |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
290 |
} |
} |
291 |
ui.AudioDriverComboBox->setCurrentText(sAudioDriver); |
m_ui.AudioDriverComboBox->setItemText( |
292 |
|
m_ui.AudioDriverComboBox->currentIndex(), |
293 |
|
sAudioDriver); |
294 |
} |
} |
295 |
selectAudioDriverItem(sAudioDriver); |
selectAudioDriverItem(sAudioDriver); |
296 |
if (!bNew) |
if (!bNew) { |
297 |
ui.AudioDeviceComboBox->setCurrentText(audioDevice.deviceName()); |
m_ui.AudioDeviceComboBox->setItemText( |
298 |
selectAudioDeviceItem(ui.AudioDeviceComboBox->currentItem()); |
m_ui.AudioDeviceComboBox->currentIndex(), |
299 |
|
audioDevice.deviceName()); |
300 |
|
} |
301 |
|
selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex()); |
302 |
|
|
303 |
|
// Let the audio routing table see the light, |
304 |
|
// if we're editing an existing sampler channel... |
305 |
|
m_ui.AudioRoutingTable->setVisible(!bNew); |
306 |
|
|
307 |
|
const QString sInstrumentNrToolTip = |
308 |
|
(pOptions->bInstrumentNames) ? |
309 |
|
"Select an instrument of the file" : |
310 |
|
"You might want to enable instrument name retrieval in the " |
311 |
|
"settings dialog"; |
312 |
|
m_ui.InstrumentNrComboBox->setToolTip( |
313 |
|
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
314 |
|
); |
315 |
|
|
316 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
317 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
318 |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
/* if (sEngineName != Channel::noEngineName() && |
319 |
sInstrumentFile != qsamplerChannel::noInstrumentName()) |
sInstrumentFile != Channel::noInstrumentName()) |
320 |
m_iDirtyCount++; */ |
m_iDirtyCount++; */ |
321 |
// Done. |
// Done. |
322 |
m_iDirtySetup--; |
m_iDirtySetup--; |
336 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
337 |
return; |
return; |
338 |
|
|
339 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
340 |
if (pOptions == NULL) |
if (pOptions == NULL) |
341 |
return; |
return; |
342 |
|
|
343 |
// Flush any pending editing... |
// Flush any pending editing... |
344 |
//ui.AudioRoutingTable->flush(); |
//m_ui.AudioRoutingTable->flush(); |
345 |
|
|
346 |
// We'll go for it! |
// We'll go for it! |
347 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
351 |
iErrors++; |
iErrors++; |
352 |
// Accept Audio driver or device selection... |
// Accept Audio driver or device selection... |
353 |
if (m_audioDevices.isEmpty()) { |
if (m_audioDevices.isEmpty()) { |
354 |
if (!m_pChannel->setAudioDriver(ui.AudioDriverComboBox->currentText())) |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
355 |
iErrors++; |
iErrors++; |
356 |
} else { |
} else { |
357 |
qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
358 |
|
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
359 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
360 |
|
pDevice = m_audioDevices.at(iAudioItem); |
361 |
|
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
362 |
if (pDevice == NULL) |
if (pDevice == NULL) |
363 |
iErrors++; |
iErrors++; |
364 |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
365 |
iErrors++; |
iErrors++; |
366 |
else if (!m_audioRouting.isEmpty()) { |
else if (!routingMap.isEmpty()) { |
367 |
// Set the audio route changes... |
// Set the audio route changes... |
368 |
qsamplerChannelRoutingMap::ConstIterator iter; |
ChannelRoutingMap::ConstIterator iter; |
369 |
for (iter = m_audioRouting.begin(); |
for (iter = routingMap.begin(); |
370 |
iter != m_audioRouting.end(); ++iter) { |
iter != routingMap.end(); ++iter) { |
371 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.data())) |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
372 |
iErrors++; |
iErrors++; |
373 |
} |
} |
374 |
} |
} |
375 |
} |
} |
376 |
// Accept MIDI driver or device selection... |
// Accept MIDI driver or device selection... |
377 |
if (m_midiDevices.isEmpty()) { |
if (m_midiDevices.isEmpty()) { |
378 |
if (!m_pChannel->setMidiDriver(ui.MidiDriverComboBox->currentText())) |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
379 |
iErrors++; |
iErrors++; |
380 |
} else { |
} else { |
381 |
qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
382 |
|
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
383 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
384 |
|
pDevice = m_midiDevices.at(iMidiItem); |
385 |
if (pDevice == NULL) |
if (pDevice == NULL) |
386 |
iErrors++; |
iErrors++; |
387 |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
388 |
iErrors++; |
iErrors++; |
389 |
} |
} |
390 |
// MIDI input port number... |
// MIDI input port number... |
391 |
if (!m_pChannel->setMidiPort(ui.MidiPortSpinBox->value())) |
if (!m_pChannel->setMidiPort(m_ui.MidiPortSpinBox->value())) |
392 |
iErrors++; |
iErrors++; |
393 |
// MIDI input channel... |
// MIDI input channel... |
394 |
if (!m_pChannel->setMidiChannel(ui.MidiChannelComboBox->currentItem())) |
if (!m_pChannel->setMidiChannel(m_ui.MidiChannelComboBox->currentIndex())) |
395 |
iErrors++; |
iErrors++; |
396 |
// Engine name... |
// Engine name... |
397 |
if (!m_pChannel->loadEngine(ui.EngineNameComboBox->currentText())) |
if (!m_pChannel->loadEngine(m_ui.EngineNameComboBox->currentText())) |
398 |
iErrors++; |
iErrors++; |
399 |
// Instrument file and index... |
// Instrument file and index... |
400 |
const QString& sPath = ui.InstrumentFileComboBox->currentText(); |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
401 |
if (!sPath.isEmpty() && QFileInfo(sPath).exists()) { |
if (!sPath.isEmpty() && QFileInfo(sPath).exists()) { |
402 |
if (!m_pChannel->loadInstrument(sPath, ui.InstrumentNrComboBox->currentItem())) |
if (!m_pChannel->loadInstrument(sPath, m_ui.InstrumentNrComboBox->currentIndex())) |
403 |
iErrors++; |
iErrors++; |
404 |
} |
} |
405 |
// MIDI intrument map... |
// MIDI intrument map... |
406 |
if (!m_pChannel->setMidiMap(ui.MidiMapComboBox->currentItem())) |
if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex())) |
407 |
iErrors++; |
iErrors++; |
408 |
// Show error messages? |
// Show error messages? |
409 |
if (iErrors > 0) |
if (iErrors > 0) { |
410 |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
m_pChannel->appendMessagesError( |
411 |
|
tr("Some channel settings could not be set.\n\nSorry.")); |
412 |
|
} |
413 |
} |
} |
414 |
|
|
415 |
// Save default engine name, instrument directory and history... |
// Save default engine name, instrument directory and history... |
416 |
pOptions->sInstrumentDir = QFileInfo(ui.InstrumentFileComboBox->currentText()).dirPath(true); |
pOptions->sInstrumentDir = QFileInfo( |
417 |
pOptions->sEngineName = ui.EngineNameComboBox->currentText(); |
m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath(); |
418 |
pOptions->sAudioDriver = ui.AudioDriverComboBox->currentText(); |
pOptions->sEngineName = m_ui.EngineNameComboBox->currentText(); |
419 |
pOptions->sMidiDriver = ui.MidiDriverComboBox->currentText(); |
pOptions->sAudioDriver = m_ui.AudioDriverComboBox->currentText(); |
420 |
pOptions->iMidiMap = ui.MidiMapComboBox->currentItem(); |
pOptions->sMidiDriver = m_ui.MidiDriverComboBox->currentText(); |
421 |
pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox); |
pOptions->iMidiMap = m_ui.MidiMapComboBox->currentIndex(); |
422 |
|
pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox); |
423 |
|
|
424 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |
425 |
QDialog::accept(); |
QDialog::accept(); |
432 |
bool bReject = true; |
bool bReject = true; |
433 |
|
|
434 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
435 |
if (m_iDirtyCount > 0 && ui.OkPushButton->isEnabled()) { |
if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) { |
436 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
437 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
438 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
463 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
464 |
return; |
return; |
465 |
|
|
466 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
467 |
if (pOptions == NULL) |
if (pOptions == NULL) |
468 |
return; |
return; |
469 |
|
|
470 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
471 |
// depending on the current engine. |
// depending on the current engine. |
472 |
QString sInstrumentFile = QFileDialog::getOpenFileName( |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
473 |
pOptions->sInstrumentDir, // Start here. |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
474 |
tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files) |
pOptions->sInstrumentDir, // Start here. |
475 |
this, 0, // Parent and name (none) |
tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) |
|
QSAMPLER_TITLE ": " + tr("Instrument files") // Caption. |
|
476 |
); |
); |
477 |
|
|
478 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
479 |
return; |
return; |
480 |
|
|
481 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
482 |
updateInstrumentName(); |
updateInstrumentName(); |
483 |
} |
} |
484 |
|
|
492 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
493 |
return; |
return; |
494 |
|
|
495 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
496 |
if (pOptions == NULL) |
if (pOptions == NULL) |
497 |
return; |
return; |
498 |
|
|
499 |
// Finally this better idea would be to use libgig |
// Finally this better idea would be to use libgig |
500 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
501 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
502 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
503 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
504 |
ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
505 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
506 |
); |
); |
507 |
|
|
510 |
|
|
511 |
|
|
512 |
// Show device options dialog. |
// Show device options dialog. |
513 |
void ChannelForm::setupDevice ( qsamplerDevice *pDevice, |
void ChannelForm::setupDevice ( Device *pDevice, |
514 |
qsamplerDevice::qsamplerDeviceType deviceTypeMode, |
Device::DeviceType deviceTypeMode, |
515 |
const QString& sDriverName ) |
const QString& sDriverName ) |
516 |
{ |
{ |
517 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
523 |
// Create the device form if not already... |
// Create the device form if not already... |
524 |
if (m_pDeviceForm == NULL) { |
if (m_pDeviceForm == NULL) { |
525 |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
526 |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
527 |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
528 |
this, SLOT(updateDevices())); |
this, SLOT(updateDevices())); |
529 |
} |
} |
548 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
549 |
return; |
return; |
550 |
|
|
551 |
const QString sDriverName = sMidiDriver.upper(); |
const QString sDriverName = sMidiDriver.toUpper(); |
552 |
|
|
553 |
// Save current device id. |
// Save current device id. |
554 |
|
// Save current device id. |
555 |
int iDeviceID = 0; |
int iDeviceID = 0; |
556 |
qsamplerDevice *pDevice = m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
557 |
|
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
558 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
559 |
|
pDevice = m_midiDevices.at(iMidiItem); |
560 |
if (pDevice) |
if (pDevice) |
561 |
iDeviceID = pDevice->deviceID(); |
iDeviceID = pDevice->deviceID(); |
562 |
|
|
563 |
// Clean maplist. |
// Clean maplist. |
564 |
ui.MidiDeviceComboBox->clear(); |
m_ui.MidiDeviceComboBox->clear(); |
565 |
|
qDeleteAll(m_midiDevices); |
566 |
m_midiDevices.clear(); |
m_midiDevices.clear(); |
567 |
|
|
568 |
// Populate with the current ones... |
// Populate with the current ones... |
569 |
const QPixmap midiPixmap(":/qsampler/pixmaps/midi2.png"); |
const QPixmap midiPixmap(":/icons/midi2.png"); |
570 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
571 |
qsamplerDevice::Midi); |
Device::Midi); |
572 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
573 |
pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]); |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
574 |
if (pDevice->driverName().upper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
575 |
ui.MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName()); |
m_ui.MidiDeviceComboBox->insertItem(0, |
576 |
|
midiPixmap, pDevice->deviceName()); |
577 |
m_midiDevices.append(pDevice); |
m_midiDevices.append(pDevice); |
578 |
} else { |
} else { |
579 |
delete pDevice; |
delete pDevice; |
584 |
bool bEnabled = !m_midiDevices.isEmpty(); |
bool bEnabled = !m_midiDevices.isEmpty(); |
585 |
if (bEnabled) { |
if (bEnabled) { |
586 |
// Select the previous current device... |
// Select the previous current device... |
587 |
int iMidiItem = 0; |
iMidiItem = 0; |
588 |
for (pDevice = m_midiDevices.first(); |
QListIterator<Device *> iter(m_midiDevices); |
589 |
pDevice; |
while (iter.hasNext()) { |
590 |
pDevice = m_midiDevices.next()) { |
pDevice = iter.next(); |
591 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
592 |
ui.MidiDeviceComboBox->setCurrentItem(iMidiItem); |
m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem); |
593 |
selectMidiDeviceItem(iMidiItem); |
selectMidiDeviceItem(iMidiItem); |
594 |
break; |
break; |
595 |
} |
} |
596 |
iMidiItem++; |
iMidiItem++; |
597 |
} |
} |
598 |
} else { |
} else { |
599 |
ui.MidiDeviceComboBox->insertItem( |
m_ui.MidiDeviceComboBox->insertItem(0, |
600 |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
601 |
} |
} |
602 |
ui.MidiDeviceTextLabel->setEnabled(bEnabled); |
m_ui.MidiDeviceTextLabel->setEnabled(bEnabled); |
603 |
ui.MidiDeviceComboBox->setEnabled(bEnabled); |
m_ui.MidiDeviceComboBox->setEnabled(bEnabled); |
604 |
} |
} |
605 |
|
|
606 |
|
|
618 |
// Select MIDI device item. |
// Select MIDI device item. |
619 |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
620 |
{ |
{ |
621 |
qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem); |
Device *pDevice = NULL; |
622 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
623 |
|
pDevice = m_midiDevices.at(iMidiItem); |
624 |
if (pDevice) { |
if (pDevice) { |
625 |
const qsamplerDeviceParamMap& params = pDevice->params(); |
const DeviceParamMap& params = pDevice->params(); |
626 |
int iPorts = params["PORTS"].value.toInt(); |
int iPorts = params["PORTS"].value.toInt(); |
627 |
ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
628 |
ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
629 |
if (iPorts > 0) |
if (iPorts > 0) |
630 |
ui.MidiPortSpinBox->setMaxValue(iPorts - 1); |
m_ui.MidiPortSpinBox->setMaximum(iPorts - 1); |
631 |
} |
} |
632 |
} |
} |
633 |
|
|
646 |
// MIDI device options. |
// MIDI device options. |
647 |
void ChannelForm::setupMidiDevice (void) |
void ChannelForm::setupMidiDevice (void) |
648 |
{ |
{ |
649 |
setupDevice(m_midiDevices.at(ui.MidiDeviceComboBox->currentItem()), |
Device *pDevice = NULL; |
650 |
qsamplerDevice::Midi, ui.MidiDriverComboBox->currentText()); |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
651 |
|
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
652 |
|
pDevice = m_midiDevices.at(iMidiItem); |
653 |
|
setupDevice(pDevice, |
654 |
|
Device::Midi, m_ui.MidiDriverComboBox->currentText()); |
655 |
} |
} |
656 |
|
|
657 |
|
|
664 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
665 |
return; |
return; |
666 |
|
|
667 |
const QString sDriverName = sAudioDriver.upper(); |
const QString sDriverName = sAudioDriver.toUpper(); |
668 |
|
|
669 |
// Save current device id. |
// Save current device id. |
670 |
int iDeviceID = 0; |
int iDeviceID = 0; |
671 |
qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()); |
Device *pDevice = NULL; |
672 |
|
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
673 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
674 |
|
pDevice = m_audioDevices.at(iAudioItem); |
675 |
if (pDevice) |
if (pDevice) |
676 |
iDeviceID = pDevice->deviceID(); |
iDeviceID = pDevice->deviceID(); |
677 |
|
|
678 |
// Clean maplist. |
// Clean maplist. |
679 |
ui.AudioDeviceComboBox->clear(); |
m_ui.AudioDeviceComboBox->clear(); |
680 |
|
qDeleteAll(m_audioDevices); |
681 |
m_audioDevices.clear(); |
m_audioDevices.clear(); |
682 |
|
|
683 |
// Populate with the current ones... |
// Populate with the current ones... |
684 |
const QPixmap audioPixmap(":/qsampler/pixmaps/audio2.png"); |
const QPixmap audioPixmap(":/icons/audio2.png"); |
685 |
int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
686 |
qsamplerDevice::Audio); |
Device::Audio); |
687 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
688 |
pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]); |
pDevice = new Device(Device::Audio, piDeviceIDs[i]); |
689 |
if (pDevice->driverName().upper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
690 |
ui.AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName()); |
m_ui.AudioDeviceComboBox->insertItem(0, |
691 |
|
audioPixmap, pDevice->deviceName()); |
692 |
m_audioDevices.append(pDevice); |
m_audioDevices.append(pDevice); |
693 |
} else { |
} else { |
694 |
delete pDevice; |
delete pDevice; |
699 |
bool bEnabled = !m_audioDevices.isEmpty(); |
bool bEnabled = !m_audioDevices.isEmpty(); |
700 |
if (bEnabled) { |
if (bEnabled) { |
701 |
// Select the previous current device... |
// Select the previous current device... |
702 |
int iAudioItem = 0; |
iAudioItem = 0; |
703 |
for (pDevice = m_audioDevices.first(); |
QListIterator<Device *> iter(m_audioDevices); |
704 |
pDevice; |
while (iter.hasNext()) { |
705 |
pDevice = m_audioDevices.next()) { |
pDevice = iter.next(); |
706 |
if (pDevice->deviceID() == iDeviceID) { |
if (pDevice->deviceID() == iDeviceID) { |
707 |
ui.AudioDeviceComboBox->setCurrentItem(iAudioItem); |
m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem); |
708 |
selectAudioDeviceItem(iAudioItem); |
selectAudioDeviceItem(iAudioItem); |
709 |
break; |
break; |
710 |
} |
} |
711 |
iAudioItem++; |
iAudioItem++; |
712 |
} |
} |
713 |
} else { |
} else { |
714 |
ui.AudioDeviceComboBox->insertItem( |
m_ui.AudioDeviceComboBox->insertItem(0, |
715 |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
716 |
//ui.AudioRoutingTable->setNumRows(0); |
//m_ui.AudioRoutingTable->setNumRows(0); |
717 |
} |
} |
718 |
ui.AudioDeviceTextLabel->setEnabled(bEnabled); |
m_ui.AudioDeviceTextLabel->setEnabled(bEnabled); |
719 |
ui.AudioDeviceComboBox->setEnabled(bEnabled); |
m_ui.AudioDeviceComboBox->setEnabled(bEnabled); |
720 |
ui.AudioRoutingTable->setEnabled(bEnabled); |
m_ui.AudioRoutingTable->setEnabled(bEnabled); |
721 |
} |
} |
722 |
|
|
723 |
|
|
735 |
// Select Audio device item. |
// Select Audio device item. |
736 |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
737 |
{ |
{ |
738 |
qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem); |
Device *pDevice = NULL; |
739 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
740 |
|
pDevice = m_audioDevices.at(iAudioItem); |
741 |
if (pDevice) { |
if (pDevice) { |
742 |
// Refresh the audio routing table. |
// Refresh the audio routing table. |
743 |
routingModel.refresh(pDevice, m_pChannel->audioRouting()); |
m_routingModel.refresh(pDevice, m_pChannel->audioRouting()); |
744 |
// Reset routing change map. |
// Reset routing change map. |
745 |
m_audioRouting.clear(); |
m_routingModel.clear(); |
746 |
} |
} |
747 |
} |
} |
748 |
|
|
761 |
// Audio device options. |
// Audio device options. |
762 |
void ChannelForm::setupAudioDevice (void) |
void ChannelForm::setupAudioDevice (void) |
763 |
{ |
{ |
764 |
setupDevice(m_audioDevices.at(ui.AudioDeviceComboBox->currentItem()), |
Device *pDevice = NULL; |
765 |
qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText()); |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
766 |
|
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
767 |
|
pDevice = m_audioDevices.at(iAudioItem); |
768 |
|
setupDevice(pDevice, |
769 |
|
Device::Audio, m_ui.AudioDriverComboBox->currentText()); |
770 |
} |
} |
771 |
|
|
|
|
|
|
// 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 |
|
|
} |
|
|
|
|
|
|
|
772 |
// UPdate all device lists slot. |
// UPdate all device lists slot. |
773 |
void ChannelForm::updateDevices (void) |
void ChannelForm::updateDevices (void) |
774 |
{ |
{ |
775 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
776 |
return; |
return; |
777 |
|
|
778 |
selectMidiDriverItem(ui.MidiDriverComboBox->currentText()); |
selectMidiDriverItem(m_ui.MidiDriverComboBox->currentText()); |
779 |
selectAudioDriverItem(ui.AudioDriverComboBox->currentText()); |
selectAudioDriverItem(m_ui.AudioDriverComboBox->currentText()); |
780 |
optionsChanged(); |
optionsChanged(); |
781 |
} |
} |
782 |
|
|
795 |
// Stabilize current form state. |
// Stabilize current form state. |
796 |
void ChannelForm::stabilizeForm (void) |
void ChannelForm::stabilizeForm (void) |
797 |
{ |
{ |
798 |
bool bValid = true; |
const bool bValid = |
799 |
|
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
800 |
|
m_ui.EngineNameComboBox->currentText() |
801 |
|
!= Channel::noEngineName(); |
802 |
#if 0 |
#if 0 |
803 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
804 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
805 |
#endif |
#endif |
806 |
ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
807 |
|
} |
808 |
|
|
809 |
|
|
810 |
|
void ChannelForm::updateTableCellRenderers (void) |
811 |
|
{ |
812 |
|
const int rows = m_routingModel.rowCount(); |
813 |
|
const int cols = m_routingModel.columnCount(); |
814 |
|
updateTableCellRenderers( |
815 |
|
m_routingModel.index(0, 0), |
816 |
|
m_routingModel.index(rows - 1, cols - 1)); |
817 |
} |
} |
818 |
|
|
819 |
|
|
820 |
|
void ChannelForm::updateTableCellRenderers ( |
821 |
|
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
822 |
|
{ |
823 |
|
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
824 |
|
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
825 |
|
const QModelIndex index = m_routingModel.index(r, c); |
826 |
|
m_ui.AudioRoutingTable->openPersistentEditor(index); |
827 |
|
} |
828 |
|
} |
829 |
|
} |
830 |
|
|
831 |
} // namespace QSampler |
} // namespace QSampler |
832 |
|
|
833 |
|
|