2 |
// |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
/**************************************************************************** |
5 |
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
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 |
26 |
#include <qprocess.h> |
#include <qprocess.h> |
27 |
#include <qmessagebox.h> |
#include <qmessagebox.h> |
28 |
#include <qdragobject.h> |
#include <qdragobject.h> |
29 |
|
#include <qregexp.h> |
30 |
#include <qfiledialog.h> |
#include <qfiledialog.h> |
31 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
32 |
#include <qfile.h> |
#include <qfile.h> |
41 |
#include "qsamplerMessages.h" |
#include "qsamplerMessages.h" |
42 |
|
|
43 |
#include "qsamplerChannelStrip.h" |
#include "qsamplerChannelStrip.h" |
44 |
|
|
45 |
|
#include "qsamplerDeviceForm.h" |
46 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
47 |
|
|
48 |
#include "config.h" |
#include "config.h" |
49 |
|
|
50 |
|
#ifdef HAVE_SIGNAL_H |
51 |
|
#include <signal.h> |
52 |
|
#endif |
53 |
|
|
54 |
// Timer constant stuff. |
// Timer constant stuff. |
55 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
107 |
m_pOptions = NULL; |
m_pOptions = NULL; |
108 |
|
|
109 |
// All child forms are to be created later, not earlier than setup. |
// All child forms are to be created later, not earlier than setup. |
110 |
m_pMessages = NULL; |
m_pMessages = NULL; |
111 |
|
m_pDeviceForm = NULL; |
112 |
|
|
113 |
// We'll start clean. |
// We'll start clean. |
114 |
m_iUntitled = 0; |
m_iUntitled = 0; |
115 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
116 |
|
|
117 |
m_pServer = NULL; |
m_pServer = NULL; |
122 |
|
|
123 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
124 |
|
|
125 |
|
#ifdef HAVE_SIGNAL_H |
126 |
|
// Set to ignore any fatal "Broken pipe" signals. |
127 |
|
::signal(SIGPIPE, SIG_IGN); |
128 |
|
#endif |
129 |
|
|
130 |
// Make it an MDI workspace. |
// Make it an MDI workspace. |
131 |
m_pWorkspace = new QWorkspace(this); |
m_pWorkspace = new QWorkspace(this); |
132 |
m_pWorkspace->setScrollBarsEnabled(true); |
m_pWorkspace->setScrollBarsEnabled(true); |
141 |
pLabel = new QLabel(tr("Connected"), this); |
pLabel = new QLabel(tr("Connected"), this); |
142 |
pLabel->setAlignment(Qt::AlignLeft); |
pLabel->setAlignment(Qt::AlignLeft); |
143 |
pLabel->setMinimumSize(pLabel->sizeHint()); |
pLabel->setMinimumSize(pLabel->sizeHint()); |
144 |
m_status[QSAMPLER_STATUS_CLIENT] = pLabel; |
m_statusItem[QSAMPLER_STATUS_CLIENT] = pLabel; |
145 |
statusBar()->addWidget(pLabel); |
statusBar()->addWidget(pLabel); |
146 |
// Server address. |
// Server address. |
147 |
pLabel = new QLabel(this); |
pLabel = new QLabel(this); |
148 |
pLabel->setAlignment(Qt::AlignLeft); |
pLabel->setAlignment(Qt::AlignLeft); |
149 |
m_status[QSAMPLER_STATUS_SERVER] = pLabel; |
m_statusItem[QSAMPLER_STATUS_SERVER] = pLabel; |
150 |
statusBar()->addWidget(pLabel, 1); |
statusBar()->addWidget(pLabel, 1); |
151 |
// Channel title. |
// Channel title. |
152 |
pLabel = new QLabel(this); |
pLabel = new QLabel(this); |
153 |
pLabel->setAlignment(Qt::AlignLeft); |
pLabel->setAlignment(Qt::AlignLeft); |
154 |
m_status[QSAMPLER_STATUS_CHANNEL] = pLabel; |
m_statusItem[QSAMPLER_STATUS_CHANNEL] = pLabel; |
155 |
statusBar()->addWidget(pLabel, 2); |
statusBar()->addWidget(pLabel, 2); |
156 |
// Session modification status. |
// Session modification status. |
157 |
pLabel = new QLabel(tr("MOD"), this); |
pLabel = new QLabel(tr("MOD"), this); |
158 |
pLabel->setAlignment(Qt::AlignHCenter); |
pLabel->setAlignment(Qt::AlignHCenter); |
159 |
pLabel->setMinimumSize(pLabel->sizeHint()); |
pLabel->setMinimumSize(pLabel->sizeHint()); |
160 |
m_status[QSAMPLER_STATUS_SESSION] = pLabel; |
m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel; |
161 |
statusBar()->addWidget(pLabel); |
statusBar()->addWidget(pLabel); |
162 |
|
|
163 |
// Create the recent files sub-menu. |
// Create the recent files sub-menu. |
176 |
{ |
{ |
177 |
// Do final processing anyway. |
// Do final processing anyway. |
178 |
processServerExit(); |
processServerExit(); |
179 |
|
|
180 |
// Delete recentfiles menu. |
#if defined(WIN32) |
181 |
if (m_pRecentFilesMenu) |
WSACleanup(); |
182 |
delete m_pRecentFilesMenu; |
#endif |
|
// Delete status item labels one by one. |
|
|
if (m_status[QSAMPLER_STATUS_CLIENT]) |
|
|
delete m_status[QSAMPLER_STATUS_CLIENT]; |
|
|
if (m_status[QSAMPLER_STATUS_SERVER]) |
|
|
delete m_status[QSAMPLER_STATUS_SERVER]; |
|
|
if (m_status[QSAMPLER_STATUS_CHANNEL]) |
|
|
delete m_status[QSAMPLER_STATUS_CHANNEL]; |
|
|
if (m_status[QSAMPLER_STATUS_SESSION]) |
|
|
delete m_status[QSAMPLER_STATUS_SESSION]; |
|
183 |
|
|
184 |
// Finally drop any widgets around... |
// Finally drop any widgets around... |
185 |
|
if (m_pDeviceForm) |
186 |
|
delete m_pDeviceForm; |
187 |
if (m_pMessages) |
if (m_pMessages) |
188 |
delete m_pMessages; |
delete m_pMessages; |
189 |
if (m_pWorkspace) |
if (m_pWorkspace) |
190 |
delete m_pWorkspace; |
delete m_pWorkspace; |
191 |
|
|
192 |
#if defined(WIN32) |
// Delete status item labels one by one. |
193 |
WSACleanup(); |
if (m_statusItem[QSAMPLER_STATUS_CLIENT]) |
194 |
#endif |
delete m_statusItem[QSAMPLER_STATUS_CLIENT]; |
195 |
|
if (m_statusItem[QSAMPLER_STATUS_SERVER]) |
196 |
|
delete m_statusItem[QSAMPLER_STATUS_SERVER]; |
197 |
|
if (m_statusItem[QSAMPLER_STATUS_CHANNEL]) |
198 |
|
delete m_statusItem[QSAMPLER_STATUS_CHANNEL]; |
199 |
|
if (m_statusItem[QSAMPLER_STATUS_SESSION]) |
200 |
|
delete m_statusItem[QSAMPLER_STATUS_SESSION]; |
201 |
|
|
202 |
|
// Delete recentfiles menu. |
203 |
|
if (m_pRecentFilesMenu) |
204 |
|
delete m_pRecentFilesMenu; |
205 |
} |
} |
206 |
|
|
207 |
|
|
213 |
|
|
214 |
// Some child forms are to be created right now. |
// Some child forms are to be created right now. |
215 |
m_pMessages = new qsamplerMessages(this); |
m_pMessages = new qsamplerMessages(this); |
216 |
|
m_pDeviceForm = new qsamplerDeviceForm(this); |
217 |
// Set message defaults... |
// Set message defaults... |
218 |
updateMessagesFont(); |
updateMessagesFont(); |
219 |
updateMessagesLimit(); |
updateMessagesLimit(); |
242 |
QTextIStream istr(&sDockables); |
QTextIStream istr(&sDockables); |
243 |
istr >> *this; |
istr >> *this; |
244 |
} |
} |
245 |
// Try to restore old window positioning. |
// Try to restore old window positioning and initial visibility. |
246 |
m_pOptions->loadWidgetGeometry(this); |
m_pOptions->loadWidgetGeometry(this); |
247 |
|
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
248 |
|
|
249 |
// Final startup stabilization... |
// Final startup stabilization... |
250 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
271 |
// Some windows default fonts is here on demand too. |
// Some windows default fonts is here on demand too. |
272 |
if (bQueryClose && m_pMessages) |
if (bQueryClose && m_pMessages) |
273 |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
274 |
|
// Other windows just need asking if it can close gracefully... |
275 |
|
if (bQueryClose && m_pDeviceForm) |
276 |
|
bQueryClose = m_pDeviceForm->queryClose(); |
277 |
// Try to save current positioning. |
// Try to save current positioning. |
278 |
if (bQueryClose) { |
if (bQueryClose) { |
279 |
// Save decorations state. |
// Save decorations state. |
285 |
QTextOStream ostr(&sDockables); |
QTextOStream ostr(&sDockables); |
286 |
ostr << *this; |
ostr << *this; |
287 |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
288 |
// And the main windows state. |
// And the children, and the main windows state,. |
289 |
|
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
290 |
m_pOptions->saveWidgetGeometry(this); |
m_pOptions->saveWidgetGeometry(this); |
291 |
|
// Close popup widgets. |
292 |
|
if (m_pDeviceForm) |
293 |
|
m_pDeviceForm->close(); |
294 |
// Stop client and/or server, gracefully. |
// Stop client and/or server, gracefully. |
295 |
stopServer(); |
stopServer(); |
296 |
} |
} |
309 |
} |
} |
310 |
|
|
311 |
|
|
312 |
// Window drag-n-drop event handlers. |
// Drag'n'drop file handler. |
313 |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files ) |
314 |
{ |
{ |
315 |
bool bAccept = false; |
bool bDecode = false; |
316 |
|
|
317 |
if (QTextDrag::canDecode(pDragEnterEvent)) { |
if (QTextDrag::canDecode(pEvent)) { |
318 |
QString sUrl; |
QString sText; |
319 |
if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient) |
bDecode = QTextDrag::decode(pEvent, sText); |
320 |
bAccept = QFileInfo(QUrl(sUrl).path()).exists(); |
if (bDecode) { |
321 |
|
files = QStringList::split('\n', sText); |
322 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) |
323 |
|
*iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path(); |
324 |
|
} |
325 |
} |
} |
326 |
|
|
327 |
pDragEnterEvent->accept(bAccept); |
return bDecode; |
328 |
|
} |
329 |
|
|
330 |
|
|
331 |
|
// Window drag-n-drop event handlers. |
332 |
|
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
333 |
|
{ |
334 |
|
QStringList files; |
335 |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
336 |
} |
} |
337 |
|
|
338 |
|
|
339 |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
340 |
{ |
{ |
341 |
if (QTextDrag::canDecode(pDropEvent)) { |
QStringList files; |
342 |
QString sUrl; |
|
343 |
if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true)) |
if (!decodeDragFiles(pDropEvent, files)) |
344 |
loadSessionFile(QUrl(sUrl).path()); |
return; |
345 |
} |
|
346 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
347 |
|
const QString& sPath = *iter; |
348 |
|
if (qsamplerChannel::isInstrumentFile(sPath)) { |
349 |
|
// Try to create a new channel from instrument file... |
350 |
|
qsamplerChannel *pChannel = new qsamplerChannel(this); |
351 |
|
if (pChannel == NULL) |
352 |
|
return; |
353 |
|
// Start setting the instrument filename... |
354 |
|
pChannel->setInstrument(sPath, 0); |
355 |
|
// Before we show it up, may be we'll |
356 |
|
// better ask for some initial values? |
357 |
|
if (!pChannel->channelSetup(this)) { |
358 |
|
delete pChannel; |
359 |
|
return; |
360 |
|
} |
361 |
|
// Finally, give it to a new channel strip... |
362 |
|
if (!createChannelStrip(pChannel)) { |
363 |
|
delete pChannel; |
364 |
|
return; |
365 |
|
} |
366 |
|
// Make that an overall update. |
367 |
|
m_iDirtyCount++; |
368 |
|
stabilizeForm(); |
369 |
|
} // Otherwise, load an usual session file (LSCP script)... |
370 |
|
else if (closeSession(true)) |
371 |
|
loadSessionFile(sPath); |
372 |
|
// Make it look responsive...:) |
373 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
374 |
|
} |
375 |
} |
} |
376 |
|
|
377 |
|
|
436 |
if (!closeSession(true)) |
if (!closeSession(true)) |
437 |
return false; |
return false; |
438 |
|
|
439 |
|
// Give us what the server has, right now... |
440 |
|
updateSession(); |
441 |
|
|
442 |
// Ok increment untitled count. |
// Ok increment untitled count. |
443 |
m_iUntitled++; |
m_iUntitled++; |
444 |
|
|
555 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
556 |
if (pChannelStrip) { |
if (pChannelStrip) { |
557 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
558 |
if (bForce && pChannel && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) |
if (bForce && pChannel) |
559 |
appendMessagesClient("lscp_remove_channel"); |
pChannel->removeChannel(); |
560 |
delete pChannelStrip; |
delete pChannelStrip; |
561 |
} |
} |
562 |
} |
} |
597 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
598 |
appendMessagesClient("lscp_client_query"); |
appendMessagesClient("lscp_client_query"); |
599 |
iErrors++; |
iErrors++; |
600 |
|
break; |
601 |
} |
} |
602 |
} |
} |
603 |
// Try to make it snappy :) |
// Try to make it snappy :) |
609 |
|
|
610 |
// Have we any errors? |
// Have we any errors? |
611 |
if (iErrors > 0) |
if (iErrors > 0) |
612 |
appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
613 |
|
|
614 |
// Now we'll try to create the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
615 |
int iChannels = ::lscp_get_channels(m_pClient); |
updateSession(); |
|
if (iChannels < 0) { |
|
|
appendMessagesClient("lscp_get_channels"); |
|
|
appendMessagesError(tr("Could not get current number of channels.\n\nSorry.")); |
|
|
} |
|
|
|
|
|
// Try to (re)create each channel. |
|
|
m_pWorkspace->setUpdatesEnabled(false); |
|
|
for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) { |
|
|
createChannel(iChannelID, false); |
|
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
|
|
} |
|
|
m_pWorkspace->setUpdatesEnabled(true); |
|
616 |
|
|
617 |
// Save as default session directory. |
// Save as default session directory. |
618 |
if (m_pOptions) |
if (m_pOptions) |
623 |
m_sFilename = sFilename; |
m_sFilename = sFilename; |
624 |
updateRecentFiles(sFilename); |
updateRecentFiles(sFilename); |
625 |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
626 |
|
|
627 |
|
// Make that an overall update. |
628 |
stabilizeForm(); |
stabilizeForm(); |
629 |
return true; |
return true; |
630 |
} |
} |
662 |
if (pChannelStrip) { |
if (pChannelStrip) { |
663 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
664 |
if (pChannel) { |
if (pChannel) { |
665 |
int iChannelID = pChannel->channelID(); |
ts << "# Channel " << iChannel << endl; |
|
ts << "# " << pChannelStrip->caption() << endl; |
|
666 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
667 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel << " " << pChannel->audioDriver() << endl; |
668 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel << " " << pChannel->midiDriver() << endl; |
669 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
// ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel << " " << pChannel->midiPort() << endl; |
670 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
671 |
if (pChannel->midiChannel() > 0) |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
|
ts << pChannel->midiChannel(); |
|
|
else |
|
672 |
ts << "ALL"; |
ts << "ALL"; |
673 |
|
else |
674 |
|
ts << pChannel->midiChannel(); |
675 |
ts << endl; |
ts << endl; |
676 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
677 |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl; |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
678 |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
679 |
ts << endl; |
ts << endl; |
680 |
} |
} |
681 |
} |
} |
775 |
|
|
776 |
// Log this. |
// Log this. |
777 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |
778 |
|
|
779 |
|
// Make it a new session... |
780 |
|
newSession(); |
781 |
} |
} |
782 |
|
|
783 |
|
|
828 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
829 |
return; |
return; |
830 |
|
|
831 |
// Create the new sampler channel. |
// Just create the channel instance... |
832 |
int iChannelID = ::lscp_add_channel(m_pClient); |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
833 |
if (iChannelID < 0) { |
if (pChannel == NULL) |
|
appendMessagesClient("lscp_add_channel"); |
|
|
appendMessagesError(tr("Could not create the new channel.\n\nSorry.")); |
|
834 |
return; |
return; |
|
} |
|
|
|
|
|
// Log this happening. |
|
|
appendMessages(tr("Channel %1 created.").arg(iChannelID)); |
|
835 |
|
|
836 |
// Just create the channel strip with given id. |
// Before we show it up, may be we'll |
837 |
createChannel(iChannelID, true); |
// better ask for some initial values? |
838 |
|
if (!pChannel->channelSetup(this)) { |
839 |
|
delete pChannel; |
840 |
|
return; |
841 |
|
} |
842 |
|
|
843 |
|
// And give it to the strip (will own the channel instance, if successful). |
844 |
|
if (!createChannelStrip(pChannel)) { |
845 |
|
delete pChannel; |
846 |
|
return; |
847 |
|
} |
848 |
|
|
849 |
// We'll be dirty, for sure... |
// Make that an overall update. |
850 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
// Stabilize form anyway. |
|
851 |
stabilizeForm(); |
stabilizeForm(); |
852 |
} |
} |
853 |
|
|
878 |
} |
} |
879 |
|
|
880 |
// Remove the existing sampler channel. |
// Remove the existing sampler channel. |
881 |
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.")); |
|
882 |
return; |
return; |
|
} |
|
883 |
|
|
|
// Log this happening. |
|
|
appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID())); |
|
|
|
|
884 |
// Just delete the channel strip. |
// Just delete the channel strip. |
885 |
delete pChannelStrip; |
delete pChannelStrip; |
886 |
|
|
905 |
return; |
return; |
906 |
|
|
907 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
908 |
pChannelStrip->showChannelSetup(false); |
pChannelStrip->channelSetup(); |
909 |
} |
} |
910 |
|
|
911 |
|
|
919 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
920 |
return; |
return; |
921 |
|
|
922 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
// Just invoque the channel strip procedure. |
923 |
if (pChannel == NULL) |
pChannelStrip->channelReset(); |
924 |
return; |
} |
925 |
|
|
|
// Remove the existing sampler channel. |
|
|
if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) { |
|
|
appendMessagesClient("lscp_reset_channel"); |
|
|
appendMessagesError(tr("Could not reset channel.\n\nSorry.")); |
|
|
return; |
|
|
} |
|
926 |
|
|
927 |
// Log this. |
// Reset all sampler channels. |
928 |
appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID())); |
void qsamplerMainForm::editResetAllChannels (void) |
929 |
|
{ |
930 |
|
if (m_pClient == NULL) |
931 |
|
return; |
932 |
|
|
933 |
// Refresh channel strip info. |
// Invoque the channel strip procedure, |
934 |
pChannelStrip->updateChannelInfo(); |
// for all channels out there... |
935 |
|
m_pWorkspace->setUpdatesEnabled(false); |
936 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
937 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
938 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
939 |
|
if (pChannelStrip) |
940 |
|
pChannelStrip->channelReset(); |
941 |
|
} |
942 |
|
m_pWorkspace->setUpdatesEnabled(true); |
943 |
} |
} |
944 |
|
|
945 |
|
|
991 |
} |
} |
992 |
|
|
993 |
|
|
994 |
|
// Show/hide the device configurator form. |
995 |
|
void qsamplerMainForm::viewDevices (void) |
996 |
|
{ |
997 |
|
if (m_pOptions == NULL) |
998 |
|
return; |
999 |
|
|
1000 |
|
if (m_pDeviceForm) { |
1001 |
|
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
1002 |
|
m_pDeviceForm->setClient(m_pClient); |
1003 |
|
if (m_pDeviceForm->isVisible()) { |
1004 |
|
m_pDeviceForm->hide(); |
1005 |
|
} else { |
1006 |
|
m_pDeviceForm->show(); |
1007 |
|
m_pDeviceForm->raise(); |
1008 |
|
m_pDeviceForm->setActiveWindow(); |
1009 |
|
} |
1010 |
|
} |
1011 |
|
} |
1012 |
|
|
1013 |
|
|
1014 |
// Show options dialog. |
// Show options dialog. |
1015 |
void qsamplerMainForm::viewOptions (void) |
void qsamplerMainForm::viewOptions (void) |
1016 |
{ |
{ |
1039 |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1040 |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1041 |
bool bOldCompletePath = m_pOptions->bCompletePath; |
bool bOldCompletePath = m_pOptions->bCompletePath; |
1042 |
|
bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
1043 |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
1044 |
// Load the current setup settings. |
// Load the current setup settings. |
1045 |
pOptionsForm->setup(m_pOptions); |
pOptionsForm->setup(m_pOptions); |
1058 |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
1059 |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
1060 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
1061 |
|
if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) || |
1062 |
|
(!bOldInstrumentNames && m_pOptions->bInstrumentNames)) |
1063 |
|
updateInstrumentNames(); |
1064 |
if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || |
if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || |
1065 |
(!bOldDisplayEffect && m_pOptions->bDisplayEffect)) |
(!bOldDisplayEffect && m_pOptions->bDisplayEffect)) |
1066 |
updateDisplayEffect(); |
updateDisplayEffect(); |
1171 |
sText += tr("GIG (libgig) file support disabled."); |
sText += tr("GIG (libgig) file support disabled."); |
1172 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1173 |
#endif |
#endif |
1174 |
|
#ifndef CONFIG_INSTRUMENT_NAME |
1175 |
|
sText += "<small><font color=\"red\">"; |
1176 |
|
sText += tr("LSCP (liblscp) instrument_name support disabled."); |
1177 |
|
sText += "</font></small><br />"; |
1178 |
|
#endif |
1179 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1180 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1181 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1203 |
void qsamplerMainForm::stabilizeForm (void) |
void qsamplerMainForm::stabilizeForm (void) |
1204 |
{ |
{ |
1205 |
// Update the main application caption... |
// Update the main application caption... |
1206 |
QString sSessioName = sessionName(m_sFilename); |
QString sSessionName = sessionName(m_sFilename); |
1207 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1208 |
sSessioName += '*'; |
sSessionName += '*'; |
1209 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
1210 |
|
|
1211 |
// Update the main menu state... |
// Update the main menu state... |
1212 |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1222 |
editRemoveChannelAction->setEnabled(bHasChannel); |
editRemoveChannelAction->setEnabled(bHasChannel); |
1223 |
editSetupChannelAction->setEnabled(bHasChannel); |
editSetupChannelAction->setEnabled(bHasChannel); |
1224 |
editResetChannelAction->setEnabled(bHasChannel); |
editResetChannelAction->setEnabled(bHasChannel); |
1225 |
channelsArrangeAction->setEnabled(bHasChannel); |
editResetAllChannelsAction->setEnabled(bHasChannel); |
1226 |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
1227 |
|
viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible()); |
1228 |
|
viewDevicesAction->setEnabled(bHasClient); |
1229 |
|
channelsArrangeAction->setEnabled(bHasChannel); |
1230 |
|
|
1231 |
// Client/Server status... |
// Client/Server status... |
1232 |
if (bHasClient) { |
if (bHasClient) { |
1233 |
m_status[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
1234 |
m_status[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort)); |
m_statusItem[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort)); |
1235 |
} else { |
} else { |
1236 |
m_status[QSAMPLER_STATUS_CLIENT]->clear(); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->clear(); |
1237 |
m_status[QSAMPLER_STATUS_SERVER]->clear(); |
m_statusItem[QSAMPLER_STATUS_SERVER]->clear(); |
1238 |
} |
} |
1239 |
// Channel status... |
// Channel status... |
1240 |
if (bHasChannel) |
if (bHasChannel) |
1241 |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
1242 |
else |
else |
1243 |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear(); |
1244 |
// Session status... |
// Session status... |
1245 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1246 |
m_status[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
m_statusItem[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
1247 |
else |
else |
1248 |
m_status[QSAMPLER_STATUS_SESSION]->clear(); |
m_statusItem[QSAMPLER_STATUS_SESSION]->clear(); |
1249 |
|
|
1250 |
// Recent files menu. |
// Recent files menu. |
1251 |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
1257 |
|
|
1258 |
|
|
1259 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1260 |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1261 |
{ |
{ |
1262 |
|
// Add this strip to the changed list... |
1263 |
|
if (m_changedStrips.containsRef(pChannelStrip) == 0) |
1264 |
|
m_changedStrips.append(pChannelStrip); |
1265 |
|
|
1266 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1267 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1268 |
// and update the form status... |
// and update the form status... |
1270 |
} |
} |
1271 |
|
|
1272 |
|
|
1273 |
|
// Grab and restore current sampler channels session. |
1274 |
|
void qsamplerMainForm::updateSession (void) |
1275 |
|
{ |
1276 |
|
// Retrieve the current channel list. |
1277 |
|
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1278 |
|
if (piChannelIDs == NULL) { |
1279 |
|
if (::lscp_client_get_errno(m_pClient)) { |
1280 |
|
appendMessagesClient("lscp_list_channels"); |
1281 |
|
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1282 |
|
} |
1283 |
|
return; |
1284 |
|
} |
1285 |
|
|
1286 |
|
// Try to (re)create each channel. |
1287 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1288 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1289 |
|
// Check if theres already a channel strip for this one... |
1290 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1291 |
|
createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); |
1292 |
|
// Make it visibly responsive... |
1293 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1294 |
|
} |
1295 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1296 |
|
} |
1297 |
|
|
1298 |
|
|
1299 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
1300 |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
1301 |
{ |
{ |
1340 |
} |
} |
1341 |
|
|
1342 |
|
|
1343 |
|
// Force update of the channels instrument names mode. |
1344 |
|
void qsamplerMainForm::updateInstrumentNames (void) |
1345 |
|
{ |
1346 |
|
// Full channel list update... |
1347 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1348 |
|
if (wlist.isEmpty()) |
1349 |
|
return; |
1350 |
|
|
1351 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1352 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1353 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1354 |
|
if (pChannelStrip) |
1355 |
|
pChannelStrip->updateInstrumentName(true); |
1356 |
|
} |
1357 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1358 |
|
} |
1359 |
|
|
1360 |
|
|
1361 |
// Force update of the channels display font. |
// Force update of the channels display font. |
1362 |
void qsamplerMainForm::updateDisplayFont (void) |
void qsamplerMainForm::updateDisplayFont (void) |
1363 |
{ |
{ |
1523 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
1524 |
|
|
1525 |
// The channel strip creation executive. |
// The channel strip creation executive. |
1526 |
void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt ) |
qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel ) |
1527 |
{ |
{ |
1528 |
if (m_pClient == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
1529 |
return; |
return NULL; |
1530 |
|
|
1531 |
// Prepare for auto-arrange? |
// Prepare for auto-arrange? |
1532 |
qsamplerChannelStrip *pChannelStrip = NULL; |
qsamplerChannelStrip *pChannelStrip = NULL; |
1535 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1536 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1537 |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1538 |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
if (pChannelStrip) { |
1539 |
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1540 |
|
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
1541 |
|
} |
1542 |
} |
} |
1543 |
} |
} |
1544 |
|
|
1545 |
// Add a new channel itema... |
// Add a new channel itema... |
1546 |
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; |
1547 |
pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
1548 |
|
if (pChannelStrip == NULL) |
1549 |
|
return NULL; |
1550 |
|
|
1551 |
|
// Actual channel strip setup... |
1552 |
|
pChannelStrip->setup(pChannel); |
1553 |
|
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
1554 |
// Set some initial aesthetic options... |
// Set some initial aesthetic options... |
1555 |
if (m_pOptions) { |
if (m_pOptions) { |
1556 |
// Background display effect... |
// Background display effect... |
1562 |
// Maximum allowed volume setting. |
// Maximum allowed volume setting. |
1563 |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
1564 |
} |
} |
1565 |
// Actual channel setup. |
|
|
pChannelStrip->setup(this, iChannelID); |
|
|
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
|
|
// Before we show it up, may be we'll |
|
|
// better ask for some initial values? |
|
|
if (bPrompt) |
|
|
pChannelStrip->showChannelSetup(true); |
|
1566 |
// Now we show up us to the world. |
// Now we show up us to the world. |
1567 |
pChannelStrip->show(); |
pChannelStrip->show(); |
1568 |
// Only then, we'll auto-arrange... |
// Only then, we'll auto-arrange... |
1572 |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1573 |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1574 |
} |
} |
1575 |
|
|
1576 |
|
// This is pretty new, so we'll watch for it closely. |
1577 |
|
channelStripChanged(pChannelStrip); |
1578 |
|
|
1579 |
|
// Return our successful reference... |
1580 |
|
return pChannelStrip; |
1581 |
} |
} |
1582 |
|
|
1583 |
|
|
1593 |
{ |
{ |
1594 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1595 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1596 |
return 0; |
return NULL; |
1597 |
|
|
1598 |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
1599 |
} |
} |
1600 |
|
|
1601 |
|
|
1602 |
|
// Retrieve a channel strip by sampler channel id. |
1603 |
|
qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID ) |
1604 |
|
{ |
1605 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1606 |
|
if (wlist.isEmpty()) |
1607 |
|
return NULL; |
1608 |
|
|
1609 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1610 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1611 |
|
if (pChannelStrip) { |
1612 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
1613 |
|
if (pChannel && pChannel->channelID() == iChannelID) |
1614 |
|
return pChannelStrip; |
1615 |
|
} |
1616 |
|
} |
1617 |
|
|
1618 |
|
// Not found. |
1619 |
|
return NULL; |
1620 |
|
} |
1621 |
|
|
1622 |
|
|
1623 |
// Construct the windows menu. |
// Construct the windows menu. |
1624 |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
1625 |
{ |
{ |
1688 |
} |
} |
1689 |
|
|
1690 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
1691 |
if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) { |
if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) { |
1692 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
1693 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
1694 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
1695 |
|
// Update the channel information for each pending strip... |
1696 |
|
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
1697 |
|
pChannelStrip; |
1698 |
|
pChannelStrip = m_changedStrips.next()) { |
1699 |
|
// If successfull, remove from pending list... |
1700 |
|
if (pChannelStrip->updateChannelInfo()) |
1701 |
|
m_changedStrips.remove(pChannelStrip); |
1702 |
|
} |
1703 |
|
// Update the channel stream usage for each strip... |
1704 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1705 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1706 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1898 |
// Log success here. |
// Log success here. |
1899 |
appendMessages(tr("Client connected.")); |
appendMessages(tr("Client connected.")); |
1900 |
|
|
1901 |
|
// Hard-notify device configuration form, |
1902 |
|
// if visible, that we're ready... |
1903 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
1904 |
|
m_pDeviceForm->setClient(m_pClient); |
1905 |
|
|
1906 |
// Is any session pending to be loaded? |
// Is any session pending to be loaded? |
1907 |
if (!m_pOptions->sSessionFile.isEmpty()) { |
if (!m_pOptions->sSessionFile.isEmpty()) { |
1908 |
// Just load the prabably startup session... |
// Just load the prabably startup session... |
1923 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1924 |
return; |
return; |
1925 |
|
|
1926 |
|
// Hard-notify device configuration form, |
1927 |
|
// if visible, that we're running out... |
1928 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
1929 |
|
m_pDeviceForm->setClient(NULL); |
1930 |
|
|
1931 |
// Log prepare here. |
// Log prepare here. |
1932 |
appendMessages(tr("Client disconnecting...")); |
appendMessages(tr("Client disconnecting...")); |
1933 |
|
|