--- qsampler/trunk/src/qsamplerMainForm.ui.h 2004/06/07 21:41:43 115
+++ qsampler/trunk/src/qsamplerMainForm.ui.h 2004/09/29 09:01:35 263
@@ -54,10 +54,42 @@
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state.
+// All winsock apps needs this.
#if defined(WIN32)
static WSADATA _wsaData;
#endif
+
+//-------------------------------------------------------------------------
+// qsamplerCustomEvent -- specialty for callback comunication.
+
+#define QSAMPLER_CUSTOM_EVENT 1000
+
+class qsamplerCustomEvent : public QCustomEvent
+{
+public:
+
+ // Constructor.
+ qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData)
+ : QCustomEvent(QSAMPLER_CUSTOM_EVENT)
+ {
+ m_event = event;
+ m_data.setLatin1(pchData, cchData);
+ }
+
+ // Accessors.
+ lscp_event_t event() { return m_event; }
+ QString& data() { return m_data; }
+
+private:
+
+ // The proper event type.
+ lscp_event_t m_event;
+ // The event data as a string.
+ QString m_data;
+};
+
+
//-------------------------------------------------------------------------
// qsamplerMainForm -- Main window form implementation.
@@ -252,6 +284,7 @@
}
+// Window drag-n-drop event handlers.
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
{
bool bAccept = false;
@@ -276,6 +309,28 @@
}
+// Custome event handler.
+void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent )
+{
+ // For the time being, just pump it to messages.
+ if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
+ qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
+ appendMessagesColor(tr("Notify event: %1 data: %2")
+ .arg(::lscp_event_to_text(pEvent->event()))
+ .arg(pEvent->data()), "#996699");
+ }
+}
+
+
+// Context menu event handler.
+void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )
+{
+ stabilizeForm();
+
+ editMenu->exec(pEvent->globalPos());
+}
+
+
//-------------------------------------------------------------------------
// qsamplerMainForm -- Brainless public property accessors.
@@ -546,10 +601,15 @@
ts << "ADD CHANNEL" << endl;
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
- // ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
- ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;
+ ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
+ ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
+ if (pChannel->midiChannel() > 0)
+ ts << pChannel->midiChannel();
+ else
+ ts << "ALL";
+ ts << endl;
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
- ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl;
+ ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;
ts << endl;
// Try to keep it snappy :)
@@ -623,6 +683,34 @@
}
+// Reset the sampler instance.
+void qsamplerMainForm::fileReset (void)
+{
+ if (m_pClient == NULL)
+ return;
+
+ // Ask user whether he/she want's an internal sampler reset...
+ if (QMessageBox::warning(this, tr("Warning"),
+ tr("Resetting the sampler instance will close\n"
+ "all device and channel configurations.\n\n"
+ "Please note that this operation may cause\n"
+ "temporary MIDI and Audio disruption\n\n"
+ "Do you want to reset the sampler engine now?"),
+ tr("Reset"), tr("Cancel")) > 0)
+ return;
+
+ // Just do the reset, after closing down current session...
+ if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
+ appendMessagesClient("lscp_reset_sampler");
+ appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
+ return;
+ }
+
+ // Log this.
+ appendMessages(tr("Sampler reset."));
+}
+
+
// Restart the client/server instance.
void qsamplerMainForm::fileRestart (void)
{
@@ -745,7 +833,7 @@
return;
// Just invoque the channel strip procedure.
- pChannel->channelSetup();
+ pChannel->showChannelSetup(false);
}
@@ -843,6 +931,7 @@
bool bOldServerStart = m_pOptions->bServerStart;
QString sOldServerCmdLine = m_pOptions->sServerCmdLine;
QString sOldDisplayFont = m_pOptions->sDisplayFont;
+ int iOldMaxVolume = m_pOptions->iMaxVolume;
QString sOldMessagesFont = m_pOptions->sMessagesFont;
bool bOldStdoutCapture = m_pOptions->bStdoutCapture;
int bOldMessagesLimit = m_pOptions->bMessagesLimit;
@@ -868,6 +957,8 @@
updateRecentFilesMenu();
if (sOldDisplayFont != m_pOptions->sDisplayFont)
updateDisplayFont();
+ if (iOldMaxVolume != m_pOptions->iMaxVolume)
+ updateMaxVolume();
if (sOldMessagesFont != m_pOptions->sMessagesFont)
updateMessagesFont();
if (( bOldMessagesLimit && !m_pOptions->bMessagesLimit) ||
@@ -966,6 +1057,11 @@
sText += tr("Debugging option enabled.");
sText += "
";
#endif
+#ifndef CONFIG_LIBGIG
+ sText += "";
+ sText += tr("GIG (libgig) file support disabled.");
+ sText += "
";
+#endif
sText += "
\n";
sText += tr("Using") + ": ";
sText += ::lscp_client_package();
@@ -1006,6 +1102,7 @@
fileOpenAction->setEnabled(bHasClient);
fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
fileSaveAsAction->setEnabled(bHasClient);
+ fileResetAction->setEnabled(bHasClient);
fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
editAddChannelAction->setEnabled(bHasClient);
editRemoveChannelAction->setEnabled(bHasChannel);
@@ -1124,6 +1221,26 @@
}
+// Force update of the channels maximum volume setting.
+void qsamplerMainForm::updateMaxVolume (void)
+{
+ if (m_pOptions == NULL)
+ return;
+
+ // Full channel list update...
+ QWidgetList wlist = m_pWorkspace->windowList();
+ if (wlist.isEmpty())
+ return;
+
+ m_pWorkspace->setUpdatesEnabled(false);
+ for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
+ qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);
+ pChannel->setMaxVolume(m_pOptions->iMaxVolume);
+ }
+ m_pWorkspace->setUpdatesEnabled(true);
+}
+
+
//-------------------------------------------------------------------------
// qsamplerMainForm -- Messages window form handlers.
@@ -1237,6 +1354,7 @@
// Add a new channel itema...
WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;
pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
+ pChannel->setMaxVolume(m_pOptions->iMaxVolume);
pChannel->setup(this, iChannelID);
// We'll need a display font.
QFont font;
@@ -1247,7 +1365,7 @@
// Before we show it up, may be we'll
// better ask for some initial values?
if (bPrompt)
- pChannel->channelSetup();
+ pChannel->showChannelSetup(true);
// Now we show up us to the world.
pChannel->show();
// Only then, we'll auto-arrange...
@@ -1438,12 +1556,16 @@
// And try to stop server.
if (m_pServer) {
appendMessages(tr("Server is stopping..."));
- if (m_pServer->isRunning()) {
+ if (m_pServer->isRunning())
m_pServer->tryTerminate();
- return;
- }
}
+ // Give it some time to terminate gracefully and stabilize...
+ QTime t;
+ t.start();
+ while (t.elapsed() < QSAMPLER_TIMER_MSECS)
+ QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
+
// Do final processing anyway.
processServerExit();
}
@@ -1485,22 +1607,17 @@
//-------------------------------------------------------------------------
// qsamplerMainForm -- Client stuff.
-
// The LSCP client callback procedure.
-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 )
{
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;
if (pMainForm == NULL)
return LSCP_FAILED;
- char *pszBuffer = (char *) malloc(cchBuffer + 1);
- if (pszBuffer == NULL)
- return LSCP_FAILED;
-
- memcpy(pszBuffer, pchBuffer, cchBuffer);
- pszBuffer[cchBuffer] = (char) 0;
- pMainForm->appendMessagesColor(pszBuffer, "#996699");
- free(pszBuffer);
+ // ATTN: DO NOT EVER call any GUI code here,
+ // as this is run under some other thread context.
+ // A custom event must be posted here...
+ QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData));
return LSCP_OK;
}