2 |
// |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
/**************************************************************************** |
5 |
Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
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 |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
18 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
41 |
#include "qsamplerMessages.h" |
#include "qsamplerMessages.h" |
42 |
|
|
43 |
#include "qsamplerChannelStrip.h" |
#include "qsamplerChannelStrip.h" |
44 |
|
#include "qsamplerInstrumentList.h" |
45 |
|
|
46 |
|
#include "qsamplerInstrumentListForm.h" |
47 |
#include "qsamplerDeviceForm.h" |
#include "qsamplerDeviceForm.h" |
48 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
49 |
|
|
|
#include "config.h" |
|
|
|
|
50 |
#ifdef HAVE_SIGNAL_H |
#ifdef HAVE_SIGNAL_H |
51 |
#include <signal.h> |
#include <signal.h> |
52 |
#endif |
#endif |
53 |
|
|
54 |
|
#ifdef CONFIG_LIBGIG |
55 |
|
#include <gig.h> |
56 |
|
#endif |
57 |
|
|
58 |
// Timer constant stuff. |
// Timer constant stuff. |
59 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
60 |
|
|
104 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
105 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
106 |
|
|
107 |
|
// Kind of singleton reference. |
108 |
|
qsamplerMainForm *qsamplerMainForm::g_pMainForm = NULL; |
109 |
|
|
110 |
|
|
111 |
// Kind of constructor. |
// Kind of constructor. |
112 |
void qsamplerMainForm::init (void) |
void qsamplerMainForm::init (void) |
113 |
{ |
{ |
114 |
|
// Pseudo-singleton reference setup. |
115 |
|
g_pMainForm = this; |
116 |
|
|
117 |
// Initialize some pointer references. |
// Initialize some pointer references. |
118 |
m_pOptions = NULL; |
m_pOptions = NULL; |
119 |
|
|
120 |
// All child forms are to be created later, not earlier than setup. |
// All child forms are to be created later, not earlier than setup. |
121 |
m_pMessages = NULL; |
m_pMessages = NULL; |
122 |
|
m_pInstrumentListForm = NULL; |
123 |
m_pDeviceForm = NULL; |
m_pDeviceForm = NULL; |
124 |
|
|
125 |
// We'll start clean. |
// We'll start clean. |
196 |
// Finally drop any widgets around... |
// Finally drop any widgets around... |
197 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
198 |
delete m_pDeviceForm; |
delete m_pDeviceForm; |
199 |
|
if (m_pInstrumentListForm) |
200 |
|
delete m_pInstrumentListForm; |
201 |
if (m_pMessages) |
if (m_pMessages) |
202 |
delete m_pMessages; |
delete m_pMessages; |
203 |
if (m_pWorkspace) |
if (m_pWorkspace) |
216 |
// Delete recentfiles menu. |
// Delete recentfiles menu. |
217 |
if (m_pRecentFilesMenu) |
if (m_pRecentFilesMenu) |
218 |
delete m_pRecentFilesMenu; |
delete m_pRecentFilesMenu; |
219 |
|
|
220 |
|
// Pseudo-singleton reference shut-down. |
221 |
|
g_pMainForm = NULL; |
222 |
} |
} |
223 |
|
|
224 |
|
|
229 |
m_pOptions = pOptions; |
m_pOptions = pOptions; |
230 |
|
|
231 |
// What style do we create these forms? |
// What style do we create these forms? |
232 |
WFlags wflags = Qt::WType_TopLevel; |
Qt::WFlags wflags = Qt::WStyle_Customize |
233 |
|
| Qt::WStyle_NormalBorder |
234 |
|
| Qt::WStyle_Title |
235 |
|
| Qt::WStyle_SysMenu |
236 |
|
| Qt::WStyle_MinMax |
237 |
|
| Qt::WType_TopLevel; |
238 |
if (m_pOptions->bKeepOnTop) |
if (m_pOptions->bKeepOnTop) |
239 |
wflags |= Qt::WStyle_Tool; |
wflags |= Qt::WStyle_Tool; |
240 |
// Some child forms are to be created right now. |
// Some child forms are to be created right now. |
241 |
m_pMessages = new qsamplerMessages(this); |
m_pMessages = new qsamplerMessages(this); |
242 |
m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags); |
m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags); |
243 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
244 |
|
m_pInstrumentListForm = new qsamplerInstrumentListForm(this, 0, wflags); |
245 |
|
QObject::connect(m_pInstrumentListForm->InstrumentList, |
246 |
|
SIGNAL(instrumentsChanged()), |
247 |
|
SLOT(sessionDirty())); |
248 |
|
#else |
249 |
|
viewInstrumentsAction->setEnabled(false); |
250 |
|
#endif |
251 |
// Set message defaults... |
// Set message defaults... |
252 |
updateMessagesFont(); |
updateMessagesFont(); |
253 |
updateMessagesLimit(); |
updateMessagesLimit(); |
254 |
updateMessagesCapture(); |
updateMessagesCapture(); |
255 |
// Set the visibility signal. |
// Set the visibility signal. |
256 |
QObject::connect(m_pMessages, SIGNAL(visibilityChanged(bool)), this, SLOT(stabilizeForm())); |
QObject::connect(m_pMessages, |
257 |
|
SIGNAL(visibilityChanged(bool)), |
258 |
|
SLOT(stabilizeForm())); |
259 |
|
|
260 |
// Initial decorations toggle state. |
// Initial decorations toggle state. |
261 |
viewMenubarAction->setOn(m_pOptions->bMenubar); |
viewMenubarAction->setOn(m_pOptions->bMenubar); |
280 |
} |
} |
281 |
// Try to restore old window positioning and initial visibility. |
// Try to restore old window positioning and initial visibility. |
282 |
m_pOptions->loadWidgetGeometry(this); |
m_pOptions->loadWidgetGeometry(this); |
283 |
|
m_pOptions->loadWidgetGeometry(m_pInstrumentListForm); |
284 |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
285 |
|
|
286 |
// Final startup stabilization... |
// Final startup stabilization... |
320 |
ostr << *this; |
ostr << *this; |
321 |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
322 |
// And the children, and the main windows state,. |
// And the children, and the main windows state,. |
323 |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
324 |
m_pOptions->saveWidgetGeometry(this); |
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
325 |
// Close popup widgets. |
m_pOptions->saveWidgetGeometry(this); |
326 |
if (m_pDeviceForm) |
// Close popup widgets. |
327 |
m_pDeviceForm->close(); |
if (m_pInstrumentListForm) |
328 |
|
m_pInstrumentListForm->close(); |
329 |
|
if (m_pDeviceForm) |
330 |
|
m_pDeviceForm->close(); |
331 |
// Stop client and/or server, gracefully. |
// Stop client and/or server, gracefully. |
332 |
stopServer(); |
stopServer(); |
333 |
} |
} |
380 |
if (!decodeDragFiles(pDropEvent, files)) |
if (!decodeDragFiles(pDropEvent, files)) |
381 |
return; |
return; |
382 |
|
|
383 |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
384 |
const QString& sPath = *iter; |
const QString& sPath = *iter; |
385 |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
386 |
// Try to create a new channel from instrument file... |
// Try to create a new channel from instrument file... |
387 |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
qsamplerChannel *pChannel = new qsamplerChannel(); |
388 |
if (pChannel == NULL) |
if (pChannel == NULL) |
389 |
return; |
return; |
390 |
// Start setting the instrument filename... |
// Start setting the instrument filename... |
391 |
pChannel->setInstrument(sPath, 0); |
pChannel->setInstrument(sPath, 0); |
392 |
// Before we show it up, may be we'll |
// Before we show it up, may be we'll |
393 |
// better ask for some initial values? |
// better ask for some initial values? |
394 |
if (!pChannel->channelSetup(this)) { |
if (!pChannel->channelSetup(this)) { |
395 |
delete pChannel; |
delete pChannel; |
396 |
return; |
return; |
397 |
} |
} |
398 |
// Finally, give it to a new channel strip... |
// Finally, give it to a new channel strip... |
399 |
if (!createChannelStrip(pChannel)) { |
if (!createChannelStrip(pChannel)) { |
400 |
delete pChannel; |
delete pChannel; |
401 |
return; |
return; |
402 |
} |
} |
403 |
// Make that an overall update. |
// Make that an overall update. |
404 |
m_iDirtyCount++; |
m_iDirtyCount++; |
405 |
stabilizeForm(); |
stabilizeForm(); |
406 |
} // Otherwise, load an usual session file (LSCP script)... |
} // Otherwise, load an usual session file (LSCP script)... |
407 |
else if (closeSession(true)) |
else if (closeSession(true)) |
408 |
loadSessionFile(sPath); |
loadSessionFile(sPath); |
418 |
// For the time being, just pump it to messages. |
// For the time being, just pump it to messages. |
419 |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
420 |
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
421 |
appendMessagesColor(tr("Notify event: %1 data: %2") |
if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) { |
422 |
.arg(::lscp_event_to_text(pEvent->event())) |
int iChannelID = pEvent->data().toInt(); |
423 |
.arg(pEvent->data()), "#996699"); |
qsamplerChannelStrip *pChannelStrip = channelStrip(iChannelID); |
424 |
|
if (pChannelStrip) |
425 |
|
channelStripChanged(pChannelStrip); |
426 |
|
} else { |
427 |
|
appendMessagesColor(tr("Notify event: %1 data: %2") |
428 |
|
.arg(::lscp_event_to_text(pEvent->event())) |
429 |
|
.arg(pEvent->data()), "#996699"); |
430 |
|
} |
431 |
} |
} |
432 |
} |
} |
433 |
|
|
436 |
void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
437 |
{ |
{ |
438 |
stabilizeForm(); |
stabilizeForm(); |
439 |
|
|
440 |
editMenu->exec(pEvent->globalPos()); |
editMenu->exec(pEvent->globalPos()); |
441 |
} |
} |
442 |
|
|
450 |
return m_pOptions; |
return m_pOptions; |
451 |
} |
} |
452 |
|
|
453 |
|
|
454 |
// The LSCP client descriptor property. |
// The LSCP client descriptor property. |
455 |
lscp_client_t *qsamplerMainForm::client (void) |
lscp_client_t *qsamplerMainForm::client (void) |
456 |
{ |
{ |
458 |
} |
} |
459 |
|
|
460 |
|
|
461 |
|
// The pseudo-singleton instance accessor. |
462 |
|
qsamplerMainForm *qsamplerMainForm::getInstance (void) |
463 |
|
{ |
464 |
|
return g_pMainForm; |
465 |
|
} |
466 |
|
|
467 |
|
|
468 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
469 |
// qsamplerMainForm -- Session file stuff. |
// qsamplerMainForm -- Session file stuff. |
470 |
|
|
512 |
|
|
513 |
// Ask for the filename to open... |
// Ask for the filename to open... |
514 |
QString sFilename = QFileDialog::getOpenFileName( |
QString sFilename = QFileDialog::getOpenFileName( |
515 |
m_pOptions->sSessionDir, // Start here. |
m_pOptions->sSessionDir, // Start here. |
516 |
tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files) |
tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files) |
517 |
this, 0, // Parent and name (none) |
this, 0, // Parent and name (none) |
518 |
tr("Open Session") // Caption. |
QSAMPLER_TITLE ": " + tr("Open Session") // Caption. |
519 |
); |
); |
520 |
|
|
521 |
// Have we cancelled? |
// Have we cancelled? |
546 |
sFilename = m_pOptions->sSessionDir; |
sFilename = m_pOptions->sSessionDir; |
547 |
// Prompt the guy... |
// Prompt the guy... |
548 |
sFilename = QFileDialog::getSaveFileName( |
sFilename = QFileDialog::getSaveFileName( |
549 |
sFilename, // Start here. |
sFilename, // Start here. |
550 |
tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files) |
tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files) |
551 |
this, 0, // Parent and name (none) |
this, 0, // Parent and name (none) |
552 |
tr("Save Session") // Caption. |
QSAMPLER_TITLE ": " + tr("Save Session") // Caption. |
553 |
); |
); |
554 |
// Have we cancelled it? |
// Have we cancelled it? |
555 |
if (sFilename.isEmpty()) |
if (sFilename.isEmpty()) |
559 |
sFilename += ".lscp"; |
sFilename += ".lscp"; |
560 |
// Check if already exists... |
// Check if already exists... |
561 |
if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) { |
if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) { |
562 |
if (QMessageBox::warning(this, tr("Warning"), |
if (QMessageBox::warning(this, |
563 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
564 |
tr("The file already exists:\n\n" |
tr("The file already exists:\n\n" |
565 |
"\"%1\"\n\n" |
"\"%1\"\n\n" |
566 |
"Do you want to replace it?") |
"Do you want to replace it?") |
582 |
|
|
583 |
// Are we dirty enough to prompt it? |
// Are we dirty enough to prompt it? |
584 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
585 |
switch (QMessageBox::warning(this, tr("Warning"), |
switch (QMessageBox::warning(this, |
586 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
587 |
tr("The current session has been changed:\n\n" |
tr("The current session has been changed:\n\n" |
588 |
"\"%1\"\n\n" |
"\"%1\"\n\n" |
589 |
"Do you want to save the changes?") |
"Do you want to save the changes?") |
641 |
QTextStream ts(&file); |
QTextStream ts(&file); |
642 |
while (!ts.atEnd()) { |
while (!ts.atEnd()) { |
643 |
// Read the line. |
// Read the line. |
644 |
QString sCommand = ts.readLine().simplifyWhiteSpace(); |
QString sCommand = ts.readLine().stripWhiteSpace(); |
645 |
// If not empty, nor a comment, call the server... |
// If not empty, nor a comment, call the server... |
646 |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
647 |
appendMessagesColor(sCommand, "#996633"); |
appendMessagesColor(sCommand, "#996633"); |
676 |
m_sFilename = sFilename; |
m_sFilename = sFilename; |
677 |
updateRecentFiles(sFilename); |
updateRecentFiles(sFilename); |
678 |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
679 |
|
|
680 |
// Make that an overall update. |
// Make that an overall update. |
681 |
stabilizeForm(); |
stabilizeForm(); |
682 |
return true; |
return true; |
686 |
// Save current session to specific file path. |
// Save current session to specific file path. |
687 |
bool qsamplerMainForm::saveSessionFile ( const QString& sFilename ) |
bool qsamplerMainForm::saveSessionFile ( const QString& sFilename ) |
688 |
{ |
{ |
689 |
|
if (m_pClient == NULL) |
690 |
|
return false; |
691 |
|
|
692 |
|
// Check whether server is apparently OK... |
693 |
|
if (::lscp_get_channels(m_pClient) < 0) { |
694 |
|
appendMessagesClient("lscp_get_channels"); |
695 |
|
return false; |
696 |
|
} |
697 |
|
|
698 |
// Open and write into real file. |
// Open and write into real file. |
699 |
QFile file(sFilename); |
QFile file(sFilename); |
700 |
if (!file.open(IO_WriteOnly | IO_Truncate)) { |
if (!file.open(IO_WriteOnly | IO_Truncate)) { |
718 |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
719 |
ts << "#" << endl; |
ts << "#" << endl; |
720 |
ts << endl; |
ts << endl; |
721 |
|
|
722 |
// It is assumed that this new kind of device+session file |
// It is assumed that this new kind of device+session file |
723 |
// will be loaded from a complete |
// will be loaded from a complete initialized server... |
724 |
int *piDeviceIDs; |
int *piDeviceIDs; |
725 |
int iDevice; |
int iDevice; |
726 |
ts << "RESET" << endl; |
ts << "RESET" << endl; |
727 |
|
|
728 |
// Audio device mapping. |
// Audio device mapping. |
729 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; |
730 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
731 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
732 |
ts << endl; |
ts << endl; |
733 |
qsamplerDevice device(m_pClient, qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
734 |
// Audio device specification... |
// Audio device specification... |
735 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
736 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
737 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
738 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
739 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
740 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
741 |
++deviceParam) { |
++deviceParam) { |
742 |
const qsamplerDeviceParam& param = deviceParam.data(); |
const qsamplerDeviceParam& param = deviceParam.data(); |
743 |
if (!param.fix && !param.value.isEmpty()) |
if (param.value.isEmpty()) ts << "# "; |
744 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
745 |
} |
} |
746 |
ts << endl; |
ts << endl; |
747 |
// Audio channel parameters... |
// Audio channel parameters... |
754 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
755 |
++portParam) { |
++portParam) { |
756 |
const qsamplerDeviceParam& param = portParam.data(); |
const qsamplerDeviceParam& param = portParam.data(); |
757 |
if (!param.fix && !param.value.isEmpty()) { |
if (param.fix || param.value.isEmpty()) ts << "# "; |
758 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
759 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
760 |
<< "='" << param.value << "'" << endl; |
<< "='" << param.value << "'" << endl; |
|
} |
|
761 |
} |
} |
762 |
} |
} |
763 |
// Audio device index/id mapping. |
// Audio device index/id mapping. |
764 |
audioDeviceMap[device.deviceID()] = iDevice; |
audioDeviceMap[device.deviceID()] = iDevice; |
765 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
766 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
767 |
} |
} |
768 |
|
|
769 |
// MIDI device mapping. |
// MIDI device mapping. |
770 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; |
771 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
772 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
773 |
ts << endl; |
ts << endl; |
774 |
qsamplerDevice device(m_pClient, qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
775 |
// MIDI device specification... |
// MIDI device specification... |
776 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
777 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
778 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
779 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
780 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
781 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
782 |
++deviceParam) { |
++deviceParam) { |
783 |
const qsamplerDeviceParam& param = deviceParam.data(); |
const qsamplerDeviceParam& param = deviceParam.data(); |
784 |
if (!param.fix && !param.value.isEmpty()) |
if (param.value.isEmpty()) ts << "# "; |
785 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
786 |
} |
} |
787 |
ts << endl; |
ts << endl; |
788 |
// MIDI port parameters... |
// MIDI port parameters... |
795 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
796 |
++portParam) { |
++portParam) { |
797 |
const qsamplerDeviceParam& param = portParam.data(); |
const qsamplerDeviceParam& param = portParam.data(); |
798 |
if (!param.fix && !param.value.isEmpty()) { |
if (param.fix || param.value.isEmpty()) ts << "# "; |
799 |
ts << "SET MIDI_INPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
800 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
801 |
<< "='" << param.value << "'" << endl; |
<< "='" << param.value << "'" << endl; |
|
} |
|
802 |
} |
} |
803 |
} |
} |
804 |
// MIDI device index/id mapping. |
// MIDI device index/id mapping. |
805 |
midiDeviceMap[device.deviceID()] = iDevice; |
midiDeviceMap[device.deviceID()] = iDevice; |
806 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
807 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
808 |
} |
} |
809 |
ts << endl; |
ts << endl; |
810 |
|
|
811 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
812 |
|
// MIDI instrument mapping... |
813 |
|
int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient); |
814 |
|
for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) { |
815 |
|
int iMidiMap = piMaps[iMap]; |
816 |
|
const char *pszMapName |
817 |
|
= ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap); |
818 |
|
ts << "# " << tr("MIDI instrument map") << " " << iMidiMap; |
819 |
|
if (pszMapName) |
820 |
|
ts << " - " << pszMapName; |
821 |
|
ts << endl; |
822 |
|
ts << "ADD MIDI_INSTRUMENT_MAP"; |
823 |
|
if (pszMapName) |
824 |
|
ts << " '" << pszMapName << "'"; |
825 |
|
ts << endl; |
826 |
|
// MIDI instrument mapping... |
827 |
|
lscp_midi_instrument_t *pInstrs |
828 |
|
= ::lscp_list_midi_instruments(m_pClient, iMidiMap); |
829 |
|
for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; iInstr++) { |
830 |
|
lscp_midi_instrument_info_t *pInstrInfo |
831 |
|
= ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]); |
832 |
|
if (pInstrInfo) { |
833 |
|
ts << "MAP MIDI_INSTRUMENT " |
834 |
|
<< pInstrs[iInstr].map << " " |
835 |
|
<< pInstrs[iInstr].bank << " " |
836 |
|
<< pInstrs[iInstr].prog << " " |
837 |
|
<< pInstrInfo->engine_name << " '" |
838 |
|
<< pInstrInfo->instrument_file << "' " |
839 |
|
<< pInstrInfo->instrument_nr << " " |
840 |
|
<< pInstrInfo->volume << " "; |
841 |
|
switch (pInstrInfo->load_mode) { |
842 |
|
case LSCP_LOAD_PERSISTENT: |
843 |
|
ts << "PERSISTENT"; |
844 |
|
break; |
845 |
|
case LSCP_LOAD_ON_DEMAND_HOLD: |
846 |
|
ts << "ON_DEMAND_HOLD"; |
847 |
|
break; |
848 |
|
case LSCP_LOAD_ON_DEMAND: |
849 |
|
case LSCP_LOAD_DEFAULT: |
850 |
|
default: |
851 |
|
ts << "ON_DEMAND"; |
852 |
|
break; |
853 |
|
} |
854 |
|
if (pInstrInfo->name) |
855 |
|
ts << " '" << pInstrInfo->name << "'"; |
856 |
|
ts << endl; |
857 |
|
} |
858 |
|
// Try to keep it snappy :) |
859 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
860 |
|
} |
861 |
|
if (pInstrs) |
862 |
|
ts << endl; |
863 |
|
} |
864 |
|
#endif // CONFIG_MIDI_INSTRUMENT |
865 |
|
|
866 |
// Sampler channel mapping. |
// Sampler channel mapping. |
867 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
868 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
872 |
if (pChannel) { |
if (pChannel) { |
873 |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
874 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
875 |
if (audioDeviceMap.isEmpty()) { |
if (audioDeviceMap.isEmpty()) { |
876 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel |
877 |
<< " " << pChannel->audioDriver() << endl; |
<< " " << pChannel->audioDriver() << endl; |
878 |
} else { |
} else { |
879 |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel |
880 |
<< " " << audioDeviceMap[pChannel->audioDevice()] << endl; |
<< " " << audioDeviceMap[pChannel->audioDevice()] << endl; |
881 |
} |
} |
882 |
if (midiDeviceMap.isEmpty()) { |
if (midiDeviceMap.isEmpty()) { |
883 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel |
884 |
<< " " << pChannel->midiDriver() << endl; |
<< " " << pChannel->midiDriver() << endl; |
885 |
} else { |
} else { |
886 |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel |
887 |
<< " " << midiDeviceMap[pChannel->midiDevice()] << endl; |
<< " " << midiDeviceMap[pChannel->midiDevice()] << endl; |
888 |
} |
} |
889 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel |
890 |
<< " " << pChannel->midiPort() << endl; |
<< " " << pChannel->midiPort() << endl; |
891 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
892 |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
893 |
ts << "ALL"; |
ts << "ALL"; |
895 |
ts << pChannel->midiChannel(); |
ts << pChannel->midiChannel(); |
896 |
ts << endl; |
ts << endl; |
897 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
898 |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
if (pChannel->instrumentStatus() < 100) ts << "# "; |
899 |
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " |
900 |
|
<< pChannel->instrumentNr() << " " << iChannel << endl; |
901 |
|
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
902 |
|
for (audioRoute = pChannel->audioRouting().begin(); |
903 |
|
audioRoute != pChannel->audioRouting().end(); |
904 |
|
++audioRoute) { |
905 |
|
ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel |
906 |
|
<< " " << audioRoute.key() |
907 |
|
<< " " << audioRoute.data() << endl; |
908 |
|
} |
909 |
|
ts << "SET CHANNEL VOLUME " << iChannel |
910 |
|
<< " " << pChannel->volume() << endl; |
911 |
|
if (pChannel->channelMute()) |
912 |
|
ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl; |
913 |
|
if (pChannel->channelSolo()) |
914 |
|
ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl; |
915 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
916 |
|
if (pChannel->midiMap() >= 0) { |
917 |
|
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel |
918 |
|
<< " " << pChannel->midiChannel() << endl; |
919 |
|
} |
920 |
|
#endif |
921 |
ts << endl; |
ts << endl; |
922 |
} |
} |
923 |
} |
} |
1009 |
return; |
return; |
1010 |
|
|
1011 |
// Ask user whether he/she want's an internal sampler reset... |
// Ask user whether he/she want's an internal sampler reset... |
1012 |
if (QMessageBox::warning(this, tr("Warning"), |
if (QMessageBox::warning(this, |
1013 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
1014 |
tr("Resetting the sampler instance will close\n" |
tr("Resetting the sampler instance will close\n" |
1015 |
"all device and channel configurations.\n\n" |
"all device and channel configurations.\n\n" |
1016 |
"Please note that this operation may cause\n" |
"Please note that this operation may cause\n" |
1017 |
"temporary MIDI and Audio disruption\n\n" |
"temporary MIDI and Audio disruption.\n\n" |
1018 |
"Do you want to reset the sampler engine now?"), |
"Do you want to reset the sampler engine now?"), |
1019 |
tr("Reset"), tr("Cancel")) > 0) |
tr("Reset"), tr("Cancel")) > 0) |
1020 |
return; |
return; |
1039 |
{ |
{ |
1040 |
if (m_pOptions == NULL) |
if (m_pOptions == NULL) |
1041 |
return; |
return; |
1042 |
|
|
1043 |
bool bRestart = true; |
bool bRestart = true; |
1044 |
|
|
1045 |
// Ask user whether he/she want's a complete restart... |
// Ask user whether he/she want's a complete restart... |
1046 |
// (if we're currently up and running) |
// (if we're currently up and running) |
1047 |
if (bRestart && m_pClient) { |
if (bRestart && m_pClient) { |
1048 |
bRestart = (QMessageBox::warning(this, tr("Warning"), |
bRestart = (QMessageBox::warning(this, |
1049 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
1050 |
tr("New settings will be effective after\n" |
tr("New settings will be effective after\n" |
1051 |
"restarting the client/server connection.\n\n" |
"restarting the client/server connection.\n\n" |
1052 |
"Please note that this operation may cause\n" |
"Please note that this operation may cause\n" |
1053 |
"temporary MIDI and Audio disruption\n\n" |
"temporary MIDI and Audio disruption.\n\n" |
1054 |
"Do you want to restart the connection now?"), |
"Do you want to restart the connection now?"), |
1055 |
tr("Restart"), tr("Cancel")) == 0); |
tr("Restart"), tr("Cancel")) == 0); |
1056 |
} |
} |
1083 |
return; |
return; |
1084 |
|
|
1085 |
// Just create the channel instance... |
// Just create the channel instance... |
1086 |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
qsamplerChannel *pChannel = new qsamplerChannel(); |
1087 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1088 |
return; |
return; |
1089 |
|
|
1093 |
delete pChannel; |
delete pChannel; |
1094 |
return; |
return; |
1095 |
} |
} |
1096 |
|
|
1097 |
// And give it to the strip (will own the channel instance, if successful). |
// And give it to the strip (will own the channel instance, if successful). |
1098 |
if (!createChannelStrip(pChannel)) { |
if (!createChannelStrip(pChannel)) { |
1099 |
delete pChannel; |
delete pChannel; |
1115 |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1116 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1117 |
return; |
return; |
1118 |
|
|
1119 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
1120 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1121 |
return; |
return; |
1122 |
|
|
1123 |
// Prompt user if he/she's sure about this... |
// Prompt user if he/she's sure about this... |
1124 |
if (m_pOptions && m_pOptions->bConfirmRemove) { |
if (m_pOptions && m_pOptions->bConfirmRemove) { |
1125 |
if (QMessageBox::warning(this, tr("Warning"), |
if (QMessageBox::warning(this, |
1126 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
1127 |
tr("About to remove channel:\n\n" |
tr("About to remove channel:\n\n" |
1128 |
"%1\n\n" |
"%1\n\n" |
1129 |
"Are you sure?") |
"Are you sure?") |
1138 |
|
|
1139 |
// Just delete the channel strip. |
// Just delete the channel strip. |
1140 |
delete pChannelStrip; |
delete pChannelStrip; |
1141 |
|
|
1142 |
// Do we auto-arrange? |
// Do we auto-arrange? |
1143 |
if (m_pOptions && m_pOptions->bAutoArrange) |
if (m_pOptions && m_pOptions->bAutoArrange) |
1144 |
channelsArrange(); |
channelsArrange(); |
1182 |
// Reset all sampler channels. |
// Reset all sampler channels. |
1183 |
void qsamplerMainForm::editResetAllChannels (void) |
void qsamplerMainForm::editResetAllChannels (void) |
1184 |
{ |
{ |
1185 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1186 |
return; |
return; |
1187 |
|
|
1188 |
// Invoque the channel strip procedure, |
// Invoque the channel strip procedure, |
1189 |
// for all channels out there... |
// for all channels out there... |
1190 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1191 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1192 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1193 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1194 |
if (pChannelStrip) |
if (pChannelStrip) |
1195 |
pChannelStrip->channelReset(); |
pChannelStrip->channelReset(); |
1196 |
} |
} |
1197 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1198 |
} |
} |
1199 |
|
|
1200 |
|
|
1246 |
} |
} |
1247 |
|
|
1248 |
|
|
1249 |
|
// Show/hide the MIDI instrument list-view form. |
1250 |
|
void qsamplerMainForm::viewInstruments (void) |
1251 |
|
{ |
1252 |
|
if (m_pOptions == NULL) |
1253 |
|
return; |
1254 |
|
|
1255 |
|
if (m_pInstrumentListForm) { |
1256 |
|
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
1257 |
|
if (m_pInstrumentListForm->isVisible()) { |
1258 |
|
m_pInstrumentListForm->hide(); |
1259 |
|
} else { |
1260 |
|
m_pInstrumentListForm->show(); |
1261 |
|
m_pInstrumentListForm->raise(); |
1262 |
|
m_pInstrumentListForm->setActiveWindow(); |
1263 |
|
} |
1264 |
|
} |
1265 |
|
} |
1266 |
|
|
1267 |
|
|
1268 |
// Show/hide the device configurator form. |
// Show/hide the device configurator form. |
1269 |
void qsamplerMainForm::viewDevices (void) |
void qsamplerMainForm::viewDevices (void) |
1270 |
{ |
{ |
1271 |
if (m_pOptions == NULL) |
if (m_pOptions == NULL) |
1272 |
return; |
return; |
1273 |
|
|
1274 |
if (m_pDeviceForm) { |
if (m_pDeviceForm) { |
1275 |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
1276 |
m_pDeviceForm->setClient(m_pClient); |
if (m_pDeviceForm->isVisible()) { |
1277 |
if (m_pDeviceForm->isVisible()) { |
m_pDeviceForm->hide(); |
1278 |
m_pDeviceForm->hide(); |
} else { |
1279 |
} else { |
m_pDeviceForm->show(); |
1280 |
m_pDeviceForm->show(); |
m_pDeviceForm->raise(); |
1281 |
m_pDeviceForm->raise(); |
m_pDeviceForm->setActiveWindow(); |
1282 |
m_pDeviceForm->setActiveWindow(); |
} |
1283 |
} |
} |
|
} |
|
1284 |
} |
} |
1285 |
|
|
1286 |
|
|
1324 |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
1325 |
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
1326 |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop)) { |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop)) { |
1327 |
QMessageBox::information(this, tr("Information"), |
QMessageBox::information(this, |
1328 |
|
QSAMPLER_TITLE ": " + tr("Information"), |
1329 |
tr("Some settings may be only effective\n" |
tr("Some settings may be only effective\n" |
1330 |
"next time you start this program."), tr("OK")); |
"next time you start this program."), tr("OK")); |
1331 |
updateMessagesCapture(); |
updateMessagesCapture(); |
1399 |
y += iHeight; |
y += iHeight; |
1400 |
} |
} |
1401 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1402 |
|
|
1403 |
stabilizeForm(); |
stabilizeForm(); |
1404 |
} |
} |
1405 |
|
|
1453 |
sText += tr("LSCP (liblscp) instrument_name support disabled."); |
sText += tr("LSCP (liblscp) instrument_name support disabled."); |
1454 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1455 |
#endif |
#endif |
1456 |
|
#ifndef CONFIG_MUTE_SOLO |
1457 |
|
sText += "<small><font color=\"red\">"; |
1458 |
|
sText += tr("Sampler channel Mute/Solo support disabled."); |
1459 |
|
sText += "</font></small><br />"; |
1460 |
|
#endif |
1461 |
|
#ifndef CONFIG_MIDI_INSTRUMENT |
1462 |
|
sText += "<small><font color=\"red\">"; |
1463 |
|
sText += tr("MIDI instrument mapping support disabled."); |
1464 |
|
sText += "</font></small><br />"; |
1465 |
|
#endif |
1466 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1467 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1468 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1469 |
sText += " "; |
sText += " "; |
1470 |
sText += ::lscp_client_version(); |
sText += ::lscp_client_version(); |
1471 |
|
#ifdef CONFIG_LIBGIG |
1472 |
|
sText += ", "; |
1473 |
|
sText += gig::libraryName().c_str(); |
1474 |
|
sText += " "; |
1475 |
|
sText += gig::libraryVersion().c_str(); |
1476 |
|
#endif |
1477 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1478 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1479 |
sText += tr("Website") + ": <a href=\"" QSAMPLER_WEBSITE "\">" QSAMPLER_WEBSITE "</a><br />\n"; |
sText += tr("Website") + ": <a href=\"" QSAMPLER_WEBSITE "\">" QSAMPLER_WEBSITE "</a><br />\n"; |
1498 |
// Update the main application caption... |
// Update the main application caption... |
1499 |
QString sSessionName = sessionName(m_sFilename); |
QString sSessionName = sessionName(m_sFilename); |
1500 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1501 |
sSessionName += '*'; |
sSessionName += " *"; |
1502 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
1503 |
|
|
1504 |
// Update the main menu state... |
// Update the main menu state... |
1517 |
editResetChannelAction->setEnabled(bHasChannel); |
editResetChannelAction->setEnabled(bHasChannel); |
1518 |
editResetAllChannelsAction->setEnabled(bHasChannel); |
editResetAllChannelsAction->setEnabled(bHasChannel); |
1519 |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
1520 |
viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible()); |
#ifdef CONFIG_MIDI_INSTRUMENT |
1521 |
|
viewInstrumentsAction->setOn(m_pInstrumentListForm |
1522 |
|
&& m_pInstrumentListForm->isVisible()); |
1523 |
|
viewInstrumentsAction->setEnabled(bHasClient); |
1524 |
|
#endif |
1525 |
|
viewDevicesAction->setOn(m_pDeviceForm |
1526 |
|
&& m_pDeviceForm->isVisible()); |
1527 |
viewDevicesAction->setEnabled(bHasClient); |
viewDevicesAction->setEnabled(bHasClient); |
1528 |
channelsArrangeAction->setEnabled(bHasChannel); |
channelsArrangeAction->setEnabled(bHasChannel); |
1529 |
|
|
1559 |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1560 |
{ |
{ |
1561 |
// Add this strip to the changed list... |
// Add this strip to the changed list... |
1562 |
if (m_changedStrips.containsRef(pChannelStrip) == 0) |
if (m_changedStrips.containsRef(pChannelStrip) == 0) { |
1563 |
m_changedStrips.append(pChannelStrip); |
m_changedStrips.append(pChannelStrip); |
1564 |
|
pChannelStrip->resetErrorCount(); |
1565 |
|
} |
1566 |
|
|
1567 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1568 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1574 |
// Grab and restore current sampler channels session. |
// Grab and restore current sampler channels session. |
1575 |
void qsamplerMainForm::updateSession (void) |
void qsamplerMainForm::updateSession (void) |
1576 |
{ |
{ |
1577 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
1578 |
|
// FIXME Make some room for default instrument maps... |
1579 |
|
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
1580 |
|
if (iMaps < 0) |
1581 |
|
appendMessagesClient("lscp_get_midi_instrument_maps"); |
1582 |
|
else if (iMaps < 1) { |
1583 |
|
::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1()); |
1584 |
|
::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1()); |
1585 |
|
} |
1586 |
|
#endif |
1587 |
|
|
1588 |
// Retrieve the current channel list. |
// Retrieve the current channel list. |
1589 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1590 |
if (piChannelIDs == NULL) { |
if (piChannelIDs == NULL) { |
1600 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1601 |
// Check if theres already a channel strip for this one... |
// Check if theres already a channel strip for this one... |
1602 |
if (!channelStrip(piChannelIDs[iChannel])) |
if (!channelStrip(piChannelIDs[iChannel])) |
1603 |
createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); |
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
1604 |
// Make it visibly responsive... |
// Make it visibly responsive... |
1605 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1606 |
} |
} |
1607 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1608 |
|
|
1609 |
// Remember to refresh devices |
// Remember to refresh devices and instruments... |
1610 |
|
if (m_pInstrumentListForm) |
1611 |
|
m_pInstrumentListForm->refreshInstruments(); |
1612 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
1613 |
m_pDeviceForm->refreshDevices(); |
m_pDeviceForm->refreshDevices(); |
1614 |
} |
} |
1781 |
|
|
1782 |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
1783 |
|
|
1784 |
QMessageBox::critical(this, tr("Error"), s, tr("Cancel")); |
QMessageBox::critical(this, |
1785 |
|
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
1786 |
} |
} |
1787 |
|
|
1788 |
|
|
1822 |
if (m_pOptions->bMessagesLimit) |
if (m_pOptions->bMessagesLimit) |
1823 |
m_pMessages->setMessagesLimit(m_pOptions->iMessagesLimitLines); |
m_pMessages->setMessagesLimit(m_pOptions->iMessagesLimitLines); |
1824 |
else |
else |
1825 |
m_pMessages->setMessagesLimit(0); |
m_pMessages->setMessagesLimit(-1); |
1826 |
} |
} |
1827 |
} |
} |
1828 |
|
|
1866 |
pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
1867 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1868 |
return NULL; |
return NULL; |
1869 |
|
|
1870 |
// Actual channel strip setup... |
// Actual channel strip setup... |
1871 |
pChannelStrip->setup(pChannel); |
pChannelStrip->setup(pChannel); |
1872 |
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
1924 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1925 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1926 |
return NULL; |
return NULL; |
1927 |
|
|
1928 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1929 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1930 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2005 |
} |
} |
2006 |
} |
} |
2007 |
} |
} |
2008 |
|
|
2009 |
// Refresh each channel usage, on each period... |
if (m_pClient) { |
2010 |
if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) { |
// Update the channel information for each pending strip... |
2011 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
if (m_changedStrips.count() > 0) { |
2012 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
2013 |
m_iTimerSlot = 0; |
pChannelStrip; pChannelStrip = m_changedStrips.next()) { |
|
// Update the channel information for each pending strip... |
|
|
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
|
|
pChannelStrip; |
|
|
pChannelStrip = m_changedStrips.next()) { |
|
2014 |
// If successfull, remove from pending list... |
// If successfull, remove from pending list... |
2015 |
if (pChannelStrip->updateChannelInfo()) |
if (pChannelStrip->updateChannelInfo()) |
2016 |
m_changedStrips.remove(pChannelStrip); |
m_changedStrips.remove(pChannelStrip); |
2017 |
} |
} |
2018 |
// Update the channel stream usage for each strip... |
} |
2019 |
QWidgetList wlist = m_pWorkspace->windowList(); |
// Refresh each channel usage, on each period... |
2020 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
if (m_pOptions->bAutoRefresh) { |
2021 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
2022 |
if (pChannelStrip && pChannelStrip->isVisible()) |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime) { |
2023 |
pChannelStrip->updateChannelUsage(); |
m_iTimerSlot = 0; |
2024 |
} |
// Update the channel stream usage for each strip... |
2025 |
} |
QWidgetList wlist = m_pWorkspace->windowList(); |
2026 |
} |
for (int iChannel = 0; |
2027 |
|
iChannel < (int) wlist.count(); iChannel++) { |
2028 |
|
qsamplerChannelStrip *pChannelStrip |
2029 |
|
= (qsamplerChannelStrip *) wlist.at(iChannel); |
2030 |
|
if (pChannelStrip && pChannelStrip->isVisible()) |
2031 |
|
pChannelStrip->updateChannelUsage(); |
2032 |
|
} |
2033 |
|
} |
2034 |
|
} |
2035 |
|
} |
2036 |
|
|
2037 |
// Register the next timer slot. |
// Register the next timer slot. |
2038 |
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(timerSlot())); |
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(timerSlot())); |
2054 |
|
|
2055 |
// Is the server process instance still here? |
// Is the server process instance still here? |
2056 |
if (m_pServer) { |
if (m_pServer) { |
2057 |
switch (QMessageBox::warning(this, tr("Warning"), |
switch (QMessageBox::warning(this, |
2058 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
2059 |
tr("Could not start the LinuxSampler server.\n\n" |
tr("Could not start the LinuxSampler server.\n\n" |
2060 |
"Maybe it ss already started."), |
"Maybe it ss already started."), |
2061 |
tr("Stop"), tr("Kill"), tr("Cancel"))) { |
tr("Stop"), tr("Kill"), tr("Cancel"))) { |
2214 |
::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout); |
::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout); |
2215 |
appendMessages(tr("Client receive timeout is set to %1 msec.").arg(::lscp_client_get_timeout(m_pClient))); |
appendMessages(tr("Client receive timeout is set to %1 msec.").arg(::lscp_client_get_timeout(m_pClient))); |
2216 |
|
|
2217 |
|
// Subscribe to channel info change notifications... |
2218 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
2219 |
|
appendMessagesClient("lscp_client_subscribe"); |
2220 |
|
|
2221 |
// We may stop scheduling around. |
// We may stop scheduling around. |
2222 |
stopSchedule(); |
stopSchedule(); |
2223 |
|
|
2227 |
// Log success here. |
// Log success here. |
2228 |
appendMessages(tr("Client connected.")); |
appendMessages(tr("Client connected.")); |
2229 |
|
|
2230 |
// Hard-notify device configuration form, |
// Hard-notify instrumnet and device configuration forms, |
2231 |
// if visible, that we're ready... |
// if visible, that we're ready... |
2232 |
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
if (m_pInstrumentListForm) |
2233 |
m_pDeviceForm->setClient(m_pClient); |
m_pInstrumentListForm->refreshInstruments(); |
2234 |
|
if (m_pDeviceForm) |
2235 |
|
m_pDeviceForm->refreshDevices(); |
2236 |
|
|
2237 |
// Is any session pending to be loaded? |
// Is any session pending to be loaded? |
2238 |
if (!m_pOptions->sSessionFile.isEmpty()) { |
if (!m_pOptions->sSessionFile.isEmpty()) { |
2239 |
// Just load the prabably startup session... |
// Just load the prabably startup session... |
2254 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
2255 |
return; |
return; |
2256 |
|
|
|
// Hard-notify device configuration form, |
|
|
// if visible, that we're running out... |
|
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
|
|
m_pDeviceForm->setClient(NULL); |
|
|
|
|
2257 |
// Log prepare here. |
// Log prepare here. |
2258 |
appendMessages(tr("Client disconnecting...")); |
appendMessages(tr("Client disconnecting...")); |
2259 |
|
|
2268 |
// channels from the back-end server. |
// channels from the back-end server. |
2269 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
2270 |
closeSession(false); |
closeSession(false); |
2271 |
|
|
2272 |
// Close us as a client... |
// Close us as a client... |
2273 |
lscp_client_destroy(m_pClient); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
2274 |
|
::lscp_client_destroy(m_pClient); |
2275 |
m_pClient = NULL; |
m_pClient = NULL; |
2276 |
|
|
2277 |
|
// Hard-notify instrumnet and device configuration forms, |
2278 |
|
// if visible, that we're running out... |
2279 |
|
if (m_pInstrumentListForm) |
2280 |
|
m_pInstrumentListForm->refreshInstruments(); |
2281 |
|
if (m_pDeviceForm) |
2282 |
|
m_pDeviceForm->refreshDevices(); |
2283 |
|
|
2284 |
// Log final here. |
// Log final here. |
2285 |
appendMessages(tr("Client disconnected.")); |
appendMessages(tr("Client disconnected.")); |
2286 |
|
|