43 |
|
|
44 |
#include "config.h" |
#include "config.h" |
45 |
|
|
|
#if !defined(WIN32) |
|
|
#include <unistd.h> |
|
|
#endif |
|
46 |
|
|
47 |
// Timer constant stuff. |
// Timer constant stuff. |
48 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
54 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
55 |
|
|
56 |
|
|
57 |
|
// All winsock apps needs this. |
58 |
#if defined(WIN32) |
#if defined(WIN32) |
59 |
static WSADATA _wsaData; |
static WSADATA _wsaData; |
60 |
#endif |
#endif |
61 |
|
|
62 |
|
|
63 |
|
//------------------------------------------------------------------------- |
64 |
|
// qsamplerCustomEvent -- specialty for callback comunication. |
65 |
|
|
66 |
|
#define QSAMPLER_CUSTOM_EVENT 1000 |
67 |
|
|
68 |
|
class qsamplerCustomEvent : public QCustomEvent |
69 |
|
{ |
70 |
|
public: |
71 |
|
|
72 |
|
// Constructor. |
73 |
|
qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData) |
74 |
|
: QCustomEvent(QSAMPLER_CUSTOM_EVENT) |
75 |
|
{ |
76 |
|
m_event = event; |
77 |
|
m_data.setLatin1(pchData, cchData); |
78 |
|
} |
79 |
|
|
80 |
|
// Accessors. |
81 |
|
lscp_event_t event() { return m_event; } |
82 |
|
QString& data() { return m_data; } |
83 |
|
|
84 |
|
private: |
85 |
|
|
86 |
|
// The proper event type. |
87 |
|
lscp_event_t m_event; |
88 |
|
// The event data as a string. |
89 |
|
QString m_data; |
90 |
|
}; |
91 |
|
|
92 |
|
|
93 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
94 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
95 |
|
|
284 |
} |
} |
285 |
|
|
286 |
|
|
287 |
|
// Window drag-n-drop event handlers. |
288 |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
289 |
{ |
{ |
290 |
bool bAccept = false; |
bool bAccept = false; |
309 |
} |
} |
310 |
|
|
311 |
|
|
312 |
|
// Custome event handler. |
313 |
|
void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent ) |
314 |
|
{ |
315 |
|
// For the time being, just pump it to messages. |
316 |
|
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
317 |
|
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
318 |
|
appendMessagesColor(tr("Notify event: %1 data: %2") |
319 |
|
.arg(::lscp_event_to_text(pEvent->event())) |
320 |
|
.arg(pEvent->data()), "#996699"); |
321 |
|
} |
322 |
|
} |
323 |
|
|
324 |
|
|
325 |
|
// Context menu event handler. |
326 |
|
void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
327 |
|
{ |
328 |
|
stabilizeForm(); |
329 |
|
|
330 |
|
editMenu->exec(pEvent->globalPos()); |
331 |
|
} |
332 |
|
|
333 |
|
|
334 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
335 |
// qsamplerMainForm -- Brainless public property accessors. |
// qsamplerMainForm -- Brainless public property accessors. |
336 |
|
|
599 |
int iChannelID = pChannel->channelID(); |
int iChannelID = pChannel->channelID(); |
600 |
ts << "# " << pChannel->caption() << endl; |
ts << "# " << pChannel->caption() << endl; |
601 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
602 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
603 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
604 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
605 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl; |
606 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
607 |
|
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl; |
608 |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
|
ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl; |
|
609 |
ts << endl; |
ts << endl; |
610 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
611 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
800 |
return; |
return; |
801 |
|
|
802 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
803 |
pChannel->channelSetup(); |
pChannel->channelSetup(false); |
804 |
} |
} |
805 |
|
|
806 |
|
|
898 |
bool bOldServerStart = m_pOptions->bServerStart; |
bool bOldServerStart = m_pOptions->bServerStart; |
899 |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
900 |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
901 |
|
int iOldMaxVolume = m_pOptions->iMaxVolume; |
902 |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
903 |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
904 |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
924 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
925 |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
926 |
updateDisplayFont(); |
updateDisplayFont(); |
927 |
|
if (iOldMaxVolume != m_pOptions->iMaxVolume) |
928 |
|
updateMaxVolume(); |
929 |
if (sOldMessagesFont != m_pOptions->sMessagesFont) |
if (sOldMessagesFont != m_pOptions->sMessagesFont) |
930 |
updateMessagesFont(); |
updateMessagesFont(); |
931 |
if (( bOldMessagesLimit && !m_pOptions->bMessagesLimit) || |
if (( bOldMessagesLimit && !m_pOptions->bMessagesLimit) || |
1024 |
sText += tr("Debugging option enabled."); |
sText += tr("Debugging option enabled."); |
1025 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1026 |
#endif |
#endif |
1027 |
|
#ifndef CONFIG_LIBGIG |
1028 |
|
sText += "<small><font color=\"red\">"; |
1029 |
|
sText += tr("GIG (libgig) file support disabled."); |
1030 |
|
sText += "</font></small><br />"; |
1031 |
|
#endif |
1032 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1033 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1034 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1187 |
} |
} |
1188 |
|
|
1189 |
|
|
1190 |
|
// Force update of the channels maximum volume setting. |
1191 |
|
void qsamplerMainForm::updateMaxVolume (void) |
1192 |
|
{ |
1193 |
|
if (m_pOptions == NULL) |
1194 |
|
return; |
1195 |
|
|
1196 |
|
// Full channel list update... |
1197 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1198 |
|
if (wlist.isEmpty()) |
1199 |
|
return; |
1200 |
|
|
1201 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1202 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1203 |
|
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
1204 |
|
pChannel->setMaxVolume(m_pOptions->iMaxVolume); |
1205 |
|
} |
1206 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1207 |
|
} |
1208 |
|
|
1209 |
|
|
1210 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
1211 |
// qsamplerMainForm -- Messages window form handlers. |
// qsamplerMainForm -- Messages window form handlers. |
1212 |
|
|
1320 |
// Add a new channel itema... |
// Add a new channel itema... |
1321 |
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; |
1322 |
pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
1323 |
|
pChannel->setMaxVolume(m_pOptions->iMaxVolume); |
1324 |
pChannel->setup(this, iChannelID); |
pChannel->setup(this, iChannelID); |
1325 |
// We'll need a display font. |
// We'll need a display font. |
1326 |
QFont font; |
QFont font; |
1331 |
// Before we show it up, may be we'll |
// Before we show it up, may be we'll |
1332 |
// better ask for some initial values? |
// better ask for some initial values? |
1333 |
if (bPrompt) |
if (bPrompt) |
1334 |
pChannel->channelSetup(); |
pChannel->channelSetup(true); |
1335 |
// Now we show up us to the world. |
// Now we show up us to the world. |
1336 |
pChannel->show(); |
pChannel->show(); |
1337 |
// Only then, we'll auto-arrange... |
// Only then, we'll auto-arrange... |
1522 |
// And try to stop server. |
// And try to stop server. |
1523 |
if (m_pServer) { |
if (m_pServer) { |
1524 |
appendMessages(tr("Server is stopping...")); |
appendMessages(tr("Server is stopping...")); |
1525 |
if (m_pServer->isRunning()) { |
if (m_pServer->isRunning()) |
1526 |
m_pServer->tryTerminate(); |
m_pServer->tryTerminate(); |
|
return; |
|
|
} |
|
1527 |
} |
} |
1528 |
|
|
1529 |
|
// Give it some time to terminate gracefully and stabilize... |
1530 |
|
QTime t; |
1531 |
|
t.start(); |
1532 |
|
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
1533 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1534 |
|
|
1535 |
// Do final processing anyway. |
// Do final processing anyway. |
1536 |
processServerExit(); |
processServerExit(); |
1537 |
} |
} |
1573 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
1574 |
// qsamplerMainForm -- Client stuff. |
// qsamplerMainForm -- Client stuff. |
1575 |
|
|
|
|
|
1576 |
// The LSCP client callback procedure. |
// The LSCP client callback procedure. |
1577 |
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 ) |
1578 |
{ |
{ |
1579 |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
1580 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
1581 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1582 |
|
|
1583 |
char *pszBuffer = (char *) malloc(cchBuffer + 1); |
// ATTN: DO NOT EVER call any GUI code here, |
1584 |
if (pszBuffer == NULL) |
// as this is run under some other thread context. |
1585 |
return LSCP_FAILED; |
// A custom event must be posted here... |
1586 |
|
QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData)); |
|
memcpy(pszBuffer, pchBuffer, cchBuffer); |
|
|
pszBuffer[cchBuffer] = (char) 0; |
|
|
pMainForm->appendMessagesColor(pszBuffer, "#996699"); |
|
|
free(pszBuffer); |
|
1587 |
|
|
1588 |
return LSCP_OK; |
return LSCP_OK; |
1589 |
} |
} |