36 |
|
|
37 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
38 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
39 |
|
#include "qsamplerChannel.h" |
40 |
#include "qsamplerMessages.h" |
#include "qsamplerMessages.h" |
41 |
|
|
42 |
#include "qsamplerChannelStrip.h" |
#include "qsamplerChannelStrip.h" |
55 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
56 |
|
|
57 |
|
|
58 |
|
// All winsock apps needs this. |
59 |
#if defined(WIN32) |
#if defined(WIN32) |
60 |
static WSADATA _wsaData; |
static WSADATA _wsaData; |
61 |
#endif |
#endif |
62 |
|
|
63 |
|
|
64 |
|
//------------------------------------------------------------------------- |
65 |
|
// qsamplerCustomEvent -- specialty for callback comunication. |
66 |
|
|
67 |
|
#define QSAMPLER_CUSTOM_EVENT 1000 |
68 |
|
|
69 |
|
class qsamplerCustomEvent : public QCustomEvent |
70 |
|
{ |
71 |
|
public: |
72 |
|
|
73 |
|
// Constructor. |
74 |
|
qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData) |
75 |
|
: QCustomEvent(QSAMPLER_CUSTOM_EVENT) |
76 |
|
{ |
77 |
|
m_event = event; |
78 |
|
m_data.setLatin1(pchData, cchData); |
79 |
|
} |
80 |
|
|
81 |
|
// Accessors. |
82 |
|
lscp_event_t event() { return m_event; } |
83 |
|
QString& data() { return m_data; } |
84 |
|
|
85 |
|
private: |
86 |
|
|
87 |
|
// The proper event type. |
88 |
|
lscp_event_t m_event; |
89 |
|
// The event data as a string. |
90 |
|
QString m_data; |
91 |
|
}; |
92 |
|
|
93 |
|
|
94 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
95 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
96 |
|
|
104 |
m_pMessages = NULL; |
m_pMessages = NULL; |
105 |
|
|
106 |
// We'll start clean. |
// We'll start clean. |
107 |
m_iUntitled = 0; |
m_iUntitled = 0; |
108 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
109 |
|
m_iChangeCount = 0; |
110 |
|
|
111 |
m_pServer = NULL; |
m_pServer = NULL; |
112 |
m_pClient = NULL; |
m_pClient = NULL; |
311 |
} |
} |
312 |
|
|
313 |
|
|
314 |
|
// Custome event handler. |
315 |
|
void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent ) |
316 |
|
{ |
317 |
|
// For the time being, just pump it to messages. |
318 |
|
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
319 |
|
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
320 |
|
appendMessagesColor(tr("Notify event: %1 data: %2") |
321 |
|
.arg(::lscp_event_to_text(pEvent->event())) |
322 |
|
.arg(pEvent->data()), "#996699"); |
323 |
|
} |
324 |
|
} |
325 |
|
|
326 |
|
|
327 |
// Context menu event handler. |
// Context menu event handler. |
328 |
void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
329 |
{ |
{ |
485 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
486 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
487 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
488 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
489 |
if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) |
if (pChannelStrip) { |
490 |
appendMessagesClient("lscp_remove_channel"); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
491 |
delete pChannel; |
if (bForce && pChannel) |
492 |
|
pChannel->removeChannel(); |
493 |
|
delete pChannelStrip; |
494 |
|
} |
495 |
} |
} |
496 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
497 |
// We're now clean, for sure. |
// We're now clean, for sure. |
553 |
// Try to (re)create each channel. |
// Try to (re)create each channel. |
554 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
555 |
for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) { |
for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) { |
556 |
createChannel(iChannelID, false); |
createChannelStrip(iChannelID); |
557 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
558 |
} |
} |
559 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
600 |
ts << endl; |
ts << endl; |
601 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
602 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
603 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
604 |
int iChannelID = pChannel->channelID(); |
if (pChannelStrip) { |
605 |
ts << "# " << pChannel->caption() << endl; |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
606 |
ts << "ADD CHANNEL" << endl; |
if (pChannel) { |
607 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
int iChannelID = pChannel->channelID(); |
608 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
ts << "# " << pChannelStrip->caption() << endl; |
609 |
// ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
ts << "ADD CHANNEL" << endl; |
610 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
611 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
612 |
ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl; |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
613 |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
614 |
ts << endl; |
if (pChannel->midiChannel() > 0) |
615 |
|
ts << pChannel->midiChannel(); |
616 |
|
else |
617 |
|
ts << "ALL"; |
618 |
|
ts << endl; |
619 |
|
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
620 |
|
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl; |
621 |
|
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
622 |
|
ts << endl; |
623 |
|
} |
624 |
|
} |
625 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
626 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
627 |
} |
} |
693 |
} |
} |
694 |
|
|
695 |
|
|
696 |
|
// Reset the sampler instance. |
697 |
|
void qsamplerMainForm::fileReset (void) |
698 |
|
{ |
699 |
|
if (m_pClient == NULL) |
700 |
|
return; |
701 |
|
|
702 |
|
// Ask user whether he/she want's an internal sampler reset... |
703 |
|
if (QMessageBox::warning(this, tr("Warning"), |
704 |
|
tr("Resetting the sampler instance will close\n" |
705 |
|
"all device and channel configurations.\n\n" |
706 |
|
"Please note that this operation may cause\n" |
707 |
|
"temporary MIDI and Audio disruption\n\n" |
708 |
|
"Do you want to reset the sampler engine now?"), |
709 |
|
tr("Reset"), tr("Cancel")) > 0) |
710 |
|
return; |
711 |
|
|
712 |
|
// Just do the reset, after closing down current session... |
713 |
|
if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
714 |
|
appendMessagesClient("lscp_reset_sampler"); |
715 |
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
716 |
|
return; |
717 |
|
} |
718 |
|
|
719 |
|
// Log this. |
720 |
|
appendMessages(tr("Sampler reset.")); |
721 |
|
} |
722 |
|
|
723 |
|
|
724 |
// Restart the client/server instance. |
// Restart the client/server instance. |
725 |
void qsamplerMainForm::fileRestart (void) |
void qsamplerMainForm::fileRestart (void) |
726 |
{ |
{ |
768 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
769 |
return; |
return; |
770 |
|
|
771 |
// Create the new sampler channel. |
// Just create the channel strip, |
772 |
int iChannelID = ::lscp_add_channel(m_pClient); |
// by giving an invalid channel id. |
773 |
if (iChannelID < 0) { |
createChannelStrip(-1); |
|
appendMessagesClient("lscp_add_channel"); |
|
|
appendMessagesError(tr("Could not create the new channel.\n\nSorry.")); |
|
|
return; |
|
|
} |
|
|
|
|
|
// Log this happening. |
|
|
appendMessages(tr("Channel %1 created.").arg(iChannelID)); |
|
|
|
|
|
// Just create the channel strip with given id. |
|
|
createChannel(iChannelID, true); |
|
|
|
|
|
// We'll be dirty, for sure... |
|
|
m_iDirtyCount++; |
|
|
// Stabilize form anyway. |
|
|
stabilizeForm(); |
|
774 |
} |
} |
775 |
|
|
776 |
|
|
780 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
781 |
return; |
return; |
782 |
|
|
783 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
784 |
|
if (pChannelStrip == NULL) |
785 |
|
return; |
786 |
|
|
787 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
788 |
if (pChannel == NULL) |
if (pChannel == NULL) |
789 |
return; |
return; |
790 |
|
|
794 |
tr("About to remove channel:\n\n" |
tr("About to remove channel:\n\n" |
795 |
"%1\n\n" |
"%1\n\n" |
796 |
"Are you sure?") |
"Are you sure?") |
797 |
.arg(pChannel->caption()), |
.arg(pChannelStrip->caption()), |
798 |
tr("OK"), tr("Cancel")) > 0) |
tr("OK"), tr("Cancel")) > 0) |
799 |
return; |
return; |
800 |
} |
} |
801 |
|
|
802 |
// Remove the existing sampler channel. |
// Remove the existing sampler channel. |
803 |
if (::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) { |
if (!pChannel->removeChannel()) |
|
appendMessagesClient("lscp_remove_channel"); |
|
|
appendMessagesError(tr("Could not remove channel.\n\nSorry.")); |
|
804 |
return; |
return; |
|
} |
|
805 |
|
|
|
// Log this happening. |
|
|
appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID())); |
|
|
|
|
806 |
// Just delete the channel strip. |
// Just delete the channel strip. |
807 |
delete pChannel; |
delete pChannelStrip; |
808 |
|
|
809 |
// Do we auto-arrange? |
// Do we auto-arrange? |
810 |
if (m_pOptions && m_pOptions->bAutoArrange) |
if (m_pOptions && m_pOptions->bAutoArrange) |
811 |
channelsArrange(); |
channelsArrange(); |
822 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
823 |
return; |
return; |
824 |
|
|
825 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
826 |
if (pChannel == NULL) |
if (pChannelStrip == NULL) |
827 |
return; |
return; |
828 |
|
|
829 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
830 |
pChannel->channelSetup(); |
pChannelStrip->channelSetup(); |
831 |
} |
} |
832 |
|
|
833 |
|
|
837 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
838 |
return; |
return; |
839 |
|
|
840 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
841 |
if (pChannel == NULL) |
if (pChannelStrip == NULL) |
842 |
return; |
return; |
843 |
|
|
844 |
// Remove the existing sampler channel. |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
845 |
if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) { |
if (pChannel == NULL) |
|
appendMessagesClient("lscp_reset_channel"); |
|
|
appendMessagesError(tr("Could not reset channel.\n\nSorry.")); |
|
846 |
return; |
return; |
|
} |
|
847 |
|
|
848 |
// Log this. |
// Reset the existing sampler channel. |
849 |
appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID())); |
pChannel->resetChannel(); |
850 |
|
|
851 |
// Refresh channel strip info. |
// Refresh channel strip info. |
852 |
pChannel->updateChannelInfo(); |
pChannelStrip->updateChannelInfo(); |
853 |
|
// And force a deferred update. |
854 |
|
m_iChangeCount++; |
855 |
} |
} |
856 |
|
|
857 |
|
|
912 |
qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this); |
qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this); |
913 |
if (pOptionsForm) { |
if (pOptionsForm) { |
914 |
// Check out some initial nullities(tm)... |
// Check out some initial nullities(tm)... |
915 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
916 |
if (m_pOptions->sDisplayFont.isEmpty() && pChannel) |
if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip) |
917 |
m_pOptions->sDisplayFont = pChannel->displayFont().toString(); |
m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString(); |
918 |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
919 |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
920 |
// To track down deferred or immediate changes. |
// To track down deferred or immediate changes. |
924 |
bool bOldServerStart = m_pOptions->bServerStart; |
bool bOldServerStart = m_pOptions->bServerStart; |
925 |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
926 |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
927 |
|
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
928 |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
929 |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
930 |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
949 |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
950 |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
951 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
952 |
|
if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || |
953 |
|
(!bOldDisplayEffect && m_pOptions->bDisplayEffect)) |
954 |
|
updateDisplayEffect(); |
955 |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
956 |
updateDisplayFont(); |
updateDisplayFont(); |
957 |
if (iOldMaxVolume != m_pOptions->iMaxVolume) |
if (iOldMaxVolume != m_pOptions->iMaxVolume) |
994 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
995 |
int y = 0; |
int y = 0; |
996 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
997 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
998 |
/* if (pChannel->testWState(WState_Maximized | WState_Minimized)) { |
/* if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) { |
999 |
// Prevent flicker... |
// Prevent flicker... |
1000 |
pChannel->hide(); |
pChannelStrip->hide(); |
1001 |
pChannel->showNormal(); |
pChannelStrip->showNormal(); |
1002 |
} */ |
} */ |
1003 |
pChannel->adjustSize(); |
pChannelStrip->adjustSize(); |
1004 |
int iWidth = m_pWorkspace->width(); |
int iWidth = m_pWorkspace->width(); |
1005 |
if (iWidth < pChannel->width()) |
if (iWidth < pChannelStrip->width()) |
1006 |
iWidth = pChannel->width(); |
iWidth = pChannelStrip->width(); |
1007 |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
// int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1008 |
int iHeight = pChannel->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1009 |
pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1010 |
y += iHeight; |
y += iHeight; |
1011 |
} |
} |
1012 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1054 |
sText += tr("Debugging option enabled."); |
sText += tr("Debugging option enabled."); |
1055 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1056 |
#endif |
#endif |
1057 |
|
#ifndef CONFIG_LIBGIG |
1058 |
|
sText += "<small><font color=\"red\">"; |
1059 |
|
sText += tr("GIG (libgig) file support disabled."); |
1060 |
|
sText += "</font></small><br />"; |
1061 |
|
#endif |
1062 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1063 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1064 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1092 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
1093 |
|
|
1094 |
// Update the main menu state... |
// Update the main menu state... |
1095 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1096 |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
1097 |
bool bHasChannel = (bHasClient && pChannel != NULL); |
bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
1098 |
fileNewAction->setEnabled(bHasClient); |
fileNewAction->setEnabled(bHasClient); |
1099 |
fileOpenAction->setEnabled(bHasClient); |
fileOpenAction->setEnabled(bHasClient); |
1100 |
fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
1101 |
fileSaveAsAction->setEnabled(bHasClient); |
fileSaveAsAction->setEnabled(bHasClient); |
1102 |
|
fileResetAction->setEnabled(bHasClient); |
1103 |
fileRestartAction->setEnabled(bHasClient || m_pServer == NULL); |
fileRestartAction->setEnabled(bHasClient || m_pServer == NULL); |
1104 |
editAddChannelAction->setEnabled(bHasClient); |
editAddChannelAction->setEnabled(bHasClient); |
1105 |
editRemoveChannelAction->setEnabled(bHasChannel); |
editRemoveChannelAction->setEnabled(bHasChannel); |
1118 |
} |
} |
1119 |
// Channel status... |
// Channel status... |
1120 |
if (bHasChannel) |
if (bHasChannel) |
1121 |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption()); |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
1122 |
else |
else |
1123 |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
1124 |
// Session status... |
// Session status... |
1137 |
|
|
1138 |
|
|
1139 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1140 |
void qsamplerMainForm::channelChanged( qsamplerChannelStrip * ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * ) |
1141 |
{ |
{ |
1142 |
|
// Flag that we're update those channel strips. |
1143 |
|
m_iChangeCount++; |
1144 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1145 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1146 |
// and update the form status... |
// and update the form status... |
1213 |
|
|
1214 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1215 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1216 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1217 |
pChannel->setDisplayFont(font); |
if (pChannelStrip) |
1218 |
|
pChannelStrip->setDisplayFont(font); |
1219 |
|
} |
1220 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1221 |
|
} |
1222 |
|
|
1223 |
|
|
1224 |
|
// Update channel strips background effect. |
1225 |
|
void qsamplerMainForm::updateDisplayEffect (void) |
1226 |
|
{ |
1227 |
|
QPixmap pm; |
1228 |
|
if (m_pOptions->bDisplayEffect) |
1229 |
|
pm = QPixmap::fromMimeSource("displaybg1.png"); |
1230 |
|
|
1231 |
|
// Full channel list update... |
1232 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1233 |
|
if (wlist.isEmpty()) |
1234 |
|
return; |
1235 |
|
|
1236 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1237 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1238 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1239 |
|
if (pChannelStrip) |
1240 |
|
pChannelStrip->setDisplayBackground(pm); |
1241 |
} |
} |
1242 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1243 |
} |
} |
1256 |
|
|
1257 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1258 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1259 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1260 |
pChannel->setMaxVolume(m_pOptions->iMaxVolume); |
if (pChannelStrip) |
1261 |
|
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
1262 |
} |
} |
1263 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1264 |
} |
} |
1357 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
1358 |
|
|
1359 |
// The channel strip creation executive. |
// The channel strip creation executive. |
1360 |
void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt ) |
qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( int iChannelID ) |
1361 |
{ |
{ |
1362 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1363 |
return; |
return NULL; |
1364 |
|
|
1365 |
// Prepare for auto-arrange? |
// Prepare for auto-arrange? |
1366 |
qsamplerChannelStrip *pChannel = NULL; |
qsamplerChannelStrip *pChannelStrip = NULL; |
1367 |
int y = 0; |
int y = 0; |
1368 |
if (m_pOptions && m_pOptions->bAutoArrange) { |
if (m_pOptions && m_pOptions->bAutoArrange) { |
1369 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1370 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1371 |
pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1372 |
// y += pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1373 |
y += pChannel->parentWidget()->frameGeometry().height(); |
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
1374 |
} |
} |
1375 |
} |
} |
1376 |
|
|
1377 |
// Add a new channel itema... |
// Add a new channel itema... |
1378 |
WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder; |
WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder; |
1379 |
pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
1380 |
pChannel->setMaxVolume(m_pOptions->iMaxVolume); |
// Actual channel setup. |
1381 |
pChannel->setup(this, iChannelID); |
pChannelStrip->setup(this, iChannelID); |
1382 |
// We'll need a display font. |
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
|
QFont font; |
|
|
if (m_pOptions && font.fromString(m_pOptions->sDisplayFont)) |
|
|
pChannel->setDisplayFont(font); |
|
|
// Track channel setup changes. |
|
|
QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *))); |
|
1383 |
// Before we show it up, may be we'll |
// Before we show it up, may be we'll |
1384 |
// better ask for some initial values? |
// better ask for some initial values? |
1385 |
if (bPrompt) |
if (iChannelID < 0 && !pChannelStrip->channelSetup()) { |
1386 |
pChannel->channelSetup(); |
// No luck, bail out... |
1387 |
|
delete pChannelStrip; |
1388 |
|
return NULL; |
1389 |
|
} |
1390 |
|
|
1391 |
|
// Set some initial aesthetic options... |
1392 |
|
if (m_pOptions) { |
1393 |
|
// Background display effect... |
1394 |
|
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
1395 |
|
// We'll need a display font. |
1396 |
|
QFont font; |
1397 |
|
if (font.fromString(m_pOptions->sDisplayFont)) |
1398 |
|
pChannelStrip->setDisplayFont(font); |
1399 |
|
// Maximum allowed volume setting. |
1400 |
|
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
1401 |
|
} |
1402 |
|
|
1403 |
// Now we show up us to the world. |
// Now we show up us to the world. |
1404 |
pChannel->show(); |
pChannelStrip->show(); |
1405 |
// Only then, we'll auto-arrange... |
// Only then, we'll auto-arrange... |
1406 |
if (m_pOptions && m_pOptions->bAutoArrange) { |
if (m_pOptions && m_pOptions->bAutoArrange) { |
1407 |
int iWidth = m_pWorkspace->width(); |
int iWidth = m_pWorkspace->width(); |
1408 |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
1409 |
int iHeight = pChannel->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1410 |
pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1411 |
} |
} |
1412 |
|
|
1413 |
|
// Return our successful reference... |
1414 |
|
return pChannelStrip; |
1415 |
} |
} |
1416 |
|
|
1417 |
|
|
1418 |
// Retrieve the active channel strip. |
// Retrieve the active channel strip. |
1419 |
qsamplerChannelStrip *qsamplerMainForm::activeChannel (void) |
qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void) |
1420 |
{ |
{ |
1421 |
return (qsamplerChannelStrip *) m_pWorkspace->activeWindow(); |
return (qsamplerChannelStrip *) m_pWorkspace->activeWindow(); |
1422 |
} |
} |
1423 |
|
|
1424 |
|
|
1425 |
// Retrieve a channel strip by index. |
// Retrieve a channel strip by index. |
1426 |
qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel ) |
qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel ) |
1427 |
{ |
{ |
1428 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1429 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1444 |
if (!wlist.isEmpty()) { |
if (!wlist.isEmpty()) { |
1445 |
channelsMenu->insertSeparator(); |
channelsMenu->insertSeparator(); |
1446 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1447 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1448 |
int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int))); |
if (pChannelStrip) { |
1449 |
channelsMenu->setItemParameter(iItemID, iChannel); |
int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int))); |
1450 |
channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel); |
channelsMenu->setItemParameter(iItemID, iChannel); |
1451 |
|
channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip); |
1452 |
|
} |
1453 |
} |
} |
1454 |
} |
} |
1455 |
} |
} |
1458 |
// Windows menu activation slot |
// Windows menu activation slot |
1459 |
void qsamplerMainForm::channelsMenuActivated ( int iChannel ) |
void qsamplerMainForm::channelsMenuActivated ( int iChannel ) |
1460 |
{ |
{ |
1461 |
qsamplerChannelStrip *pChannel = channelAt(iChannel); |
qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel); |
1462 |
if (pChannel) |
if (pChannelStrip) |
1463 |
pChannel->showNormal(); |
pChannelStrip->showNormal(); |
1464 |
pChannel->setFocus(); |
pChannelStrip->setFocus(); |
1465 |
} |
} |
1466 |
|
|
1467 |
|
|
1501 |
} |
} |
1502 |
|
|
1503 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
1504 |
if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) { |
if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) { |
1505 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
1506 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
1507 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
1508 |
|
m_iChangeCount = 0; |
1509 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1510 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1511 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1512 |
if (pChannel->isVisible()) |
if (pChannelStrip && pChannelStrip->isVisible()) { |
1513 |
pChannel->updateChannelUsage(); |
// If we can't make it clean, try next time. |
1514 |
|
if (!pChannelStrip->updateChannelUsage()) |
1515 |
|
m_iChangeCount++; |
1516 |
|
} |
1517 |
} |
} |
1518 |
} |
} |
1519 |
} |
} |
1650 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
1651 |
// qsamplerMainForm -- Client stuff. |
// qsamplerMainForm -- Client stuff. |
1652 |
|
|
|
|
|
1653 |
// The LSCP client callback procedure. |
// The LSCP client callback procedure. |
1654 |
lscp_status_t qsampler_client_callback ( lscp_client_t *pClient, const char *pchBuffer, int cchBuffer, void *pvData ) |
lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/, lscp_event_t event, const char *pchData, int cchData, void *pvData ) |
1655 |
{ |
{ |
1656 |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
1657 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
1658 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1659 |
|
|
1660 |
char *pszBuffer = (char *) malloc(cchBuffer + 1); |
// ATTN: DO NOT EVER call any GUI code here, |
1661 |
if (pszBuffer == NULL) |
// as this is run under some other thread context. |
1662 |
return LSCP_FAILED; |
// A custom event must be posted here... |
1663 |
|
QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData)); |
|
memcpy(pszBuffer, pchBuffer, cchBuffer); |
|
|
pszBuffer[cchBuffer] = (char) 0; |
|
|
pMainForm->appendMessagesColor(pszBuffer, "#996699"); |
|
|
free(pszBuffer); |
|
1664 |
|
|
1665 |
return LSCP_OK; |
return LSCP_OK; |
1666 |
} |
} |