1 |
// qsamplerMainForm.cpp |
// qsamplerMainForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
|
#include "qsamplerAbout.h" |
24 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
25 |
|
|
|
#include "qsamplerAbout.h" |
|
26 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
27 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
28 |
#include "qsamplerMessages.h" |
#include "qsamplerMessages.h" |
33 |
#include "qsamplerInstrumentListForm.h" |
#include "qsamplerInstrumentListForm.h" |
34 |
#include "qsamplerDeviceForm.h" |
#include "qsamplerDeviceForm.h" |
35 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
36 |
|
#include "qsamplerDeviceStatusForm.h" |
37 |
|
|
38 |
#include <QApplication> |
#include <QApplication> |
39 |
#include <QWorkspace> |
#include <QWorkspace> |
56 |
#include <QTimer> |
#include <QTimer> |
57 |
#include <QDateTime> |
#include <QDateTime> |
58 |
|
|
59 |
|
#if QT_VERSION < 0x040500 |
60 |
|
namespace Qt { |
61 |
|
const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000); |
62 |
|
#if QT_VERSION < 0x040200 |
63 |
|
const WindowFlags CustomizeWindowHint = WindowFlags(0x02000000); |
64 |
|
#endif |
65 |
|
} |
66 |
|
#endif |
67 |
|
|
68 |
#ifdef HAVE_SIGNAL_H |
#ifdef HAVE_SIGNAL_H |
69 |
#include <signal.h> |
#include <signal.h> |
86 |
} |
} |
87 |
#endif |
#endif |
88 |
|
|
89 |
|
|
90 |
|
// All winsock apps needs this. |
91 |
|
#if defined(WIN32) |
92 |
|
static WSADATA _wsaData; |
93 |
|
#endif |
94 |
|
|
95 |
|
|
96 |
|
//------------------------------------------------------------------------- |
97 |
|
// LADISH Level 1 support stuff. |
98 |
|
|
99 |
|
#ifdef HAVE_SIGNAL_H |
100 |
|
|
101 |
|
#include <QSocketNotifier> |
102 |
|
|
103 |
|
#include <sys/types.h> |
104 |
|
#include <sys/socket.h> |
105 |
|
|
106 |
|
#include <signal.h> |
107 |
|
|
108 |
|
// File descriptor for SIGUSR1 notifier. |
109 |
|
static int g_fdUsr1[2]; |
110 |
|
|
111 |
|
// Unix SIGUSR1 signal handler. |
112 |
|
static void qsampler_sigusr1_handler ( int /* signo */ ) |
113 |
|
{ |
114 |
|
char c = 1; |
115 |
|
|
116 |
|
(::write(g_fdUsr1[0], &c, sizeof(c)) > 0); |
117 |
|
} |
118 |
|
|
119 |
|
#endif // HAVE_SIGNAL_H |
120 |
|
|
121 |
|
|
122 |
|
//------------------------------------------------------------------------- |
123 |
|
// qsampler -- namespace |
124 |
|
|
125 |
|
|
126 |
|
namespace QSampler { |
127 |
|
|
128 |
// Timer constant stuff. |
// Timer constant stuff. |
129 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
130 |
|
|
135 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
136 |
|
|
137 |
|
|
138 |
// All winsock apps needs this. |
// Specialties for thread-callback comunication. |
139 |
#if defined(WIN32) |
#define QSAMPLER_LSCP_EVENT QEvent::Type(QEvent::User + 1) |
|
static WSADATA _wsaData; |
|
|
#endif |
|
140 |
|
|
141 |
|
|
142 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
143 |
// qsamplerCustomEvent -- specialty for callback comunication. |
// LscpEvent -- specialty for LSCP callback comunication. |
144 |
|
|
|
#define QSAMPLER_CUSTOM_EVENT QEvent::Type(QEvent::User + 0) |
|
145 |
|
|
146 |
class qsamplerCustomEvent : public QEvent |
class LscpEvent : public QEvent |
147 |
{ |
{ |
148 |
public: |
public: |
149 |
|
|
150 |
// Constructor. |
// Constructor. |
151 |
qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData) |
LscpEvent(lscp_event_t event, const char *pchData, int cchData) |
152 |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
: QEvent(QSAMPLER_LSCP_EVENT) |
153 |
{ |
{ |
154 |
m_event = event; |
m_event = event; |
155 |
m_data = QString::fromUtf8(pchData, cchData); |
m_data = QString::fromUtf8(pchData, cchData); |
171 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
172 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
173 |
|
|
|
namespace QSampler { |
|
|
|
|
174 |
// Kind of singleton reference. |
// Kind of singleton reference. |
175 |
MainForm* MainForm::g_pMainForm = NULL; |
MainForm* MainForm::g_pMainForm = NULL; |
176 |
|
|
203 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
204 |
|
|
205 |
#ifdef HAVE_SIGNAL_H |
#ifdef HAVE_SIGNAL_H |
206 |
|
|
207 |
// Set to ignore any fatal "Broken pipe" signals. |
// Set to ignore any fatal "Broken pipe" signals. |
208 |
::signal(SIGPIPE, SIG_IGN); |
::signal(SIGPIPE, SIG_IGN); |
209 |
#endif |
|
210 |
|
// LADISH Level 1 suport. |
211 |
|
|
212 |
|
// Initialize file descriptors for SIGUSR1 socket notifier. |
213 |
|
::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1); |
214 |
|
m_pUsr1Notifier |
215 |
|
= new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this); |
216 |
|
|
217 |
|
QObject::connect(m_pUsr1Notifier, |
218 |
|
SIGNAL(activated(int)), |
219 |
|
SLOT(handle_sigusr1())); |
220 |
|
|
221 |
|
// Install SIGUSR1 signal handler. |
222 |
|
struct sigaction usr1; |
223 |
|
usr1.sa_handler = qsampler_sigusr1_handler; |
224 |
|
::sigemptyset(&usr1.sa_mask); |
225 |
|
usr1.sa_flags = 0; |
226 |
|
usr1.sa_flags |= SA_RESTART; |
227 |
|
::sigaction(SIGUSR1, &usr1, NULL); |
228 |
|
|
229 |
|
#else // HAVE_SIGNAL_H |
230 |
|
|
231 |
|
m_pSocketNotifier = NULL; |
232 |
|
|
233 |
|
#endif // !HAVE_SIGNAL_H |
234 |
|
|
235 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
236 |
// Make some extras into the toolbar... |
// Make some extras into the toolbar... |
239 |
// Volume slider... |
// Volume slider... |
240 |
m_ui.channelsToolbar->addSeparator(); |
m_ui.channelsToolbar->addSeparator(); |
241 |
m_pVolumeSlider = new QSlider(Qt::Horizontal, m_ui.channelsToolbar); |
m_pVolumeSlider = new QSlider(Qt::Horizontal, m_ui.channelsToolbar); |
242 |
m_pVolumeSlider->setTickPosition(QSlider::TicksBelow); |
m_pVolumeSlider->setTickPosition(QSlider::TicksBothSides); |
243 |
m_pVolumeSlider->setTickInterval(10); |
m_pVolumeSlider->setTickInterval(10); |
244 |
m_pVolumeSlider->setPageStep(10); |
m_pVolumeSlider->setPageStep(10); |
245 |
m_pVolumeSlider->setSingleStep(10); |
m_pVolumeSlider->setSingleStep(10); |
257 |
// Volume spin-box |
// Volume spin-box |
258 |
m_ui.channelsToolbar->addSeparator(); |
m_ui.channelsToolbar->addSeparator(); |
259 |
m_pVolumeSpinBox = new QSpinBox(m_ui.channelsToolbar); |
m_pVolumeSpinBox = new QSpinBox(m_ui.channelsToolbar); |
260 |
|
m_pVolumeSpinBox->setMaximumHeight(24); |
261 |
m_pVolumeSpinBox->setSuffix(" %"); |
m_pVolumeSpinBox->setSuffix(" %"); |
262 |
m_pVolumeSpinBox->setMinimum(0); |
m_pVolumeSpinBox->setMinimum(0); |
263 |
m_pVolumeSpinBox->setMaximum(100); |
m_pVolumeSpinBox->setMaximum(100); |
274 |
// Set the activation connection. |
// Set the activation connection. |
275 |
QObject::connect(m_pWorkspace, |
QObject::connect(m_pWorkspace, |
276 |
SIGNAL(windowActivated(QWidget *)), |
SIGNAL(windowActivated(QWidget *)), |
277 |
SLOT(stabilizeForm())); |
SLOT(activateStrip(QWidget *))); |
278 |
// Make it shine :-) |
// Make it shine :-) |
279 |
setCentralWidget(m_pWorkspace); |
setCentralWidget(m_pWorkspace); |
280 |
|
|
307 |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
308 |
#endif |
#endif |
309 |
|
|
310 |
|
// Some actions surely need those |
311 |
|
// shortcuts firmly attached... |
312 |
|
addAction(m_ui.viewMenubarAction); |
313 |
|
addAction(m_ui.viewToolbarAction); |
314 |
|
|
315 |
QObject::connect(m_ui.fileNewAction, |
QObject::connect(m_ui.fileNewAction, |
316 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
317 |
SLOT(fileNew())); |
SLOT(fileNew())); |
403 |
WSACleanup(); |
WSACleanup(); |
404 |
#endif |
#endif |
405 |
|
|
406 |
|
#ifdef HAVE_SIGNAL_H |
407 |
|
if (m_pUsr1Notifier) |
408 |
|
delete m_pUsr1Notifier; |
409 |
|
#endif |
410 |
|
|
411 |
// Finally drop any widgets around... |
// Finally drop any widgets around... |
412 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
413 |
delete m_pDeviceForm; |
delete m_pDeviceForm; |
439 |
|
|
440 |
|
|
441 |
// Make and set a proper setup options step. |
// Make and set a proper setup options step. |
442 |
void MainForm::setup ( qsamplerOptions *pOptions ) |
void MainForm::setup ( Options *pOptions ) |
443 |
{ |
{ |
444 |
// We got options? |
// We got options? |
445 |
m_pOptions = pOptions; |
m_pOptions = pOptions; |
446 |
|
|
447 |
// What style do we create these forms? |
// What style do we create these forms? |
448 |
Qt::WindowFlags wflags = Qt::Window |
Qt::WindowFlags wflags = Qt::Window |
|
#if QT_VERSION >= 0x040200 |
|
449 |
| Qt::CustomizeWindowHint |
| Qt::CustomizeWindowHint |
|
#endif |
|
450 |
| Qt::WindowTitleHint |
| Qt::WindowTitleHint |
451 |
| Qt::WindowSystemMenuHint |
| Qt::WindowSystemMenuHint |
452 |
| Qt::WindowMinMaxButtonsHint; |
| Qt::WindowMinMaxButtonsHint |
453 |
|
| Qt::WindowCloseButtonHint; |
454 |
if (m_pOptions->bKeepOnTop) |
if (m_pOptions->bKeepOnTop) |
455 |
wflags |= Qt::Tool; |
wflags |= Qt::Tool; |
456 |
|
|
457 |
// Some child forms are to be created right now. |
// Some child forms are to be created right now. |
458 |
m_pMessages = new qsamplerMessages(this); |
m_pMessages = new Messages(this); |
459 |
m_pDeviceForm = new DeviceForm(this, wflags); |
m_pDeviceForm = new DeviceForm(this, wflags); |
460 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
461 |
m_pInstrumentListForm = new InstrumentListForm(this, wflags); |
m_pInstrumentListForm = new InstrumentListForm(this, wflags); |
462 |
#else |
#else |
463 |
viewInstrumentsAction->setEnabled(false); |
m_ui.viewInstrumentsAction->setEnabled(false); |
464 |
#endif |
#endif |
465 |
|
|
466 |
|
// Setup messages logging appropriately... |
467 |
|
m_pMessages->setLogging( |
468 |
|
m_pOptions->bMessagesLog, |
469 |
|
m_pOptions->sMessagesLogPath); |
470 |
|
|
471 |
// Set message defaults... |
// Set message defaults... |
472 |
updateMessagesFont(); |
updateMessagesFont(); |
473 |
updateMessagesLimit(); |
updateMessagesLimit(); |
498 |
} |
} |
499 |
|
|
500 |
// Try to restore old window positioning and initial visibility. |
// Try to restore old window positioning and initial visibility. |
501 |
m_pOptions->loadWidgetGeometry(this); |
m_pOptions->loadWidgetGeometry(this, true); |
502 |
m_pOptions->loadWidgetGeometry(m_pInstrumentListForm); |
m_pOptions->loadWidgetGeometry(m_pInstrumentListForm); |
503 |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
504 |
|
|
542 |
// And the children, and the main windows state,. |
// And the children, and the main windows state,. |
543 |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
544 |
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
545 |
m_pOptions->saveWidgetGeometry(this); |
m_pOptions->saveWidgetGeometry(this, true); |
546 |
// Close popup widgets. |
// Close popup widgets. |
547 |
if (m_pInstrumentListForm) |
if (m_pInstrumentListForm) |
548 |
m_pInstrumentListForm->close(); |
m_pInstrumentListForm->close(); |
549 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
550 |
m_pDeviceForm->close(); |
m_pDeviceForm->close(); |
551 |
// Stop client and/or server, gracefully. |
// Stop client and/or server, gracefully. |
552 |
stopServer(); |
stopServer(true /*interactive*/); |
553 |
} |
} |
554 |
} |
} |
555 |
|
|
559 |
|
|
560 |
void MainForm::closeEvent ( QCloseEvent *pCloseEvent ) |
void MainForm::closeEvent ( QCloseEvent *pCloseEvent ) |
561 |
{ |
{ |
562 |
if (queryClose()) |
if (queryClose()) { |
563 |
|
DeviceStatusForm::deleteAllInstances(); |
564 |
pCloseEvent->accept(); |
pCloseEvent->accept(); |
565 |
else |
} else |
566 |
pCloseEvent->ignore(); |
pCloseEvent->ignore(); |
567 |
} |
} |
568 |
|
|
591 |
QListIterator<QUrl> iter(pMimeData->urls()); |
QListIterator<QUrl> iter(pMimeData->urls()); |
592 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
593 |
const QString& sPath = iter.next().toLocalFile(); |
const QString& sPath = iter.next().toLocalFile(); |
594 |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
// if (Channel::isDlsInstrumentFile(sPath)) { |
595 |
|
if (QFileInfo(sPath).exists()) { |
596 |
// Try to create a new channel from instrument file... |
// Try to create a new channel from instrument file... |
597 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
Channel *pChannel = new Channel(); |
598 |
if (pChannel == NULL) |
if (pChannel == NULL) |
599 |
return; |
return; |
600 |
// Start setting the instrument filename... |
// Start setting the instrument filename... |
626 |
|
|
627 |
|
|
628 |
// Custome event handler. |
// Custome event handler. |
629 |
void MainForm::customEvent(QEvent* pCustomEvent) |
void MainForm::customEvent ( QEvent* pEvent ) |
630 |
{ |
{ |
631 |
// For the time being, just pump it to messages. |
// For the time being, just pump it to messages. |
632 |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
if (pEvent->type() == QSAMPLER_LSCP_EVENT) { |
633 |
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
LscpEvent *pLscpEvent = static_cast<LscpEvent *> (pEvent); |
634 |
if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) { |
switch (pLscpEvent->event()) { |
635 |
int iChannelID = pEvent->data().toInt(); |
case LSCP_EVENT_CHANNEL_COUNT: |
636 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
updateAllChannelStrips(true); |
637 |
if (pChannelStrip) |
break; |
638 |
channelStripChanged(pChannelStrip); |
case LSCP_EVENT_CHANNEL_INFO: { |
639 |
} else { |
int iChannelID = pLscpEvent->data().toInt(); |
640 |
appendMessagesColor(tr("Notify event: %1 data: %2") |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
641 |
.arg(::lscp_event_to_text(pEvent->event())) |
if (pChannelStrip) |
642 |
.arg(pEvent->data()), "#996699"); |
channelStripChanged(pChannelStrip); |
643 |
|
break; |
644 |
|
} |
645 |
|
case LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT: |
646 |
|
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
647 |
|
DeviceStatusForm::onDevicesChanged(); |
648 |
|
updateViewMidiDeviceStatusMenu(); |
649 |
|
break; |
650 |
|
case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: { |
651 |
|
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
652 |
|
const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt(); |
653 |
|
DeviceStatusForm::onDeviceChanged(iDeviceID); |
654 |
|
break; |
655 |
|
} |
656 |
|
case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT: |
657 |
|
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
658 |
|
break; |
659 |
|
case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO: |
660 |
|
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
661 |
|
break; |
662 |
|
#if CONFIG_EVENT_CHANNEL_MIDI |
663 |
|
case LSCP_EVENT_CHANNEL_MIDI: { |
664 |
|
const int iChannelID = pLscpEvent->data().section(' ', 0, 0).toInt(); |
665 |
|
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
666 |
|
if (pChannelStrip) |
667 |
|
pChannelStrip->midiActivityLedOn(); |
668 |
|
break; |
669 |
|
} |
670 |
|
#endif |
671 |
|
#if CONFIG_EVENT_DEVICE_MIDI |
672 |
|
case LSCP_EVENT_DEVICE_MIDI: { |
673 |
|
const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt(); |
674 |
|
const int iPortID = pLscpEvent->data().section(' ', 1, 1).toInt(); |
675 |
|
DeviceStatusForm *pDeviceStatusForm |
676 |
|
= DeviceStatusForm::getInstance(iDeviceID); |
677 |
|
if (pDeviceStatusForm) |
678 |
|
pDeviceStatusForm->midiArrived(iPortID); |
679 |
|
break; |
680 |
|
} |
681 |
|
#endif |
682 |
|
default: |
683 |
|
appendMessagesColor(tr("LSCP Event: %1 data: %2") |
684 |
|
.arg(::lscp_event_to_text(pLscpEvent->event())) |
685 |
|
.arg(pLscpEvent->data()), "#996699"); |
686 |
} |
} |
687 |
} |
} |
688 |
} |
} |
689 |
|
|
690 |
|
|
691 |
|
// LADISH Level 1 -- SIGUSR1 signal handler. |
692 |
|
void MainForm::handle_sigusr1 (void) |
693 |
|
{ |
694 |
|
char c; |
695 |
|
|
696 |
|
if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0) |
697 |
|
saveSession(false); |
698 |
|
} |
699 |
|
|
700 |
|
|
701 |
|
void MainForm::updateViewMidiDeviceStatusMenu (void) |
702 |
|
{ |
703 |
|
m_ui.viewMidiDeviceStatusMenu->clear(); |
704 |
|
const std::map<int, DeviceStatusForm *> statusForms |
705 |
|
= DeviceStatusForm::getInstances(); |
706 |
|
std::map<int, DeviceStatusForm *>::const_iterator iter |
707 |
|
= statusForms.begin(); |
708 |
|
for ( ; iter != statusForms.end(); ++iter) { |
709 |
|
DeviceStatusForm *pStatusForm = iter->second; |
710 |
|
m_ui.viewMidiDeviceStatusMenu->addAction( |
711 |
|
pStatusForm->visibleAction()); |
712 |
|
} |
713 |
|
} |
714 |
|
|
715 |
|
|
716 |
// Context menu event handler. |
// Context menu event handler. |
717 |
void MainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
void MainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
718 |
{ |
{ |
726 |
// qsamplerMainForm -- Brainless public property accessors. |
// qsamplerMainForm -- Brainless public property accessors. |
727 |
|
|
728 |
// The global options settings property. |
// The global options settings property. |
729 |
qsamplerOptions *MainForm::options (void) const |
Options *MainForm::options (void) const |
730 |
{ |
{ |
731 |
return m_pOptions; |
return m_pOptions; |
732 |
} |
} |
844 |
"\"%1\"\n\n" |
"\"%1\"\n\n" |
845 |
"Do you want to replace it?") |
"Do you want to replace it?") |
846 |
.arg(sFilename), |
.arg(sFilename), |
847 |
tr("Replace"), tr("Cancel")) > 0) |
QMessageBox::Yes | QMessageBox::No) |
848 |
|
== QMessageBox::No) |
849 |
return false; |
return false; |
850 |
} |
} |
851 |
} |
} |
868 |
"\"%1\"\n\n" |
"\"%1\"\n\n" |
869 |
"Do you want to save the changes?") |
"Do you want to save the changes?") |
870 |
.arg(sessionName(m_sFilename)), |
.arg(sessionName(m_sFilename)), |
871 |
tr("Save"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Save | |
872 |
case 0: // Save... |
QMessageBox::Discard | |
873 |
|
QMessageBox::Cancel)) { |
874 |
|
case QMessageBox::Save: |
875 |
bClose = saveSession(false); |
bClose = saveSession(false); |
876 |
// Fall thru.... |
// Fall thru.... |
877 |
case 1: // Discard |
case QMessageBox::Discard: |
878 |
break; |
break; |
879 |
default: // Cancel. |
default: // Cancel. |
880 |
bClose = false; |
bClose = false; |
890 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
891 |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
892 |
if (pChannelStrip) { |
if (pChannelStrip) { |
893 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
894 |
if (bForce && pChannel) |
if (bForce && pChannel) |
895 |
pChannel->removeChannel(); |
pChannel->removeChannel(); |
896 |
delete pChannelStrip; |
delete pChannelStrip; |
1030 |
|
|
1031 |
// Audio device mapping. |
// Audio device mapping. |
1032 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; |
1033 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Audio); |
1034 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
1035 |
ts << endl; |
ts << endl; |
1036 |
qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
Device device(Device::Audio, piDeviceIDs[iDevice]); |
1037 |
// Audio device specification... |
// Audio device specification... |
1038 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1039 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
1040 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
1041 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
1042 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
1043 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
1044 |
++deviceParam) { |
++deviceParam) { |
1045 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
1046 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
1047 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
1048 |
} |
} |
1049 |
ts << endl; |
ts << endl; |
1050 |
// Audio channel parameters... |
// Audio channel parameters... |
1051 |
int iPort = 0; |
int iPort = 0; |
1052 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
1053 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
1054 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
1055 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
1056 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
1057 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
1058 |
++portParam) { |
++portParam) { |
1059 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
1060 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
1061 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
1062 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1072 |
|
|
1073 |
// MIDI device mapping. |
// MIDI device mapping. |
1074 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; |
1075 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Midi); |
1076 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
1077 |
ts << endl; |
ts << endl; |
1078 |
qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
Device device(Device::Midi, piDeviceIDs[iDevice]); |
1079 |
// MIDI device specification... |
// MIDI device specification... |
1080 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1081 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
1082 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
1083 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
1084 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
1085 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
1086 |
++deviceParam) { |
++deviceParam) { |
1087 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
1088 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
1089 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
1090 |
} |
} |
1091 |
ts << endl; |
ts << endl; |
1092 |
// MIDI port parameters... |
// MIDI port parameters... |
1093 |
int iPort = 0; |
int iPort = 0; |
1094 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
1095 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
1096 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
1097 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
1098 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
1099 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
1100 |
++portParam) { |
++portParam) { |
1101 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
1102 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
1103 |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
1104 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1190 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
1191 |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
1192 |
if (pChannelStrip) { |
if (pChannelStrip) { |
1193 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1194 |
if (pChannel) { |
if (pChannel) { |
1195 |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
1196 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
1222 |
ts << "LOAD INSTRUMENT NON_MODAL '" |
ts << "LOAD INSTRUMENT NON_MODAL '" |
1223 |
<< pChannel->instrumentFile() << "' " |
<< pChannel->instrumentFile() << "' " |
1224 |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
1225 |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
ChannelRoutingMap::ConstIterator audioRoute; |
1226 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
1227 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
1228 |
++audioRoute) { |
++audioRoute) { |
1395 |
"Please note that this operation may cause\n" |
"Please note that this operation may cause\n" |
1396 |
"temporary MIDI and Audio disruption.\n\n" |
"temporary MIDI and Audio disruption.\n\n" |
1397 |
"Do you want to reset the sampler engine now?"), |
"Do you want to reset the sampler engine now?"), |
1398 |
tr("Reset"), tr("Cancel")) > 0) |
QMessageBox::Ok | QMessageBox::Cancel) |
1399 |
|
== QMessageBox::Cancel) |
1400 |
return; |
return; |
1401 |
|
|
1402 |
// Trye closing the current session, first... |
// Trye closing the current session, first... |
1437 |
"Please note that this operation may cause\n" |
"Please note that this operation may cause\n" |
1438 |
"temporary MIDI and Audio disruption.\n\n" |
"temporary MIDI and Audio disruption.\n\n" |
1439 |
"Do you want to restart the connection now?"), |
"Do you want to restart the connection now?"), |
1440 |
tr("Restart"), tr("Cancel")) == 0); |
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok); |
1441 |
} |
} |
1442 |
|
|
1443 |
// Are we still for it? |
// Are we still for it? |
1468 |
return; |
return; |
1469 |
|
|
1470 |
// Just create the channel instance... |
// Just create the channel instance... |
1471 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
Channel *pChannel = new Channel(); |
1472 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1473 |
return; |
return; |
1474 |
|
|
1486 |
return; |
return; |
1487 |
} |
} |
1488 |
|
|
1489 |
|
// Do we auto-arrange? |
1490 |
|
if (m_pOptions && m_pOptions->bAutoArrange) |
1491 |
|
channelsArrange(); |
1492 |
|
|
1493 |
// Make that an overall update. |
// Make that an overall update. |
1494 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1495 |
stabilizeForm(); |
stabilizeForm(); |
1506 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1507 |
return; |
return; |
1508 |
|
|
1509 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1510 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1511 |
return; |
return; |
1512 |
|
|
1518 |
"%1\n\n" |
"%1\n\n" |
1519 |
"Are you sure?") |
"Are you sure?") |
1520 |
.arg(pChannelStrip->windowTitle()), |
.arg(pChannelStrip->windowTitle()), |
1521 |
tr("OK"), tr("Cancel")) > 0) |
QMessageBox::Ok | QMessageBox::Cancel) |
1522 |
|
== QMessageBox::Cancel) |
1523 |
return; |
return; |
1524 |
} |
} |
1525 |
|
|
1710 |
int iOldServerTimeout = m_pOptions->iServerTimeout; |
int iOldServerTimeout = m_pOptions->iServerTimeout; |
1711 |
bool bOldServerStart = m_pOptions->bServerStart; |
bool bOldServerStart = m_pOptions->bServerStart; |
1712 |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
1713 |
|
bool bOldMessagesLog = m_pOptions->bMessagesLog; |
1714 |
|
QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath; |
1715 |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
1716 |
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
1717 |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
1723 |
bool bOldCompletePath = m_pOptions->bCompletePath; |
bool bOldCompletePath = m_pOptions->bCompletePath; |
1724 |
bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
1725 |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
1726 |
|
int iOldBaseFontSize = m_pOptions->iBaseFontSize; |
1727 |
// Load the current setup settings. |
// Load the current setup settings. |
1728 |
pOptionsForm->setup(m_pOptions); |
pOptionsForm->setup(m_pOptions); |
1729 |
// Show the setup dialog... |
// Show the setup dialog... |
1732 |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
1733 |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
1734 |
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
1735 |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop)) { |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop) || |
1736 |
|
(iOldBaseFontSize != m_pOptions->iBaseFontSize)) { |
1737 |
QMessageBox::information(this, |
QMessageBox::information(this, |
1738 |
QSAMPLER_TITLE ": " + tr("Information"), |
QSAMPLER_TITLE ": " + tr("Information"), |
1739 |
tr("Some settings may be only effective\n" |
tr("Some settings may be only effective\n" |
1740 |
"next time you start this program."), tr("OK")); |
"next time you start this program.")); |
1741 |
updateMessagesCapture(); |
updateMessagesCapture(); |
1742 |
} |
} |
1743 |
// Check wheather something immediate has changed. |
// Check wheather something immediate has changed. |
1744 |
|
if (( bOldMessagesLog && !m_pOptions->bMessagesLog) || |
1745 |
|
(!bOldMessagesLog && m_pOptions->bMessagesLog) || |
1746 |
|
(sOldMessagesLogPath != m_pOptions->sMessagesLogPath)) |
1747 |
|
m_pMessages->setLogging( |
1748 |
|
m_pOptions->bMessagesLog, m_pOptions->sMessagesLogPath); |
1749 |
if (( bOldCompletePath && !m_pOptions->bCompletePath) || |
if (( bOldCompletePath && !m_pOptions->bCompletePath) || |
1750 |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
1751 |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
1900 |
sText += tr("Instrument editing support disabled."); |
sText += tr("Instrument editing support disabled."); |
1901 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1902 |
#endif |
#endif |
1903 |
|
#ifndef CONFIG_EVENT_CHANNEL_MIDI |
1904 |
|
sText += "<small><font color=\"red\">"; |
1905 |
|
sText += tr("Channel MIDI event support disabled."); |
1906 |
|
sText += "</font></small><br />"; |
1907 |
|
#endif |
1908 |
|
#ifndef CONFIG_EVENT_DEVICE_MIDI |
1909 |
|
sText += "<small><font color=\"red\">"; |
1910 |
|
sText += tr("Device MIDI event support disabled."); |
1911 |
|
sText += "</font></small><br />"; |
1912 |
|
#endif |
1913 |
|
#ifndef CONFIG_MAX_VOICES |
1914 |
|
sText += "<small><font color=\"red\">"; |
1915 |
|
sText += tr("Runtime max. voices / disk streams support disabled."); |
1916 |
|
sText += "</font></small><br />"; |
1917 |
|
#endif |
1918 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1919 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1920 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1955 |
setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
1956 |
|
|
1957 |
// Update the main menu state... |
// Update the main menu state... |
1958 |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1959 |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
1960 |
bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
1961 |
|
bool bHasChannels = (bHasClient && m_pWorkspace->windowList().count() > 0); |
1962 |
m_ui.fileNewAction->setEnabled(bHasClient); |
m_ui.fileNewAction->setEnabled(bHasClient); |
1963 |
m_ui.fileOpenAction->setEnabled(bHasClient); |
m_ui.fileOpenAction->setEnabled(bHasClient); |
1964 |
m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
1974 |
m_ui.editEditChannelAction->setEnabled(false); |
m_ui.editEditChannelAction->setEnabled(false); |
1975 |
#endif |
#endif |
1976 |
m_ui.editResetChannelAction->setEnabled(bHasChannel); |
m_ui.editResetChannelAction->setEnabled(bHasChannel); |
1977 |
m_ui.editResetAllChannelsAction->setEnabled(bHasChannel); |
m_ui.editResetAllChannelsAction->setEnabled(bHasChannels); |
1978 |
m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible()); |
m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible()); |
1979 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1980 |
m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm |
m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm |
1986 |
m_ui.viewDevicesAction->setChecked(m_pDeviceForm |
m_ui.viewDevicesAction->setChecked(m_pDeviceForm |
1987 |
&& m_pDeviceForm->isVisible()); |
&& m_pDeviceForm->isVisible()); |
1988 |
m_ui.viewDevicesAction->setEnabled(bHasClient); |
m_ui.viewDevicesAction->setEnabled(bHasClient); |
1989 |
m_ui.channelsArrangeAction->setEnabled(bHasChannel); |
m_ui.viewMidiDeviceStatusMenu->setEnabled( |
1990 |
|
DeviceStatusForm::getInstances().size() > 0); |
1991 |
|
m_ui.channelsArrangeAction->setEnabled(bHasChannels); |
1992 |
|
|
1993 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
1994 |
// Toolbar widgets are also affected... |
// Toolbar widgets are also affected... |
2092 |
} |
} |
2093 |
#endif |
#endif |
2094 |
|
|
2095 |
|
updateAllChannelStrips(false); |
2096 |
|
|
2097 |
|
// Do we auto-arrange? |
2098 |
|
if (m_pOptions && m_pOptions->bAutoArrange) |
2099 |
|
channelsArrange(); |
2100 |
|
|
2101 |
|
// Remember to refresh devices and instruments... |
2102 |
|
if (m_pInstrumentListForm) |
2103 |
|
m_pInstrumentListForm->refreshInstruments(); |
2104 |
|
if (m_pDeviceForm) |
2105 |
|
m_pDeviceForm->refreshDevices(); |
2106 |
|
} |
2107 |
|
|
2108 |
|
void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) { |
2109 |
// Retrieve the current channel list. |
// Retrieve the current channel list. |
2110 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
2111 |
if (piChannelIDs == NULL) { |
if (piChannelIDs == NULL) { |
2120 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
2121 |
// Check if theres already a channel strip for this one... |
// Check if theres already a channel strip for this one... |
2122 |
if (!channelStrip(piChannelIDs[iChannel])) |
if (!channelStrip(piChannelIDs[iChannel])) |
2123 |
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
2124 |
} |
} |
|
m_pWorkspace->setUpdatesEnabled(true); |
|
|
} |
|
2125 |
|
|
2126 |
// Do we auto-arrange? |
// Do we auto-arrange? |
2127 |
if (m_pOptions && m_pOptions->bAutoArrange) |
if (m_pOptions && m_pOptions->bAutoArrange) |
2128 |
channelsArrange(); |
channelsArrange(); |
2129 |
|
|
2130 |
// Remember to refresh devices and instruments... |
stabilizeForm(); |
|
if (m_pInstrumentListForm) |
|
|
m_pInstrumentListForm->refreshInstruments(); |
|
|
if (m_pDeviceForm) |
|
|
m_pDeviceForm->refreshDevices(); |
|
|
} |
|
2131 |
|
|
2132 |
|
// remove dead channel strips |
2133 |
|
if (bRemoveDeadStrips) { |
2134 |
|
for (int i = 0; channelStripAt(i); ++i) { |
2135 |
|
ChannelStrip* pChannelStrip = channelStripAt(i); |
2136 |
|
bool bExists = false; |
2137 |
|
for (int j = 0; piChannelIDs[j] >= 0; ++j) { |
2138 |
|
if (!pChannelStrip->channel()) break; |
2139 |
|
if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) { |
2140 |
|
// strip exists, don't touch it |
2141 |
|
bExists = true; |
2142 |
|
break; |
2143 |
|
} |
2144 |
|
} |
2145 |
|
if (!bExists) destroyChannelStrip(pChannelStrip); |
2146 |
|
} |
2147 |
|
} |
2148 |
|
m_pWorkspace->setUpdatesEnabled(true); |
2149 |
|
} |
2150 |
|
} |
2151 |
|
|
2152 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
2153 |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
2321 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2322 |
|
|
2323 |
QMessageBox::critical(this, |
QMessageBox::critical(this, |
2324 |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
QSAMPLER_TITLE ": " + tr("Error"), s, QMessageBox::Cancel); |
2325 |
} |
} |
2326 |
|
|
2327 |
|
|
2384 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
2385 |
|
|
2386 |
// The channel strip creation executive. |
// The channel strip creation executive. |
2387 |
ChannelStrip* MainForm::createChannelStrip(qsamplerChannel* pChannel) |
ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel ) |
2388 |
{ |
{ |
2389 |
if (m_pClient == NULL || pChannel == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
2390 |
return NULL; |
return NULL; |
2391 |
|
|
|
// Prepare for auto-arrange? |
|
|
ChannelStrip* pChannelStrip = NULL; |
|
|
int y = 0; |
|
|
if (m_pOptions && m_pOptions->bAutoArrange) { |
|
|
QWidgetList wlist = m_pWorkspace->windowList(); |
|
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
|
|
pChannelStrip = static_cast<ChannelStrip *> (wlist.at(iChannel)); |
|
|
if (pChannelStrip) { |
|
|
// y += pChannelStrip->height() |
|
|
// + pChannelStrip->parentWidget()->baseSize().height(); |
|
|
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
2392 |
// Add a new channel itema... |
// Add a new channel itema... |
2393 |
pChannelStrip = new ChannelStrip(); |
ChannelStrip *pChannelStrip = new ChannelStrip(); |
2394 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
2395 |
return NULL; |
return NULL; |
2396 |
|
|
2397 |
m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint); |
// Set some initial channel strip options... |
|
|
|
|
// Actual channel strip setup... |
|
|
pChannelStrip->setup(pChannel); |
|
|
QObject::connect(pChannelStrip, |
|
|
SIGNAL(channelChanged(ChannelStrip*)), |
|
|
SLOT(channelStripChanged(ChannelStrip*))); |
|
|
// Set some initial aesthetic options... |
|
2398 |
if (m_pOptions) { |
if (m_pOptions) { |
2399 |
// Background display effect... |
// Background display effect... |
2400 |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
2406 |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
2407 |
} |
} |
2408 |
|
|
2409 |
|
// Add it to workspace... |
2410 |
|
m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint); |
2411 |
|
|
2412 |
|
// Actual channel strip setup... |
2413 |
|
pChannelStrip->setup(pChannel); |
2414 |
|
|
2415 |
|
QObject::connect(pChannelStrip, |
2416 |
|
SIGNAL(channelChanged(ChannelStrip*)), |
2417 |
|
SLOT(channelStripChanged(ChannelStrip*))); |
2418 |
|
|
2419 |
// Now we show up us to the world. |
// Now we show up us to the world. |
2420 |
pChannelStrip->show(); |
pChannelStrip->show(); |
|
// Only then, we'll auto-arrange... |
|
|
if (m_pOptions && m_pOptions->bAutoArrange) { |
|
|
int iWidth = m_pWorkspace->width(); |
|
|
// int iHeight = pChannel->height() |
|
|
// + pChannel->parentWidget()->baseSize().height(); |
|
|
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
|
|
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
|
|
} |
|
2421 |
|
|
2422 |
// This is pretty new, so we'll watch for it closely. |
// This is pretty new, so we'll watch for it closely. |
2423 |
channelStripChanged(pChannelStrip); |
channelStripChanged(pChannelStrip); |
2426 |
return pChannelStrip; |
return pChannelStrip; |
2427 |
} |
} |
2428 |
|
|
2429 |
|
void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) { |
2430 |
|
// Just delete the channel strip. |
2431 |
|
delete pChannelStrip; |
2432 |
|
|
2433 |
|
// Do we auto-arrange? |
2434 |
|
if (m_pOptions && m_pOptions->bAutoArrange) |
2435 |
|
channelsArrange(); |
2436 |
|
|
2437 |
|
stabilizeForm(); |
2438 |
|
} |
2439 |
|
|
2440 |
// Retrieve the active channel strip. |
// Retrieve the active channel strip. |
2441 |
ChannelStrip* MainForm::activeChannelStrip (void) |
ChannelStrip* MainForm::activeChannelStrip (void) |
2447 |
// Retrieve a channel strip by index. |
// Retrieve a channel strip by index. |
2448 |
ChannelStrip* MainForm::channelStripAt ( int iChannel ) |
ChannelStrip* MainForm::channelStripAt ( int iChannel ) |
2449 |
{ |
{ |
2450 |
|
if (!m_pWorkspace) return NULL; |
2451 |
|
|
2452 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
2453 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2454 |
return NULL; |
return NULL; |
2455 |
|
|
2456 |
return static_cast<ChannelStrip *> (wlist.at(iChannel)); |
if (iChannel < 0 || iChannel >= wlist.size()) |
2457 |
|
return NULL; |
2458 |
|
|
2459 |
|
return dynamic_cast<ChannelStrip *> (wlist.at(iChannel)); |
2460 |
} |
} |
2461 |
|
|
2462 |
|
|
2471 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
2472 |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
2473 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2474 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2475 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2476 |
return pChannelStrip; |
return pChannelStrip; |
2477 |
} |
} |
2609 |
|
|
2610 |
// Is the server process instance still here? |
// Is the server process instance still here? |
2611 |
if (m_pServer) { |
if (m_pServer) { |
2612 |
switch (QMessageBox::warning(this, |
if (QMessageBox::warning(this, |
2613 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
2614 |
tr("Could not start the LinuxSampler server.\n\n" |
tr("Could not start the LinuxSampler server.\n\n" |
2615 |
"Maybe it ss already started."), |
"Maybe it is already started."), |
2616 |
tr("Stop"), tr("Kill"), tr("Cancel"))) { |
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { |
|
case 0: |
|
2617 |
m_pServer->terminate(); |
m_pServer->terminate(); |
|
break; |
|
|
case 1: |
|
2618 |
m_pServer->kill(); |
m_pServer->kill(); |
|
break; |
|
2619 |
} |
} |
2620 |
return; |
return; |
2621 |
} |
} |
2628 |
return; |
return; |
2629 |
|
|
2630 |
// OK. Let's build the startup process... |
// OK. Let's build the startup process... |
2631 |
m_pServer = new QProcess(this); |
m_pServer = new QProcess(); |
2632 |
|
bForceServerStop = true; |
2633 |
|
|
2634 |
// Setup stdout/stderr capture... |
// Setup stdout/stderr capture... |
2635 |
// if (m_pOptions->bStdoutCapture) { |
// if (m_pOptions->bStdoutCapture) { |
2636 |
//m_pServer->setProcessChannelMode( |
#if QT_VERSION >= 0x040200 |
2637 |
// QProcess::StandardOutput); |
m_pServer->setProcessChannelMode(QProcess::ForwardedChannels); |
2638 |
|
#endif |
2639 |
QObject::connect(m_pServer, |
QObject::connect(m_pServer, |
2640 |
SIGNAL(readyReadStandardOutput()), |
SIGNAL(readyReadStandardOutput()), |
2641 |
SLOT(readServerStdout())); |
SLOT(readServerStdout())); |
2646 |
|
|
2647 |
// The unforgiveable signal communication... |
// The unforgiveable signal communication... |
2648 |
QObject::connect(m_pServer, |
QObject::connect(m_pServer, |
2649 |
SIGNAL(finished(int,QProcess::ExitStatus)), |
SIGNAL(finished(int, QProcess::ExitStatus)), |
2650 |
SLOT(processServerExit())); |
SLOT(processServerExit())); |
2651 |
|
|
2652 |
// Build process arguments... |
// Build process arguments... |
2677 |
|
|
2678 |
|
|
2679 |
// Stop linuxsampler server... |
// Stop linuxsampler server... |
2680 |
void MainForm::stopServer (void) |
void MainForm::stopServer (bool bInteractive) |
2681 |
{ |
{ |
2682 |
// Stop client code. |
// Stop client code. |
2683 |
stopClient(); |
stopClient(); |
2684 |
|
|
2685 |
|
if (m_pServer && bInteractive) { |
2686 |
|
if (QMessageBox::question(this, |
2687 |
|
QSAMPLER_TITLE ": " + tr("The backend's fate ..."), |
2688 |
|
tr("You have the option to keep the sampler backend (LinuxSampler)\n" |
2689 |
|
"running in the background. The sampler would continue to work\n" |
2690 |
|
"according to your current sampler session and you could alter the\n" |
2691 |
|
"sampler session at any time by relaunching QSampler.\n\n" |
2692 |
|
"Do you want LinuxSampler to stop?"), |
2693 |
|
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) |
2694 |
|
{ |
2695 |
|
bForceServerStop = false; |
2696 |
|
} |
2697 |
|
} |
2698 |
|
|
2699 |
// And try to stop server. |
// And try to stop server. |
2700 |
if (m_pServer) { |
if (m_pServer && bForceServerStop) { |
2701 |
appendMessages(tr("Server is stopping...")); |
appendMessages(tr("Server is stopping...")); |
2702 |
if (m_pServer->state() == QProcess::Running) |
if (m_pServer->state() == QProcess::Running) { |
2703 |
|
#if defined(WIN32) |
2704 |
|
// Try harder... |
2705 |
|
m_pServer->kill(); |
2706 |
|
#else |
2707 |
|
// Try softly... |
2708 |
m_pServer->terminate(); |
m_pServer->terminate(); |
2709 |
} |
#endif |
2710 |
|
} |
2711 |
|
} // Do final processing anyway. |
2712 |
|
else processServerExit(); |
2713 |
|
|
2714 |
// Give it some time to terminate gracefully and stabilize... |
// Give it some time to terminate gracefully and stabilize... |
2715 |
QTime t; |
QTime t; |
2716 |
t.start(); |
t.start(); |
2717 |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2718 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
|
|
|
|
// Do final processing anyway. |
|
|
processServerExit(); |
|
2719 |
} |
} |
2720 |
|
|
2721 |
|
|
2737 |
if (m_pMessages) |
if (m_pMessages) |
2738 |
m_pMessages->flushStdoutBuffer(); |
m_pMessages->flushStdoutBuffer(); |
2739 |
|
|
2740 |
if (m_pServer) { |
if (m_pServer && bForceServerStop) { |
2741 |
|
if (m_pServer->state() != QProcess::NotRunning) { |
2742 |
|
appendMessages(tr("Server is being forced...")); |
2743 |
|
// Force final server shutdown... |
2744 |
|
m_pServer->kill(); |
2745 |
|
// Give it some time to terminate gracefully and stabilize... |
2746 |
|
QTime t; |
2747 |
|
t.start(); |
2748 |
|
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2749 |
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2750 |
|
} |
2751 |
// Force final server shutdown... |
// Force final server shutdown... |
2752 |
appendMessages( |
appendMessages( |
2753 |
tr("Server was stopped with exit status %1.") |
tr("Server was stopped with exit status %1.") |
2754 |
.arg(m_pServer->exitStatus())); |
.arg(m_pServer->exitStatus())); |
|
m_pServer->terminate(); |
|
|
if (!m_pServer->waitForFinished(2000)) |
|
|
m_pServer->kill(); |
|
|
// Destroy it. |
|
2755 |
delete m_pServer; |
delete m_pServer; |
2756 |
m_pServer = NULL; |
m_pServer = NULL; |
2757 |
} |
} |
2776 |
// as this is run under some other thread context. |
// as this is run under some other thread context. |
2777 |
// A custom event must be posted here... |
// A custom event must be posted here... |
2778 |
QApplication::postEvent(pMainForm, |
QApplication::postEvent(pMainForm, |
2779 |
new qsamplerCustomEvent(event, pchData, cchData)); |
new LscpEvent(event, pchData, cchData)); |
2780 |
|
|
2781 |
return LSCP_OK; |
return LSCP_OK; |
2782 |
} |
} |
2821 |
.arg(::lscp_client_get_timeout(m_pClient))); |
.arg(::lscp_client_get_timeout(m_pClient))); |
2822 |
|
|
2823 |
// Subscribe to channel info change notifications... |
// Subscribe to channel info change notifications... |
2824 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT) != LSCP_OK) |
2825 |
|
appendMessagesClient("lscp_client_subscribe(CHANNEL_COUNT)"); |
2826 |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
2827 |
appendMessagesClient("lscp_client_subscribe"); |
appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)"); |
2828 |
|
|
2829 |
|
DeviceStatusForm::onDevicesChanged(); // initialize |
2830 |
|
updateViewMidiDeviceStatusMenu(); |
2831 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT) != LSCP_OK) |
2832 |
|
appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)"); |
2833 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO) != LSCP_OK) |
2834 |
|
appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)"); |
2835 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT) != LSCP_OK) |
2836 |
|
appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_COUNT)"); |
2837 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO) != LSCP_OK) |
2838 |
|
appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_INFO)"); |
2839 |
|
|
2840 |
|
#if CONFIG_EVENT_CHANNEL_MIDI |
2841 |
|
// Subscribe to channel MIDI data notifications... |
2842 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK) |
2843 |
|
appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)"); |
2844 |
|
#endif |
2845 |
|
|
2846 |
|
#if CONFIG_EVENT_DEVICE_MIDI |
2847 |
|
// Subscribe to channel MIDI data notifications... |
2848 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK) |
2849 |
|
appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)"); |
2850 |
|
#endif |
2851 |
|
|
2852 |
// We may stop scheduling around. |
// We may stop scheduling around. |
2853 |
stopSchedule(); |
stopSchedule(); |
2874 |
} |
} |
2875 |
} |
} |
2876 |
|
|
2877 |
|
// send the current / loaded fine tuning settings to the sampler |
2878 |
|
m_pOptions->sendFineTuningSettings(); |
2879 |
|
|
2880 |
// Make a new session |
// Make a new session |
2881 |
return newSession(); |
return newSession(); |
2882 |
} |
} |
2904 |
closeSession(false); |
closeSession(false); |
2905 |
|
|
2906 |
// Close us as a client... |
// Close us as a client... |
2907 |
|
#if CONFIG_EVENT_DEVICE_MIDI |
2908 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI); |
2909 |
|
#endif |
2910 |
|
#if CONFIG_EVENT_CHANNEL_MIDI |
2911 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI); |
2912 |
|
#endif |
2913 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO); |
2914 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT); |
2915 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO); |
2916 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT); |
2917 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
2918 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT); |
2919 |
::lscp_client_destroy(m_pClient); |
::lscp_client_destroy(m_pClient); |
2920 |
m_pClient = NULL; |
m_pClient = NULL; |
2921 |
|
|
2933 |
stabilizeForm(); |
stabilizeForm(); |
2934 |
} |
} |
2935 |
|
|
2936 |
|
|
2937 |
|
// Channel strip activation/selection. |
2938 |
|
void MainForm::activateStrip ( QWidget *pWidget ) |
2939 |
|
{ |
2940 |
|
ChannelStrip *pChannelStrip |
2941 |
|
= static_cast<ChannelStrip *> (pWidget); |
2942 |
|
if (pChannelStrip) |
2943 |
|
pChannelStrip->setSelected(true); |
2944 |
|
|
2945 |
|
stabilizeForm(); |
2946 |
|
} |
2947 |
|
|
2948 |
|
|
2949 |
} // namespace QSampler |
} // namespace QSampler |
2950 |
|
|
2951 |
|
|