1 |
// qsamplerMainForm.cpp |
// qsamplerMainForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2016, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007,2008,2015 Christian Schoenebeck |
Copyright (C) 2007,2008,2015 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
58 |
#include <QTimer> |
#include <QTimer> |
59 |
#include <QDateTime> |
#include <QDateTime> |
60 |
|
|
61 |
#if QT_VERSION >= 0x050000 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
62 |
#include <QMimeData> |
#include <QMimeData> |
63 |
#endif |
#endif |
64 |
|
|
65 |
#if QT_VERSION < 0x040500 |
#if QT_VERSION < QT_VERSION_CHECK(4, 5, 0) |
66 |
namespace Qt { |
namespace Qt { |
67 |
const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000); |
const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000); |
68 |
} |
} |
69 |
#endif |
#endif |
70 |
|
|
|
#ifdef HAVE_SIGNAL_H |
|
|
#include <signal.h> |
|
|
#endif |
|
|
|
|
71 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
72 |
#include <gig.h> |
#include <gig.h> |
73 |
#endif |
#endif |
87 |
|
|
88 |
|
|
89 |
// All winsock apps needs this. |
// All winsock apps needs this. |
90 |
#if defined(WIN32) |
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) |
91 |
static WSADATA _wsaData; |
static WSADATA _wsaData; |
92 |
|
#undef HAVE_SIGNAL_H |
93 |
#endif |
#endif |
94 |
|
|
95 |
|
|
100 |
|
|
101 |
#include <QSocketNotifier> |
#include <QSocketNotifier> |
102 |
|
|
103 |
|
#include <unistd.h> |
104 |
#include <sys/types.h> |
#include <sys/types.h> |
105 |
#include <sys/socket.h> |
#include <sys/socket.h> |
|
|
|
106 |
#include <signal.h> |
#include <signal.h> |
107 |
|
|
108 |
// File descriptor for SIGUSR1 notifier. |
// File descriptor for SIGUSR1 notifier. |
109 |
static int g_fdUsr1[2]; |
static int g_fdSigusr1[2] = { -1, -1 }; |
110 |
|
|
111 |
// Unix SIGUSR1 signal handler. |
// Unix SIGUSR1 signal handler. |
112 |
static void qsampler_sigusr1_handler ( int /* signo */ ) |
static void qsampler_sigusr1_handler ( int /* signo */ ) |
113 |
{ |
{ |
114 |
char c = 1; |
char c = 1; |
115 |
|
|
116 |
(::write(g_fdUsr1[0], &c, sizeof(c)) > 0); |
(::write(g_fdSigusr1[0], &c, sizeof(c)) > 0); |
117 |
|
} |
118 |
|
|
119 |
|
// File descriptor for SIGTERM notifier. |
120 |
|
static int g_fdSigterm[2] = { -1, -1 }; |
121 |
|
|
122 |
|
// Unix SIGTERM signal handler. |
123 |
|
static void qsampler_sigterm_handler ( int /* signo */ ) |
124 |
|
{ |
125 |
|
char c = 1; |
126 |
|
|
127 |
|
(::write(g_fdSigterm[0], &c, sizeof(c)) > 0); |
128 |
} |
} |
129 |
|
|
130 |
#endif // HAVE_SIGNAL_H |
#endif // HAVE_SIGNAL_H |
202 |
// QSampler::MainForm -- Main window form implementation. |
// QSampler::MainForm -- Main window form implementation. |
203 |
|
|
204 |
// Kind of singleton reference. |
// Kind of singleton reference. |
205 |
MainForm *MainForm::g_pMainForm = NULL; |
MainForm *MainForm::g_pMainForm = nullptr; |
206 |
|
|
207 |
MainForm::MainForm ( QWidget *pParent ) |
MainForm::MainForm ( QWidget *pParent ) |
208 |
: QMainWindow(pParent) |
: QMainWindow(pParent) |
213 |
g_pMainForm = this; |
g_pMainForm = this; |
214 |
|
|
215 |
// Initialize some pointer references. |
// Initialize some pointer references. |
216 |
m_pOptions = NULL; |
m_pOptions = nullptr; |
217 |
|
|
218 |
// All child forms are to be created later, not earlier than setup. |
// All child forms are to be created later, not earlier than setup. |
219 |
m_pMessages = NULL; |
m_pMessages = nullptr; |
220 |
m_pInstrumentListForm = NULL; |
m_pInstrumentListForm = nullptr; |
221 |
m_pDeviceForm = NULL; |
m_pDeviceForm = nullptr; |
222 |
|
|
223 |
// We'll start clean. |
// We'll start clean. |
224 |
m_iUntitled = 0; |
m_iUntitled = 0; |
225 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
226 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
227 |
|
|
228 |
m_pServer = NULL; |
m_pServer = nullptr; |
229 |
m_pClient = NULL; |
m_pClient = nullptr; |
230 |
|
|
231 |
m_iStartDelay = 0; |
m_iStartDelay = 0; |
232 |
m_iTimerDelay = 0; |
m_iTimerDelay = 0; |
241 |
// LADISH Level 1 suport. |
// LADISH Level 1 suport. |
242 |
|
|
243 |
// Initialize file descriptors for SIGUSR1 socket notifier. |
// Initialize file descriptors for SIGUSR1 socket notifier. |
244 |
::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1); |
::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigusr1); |
245 |
m_pUsr1Notifier |
m_pSigusr1Notifier |
246 |
= new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this); |
= new QSocketNotifier(g_fdSigusr1[1], QSocketNotifier::Read, this); |
247 |
|
|
248 |
QObject::connect(m_pUsr1Notifier, |
QObject::connect(m_pSigusr1Notifier, |
249 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
250 |
SLOT(handle_sigusr1())); |
SLOT(handle_sigusr1())); |
251 |
|
|
252 |
// Install SIGUSR1 signal handler. |
// Install SIGUSR1 signal handler. |
253 |
struct sigaction usr1; |
struct sigaction sigusr1; |
254 |
usr1.sa_handler = qsampler_sigusr1_handler; |
sigusr1.sa_handler = qsampler_sigusr1_handler; |
255 |
sigemptyset(&usr1.sa_mask); |
sigemptyset(&sigusr1.sa_mask); |
256 |
usr1.sa_flags = 0; |
sigusr1.sa_flags = 0; |
257 |
usr1.sa_flags |= SA_RESTART; |
sigusr1.sa_flags |= SA_RESTART; |
258 |
::sigaction(SIGUSR1, &usr1, NULL); |
::sigaction(SIGUSR1, &sigusr1, nullptr); |
259 |
|
|
260 |
|
// Initialize file descriptors for SIGTERM socket notifier. |
261 |
|
::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm); |
262 |
|
m_pSigtermNotifier |
263 |
|
= new QSocketNotifier(g_fdSigterm[1], QSocketNotifier::Read, this); |
264 |
|
|
265 |
|
QObject::connect(m_pSigtermNotifier, |
266 |
|
SIGNAL(activated(int)), |
267 |
|
SLOT(handle_sigterm())); |
268 |
|
|
269 |
|
// Install SIGTERM signal handler. |
270 |
|
struct sigaction sigterm; |
271 |
|
sigterm.sa_handler = qsampler_sigterm_handler; |
272 |
|
sigemptyset(&sigterm.sa_mask); |
273 |
|
sigterm.sa_flags = 0; |
274 |
|
sigterm.sa_flags |= SA_RESTART; |
275 |
|
::sigaction(SIGTERM, &sigterm, nullptr); |
276 |
|
::sigaction(SIGQUIT, &sigterm, nullptr); |
277 |
|
|
278 |
|
// Ignore SIGHUP/SIGINT signals. |
279 |
|
::signal(SIGHUP, SIG_IGN); |
280 |
|
::signal(SIGINT, SIG_IGN); |
281 |
|
|
282 |
#else // HAVE_SIGNAL_H |
#else // HAVE_SIGNAL_H |
283 |
|
|
284 |
m_pUsr1Notifier = NULL; |
m_pSigusr1Notifier = nullptr; |
285 |
|
m_pSigtermNotifier = nullptr; |
286 |
|
|
287 |
#endif // !HAVE_SIGNAL_H |
#endif // !HAVE_SIGNAL_H |
288 |
|
|
355 |
m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel; |
m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel; |
356 |
statusBar()->addWidget(pLabel); |
statusBar()->addWidget(pLabel); |
357 |
|
|
358 |
#if defined(WIN32) |
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) |
359 |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
360 |
#endif |
#endif |
361 |
|
|
456 |
// Do final processing anyway. |
// Do final processing anyway. |
457 |
processServerExit(); |
processServerExit(); |
458 |
|
|
459 |
#if defined(WIN32) |
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) |
460 |
WSACleanup(); |
WSACleanup(); |
461 |
#endif |
#endif |
462 |
|
|
463 |
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
464 |
if (m_pUsr1Notifier) |
if (m_pSigusr1Notifier) |
465 |
delete m_pUsr1Notifier; |
delete m_pSigusr1Notifier; |
466 |
|
if (m_pSigtermNotifier) |
467 |
|
delete m_pSigtermNotifier; |
468 |
#endif |
#endif |
469 |
|
|
470 |
// Finally drop any widgets around... |
// Finally drop any widgets around... |
493 |
#endif |
#endif |
494 |
|
|
495 |
// Pseudo-singleton reference shut-down. |
// Pseudo-singleton reference shut-down. |
496 |
g_pMainForm = NULL; |
g_pMainForm = nullptr; |
497 |
} |
} |
498 |
|
|
499 |
|
|
630 |
void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
631 |
{ |
{ |
632 |
// Accept external drags only... |
// Accept external drags only... |
633 |
if (pDragEnterEvent->source() == NULL |
if (pDragEnterEvent->source() == nullptr |
634 |
&& pDragEnterEvent->mimeData()->hasUrls()) { |
&& pDragEnterEvent->mimeData()->hasUrls()) { |
635 |
pDragEnterEvent->accept(); |
pDragEnterEvent->accept(); |
636 |
} else { |
} else { |
654 |
if (QFileInfo(sPath).exists()) { |
if (QFileInfo(sPath).exists()) { |
655 |
// Try to create a new channel from instrument file... |
// Try to create a new channel from instrument file... |
656 |
Channel *pChannel = new Channel(); |
Channel *pChannel = new Channel(); |
657 |
if (pChannel == NULL) |
if (pChannel == nullptr) |
658 |
return; |
return; |
659 |
// Start setting the instrument filename... |
// Start setting the instrument filename... |
660 |
pChannel->setInstrument(sPath, 0); |
pChannel->setInstrument(sPath, 0); |
754 |
|
|
755 |
char c; |
char c; |
756 |
|
|
757 |
if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0) |
if (::read(g_fdSigusr1[1], &c, sizeof(c)) > 0) |
758 |
saveSession(false); |
saveSession(false); |
759 |
|
|
760 |
#endif |
#endif |
761 |
} |
} |
762 |
|
|
763 |
|
|
764 |
|
void MainForm::handle_sigterm (void) |
765 |
|
{ |
766 |
|
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
767 |
|
|
768 |
|
char c; |
769 |
|
|
770 |
|
if (::read(g_fdSigterm[1], &c, sizeof(c)) > 0) |
771 |
|
close(); |
772 |
|
|
773 |
|
#endif |
774 |
|
} |
775 |
|
|
776 |
|
|
777 |
void MainForm::updateViewMidiDeviceStatusMenu (void) |
void MainForm::updateViewMidiDeviceStatusMenu (void) |
778 |
{ |
{ |
779 |
m_ui.viewMidiDeviceStatusMenu->clear(); |
m_ui.viewMidiDeviceStatusMenu->clear(); |
852 |
m_iUntitled++; |
m_iUntitled++; |
853 |
|
|
854 |
// Stabilize form. |
// Stabilize form. |
855 |
m_sFilename = QString::null; |
m_sFilename = QString(); |
856 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
857 |
appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename))); |
appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename))); |
858 |
stabilizeForm(); |
stabilizeForm(); |
864 |
// Open an existing sampler session. |
// Open an existing sampler session. |
865 |
bool MainForm::openSession (void) |
bool MainForm::openSession (void) |
866 |
{ |
{ |
867 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
868 |
return false; |
return false; |
869 |
|
|
870 |
// Ask for the filename to open... |
// Ask for the filename to open... |
871 |
QString sFilename = QFileDialog::getOpenFileName(this, |
QString sFilename = QFileDialog::getOpenFileName(this, |
872 |
QSAMPLER_TITLE ": " + tr("Open Session"), // Caption. |
tr("Open Session"), // Caption. |
873 |
m_pOptions->sSessionDir, // Start here. |
m_pOptions->sSessionDir, // Start here. |
874 |
tr("LSCP Session files") + " (*.lscp)" // Filter (LSCP files) |
tr("LSCP Session files") + " (*.lscp)" // Filter (LSCP files) |
875 |
); |
); |
890 |
// Save current sampler session with another name. |
// Save current sampler session with another name. |
891 |
bool MainForm::saveSession ( bool bPrompt ) |
bool MainForm::saveSession ( bool bPrompt ) |
892 |
{ |
{ |
893 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
894 |
return false; |
return false; |
895 |
|
|
896 |
QString sFilename = m_sFilename; |
QString sFilename = m_sFilename; |
902 |
sFilename = m_pOptions->sSessionDir; |
sFilename = m_pOptions->sSessionDir; |
903 |
// Prompt the guy... |
// Prompt the guy... |
904 |
sFilename = QFileDialog::getSaveFileName(this, |
sFilename = QFileDialog::getSaveFileName(this, |
905 |
QSAMPLER_TITLE ": " + tr("Save Session"), // Caption. |
tr("Save Session"), // Caption. |
906 |
sFilename, // Start here. |
sFilename, // Start here. |
907 |
tr("LSCP Session files") + " (*.lscp)" // Filter (LSCP files) |
tr("LSCP Session files") + " (*.lscp)" // Filter (LSCP files) |
908 |
); |
); |
912 |
// Enforce .lscp extension... |
// Enforce .lscp extension... |
913 |
if (QFileInfo(sFilename).suffix().isEmpty()) |
if (QFileInfo(sFilename).suffix().isEmpty()) |
914 |
sFilename += ".lscp"; |
sFilename += ".lscp"; |
915 |
|
#if 0 |
916 |
// Check if already exists... |
// Check if already exists... |
917 |
if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) { |
if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) { |
918 |
if (QMessageBox::warning(this, |
if (QMessageBox::warning(this, |
919 |
QSAMPLER_TITLE ": " + tr("Warning"), |
tr("Warning"), |
920 |
tr("The file already exists:\n\n" |
tr("The file already exists:\n\n" |
921 |
"\"%1\"\n\n" |
"\"%1\"\n\n" |
922 |
"Do you want to replace it?") |
"Do you want to replace it?") |
925 |
== QMessageBox::No) |
== QMessageBox::No) |
926 |
return false; |
return false; |
927 |
} |
} |
928 |
|
#endif |
929 |
} |
} |
930 |
|
|
931 |
// Save it right away. |
// Save it right away. |
941 |
// Are we dirty enough to prompt it? |
// Are we dirty enough to prompt it? |
942 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
943 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
944 |
QSAMPLER_TITLE ": " + tr("Warning"), |
tr("Warning"), |
945 |
tr("The current session has been changed:\n\n" |
tr("The current session has been changed:\n\n" |
946 |
"\"%1\"\n\n" |
"\"%1\"\n\n" |
947 |
"Do you want to save the changes?") |
"Do you want to save the changes?") |
966 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
967 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
968 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
969 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
970 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
971 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
972 |
if (pChannelStrip) { |
if (pChannelStrip) { |
973 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
974 |
if (bForce && pChannel) |
if (bForce && pChannel) |
975 |
pChannel->removeChannel(); |
pChannel->removeChannel(); |
976 |
delete pChannelStrip; |
delete pChannelStrip; |
977 |
} |
} |
978 |
if (pMdiSubWindow) |
delete pMdiSubWindow; |
|
delete pMdiSubWindow; |
|
979 |
} |
} |
980 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
981 |
// We're now clean, for sure. |
// We're now clean, for sure. |
989 |
// Load a session from specific file path. |
// Load a session from specific file path. |
990 |
bool MainForm::loadSessionFile ( const QString& sFilename ) |
bool MainForm::loadSessionFile ( const QString& sFilename ) |
991 |
{ |
{ |
992 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
993 |
return false; |
return false; |
994 |
|
|
995 |
// Open and read from real file. |
// Open and read from real file. |
1065 |
// Save current session to specific file path. |
// Save current session to specific file path. |
1066 |
bool MainForm::saveSessionFile ( const QString& sFilename ) |
bool MainForm::saveSessionFile ( const QString& sFilename ) |
1067 |
{ |
{ |
1068 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1069 |
return false; |
return false; |
1070 |
|
|
1071 |
// Check whether server is apparently OK... |
// Check whether server is apparently OK... |
1090 |
int iErrors = 0; |
int iErrors = 0; |
1091 |
QTextStream ts(&file); |
QTextStream ts(&file); |
1092 |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
1093 |
ts << "# " << tr("Version") |
ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << endl; |
1094 |
<< ": " QSAMPLER_VERSION << endl; |
// ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << endl; |
|
ts << "# " << tr("Build") |
|
|
<< ": " CONFIG_BUILD_DATE << endl; |
|
1095 |
ts << "#" << endl; |
ts << "#" << endl; |
1096 |
ts << "# " << tr("File") |
ts << "# " << tr("File") |
1097 |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
1104 |
// It is assumed that this new kind of device+session file |
// It is assumed that this new kind of device+session file |
1105 |
// will be loaded from a complete initialized server... |
// will be loaded from a complete initialized server... |
1106 |
int *piDeviceIDs; |
int *piDeviceIDs; |
1107 |
int iDevice; |
int i, iDevice; |
1108 |
ts << "RESET" << endl; |
ts << "RESET" << endl; |
1109 |
|
|
1110 |
// Audio device mapping. |
// Audio device mapping. |
1111 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; iDevice = 0; |
1112 |
piDeviceIDs = Device::getDevices(m_pClient, Device::Audio); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Audio); |
1113 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) { |
1114 |
ts << endl; |
Device device(Device::Audio, piDeviceIDs[i]); |
1115 |
Device device(Device::Audio, piDeviceIDs[iDevice]); |
// Avoid plug-in driver devices... |
1116 |
|
if (device.driverName().toUpper() == "PLUGIN") |
1117 |
|
continue; |
1118 |
// Audio device specification... |
// Audio device specification... |
1119 |
|
ts << endl; |
1120 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1121 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
1122 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
1147 |
iPort++; |
iPort++; |
1148 |
} |
} |
1149 |
// Audio device index/id mapping. |
// Audio device index/id mapping. |
1150 |
audioDeviceMap[device.deviceID()] = iDevice; |
audioDeviceMap.insert(device.deviceID(), iDevice++); |
1151 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1152 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1153 |
} |
} |
1154 |
|
|
1155 |
// MIDI device mapping. |
// MIDI device mapping. |
1156 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; iDevice = 0; |
1157 |
piDeviceIDs = Device::getDevices(m_pClient, Device::Midi); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Midi); |
1158 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) { |
1159 |
ts << endl; |
Device device(Device::Midi, piDeviceIDs[i]); |
1160 |
Device device(Device::Midi, piDeviceIDs[iDevice]); |
// Avoid plug-in driver devices... |
1161 |
|
if (device.driverName().toUpper() == "PLUGIN") |
1162 |
|
continue; |
1163 |
// MIDI device specification... |
// MIDI device specification... |
1164 |
|
ts << endl; |
1165 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1166 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
1167 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
1192 |
iPort++; |
iPort++; |
1193 |
} |
} |
1194 |
// MIDI device index/id mapping. |
// MIDI device index/id mapping. |
1195 |
midiDeviceMap[device.deviceID()] = iDevice; |
midiDeviceMap.insert(device.deviceID(), iDevice++); |
1196 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1197 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1198 |
} |
} |
1255 |
} |
} |
1256 |
ts << endl; |
ts << endl; |
1257 |
// Check for errors... |
// Check for errors... |
1258 |
if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) { |
if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) { |
1259 |
appendMessagesClient("lscp_list_midi_instruments"); |
appendMessagesClient("lscp_list_midi_instruments"); |
1260 |
iErrors++; |
iErrors++; |
1261 |
} |
} |
1262 |
// MIDI strument index/id mapping. |
// MIDI strument index/id mapping. |
1263 |
midiInstrumentMap[iMidiMap] = iMap; |
midiInstrumentMap.insert(iMidiMap, iMap); |
1264 |
} |
} |
1265 |
// Check for errors... |
// Check for errors... |
1266 |
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
if (piMaps == nullptr && ::lscp_client_get_errno(m_pClient)) { |
1267 |
appendMessagesClient("lscp_list_midi_instrument_maps"); |
appendMessagesClient("lscp_list_midi_instrument_maps"); |
1268 |
iErrors++; |
iErrors++; |
1269 |
} |
} |
1270 |
#endif // CONFIG_MIDI_INSTRUMENT |
#endif // CONFIG_MIDI_INSTRUMENT |
1271 |
|
|
1272 |
// Sampler channel mapping. |
// Sampler channel mapping... |
1273 |
|
int iChannelID = 0; |
1274 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
1275 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
1276 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
1277 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
1278 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
1279 |
if (pChannelStrip) { |
if (pChannelStrip) { |
1280 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1281 |
if (pChannel) { |
if (pChannel) { |
1282 |
const int iChannelID = pChannel->channelID(); |
// Avoid "artifial" plug-in devices... |
1283 |
|
const int iAudioDevice = pChannel->audioDevice(); |
1284 |
|
if (!audioDeviceMap.contains(iAudioDevice)) |
1285 |
|
continue; |
1286 |
|
const int iMidiDevice = pChannel->midiDevice(); |
1287 |
|
if (!midiDeviceMap.contains(iMidiDevice)) |
1288 |
|
continue; |
1289 |
|
// Go for regular, canonical devices... |
1290 |
ts << "# " << tr("Channel") << " " << iChannelID << endl; |
ts << "# " << tr("Channel") << " " << iChannelID << endl; |
1291 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
1292 |
if (audioDeviceMap.isEmpty()) { |
if (audioDeviceMap.isEmpty()) { |
1294 |
<< " " << pChannel->audioDriver() << endl; |
<< " " << pChannel->audioDriver() << endl; |
1295 |
} else { |
} else { |
1296 |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID |
1297 |
<< " " << audioDeviceMap[pChannel->audioDevice()] << endl; |
<< " " << audioDeviceMap.value(iAudioDevice) << endl; |
1298 |
} |
} |
1299 |
if (midiDeviceMap.isEmpty()) { |
if (midiDeviceMap.isEmpty()) { |
1300 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID |
1301 |
<< " " << pChannel->midiDriver() << endl; |
<< " " << pChannel->midiDriver() << endl; |
1302 |
} else { |
} else { |
1303 |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID |
1304 |
<< " " << midiDeviceMap[pChannel->midiDevice()] << endl; |
<< " " << midiDeviceMap.value(iMidiDevice) << endl; |
1305 |
} |
} |
1306 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID |
1307 |
<< " " << pChannel->midiPort() << endl; |
<< " " << pChannel->midiPort() << endl; |
1332 |
if (pChannel->channelSolo()) |
if (pChannel->channelSolo()) |
1333 |
ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl; |
ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl; |
1334 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1335 |
if (pChannel->midiMap() >= 0) { |
const int iMidiMap = pChannel->midiMap(); |
1336 |
|
if (midiInstrumentMap.contains(iMidiMap)) { |
1337 |
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID |
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID |
1338 |
<< " " << midiInstrumentMap[pChannel->midiMap()] << endl; |
<< " " << midiInstrumentMap.value(iMidiMap) << endl; |
1339 |
} |
} |
1340 |
#endif |
#endif |
1341 |
#ifdef CONFIG_FXSEND |
#ifdef CONFIG_FXSEND |
1374 |
} |
} |
1375 |
#endif |
#endif |
1376 |
ts << endl; |
ts << endl; |
1377 |
|
// Go for next channel... |
1378 |
|
++iChannelID; |
1379 |
} |
} |
1380 |
} |
} |
1381 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1481 |
// Reset the sampler instance. |
// Reset the sampler instance. |
1482 |
void MainForm::fileReset (void) |
void MainForm::fileReset (void) |
1483 |
{ |
{ |
1484 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1485 |
return; |
return; |
1486 |
|
|
1487 |
// Ask user whether he/she want's an internal sampler reset... |
// Ask user whether he/she want's an internal sampler reset... |
1488 |
if (m_pOptions && m_pOptions->bConfirmReset) { |
if (m_pOptions && m_pOptions->bConfirmReset) { |
1489 |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning"); |
const QString& sTitle = tr("Warning"); |
1490 |
const QString& sText = tr( |
const QString& sText = tr( |
1491 |
"Resetting the sampler instance will close\n" |
"Resetting the sampler instance will close\n" |
1492 |
"all device and channel configurations.\n\n" |
"all device and channel configurations.\n\n" |
1537 |
// Restart the client/server instance. |
// Restart the client/server instance. |
1538 |
void MainForm::fileRestart (void) |
void MainForm::fileRestart (void) |
1539 |
{ |
{ |
1540 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
1541 |
return; |
return; |
1542 |
|
|
1543 |
bool bRestart = true; |
bool bRestart = true; |
1545 |
// Ask user whether he/she want's a complete restart... |
// Ask user whether he/she want's a complete restart... |
1546 |
// (if we're currently up and running) |
// (if we're currently up and running) |
1547 |
if (m_pOptions && m_pOptions->bConfirmRestart) { |
if (m_pOptions && m_pOptions->bConfirmRestart) { |
1548 |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning"); |
const QString& sTitle = tr("Warning"); |
1549 |
const QString& sText = tr( |
const QString& sText = tr( |
1550 |
"New settings will be effective after\n" |
"New settings will be effective after\n" |
1551 |
"restarting the client/server connection.\n\n" |
"restarting the client/server connection.\n\n" |
1605 |
|
|
1606 |
void MainForm::addChannelStrip (void) |
void MainForm::addChannelStrip (void) |
1607 |
{ |
{ |
1608 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1609 |
return; |
return; |
1610 |
|
|
1611 |
// Just create the channel instance... |
// Just create the channel instance... |
1612 |
Channel *pChannel = new Channel(); |
Channel *pChannel = new Channel(); |
1613 |
if (pChannel == NULL) |
if (pChannel == nullptr) |
1614 |
return; |
return; |
1615 |
|
|
1616 |
// Before we show it up, may be we'll |
// Before we show it up, may be we'll |
1646 |
|
|
1647 |
void MainForm::removeChannelStrip (void) |
void MainForm::removeChannelStrip (void) |
1648 |
{ |
{ |
1649 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1650 |
return; |
return; |
1651 |
|
|
1652 |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1653 |
if (pChannelStrip == NULL) |
if (pChannelStrip == nullptr) |
1654 |
return; |
return; |
1655 |
|
|
1656 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1657 |
if (pChannel == NULL) |
if (pChannel == nullptr) |
1658 |
return; |
return; |
1659 |
|
|
1660 |
// Prompt user if he/she's sure about this... |
// Prompt user if he/she's sure about this... |
1661 |
if (m_pOptions && m_pOptions->bConfirmRemove) { |
if (m_pOptions && m_pOptions->bConfirmRemove) { |
1662 |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning"); |
const QString& sTitle = tr("Warning"); |
1663 |
const QString& sText = tr( |
const QString& sText = tr( |
1664 |
"About to remove channel:\n\n" |
"About to remove channel:\n\n" |
1665 |
"%1\n\n" |
"%1\n\n" |
1702 |
// Setup current sampler channel. |
// Setup current sampler channel. |
1703 |
void MainForm::editSetupChannel (void) |
void MainForm::editSetupChannel (void) |
1704 |
{ |
{ |
1705 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1706 |
return; |
return; |
1707 |
|
|
1708 |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1709 |
if (pChannelStrip == NULL) |
if (pChannelStrip == nullptr) |
1710 |
return; |
return; |
1711 |
|
|
1712 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
1717 |
// Edit current sampler channel. |
// Edit current sampler channel. |
1718 |
void MainForm::editEditChannel (void) |
void MainForm::editEditChannel (void) |
1719 |
{ |
{ |
1720 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1721 |
return; |
return; |
1722 |
|
|
1723 |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1724 |
if (pChannelStrip == NULL) |
if (pChannelStrip == nullptr) |
1725 |
return; |
return; |
1726 |
|
|
1727 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
1732 |
// Reset current sampler channel. |
// Reset current sampler channel. |
1733 |
void MainForm::editResetChannel (void) |
void MainForm::editResetChannel (void) |
1734 |
{ |
{ |
1735 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1736 |
return; |
return; |
1737 |
|
|
1738 |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1739 |
if (pChannelStrip == NULL) |
if (pChannelStrip == nullptr) |
1740 |
return; |
return; |
1741 |
|
|
1742 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
1747 |
// Reset all sampler channels. |
// Reset all sampler channels. |
1748 |
void MainForm::editResetAllChannels (void) |
void MainForm::editResetAllChannels (void) |
1749 |
{ |
{ |
1750 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
1751 |
return; |
return; |
1752 |
|
|
1753 |
// Invoque the channel strip procedure, |
// Invoque the channel strip procedure, |
1755 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1756 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
1757 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
1758 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
1759 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
1760 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
1761 |
if (pChannelStrip) |
if (pChannelStrip) |
1762 |
pChannelStrip->channelReset(); |
pChannelStrip->channelReset(); |
1763 |
} |
} |
1816 |
// Show/hide the MIDI instrument list-view form. |
// Show/hide the MIDI instrument list-view form. |
1817 |
void MainForm::viewInstruments (void) |
void MainForm::viewInstruments (void) |
1818 |
{ |
{ |
1819 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
1820 |
return; |
return; |
1821 |
|
|
1822 |
if (m_pInstrumentListForm) { |
if (m_pInstrumentListForm) { |
1835 |
// Show/hide the device configurator form. |
// Show/hide the device configurator form. |
1836 |
void MainForm::viewDevices (void) |
void MainForm::viewDevices (void) |
1837 |
{ |
{ |
1838 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
1839 |
return; |
return; |
1840 |
|
|
1841 |
if (m_pDeviceForm) { |
if (m_pDeviceForm) { |
1854 |
// Show options dialog. |
// Show options dialog. |
1855 |
void MainForm::viewOptions (void) |
void MainForm::viewOptions (void) |
1856 |
{ |
{ |
1857 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
1858 |
return; |
return; |
1859 |
|
|
1860 |
OptionsForm* pOptionsForm = new OptionsForm(this); |
OptionsForm* pOptionsForm = new OptionsForm(this); |
1896 |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop) || |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop) || |
1897 |
(iOldBaseFontSize != m_pOptions->iBaseFontSize)) { |
(iOldBaseFontSize != m_pOptions->iBaseFontSize)) { |
1898 |
QMessageBox::information(this, |
QMessageBox::information(this, |
1899 |
QSAMPLER_TITLE ": " + tr("Information"), |
tr("Information"), |
1900 |
tr("Some settings may be only effective\n" |
tr("Some settings may be only effective\n" |
1901 |
"next time you start this program.")); |
"next time you start this program.")); |
1902 |
updateMessagesCapture(); |
updateMessagesCapture(); |
1960 |
|
|
1961 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1962 |
int y = 0; |
int y = 0; |
1963 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
1964 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
pMdiSubWindow->adjustSize(); |
1965 |
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
const QRect& frameRect |
1966 |
if (pMdiSubWindow) { |
= pMdiSubWindow->frameGeometry(); |
1967 |
pMdiSubWindow->adjustSize(); |
int w = m_pWorkspace->width(); |
1968 |
int iWidth = m_pWorkspace->width(); |
if (w < frameRect.width()) |
1969 |
if (iWidth < pMdiSubWindow->width()) |
w = frameRect.width(); |
1970 |
iWidth = pMdiSubWindow->width(); |
const int h = frameRect.height(); |
1971 |
const int iHeight = pMdiSubWindow->frameGeometry().height(); |
pMdiSubWindow->setGeometry(0, y, w, h); |
1972 |
pMdiSubWindow->setGeometry(0, y, iWidth, iHeight); |
y += h; |
|
y += iHeight; |
|
|
} |
|
1973 |
} |
} |
1974 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1975 |
|
|
1980 |
// Auto-arrange channel strips. |
// Auto-arrange channel strips. |
1981 |
void MainForm::channelsAutoArrange ( bool bOn ) |
void MainForm::channelsAutoArrange ( bool bOn ) |
1982 |
{ |
{ |
1983 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
1984 |
return; |
return; |
1985 |
|
|
1986 |
// Toggle the auto-arrange flag. |
// Toggle the auto-arrange flag. |
2011 |
// Show information about application program. |
// Show information about application program. |
2012 |
void MainForm::helpAbout (void) |
void MainForm::helpAbout (void) |
2013 |
{ |
{ |
2014 |
// Stuff the about box text... |
QStringList list; |
|
QString sText = "<p>\n"; |
|
|
sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n"; |
|
|
sText += "<br />\n"; |
|
|
sText += tr("Version") + ": <b>" QSAMPLER_VERSION "</b><br />\n"; |
|
|
sText += "<small>" + tr("Build") + ": " CONFIG_BUILD_DATE "</small><br />\n"; |
|
2015 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
2016 |
sText += "<small><font color=\"red\">"; |
list << tr("Debugging option enabled."); |
|
sText += tr("Debugging option enabled."); |
|
|
sText += "</font></small><br />"; |
|
2017 |
#endif |
#endif |
2018 |
#ifndef CONFIG_LIBGIG |
#ifndef CONFIG_LIBGIG |
2019 |
sText += "<small><font color=\"red\">"; |
list << tr("GIG (libgig) file support disabled."); |
|
sText += tr("GIG (libgig) file support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2020 |
#endif |
#endif |
2021 |
#ifndef CONFIG_INSTRUMENT_NAME |
#ifndef CONFIG_INSTRUMENT_NAME |
2022 |
sText += "<small><font color=\"red\">"; |
list << tr("LSCP (liblscp) instrument_name support disabled."); |
|
sText += tr("LSCP (liblscp) instrument_name support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2023 |
#endif |
#endif |
2024 |
#ifndef CONFIG_MUTE_SOLO |
#ifndef CONFIG_MUTE_SOLO |
2025 |
sText += "<small><font color=\"red\">"; |
list << tr("Sampler channel Mute/Solo support disabled."); |
|
sText += tr("Sampler channel Mute/Solo support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2026 |
#endif |
#endif |
2027 |
#ifndef CONFIG_AUDIO_ROUTING |
#ifndef CONFIG_AUDIO_ROUTING |
2028 |
sText += "<small><font color=\"red\">"; |
list << tr("LSCP (liblscp) audio_routing support disabled."); |
|
sText += tr("LSCP (liblscp) audio_routing support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2029 |
#endif |
#endif |
2030 |
#ifndef CONFIG_FXSEND |
#ifndef CONFIG_FXSEND |
2031 |
sText += "<small><font color=\"red\">"; |
list << tr("Sampler channel Effect Sends support disabled."); |
|
sText += tr("Sampler channel Effect Sends support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2032 |
#endif |
#endif |
2033 |
#ifndef CONFIG_VOLUME |
#ifndef CONFIG_VOLUME |
2034 |
sText += "<small><font color=\"red\">"; |
list << tr("Global volume support disabled."); |
|
sText += tr("Global volume support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2035 |
#endif |
#endif |
2036 |
#ifndef CONFIG_MIDI_INSTRUMENT |
#ifndef CONFIG_MIDI_INSTRUMENT |
2037 |
sText += "<small><font color=\"red\">"; |
list << tr("MIDI instrument mapping support disabled."); |
|
sText += tr("MIDI instrument mapping support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2038 |
#endif |
#endif |
2039 |
#ifndef CONFIG_EDIT_INSTRUMENT |
#ifndef CONFIG_EDIT_INSTRUMENT |
2040 |
sText += "<small><font color=\"red\">"; |
list << tr("Instrument editing support disabled."); |
|
sText += tr("Instrument editing support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2041 |
#endif |
#endif |
2042 |
#ifndef CONFIG_EVENT_CHANNEL_MIDI |
#ifndef CONFIG_EVENT_CHANNEL_MIDI |
2043 |
sText += "<small><font color=\"red\">"; |
list << tr("Channel MIDI event support disabled."); |
|
sText += tr("Channel MIDI event support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2044 |
#endif |
#endif |
2045 |
#ifndef CONFIG_EVENT_DEVICE_MIDI |
#ifndef CONFIG_EVENT_DEVICE_MIDI |
2046 |
sText += "<small><font color=\"red\">"; |
list << tr("Device MIDI event support disabled."); |
|
sText += tr("Device MIDI event support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2047 |
#endif |
#endif |
2048 |
#ifndef CONFIG_MAX_VOICES |
#ifndef CONFIG_MAX_VOICES |
2049 |
sText += "<small><font color=\"red\">"; |
list << tr("Runtime max. voices / disk streams support disabled."); |
|
sText += tr("Runtime max. voices / disk streams support disabled."); |
|
|
sText += "</font></small><br />"; |
|
2050 |
#endif |
#endif |
2051 |
|
|
2052 |
|
// Stuff the about box text... |
2053 |
|
QString sText = "<p>\n"; |
2054 |
|
sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n"; |
2055 |
|
sText += "<br />\n"; |
2056 |
|
sText += tr("Version") + ": <b>" CONFIG_BUILD_VERSION "</b><br />\n"; |
2057 |
|
// sText += "<small>" + tr("Build") + ": " CONFIG_BUILD_DATE "</small><br />\n"; |
2058 |
|
if (!list.isEmpty()) { |
2059 |
|
sText += "<small><font color=\"red\">"; |
2060 |
|
sText += list.join("<br />\n"); |
2061 |
|
sText += "</font></small>"; |
2062 |
|
} |
2063 |
sText += "<br />\n"; |
sText += "<br />\n"; |
2064 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
2065 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
2084 |
sText += "</small>"; |
sText += "</small>"; |
2085 |
sText += "</p>\n"; |
sText += "</p>\n"; |
2086 |
|
|
2087 |
QMessageBox::about(this, tr("About") + " " QSAMPLER_TITLE, sText); |
QMessageBox::about(this, tr("About"), sText); |
2088 |
} |
} |
2089 |
|
|
2090 |
|
|
2097 |
QString sSessionName = sessionName(m_sFilename); |
QString sSessionName = sessionName(m_sFilename); |
2098 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
2099 |
sSessionName += " *"; |
sSessionName += " *"; |
2100 |
setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
setWindowTitle(sSessionName); |
2101 |
|
|
2102 |
// Update the main menu state... |
// Update the main menu state... |
2103 |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
2104 |
const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList(); |
const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList(); |
2105 |
const bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
const bool bHasClient = (m_pOptions != nullptr && m_pClient != nullptr); |
2106 |
const bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
const bool bHasChannel = (bHasClient && pChannelStrip != nullptr); |
2107 |
const bool bHasChannels = (bHasClient && wlist.count() > 0); |
const bool bHasChannels = (bHasClient && wlist.count() > 0); |
2108 |
m_ui.fileNewAction->setEnabled(bHasClient); |
m_ui.fileNewAction->setEnabled(bHasClient); |
2109 |
m_ui.fileOpenAction->setEnabled(bHasClient); |
m_ui.fileOpenAction->setEnabled(bHasClient); |
2110 |
m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
2111 |
m_ui.fileSaveAsAction->setEnabled(bHasClient); |
m_ui.fileSaveAsAction->setEnabled(bHasClient); |
2112 |
m_ui.fileResetAction->setEnabled(bHasClient); |
m_ui.fileResetAction->setEnabled(bHasClient); |
2113 |
m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == NULL); |
m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == nullptr); |
2114 |
m_ui.editAddChannelAction->setEnabled(bHasClient); |
m_ui.editAddChannelAction->setEnabled(bHasClient); |
2115 |
m_ui.editRemoveChannelAction->setEnabled(bHasChannel); |
m_ui.editRemoveChannelAction->setEnabled(bHasChannel); |
2116 |
m_ui.editSetupChannelAction->setEnabled(bHasChannel); |
m_ui.editSetupChannelAction->setEnabled(bHasChannel); |
2259 |
|
|
2260 |
// Retrieve the current channel list. |
// Retrieve the current channel list. |
2261 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
2262 |
if (piChannelIDs == NULL) { |
if (piChannelIDs == nullptr) { |
2263 |
if (::lscp_client_get_errno(m_pClient)) { |
if (::lscp_client_get_errno(m_pClient)) { |
2264 |
appendMessagesClient("lscp_list_channels"); |
appendMessagesClient("lscp_list_channels"); |
2265 |
appendMessagesError( |
appendMessagesError( |
2279 |
if (bRemoveDeadStrips) { |
if (bRemoveDeadStrips) { |
2280 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
2281 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2282 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2283 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2284 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2285 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2286 |
bool bExists = false; |
bool bExists = false; |
2287 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) { |
2288 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2289 |
if (pChannel == NULL) |
if (pChannel == nullptr) |
2290 |
break; |
break; |
2291 |
if (piChannelIDs[iChannel] == pChannel->channelID()) { |
if (piChannelIDs[iChannel] == pChannel->channelID()) { |
2292 |
// strip exists, don't touch it |
// strip exists, don't touch it |
2309 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
2310 |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
2311 |
{ |
{ |
2312 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2313 |
return; |
return; |
2314 |
|
|
2315 |
// Remove from list if already there (avoid duplicates) |
// Remove from list if already there (avoid duplicates) |
2324 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
2325 |
void MainForm::updateRecentFilesMenu (void) |
void MainForm::updateRecentFilesMenu (void) |
2326 |
{ |
{ |
2327 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2328 |
return; |
return; |
2329 |
|
|
2330 |
// Time to keep the list under limits. |
// Time to keep the list under limits. |
2358 |
return; |
return; |
2359 |
|
|
2360 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2361 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2362 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2363 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2364 |
if (pChannelStrip) |
if (pChannelStrip) |
2365 |
pChannelStrip->updateInstrumentName(true); |
pChannelStrip->updateInstrumentName(true); |
2366 |
} |
} |
2371 |
// Force update of the channels display font. |
// Force update of the channels display font. |
2372 |
void MainForm::updateDisplayFont (void) |
void MainForm::updateDisplayFont (void) |
2373 |
{ |
{ |
2374 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2375 |
return; |
return; |
2376 |
|
|
2377 |
// Check if display font is legal. |
// Check if display font is legal. |
2390 |
return; |
return; |
2391 |
|
|
2392 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2393 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2394 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2395 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2396 |
if (pChannelStrip) |
if (pChannelStrip) |
2397 |
pChannelStrip->setDisplayFont(font); |
pChannelStrip->setDisplayFont(font); |
2398 |
} |
} |
2410 |
return; |
return; |
2411 |
|
|
2412 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2413 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2414 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2415 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2416 |
if (pChannelStrip) |
if (pChannelStrip) |
2417 |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
2418 |
} |
} |
2423 |
// Force update of the channels maximum volume setting. |
// Force update of the channels maximum volume setting. |
2424 |
void MainForm::updateMaxVolume (void) |
void MainForm::updateMaxVolume (void) |
2425 |
{ |
{ |
2426 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2427 |
return; |
return; |
2428 |
|
|
2429 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
2440 |
return; |
return; |
2441 |
|
|
2442 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2443 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2444 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2445 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2446 |
if (pChannelStrip) |
if (pChannelStrip) |
2447 |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
2448 |
} |
} |
2487 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2488 |
|
|
2489 |
if (m_pOptions && m_pOptions->bConfirmError) { |
if (m_pOptions && m_pOptions->bConfirmError) { |
2490 |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Error"); |
const QString& sTitle = tr("Error"); |
2491 |
#if 0 |
#if 0 |
2492 |
QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel); |
QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel); |
2493 |
#else |
#else |
2510 |
// This is a special message format, just for client results. |
// This is a special message format, just for client results. |
2511 |
void MainForm::appendMessagesClient( const QString& s ) |
void MainForm::appendMessagesClient( const QString& s ) |
2512 |
{ |
{ |
2513 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
2514 |
return; |
return; |
2515 |
|
|
2516 |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
2525 |
// Force update of the messages font. |
// Force update of the messages font. |
2526 |
void MainForm::updateMessagesFont (void) |
void MainForm::updateMessagesFont (void) |
2527 |
{ |
{ |
2528 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2529 |
return; |
return; |
2530 |
|
|
2531 |
if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) { |
if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) { |
2539 |
// Update messages window line limit. |
// Update messages window line limit. |
2540 |
void MainForm::updateMessagesLimit (void) |
void MainForm::updateMessagesLimit (void) |
2541 |
{ |
{ |
2542 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2543 |
return; |
return; |
2544 |
|
|
2545 |
if (m_pMessages) { |
if (m_pMessages) { |
2554 |
// Enablement of the messages capture feature. |
// Enablement of the messages capture feature. |
2555 |
void MainForm::updateMessagesCapture (void) |
void MainForm::updateMessagesCapture (void) |
2556 |
{ |
{ |
2557 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2558 |
return; |
return; |
2559 |
|
|
2560 |
if (m_pMessages) |
if (m_pMessages) |
2568 |
// The channel strip creation executive. |
// The channel strip creation executive. |
2569 |
ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel ) |
ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel ) |
2570 |
{ |
{ |
2571 |
if (m_pClient == NULL || pChannel == NULL) |
if (m_pClient == nullptr || pChannel == nullptr) |
2572 |
return NULL; |
return nullptr; |
2573 |
|
|
2574 |
// Add a new channel itema... |
// Add a new channel itema... |
2575 |
ChannelStrip *pChannelStrip = new ChannelStrip(); |
ChannelStrip *pChannelStrip = new ChannelStrip(); |
2576 |
if (pChannelStrip == NULL) |
if (pChannelStrip == nullptr) |
2577 |
return NULL; |
return nullptr; |
2578 |
|
|
2579 |
// Set some initial channel strip options... |
// Set some initial channel strip options... |
2580 |
if (m_pOptions) { |
if (m_pOptions) { |
2590 |
} |
} |
2591 |
|
|
2592 |
// Add it to workspace... |
// Add it to workspace... |
2593 |
m_pWorkspace->addSubWindow(pChannelStrip, |
QMdiSubWindow *pMdiSubWindow |
2594 |
Qt::SubWindow | Qt::FramelessWindowHint); |
= m_pWorkspace->addSubWindow(pChannelStrip, |
2595 |
|
Qt::SubWindow | Qt::FramelessWindowHint); |
2596 |
|
pMdiSubWindow->setAttribute(Qt::WA_DeleteOnClose); |
2597 |
|
|
2598 |
// Actual channel strip setup... |
// Actual channel strip setup... |
2599 |
pChannelStrip->setup(pChannel); |
pChannelStrip->setup(pChannel); |
2617 |
{ |
{ |
2618 |
QMdiSubWindow *pMdiSubWindow |
QMdiSubWindow *pMdiSubWindow |
2619 |
= static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget()); |
= static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget()); |
2620 |
if (pMdiSubWindow == NULL) |
if (pMdiSubWindow == nullptr) |
2621 |
return; |
return; |
2622 |
|
|
2623 |
// Just delete the channel strip. |
// Just delete the channel strip. |
2636 |
if (pMdiSubWindow) |
if (pMdiSubWindow) |
2637 |
return static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
return static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2638 |
else |
else |
2639 |
return NULL; |
return nullptr; |
2640 |
} |
} |
2641 |
|
|
2642 |
|
|
2643 |
// Retrieve a channel strip by index. |
// Retrieve a channel strip by index. |
2644 |
ChannelStrip *MainForm::channelStripAt ( int iStrip ) |
ChannelStrip *MainForm::channelStripAt ( int iStrip ) |
2645 |
{ |
{ |
2646 |
if (!m_pWorkspace) return NULL; |
if (!m_pWorkspace) return nullptr; |
2647 |
|
|
2648 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
2649 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2650 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2651 |
return NULL; |
return nullptr; |
2652 |
|
|
2653 |
if (iStrip < 0 || iStrip >= wlist.count()) |
if (iStrip < 0 || iStrip >= wlist.count()) |
2654 |
return NULL; |
return nullptr; |
2655 |
|
|
2656 |
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
2657 |
if (pMdiSubWindow) |
if (pMdiSubWindow) |
2658 |
return static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
return static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2659 |
else |
else |
2660 |
return NULL; |
return nullptr; |
2661 |
} |
} |
2662 |
|
|
2663 |
|
|
2667 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
2668 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2669 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2670 |
return NULL; |
return nullptr; |
2671 |
|
|
2672 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2673 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2674 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2675 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2676 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2677 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2680 |
} |
} |
2681 |
|
|
2682 |
// Not found. |
// Not found. |
2683 |
return NULL; |
return nullptr; |
2684 |
} |
} |
2685 |
|
|
2686 |
|
|
2695 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2696 |
if (!wlist.isEmpty()) { |
if (!wlist.isEmpty()) { |
2697 |
m_ui.channelsMenu->addSeparator(); |
m_ui.channelsMenu->addSeparator(); |
2698 |
const int iStripCount = wlist.count(); |
int iStrip = 0; |
2699 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2700 |
ChannelStrip *pChannelStrip = NULL; |
ChannelStrip *pChannelStrip |
2701 |
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2702 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2703 |
QAction *pAction = m_ui.channelsMenu->addAction( |
QAction *pAction = m_ui.channelsMenu->addAction( |
2704 |
pChannelStrip->windowTitle(), |
pChannelStrip->windowTitle(), |
2707 |
pAction->setChecked(activeChannelStrip() == pChannelStrip); |
pAction->setChecked(activeChannelStrip() == pChannelStrip); |
2708 |
pAction->setData(iStrip); |
pAction->setData(iStrip); |
2709 |
} |
} |
2710 |
|
++iStrip; |
2711 |
} |
} |
2712 |
} |
} |
2713 |
} |
} |
2718 |
{ |
{ |
2719 |
// Retrive channel index from action data... |
// Retrive channel index from action data... |
2720 |
QAction *pAction = qobject_cast<QAction *> (sender()); |
QAction *pAction = qobject_cast<QAction *> (sender()); |
2721 |
if (pAction == NULL) |
if (pAction == nullptr) |
2722 |
return; |
return; |
2723 |
|
|
2724 |
ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt()); |
ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt()); |
2749 |
// Timer slot funtion. |
// Timer slot funtion. |
2750 |
void MainForm::timerSlot (void) |
void MainForm::timerSlot (void) |
2751 |
{ |
{ |
2752 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2753 |
return; |
return; |
2754 |
|
|
2755 |
// Is it the first shot on server start after a few delay? |
// Is it the first shot on server start after a few delay? |
2784 |
// Update the channel stream usage for each strip... |
// Update the channel stream usage for each strip... |
2785 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
2786 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2787 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2788 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2789 |
ChannelStrip *pChannelStrip = NULL; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2790 |
if (pChannelStrip && pChannelStrip->isVisible()) |
if (pChannelStrip && pChannelStrip->isVisible()) |
2791 |
pChannelStrip->updateChannelUsage(); |
pChannelStrip->updateChannelUsage(); |
2792 |
} |
} |
2793 |
} |
} |
2794 |
} |
} |
2795 |
|
|
2796 |
|
#if CONFIG_LSCP_CLIENT_CONNECTION_LOST |
2797 |
|
// If we lost connection to server: Try to automatically reconnect if we |
2798 |
|
// did not start the server. |
2799 |
|
// |
2800 |
|
// TODO: If we started the server, then we might inform the user that |
2801 |
|
// the server probably crashed and asking user ONCE whether we should |
2802 |
|
// restart the server. |
2803 |
|
if (lscp_client_connection_lost(m_pClient) && !m_pServer) |
2804 |
|
startAutoReconnectClient(); |
2805 |
|
#endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST |
2806 |
} |
} |
2807 |
|
|
2808 |
// Register the next timer slot. |
// Register the next timer slot. |
2816 |
// Start linuxsampler server... |
// Start linuxsampler server... |
2817 |
void MainForm::startServer (void) |
void MainForm::startServer (void) |
2818 |
{ |
{ |
2819 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
2820 |
return; |
return; |
2821 |
|
|
2822 |
// Aren't already a client, are we? |
// Aren't already a client, are we? |
2826 |
// Is the server process instance still here? |
// Is the server process instance still here? |
2827 |
if (m_pServer) { |
if (m_pServer) { |
2828 |
if (QMessageBox::warning(this, |
if (QMessageBox::warning(this, |
2829 |
QSAMPLER_TITLE ": " + tr("Warning"), |
tr("Warning"), |
2830 |
tr("Could not start the LinuxSampler server.\n\n" |
tr("Could not start the LinuxSampler server.\n\n" |
2831 |
"Maybe it is already started."), |
"Maybe it is already started."), |
2832 |
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { |
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { |
2845 |
|
|
2846 |
// OK. Let's build the startup process... |
// OK. Let's build the startup process... |
2847 |
m_pServer = new QProcess(); |
m_pServer = new QProcess(); |
2848 |
bForceServerStop = true; |
m_bForceServerStop = true; |
2849 |
|
|
2850 |
// Setup stdout/stderr capture... |
// Setup stdout/stderr capture... |
2851 |
m_pServer->setProcessChannelMode(QProcess::ForwardedChannels); |
m_pServer->setProcessChannelMode(QProcess::ForwardedChannels); |
2889 |
|
|
2890 |
|
|
2891 |
// Stop linuxsampler server... |
// Stop linuxsampler server... |
2892 |
void MainForm::stopServer (bool bInteractive) |
void MainForm::stopServer ( bool bInteractive ) |
2893 |
{ |
{ |
2894 |
// Stop client code. |
// Stop client code. |
2895 |
stopClient(); |
stopClient(); |
2896 |
|
|
2897 |
if (m_pServer && bInteractive) { |
if (m_pServer && bInteractive) { |
2898 |
if (QMessageBox::question(this, |
if (QMessageBox::question(this, |
2899 |
QSAMPLER_TITLE ": " + tr("The backend's fate ..."), |
tr("The backend's fate ..."), |
2900 |
tr("You have the option to keep the sampler backend (LinuxSampler)\n" |
tr("You have the option to keep the sampler backend (LinuxSampler)\n" |
2901 |
"running in the background. The sampler would continue to work\n" |
"running in the background. The sampler would continue to work\n" |
2902 |
"according to your current sampler session and you could alter the\n" |
"according to your current sampler session and you could alter the\n" |
2903 |
"sampler session at any time by relaunching QSampler.\n\n" |
"sampler session at any time by relaunching QSampler.\n\n" |
2904 |
"Do you want LinuxSampler to stop?"), |
"Do you want LinuxSampler to stop?"), |
2905 |
QMessageBox::Yes | QMessageBox::No, |
QMessageBox::Yes | QMessageBox::No, |
2906 |
QMessageBox::Yes) == QMessageBox::No) |
QMessageBox::Yes) == QMessageBox::No) { |
2907 |
{ |
m_bForceServerStop = false; |
|
bForceServerStop = false; |
|
2908 |
} |
} |
2909 |
} |
} |
2910 |
|
|
2911 |
|
bool bGraceWait = true; |
2912 |
|
|
2913 |
// And try to stop server. |
// And try to stop server. |
2914 |
if (m_pServer && bForceServerStop) { |
if (m_pServer && m_bForceServerStop) { |
2915 |
appendMessages(tr("Server is stopping...")); |
appendMessages(tr("Server is stopping...")); |
2916 |
if (m_pServer->state() == QProcess::Running) { |
if (m_pServer->state() == QProcess::Running) { |
2917 |
#if defined(WIN32) |
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) |
2918 |
// Try harder... |
// Try harder... |
2919 |
m_pServer->kill(); |
m_pServer->kill(); |
2920 |
#else |
#else |
2921 |
// Try softly... |
// Try softly... |
2922 |
m_pServer->terminate(); |
m_pServer->terminate(); |
2923 |
|
bool bFinished = m_pServer->waitForFinished(QSAMPLER_TIMER_MSECS * 1000); |
2924 |
|
if (bFinished) bGraceWait = false; |
2925 |
#endif |
#endif |
2926 |
} |
} |
2927 |
} // Do final processing anyway. |
} // Do final processing anyway. |
2928 |
else processServerExit(); |
else processServerExit(); |
2929 |
|
|
2930 |
// Give it some time to terminate gracefully and stabilize... |
// Give it some time to terminate gracefully and stabilize... |
2931 |
QTime t; |
if (bGraceWait) { |
2932 |
t.start(); |
QTime t; |
2933 |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
t.start(); |
2934 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2935 |
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2936 |
|
} |
2937 |
} |
} |
2938 |
|
|
2939 |
|
|
2955 |
if (m_pMessages) |
if (m_pMessages) |
2956 |
m_pMessages->flushStdoutBuffer(); |
m_pMessages->flushStdoutBuffer(); |
2957 |
|
|
2958 |
if (m_pServer && bForceServerStop) { |
if (m_pServer && m_bForceServerStop) { |
2959 |
if (m_pServer->state() != QProcess::NotRunning) { |
if (m_pServer->state() != QProcess::NotRunning) { |
2960 |
appendMessages(tr("Server is being forced...")); |
appendMessages(tr("Server is being forced...")); |
2961 |
// Force final server shutdown... |
// Force final server shutdown... |
2971 |
tr("Server was stopped with exit status %1.") |
tr("Server was stopped with exit status %1.") |
2972 |
.arg(m_pServer->exitStatus())); |
.arg(m_pServer->exitStatus())); |
2973 |
delete m_pServer; |
delete m_pServer; |
2974 |
m_pServer = NULL; |
m_pServer = nullptr; |
2975 |
} |
} |
2976 |
|
|
2977 |
// Again, make status visible stable. |
// Again, make status visible stable. |
2987 |
lscp_event_t event, const char *pchData, int cchData, void *pvData ) |
lscp_event_t event, const char *pchData, int cchData, void *pvData ) |
2988 |
{ |
{ |
2989 |
MainForm* pMainForm = (MainForm *) pvData; |
MainForm* pMainForm = (MainForm *) pvData; |
2990 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
2991 |
return LSCP_FAILED; |
return LSCP_FAILED; |
2992 |
|
|
2993 |
// ATTN: DO NOT EVER call any GUI code here, |
// ATTN: DO NOT EVER call any GUI code here, |
3001 |
|
|
3002 |
|
|
3003 |
// Start our almighty client... |
// Start our almighty client... |
3004 |
bool MainForm::startClient (void) |
bool MainForm::startClient (bool bReconnectOnly) |
3005 |
{ |
{ |
3006 |
// Have it a setup? |
// Have it a setup? |
3007 |
if (m_pOptions == NULL) |
if (m_pOptions == nullptr) |
3008 |
return false; |
return false; |
3009 |
|
|
3010 |
// Aren't we already started, are we? |
// Aren't we already started, are we? |
3018 |
m_pClient = ::lscp_client_create( |
m_pClient = ::lscp_client_create( |
3019 |
m_pOptions->sServerHost.toUtf8().constData(), |
m_pOptions->sServerHost.toUtf8().constData(), |
3020 |
m_pOptions->iServerPort, qsampler_client_callback, this); |
m_pOptions->iServerPort, qsampler_client_callback, this); |
3021 |
if (m_pClient == NULL) { |
if (m_pClient == nullptr) { |
3022 |
// Is this the first try? |
// Is this the first try? |
3023 |
// maybe we need to start a local server... |
// maybe we need to start a local server... |
3024 |
if ((m_pServer && m_pServer->state() == QProcess::Running) |
if ((m_pServer && m_pServer->state() == QProcess::Running) |
3025 |
|| !m_pOptions->bServerStart) { |
|| !m_pOptions->bServerStart || bReconnectOnly) |
3026 |
appendMessagesError( |
{ |
3027 |
tr("Could not connect to server as client.\n\nSorry.")); |
// if this method is called from doAutoReconnect() then don't bother |
3028 |
|
// user with an error message |
3029 |
|
if (!bReconnectOnly) { |
3030 |
|
appendMessagesError( |
3031 |
|
tr("Could not connect to server as client.\n\nSorry.") |
3032 |
|
); |
3033 |
|
} |
3034 |
} else { |
} else { |
3035 |
startServer(); |
startServer(); |
3036 |
} |
} |
3038 |
stabilizeForm(); |
stabilizeForm(); |
3039 |
return false; |
return false; |
3040 |
} |
} |
3041 |
|
|
3042 |
// Just set receive timeout value, blindly. |
// Just set receive timeout value, blindly. |
3043 |
::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout); |
::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout); |
3044 |
appendMessages( |
appendMessages( |
3094 |
if (!m_pOptions->sSessionFile.isEmpty()) { |
if (!m_pOptions->sSessionFile.isEmpty()) { |
3095 |
// Just load the prabably startup session... |
// Just load the prabably startup session... |
3096 |
if (loadSessionFile(m_pOptions->sSessionFile)) { |
if (loadSessionFile(m_pOptions->sSessionFile)) { |
3097 |
m_pOptions->sSessionFile = QString::null; |
m_pOptions->sSessionFile = QString(); |
3098 |
return true; |
return true; |
3099 |
} |
} |
3100 |
} |
} |
3110 |
// Stop client... |
// Stop client... |
3111 |
void MainForm::stopClient (void) |
void MainForm::stopClient (void) |
3112 |
{ |
{ |
3113 |
if (m_pClient == NULL) |
if (m_pClient == nullptr) |
3114 |
return; |
return; |
3115 |
|
|
3116 |
// Log prepare here. |
// Log prepare here. |
3142 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
3143 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT); |
3144 |
::lscp_client_destroy(m_pClient); |
::lscp_client_destroy(m_pClient); |
3145 |
m_pClient = NULL; |
m_pClient = nullptr; |
3146 |
|
|
3147 |
// Hard-notify instrumnet and device configuration forms, |
// Hard-notify instrumnet and device configuration forms, |
3148 |
// if visible, that we're running out... |
// if visible, that we're running out... |
3158 |
stabilizeForm(); |
stabilizeForm(); |
3159 |
} |
} |
3160 |
|
|
3161 |
|
void MainForm::startAutoReconnectClient() { |
3162 |
|
stopClient(); |
3163 |
|
appendMessages("Trying to reconnect."); |
3164 |
|
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(doAutoReconnectClient())); |
3165 |
|
} |
3166 |
|
|
3167 |
|
void MainForm::doAutoReconnectClient() { |
3168 |
|
bool success = startClient(true); |
3169 |
|
if (!success) |
3170 |
|
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(doAutoReconnectClient())); |
3171 |
|
} |
3172 |
|
|
3173 |
|
|
3174 |
// Channel strip activation/selection. |
// Channel strip activation/selection. |
3175 |
void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow ) |
void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow ) |
3176 |
{ |
{ |
3177 |
ChannelStrip *pChannelStrip = NULL; |
ChannelStrip *pChannelStrip = nullptr; |
3178 |
if (pMdiSubWindow) |
if (pMdiSubWindow) |
3179 |
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
3180 |
if (pChannelStrip) |
if (pChannelStrip) |