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-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, 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 |
32 |
#include <qfile.h> |
#include <qfile.h> |
33 |
#include <qtextstream.h> |
#include <qtextstream.h> |
34 |
#include <qstatusbar.h> |
#include <qstatusbar.h> |
35 |
|
#include <qslider.h> |
36 |
|
#include <qspinbox.h> |
37 |
#include <qlabel.h> |
#include <qlabel.h> |
38 |
#include <qtimer.h> |
#include <qtimer.h> |
39 |
|
#include <qtooltip.h> |
40 |
|
|
41 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
42 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
142 |
::signal(SIGPIPE, SIG_IGN); |
::signal(SIGPIPE, SIG_IGN); |
143 |
#endif |
#endif |
144 |
|
|
145 |
|
#ifdef CONFIG_VOLUME |
146 |
|
// Make some extras into the toolbar... |
147 |
|
channelsToolbar->addSeparator(); |
148 |
|
const QString& sVolumeText = tr("Master volume"); |
149 |
|
m_iVolumeChanging = 0; |
150 |
|
// Volume slider... |
151 |
|
m_pVolumeSlider = new QSlider(Qt::Horizontal, channelsToolbar); |
152 |
|
// m_pVolumeSlider->setTickmarks(QSlider::Below); |
153 |
|
// m_pVolumeSlider->setTickInterval(10); |
154 |
|
m_pVolumeSlider->setPageStep(10); |
155 |
|
m_pVolumeSlider->setRange(0, 100); |
156 |
|
m_pVolumeSlider->setMaximumHeight(22); |
157 |
|
m_pVolumeSlider->setMinimumWidth(160); |
158 |
|
m_pVolumeSlider->setSizePolicy( |
159 |
|
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
160 |
|
QToolTip::add(m_pVolumeSlider, sVolumeText); |
161 |
|
QObject::connect(m_pVolumeSlider, |
162 |
|
SIGNAL(valueChanged(int)), |
163 |
|
SLOT(volumeChanged(int))); |
164 |
|
// Volume spin-box |
165 |
|
m_pVolumeSpinBox = new QSpinBox(channelsToolbar); |
166 |
|
m_pVolumeSpinBox->setSuffix(" %"); |
167 |
|
m_pVolumeSpinBox->setRange(0, 100); |
168 |
|
QToolTip::add(m_pVolumeSpinBox, sVolumeText); |
169 |
|
QObject::connect(m_pVolumeSpinBox, |
170 |
|
SIGNAL(valueChanged(int)), |
171 |
|
SLOT(volumeChanged(int))); |
172 |
|
#endif |
173 |
|
|
174 |
// Make it an MDI workspace. |
// Make it an MDI workspace. |
175 |
m_pWorkspace = new QWorkspace(this); |
m_pWorkspace = new QWorkspace(this); |
176 |
m_pWorkspace->setScrollBarsEnabled(true); |
m_pWorkspace->setScrollBarsEnabled(true); |
177 |
// Set the activation connection. |
// Set the activation connection. |
178 |
QObject::connect(m_pWorkspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(stabilizeForm())); |
QObject::connect(m_pWorkspace, |
179 |
|
SIGNAL(windowActivated(QWidget *)), |
180 |
|
SLOT(stabilizeForm())); |
181 |
// Make it shine :-) |
// Make it shine :-) |
182 |
setCentralWidget(m_pWorkspace); |
setCentralWidget(m_pWorkspace); |
183 |
|
|
247 |
if (m_statusItem[QSAMPLER_STATUS_SESSION]) |
if (m_statusItem[QSAMPLER_STATUS_SESSION]) |
248 |
delete m_statusItem[QSAMPLER_STATUS_SESSION]; |
delete m_statusItem[QSAMPLER_STATUS_SESSION]; |
249 |
|
|
250 |
|
#ifdef CONFIG_VOLUME |
251 |
|
delete m_pVolumeSpinBox; |
252 |
|
delete m_pVolumeSlider; |
253 |
|
#endif |
254 |
|
|
255 |
// Delete recentfiles menu. |
// Delete recentfiles menu. |
256 |
if (m_pRecentFilesMenu) |
if (m_pRecentFilesMenu) |
257 |
delete m_pRecentFilesMenu; |
delete m_pRecentFilesMenu; |
292 |
updateMessagesLimit(); |
updateMessagesLimit(); |
293 |
updateMessagesCapture(); |
updateMessagesCapture(); |
294 |
// Set the visibility signal. |
// Set the visibility signal. |
295 |
QObject::connect(m_pMessages, |
QObject::connect(m_pMessages, |
296 |
SIGNAL(visibilityChanged(bool)), |
SIGNAL(visibilityChanged(bool)), |
297 |
SLOT(stabilizeForm())); |
SLOT(stabilizeForm())); |
298 |
|
|
323 |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
324 |
|
|
325 |
// Final startup stabilization... |
// Final startup stabilization... |
326 |
|
updateMaxVolume(); |
327 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
328 |
stabilizeForm(); |
stabilizeForm(); |
329 |
|
|
444 |
m_iDirtyCount++; |
m_iDirtyCount++; |
445 |
stabilizeForm(); |
stabilizeForm(); |
446 |
} // Otherwise, load an usual session file (LSCP script)... |
} // Otherwise, load an usual session file (LSCP script)... |
447 |
else if (closeSession(true)) |
else if (closeSession(true)) { |
448 |
loadSessionFile(sPath); |
loadSessionFile(sPath); |
449 |
|
break; |
450 |
|
} |
451 |
// Make it look responsive...:) |
// Make it look responsive...:) |
452 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
453 |
} |
} |
678 |
return false; |
return false; |
679 |
} |
} |
680 |
|
|
681 |
|
// Tell the world we'll take some time... |
682 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
683 |
|
|
684 |
// Read the file. |
// Read the file. |
685 |
|
int iLine = 0; |
686 |
int iErrors = 0; |
int iErrors = 0; |
687 |
QTextStream ts(&file); |
QTextStream ts(&file); |
688 |
while (!ts.atEnd()) { |
while (!ts.atEnd()) { |
689 |
// Read the line. |
// Read the line. |
690 |
QString sCommand = ts.readLine().stripWhiteSpace(); |
QString sCommand = ts.readLine().stripWhiteSpace(); |
691 |
|
iLine++; |
692 |
// If not empty, nor a comment, call the server... |
// If not empty, nor a comment, call the server... |
693 |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
694 |
appendMessagesColor(sCommand, "#996633"); |
// Remember that, no matter what, |
695 |
// Remember that, no matter what, |
// all LSCP commands are CR/LF terminated. |
696 |
// all LSCP commands are CR/LF terminated. |
sCommand += "\r\n"; |
697 |
sCommand += "\r\n"; |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
698 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
appendMessagesColor(QString("%1(%2): %3") |
699 |
appendMessagesClient("lscp_client_query"); |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
700 |
iErrors++; |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
701 |
} |
appendMessagesClient("lscp_client_query"); |
702 |
|
iErrors++; |
703 |
|
} |
704 |
} |
} |
705 |
// Try to make it snappy :) |
// Try to make it snappy :) |
706 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
712 |
// Now we'll try to create (update) the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
713 |
updateSession(); |
updateSession(); |
714 |
|
|
715 |
|
// We're fornerly done. |
716 |
|
QApplication::restoreOverrideCursor(); |
717 |
|
|
718 |
// Have we any errors? |
// Have we any errors? |
719 |
if (iErrors > 0) |
if (iErrors > 0) |
720 |
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
738 |
// Save current session to specific file path. |
// Save current session to specific file path. |
739 |
bool qsamplerMainForm::saveSessionFile ( const QString& sFilename ) |
bool qsamplerMainForm::saveSessionFile ( const QString& sFilename ) |
740 |
{ |
{ |
741 |
|
if (m_pClient == NULL) |
742 |
|
return false; |
743 |
|
|
744 |
|
// Check whether server is apparently OK... |
745 |
|
if (::lscp_get_channels(m_pClient) < 0) { |
746 |
|
appendMessagesClient("lscp_get_channels"); |
747 |
|
return false; |
748 |
|
} |
749 |
|
|
750 |
// Open and write into real file. |
// Open and write into real file. |
751 |
QFile file(sFilename); |
QFile file(sFilename); |
752 |
if (!file.open(IO_WriteOnly | IO_Truncate)) { |
if (!file.open(IO_WriteOnly | IO_Truncate)) { |
754 |
return false; |
return false; |
755 |
} |
} |
756 |
|
|
757 |
|
// Tell the world we'll take some time... |
758 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
759 |
|
|
760 |
// Write the file. |
// Write the file. |
761 |
int iErrors = 0; |
int iErrors = 0; |
762 |
QTextStream ts(&file); |
QTextStream ts(&file); |
773 |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
774 |
ts << "#" << endl; |
ts << "#" << endl; |
775 |
ts << endl; |
ts << endl; |
776 |
|
|
777 |
// It is assumed that this new kind of device+session file |
// It is assumed that this new kind of device+session file |
778 |
// will be loaded from a complete |
// will be loaded from a complete initialized server... |
779 |
int *piDeviceIDs; |
int *piDeviceIDs; |
780 |
int iDevice; |
int iDevice; |
781 |
ts << "RESET" << endl; |
ts << "RESET" << endl; |
782 |
|
|
783 |
// Audio device mapping. |
// Audio device mapping. |
784 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; |
785 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
817 |
} |
} |
818 |
// Audio device index/id mapping. |
// Audio device index/id mapping. |
819 |
audioDeviceMap[device.deviceID()] = iDevice; |
audioDeviceMap[device.deviceID()] = iDevice; |
820 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
821 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
822 |
} |
} |
823 |
|
|
824 |
// MIDI device mapping. |
// MIDI device mapping. |
825 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; |
826 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
858 |
} |
} |
859 |
// MIDI device index/id mapping. |
// MIDI device index/id mapping. |
860 |
midiDeviceMap[device.deviceID()] = iDevice; |
midiDeviceMap[device.deviceID()] = iDevice; |
861 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
862 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
863 |
} |
} |
864 |
ts << endl; |
ts << endl; |
865 |
|
|
866 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
867 |
|
// MIDI instrument mapping... |
868 |
|
QMap<int, int> midiInstrumentMap; |
869 |
|
int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient); |
870 |
|
for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) { |
871 |
|
int iMidiMap = piMaps[iMap]; |
872 |
|
const char *pszMapName |
873 |
|
= ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap); |
874 |
|
ts << "# " << tr("MIDI instrument map") << " " << iMap; |
875 |
|
if (pszMapName) |
876 |
|
ts << " - " << pszMapName; |
877 |
|
ts << endl; |
878 |
|
ts << "ADD MIDI_INSTRUMENT_MAP"; |
879 |
|
if (pszMapName) |
880 |
|
ts << " '" << pszMapName << "'"; |
881 |
|
ts << endl; |
882 |
|
// MIDI instrument mapping... |
883 |
|
lscp_midi_instrument_t *pInstrs |
884 |
|
= ::lscp_list_midi_instruments(m_pClient, iMidiMap); |
885 |
|
for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; iInstr++) { |
886 |
|
lscp_midi_instrument_info_t *pInstrInfo |
887 |
|
= ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]); |
888 |
|
if (pInstrInfo) { |
889 |
|
ts << "MAP MIDI_INSTRUMENT " |
890 |
|
<< iMap << " " |
891 |
|
<< pInstrs[iInstr].bank << " " |
892 |
|
<< pInstrs[iInstr].prog << " " |
893 |
|
<< pInstrInfo->engine_name << " '" |
894 |
|
<< pInstrInfo->instrument_file << "' " |
895 |
|
<< pInstrInfo->instrument_nr << " " |
896 |
|
<< pInstrInfo->volume << " "; |
897 |
|
switch (pInstrInfo->load_mode) { |
898 |
|
case LSCP_LOAD_PERSISTENT: |
899 |
|
ts << "PERSISTENT"; |
900 |
|
break; |
901 |
|
case LSCP_LOAD_ON_DEMAND_HOLD: |
902 |
|
ts << "ON_DEMAND_HOLD"; |
903 |
|
break; |
904 |
|
case LSCP_LOAD_ON_DEMAND: |
905 |
|
case LSCP_LOAD_DEFAULT: |
906 |
|
default: |
907 |
|
ts << "ON_DEMAND"; |
908 |
|
break; |
909 |
|
} |
910 |
|
if (pInstrInfo->name) |
911 |
|
ts << " '" << pInstrInfo->name << "'"; |
912 |
|
ts << endl; |
913 |
|
} // Check for errors... |
914 |
|
else if (::lscp_client_get_errno(m_pClient)) { |
915 |
|
appendMessagesClient("lscp_get_midi_instrument_info"); |
916 |
|
iErrors++; |
917 |
|
} |
918 |
|
// Try to keep it snappy :) |
919 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
920 |
|
} |
921 |
|
ts << endl; |
922 |
|
// Check for errors... |
923 |
|
if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) { |
924 |
|
appendMessagesClient("lscp_list_midi_instruments"); |
925 |
|
iErrors++; |
926 |
|
} |
927 |
|
// MIDI strument index/id mapping. |
928 |
|
midiInstrumentMap[iMidiMap] = iMap; |
929 |
|
} |
930 |
|
// Check for errors... |
931 |
|
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
932 |
|
appendMessagesClient("lscp_list_midi_instrument_maps"); |
933 |
|
iErrors++; |
934 |
|
} |
935 |
|
#endif // CONFIG_MIDI_INSTRUMENT |
936 |
|
|
937 |
// Sampler channel mapping. |
// Sampler channel mapping. |
938 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
939 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
940 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip |
941 |
|
= static_cast<qsamplerChannelStrip *> (wlist.at(iChannel)); |
942 |
if (pChannelStrip) { |
if (pChannelStrip) { |
943 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
944 |
if (pChannel) { |
if (pChannel) { |
967 |
ts << pChannel->midiChannel(); |
ts << pChannel->midiChannel(); |
968 |
ts << endl; |
ts << endl; |
969 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
970 |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
if (pChannel->instrumentStatus() < 100) ts << "# "; |
971 |
|
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " |
972 |
|
<< pChannel->instrumentNr() << " " << iChannel << endl; |
973 |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
974 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
975 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
978 |
<< " " << audioRoute.key() |
<< " " << audioRoute.key() |
979 |
<< " " << audioRoute.data() << endl; |
<< " " << audioRoute.data() << endl; |
980 |
} |
} |
981 |
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL VOLUME " << iChannel |
982 |
|
<< " " << pChannel->volume() << endl; |
983 |
if (pChannel->channelMute()) |
if (pChannel->channelMute()) |
984 |
ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl; |
ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl; |
985 |
if (pChannel->channelSolo()) |
if (pChannel->channelSolo()) |
986 |
ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl; |
ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl; |
987 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
988 |
|
if (pChannel->midiMap() >= 0) { |
989 |
|
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel |
990 |
|
<< " " << midiInstrumentMap[pChannel->midiMap()] << endl; |
991 |
|
} |
992 |
|
#endif |
993 |
|
#ifdef CONFIG_FXSEND |
994 |
|
int iChannelID = pChannel->channelID(); |
995 |
|
int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID); |
996 |
|
for (int iFxSend = 0; |
997 |
|
piFxSends && piFxSends[iFxSend] >= 0; |
998 |
|
iFxSend++) { |
999 |
|
lscp_fxsend_info_t *pFxSendInfo = ::lscp_get_fxsend_info( |
1000 |
|
m_pClient, iChannelID, piFxSends[iFxSend]); |
1001 |
|
if (pFxSendInfo) { |
1002 |
|
ts << "CREATE FX_SEND " << iChannel |
1003 |
|
<< " " << pFxSendInfo->midi_controller; |
1004 |
|
if (pFxSendInfo->name) |
1005 |
|
ts << " '" << pFxSendInfo->name << "'"; |
1006 |
|
ts << endl; |
1007 |
|
int *piRouting = pFxSendInfo->audio_routing; |
1008 |
|
for (int iAudioSrc = 0; |
1009 |
|
piRouting && piRouting[iAudioSrc] >= 0; |
1010 |
|
iAudioSrc++) { |
1011 |
|
ts << "SET FX_SEND AUDIO_OUTPUT_CHANNEL " |
1012 |
|
<< iChannel |
1013 |
|
<< " " << iFxSend |
1014 |
|
<< " " << iAudioSrc |
1015 |
|
<< " " << piRouting[iAudioSrc] << endl; |
1016 |
|
} |
1017 |
|
#ifdef CONFIG_FXSEND_LEVEL |
1018 |
|
ts << "SET FX_SEND LEVEL " << iChannel |
1019 |
|
<< " " << iFxSend |
1020 |
|
<< " " << pFxSendInfo->level << endl; |
1021 |
|
#endif |
1022 |
|
} // Check for errors... |
1023 |
|
else if (::lscp_client_get_errno(m_pClient)) { |
1024 |
|
appendMessagesClient("lscp_get_fxsend_info"); |
1025 |
|
iErrors++; |
1026 |
|
} |
1027 |
|
} |
1028 |
|
#endif |
1029 |
ts << endl; |
ts << endl; |
1030 |
} |
} |
1031 |
} |
} |
1033 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1034 |
} |
} |
1035 |
|
|
1036 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_VOLUME |
1037 |
// MIDI instrument mapping... |
ts << "# " << tr("Global volume level") << endl; |
1038 |
lscp_midi_instrument_t *pInstrs = ::lscp_list_midi_instruments(m_pClient); |
ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << endl; |
1039 |
if (pInstrs) |
ts << endl; |
1040 |
ts << "# " << tr("MIDI instrument mapping") << endl; |
#endif |
|
for (int iInstr = 0; pInstrs && pInstrs[iInstr].program >= 0; iInstr++) { |
|
|
lscp_midi_instrument_info_t *pInstrInfo |
|
|
= ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]); |
|
|
if (pInstrInfo) { |
|
|
ts << "MAP MIDI_INSTRUMENT " |
|
|
<< pInstrs[iInstr].bank_msb << " " |
|
|
<< pInstrs[iInstr].bank_lsb << " " |
|
|
<< pInstrs[iInstr].program << " " |
|
|
<< pInstrInfo->engine_name << " '" |
|
|
<< pInstrInfo->instrument_file << "' " |
|
|
<< pInstrInfo->instrument_nr << " " |
|
|
<< pInstrInfo->volume << " "; |
|
|
switch (pInstrInfo->load_mode) { |
|
|
case LSCP_LOAD_PERSISTENT: |
|
|
ts << "PERSISTENT"; |
|
|
break; |
|
|
case LSCP_LOAD_ON_DEMAND_HOLD: |
|
|
ts << "ON_DEMAND_HOLD"; |
|
|
break; |
|
|
case LSCP_LOAD_ON_DEMAND: |
|
|
case LSCP_LOAD_DEFAULT: |
|
|
default: |
|
|
ts << "ON_DEMAND"; |
|
|
break; |
|
|
} |
|
|
if (pInstrInfo->name) |
|
|
ts << " '" << pInstrInfo->name << "'"; |
|
|
ts << endl; |
|
|
} |
|
|
// Try to keep it snappy :) |
|
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
|
|
} |
|
|
if (pInstrs) |
|
|
ts << endl; |
|
|
#endif // CONFIG_MIDI_INSTRUMENT |
|
1041 |
|
|
1042 |
// Ok. we've wrote it. |
// Ok. we've wrote it. |
1043 |
file.close(); |
file.close(); |
1044 |
|
|
1045 |
|
// We're fornerly done. |
1046 |
|
QApplication::restoreOverrideCursor(); |
1047 |
|
|
1048 |
// Have we any errors? |
// Have we any errors? |
1049 |
if (iErrors > 0) |
if (iErrors > 0) |
1050 |
appendMessagesError(tr("Some settings could not be saved\nto \"%1\" session file.\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Some settings could not be saved\nto \"%1\" session file.\n\nSorry.").arg(sFilename)); |
1136 |
tr("Reset"), tr("Cancel")) > 0) |
tr("Reset"), tr("Cancel")) > 0) |
1137 |
return; |
return; |
1138 |
|
|
1139 |
|
// Trye closing the current session, first... |
1140 |
|
if (!closeSession(true)) |
1141 |
|
return; |
1142 |
|
|
1143 |
// Just do the reset, after closing down current session... |
// Just do the reset, after closing down current session... |
1144 |
if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
// Do the actual sampler reset... |
1145 |
appendMessagesClient("lscp_reset_sampler"); |
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
1146 |
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
appendMessagesClient("lscp_reset_sampler"); |
1147 |
return; |
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
1148 |
} |
return; |
1149 |
|
} |
1150 |
|
|
1151 |
// Log this. |
// Log this. |
1152 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |
1580 |
sText += tr("Sampler channel Mute/Solo support disabled."); |
sText += tr("Sampler channel Mute/Solo support disabled."); |
1581 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1582 |
#endif |
#endif |
1583 |
|
#ifndef CONFIG_AUDIO_ROUTING |
1584 |
|
sText += "<small><font color=\"red\">"; |
1585 |
|
sText += tr("LSCP (liblscp) audio_routing support disabled."); |
1586 |
|
sText += "</font></small><br />"; |
1587 |
|
#endif |
1588 |
|
#ifndef CONFIG_FXSEND |
1589 |
|
sText += "<small><font color=\"red\">"; |
1590 |
|
sText += tr("Sampler channel Effect Sends support disabled."); |
1591 |
|
sText += "</font></small><br />"; |
1592 |
|
#endif |
1593 |
|
#ifndef CONFIG_VOLUME |
1594 |
|
sText += "<small><font color=\"red\">"; |
1595 |
|
sText += tr("Global volume support disabled."); |
1596 |
|
sText += "</font></small><br />"; |
1597 |
|
#endif |
1598 |
#ifndef CONFIG_MIDI_INSTRUMENT |
#ifndef CONFIG_MIDI_INSTRUMENT |
1599 |
sText += "<small><font color=\"red\">"; |
sText += "<small><font color=\"red\">"; |
1600 |
sText += tr("MIDI instrument mapping support disabled."); |
sText += tr("MIDI instrument mapping support disabled."); |
1664 |
viewDevicesAction->setEnabled(bHasClient); |
viewDevicesAction->setEnabled(bHasClient); |
1665 |
channelsArrangeAction->setEnabled(bHasChannel); |
channelsArrangeAction->setEnabled(bHasChannel); |
1666 |
|
|
1667 |
|
#ifdef CONFIG_VOLUME |
1668 |
|
// Toolbar widgets are also affected... |
1669 |
|
m_pVolumeSlider->setEnabled(bHasClient); |
1670 |
|
m_pVolumeSpinBox->setEnabled(bHasClient); |
1671 |
|
#endif |
1672 |
|
|
1673 |
// Client/Server status... |
// Client/Server status... |
1674 |
if (bHasClient) { |
if (bHasClient) { |
1675 |
m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
1698 |
} |
} |
1699 |
|
|
1700 |
|
|
1701 |
|
// Global volume change receiver slot. |
1702 |
|
void qsamplerMainForm::volumeChanged ( int iVolume ) |
1703 |
|
{ |
1704 |
|
#ifdef CONFIG_VOLUME |
1705 |
|
|
1706 |
|
if (m_iVolumeChanging > 0) |
1707 |
|
return; |
1708 |
|
|
1709 |
|
m_iVolumeChanging++; |
1710 |
|
|
1711 |
|
// Update the toolbar widgets... |
1712 |
|
if (m_pVolumeSlider->value() != iVolume) |
1713 |
|
m_pVolumeSlider->setValue(iVolume); |
1714 |
|
if (m_pVolumeSpinBox->value() != iVolume) |
1715 |
|
m_pVolumeSpinBox->setValue(iVolume); |
1716 |
|
|
1717 |
|
// Do it as commanded... |
1718 |
|
float fVolume = 0.01f * float(iVolume); |
1719 |
|
if (::lscp_set_volume(m_pClient, fVolume) == LSCP_OK) |
1720 |
|
appendMessages(QObject::tr("Volume: %1.").arg(fVolume)); |
1721 |
|
else |
1722 |
|
appendMessagesClient("lscp_set_channel_volume"); |
1723 |
|
|
1724 |
|
m_iVolumeChanging--; |
1725 |
|
|
1726 |
|
m_iDirtyCount++; |
1727 |
|
stabilizeForm(); |
1728 |
|
|
1729 |
|
#endif |
1730 |
|
} |
1731 |
|
|
1732 |
|
|
1733 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1734 |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1735 |
{ |
{ |
1749 |
// Grab and restore current sampler channels session. |
// Grab and restore current sampler channels session. |
1750 |
void qsamplerMainForm::updateSession (void) |
void qsamplerMainForm::updateSession (void) |
1751 |
{ |
{ |
1752 |
|
#ifdef CONFIG_VOLUME |
1753 |
|
int iVolume = 100.0f * ::lscp_get_volume(m_pClient); |
1754 |
|
m_iVolumeChanging++; |
1755 |
|
m_pVolumeSlider->setValue(iVolume); |
1756 |
|
m_pVolumeSpinBox->setValue(iVolume); |
1757 |
|
m_iVolumeChanging--; |
1758 |
|
#endif |
1759 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
1760 |
|
// FIXME: Make some room for default instrument maps... |
1761 |
|
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
1762 |
|
if (iMaps < 0) |
1763 |
|
appendMessagesClient("lscp_get_midi_instrument_maps"); |
1764 |
|
else if (iMaps < 1) { |
1765 |
|
::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1()); |
1766 |
|
::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1()); |
1767 |
|
} |
1768 |
|
#endif |
1769 |
|
|
1770 |
// Retrieve the current channel list. |
// Retrieve the current channel list. |
1771 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1772 |
if (piChannelIDs == NULL) { |
if (piChannelIDs == NULL) { |
1774 |
appendMessagesClient("lscp_list_channels"); |
appendMessagesClient("lscp_list_channels"); |
1775 |
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1776 |
} |
} |
1777 |
return; |
} else { |
1778 |
|
// Try to (re)create each channel. |
1779 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1780 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1781 |
|
// Check if theres already a channel strip for this one... |
1782 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1783 |
|
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
1784 |
|
} |
1785 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1786 |
} |
} |
1787 |
|
|
1788 |
// Try to (re)create each channel. |
// Do we auto-arrange? |
1789 |
m_pWorkspace->setUpdatesEnabled(false); |
if (m_pOptions && m_pOptions->bAutoArrange) |
1790 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
channelsArrange(); |
1791 |
// Check if theres already a channel strip for this one... |
|
|
if (!channelStrip(piChannelIDs[iChannel])) |
|
|
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
|
|
// Make it visibly responsive... |
|
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
|
|
} |
|
|
m_pWorkspace->setUpdatesEnabled(true); |
|
|
|
|
1792 |
// Remember to refresh devices and instruments... |
// Remember to refresh devices and instruments... |
1793 |
if (m_pInstrumentListForm) |
if (m_pInstrumentListForm) |
1794 |
m_pInstrumentListForm->refreshInstruments(); |
m_pInstrumentListForm->refreshInstruments(); |
1916 |
if (m_pOptions == NULL) |
if (m_pOptions == NULL) |
1917 |
return; |
return; |
1918 |
|
|
1919 |
|
#ifdef CONFIG_VOLUME |
1920 |
|
m_iVolumeChanging++; |
1921 |
|
m_pVolumeSlider->setMaxValue(m_pOptions->iMaxVolume); |
1922 |
|
m_pVolumeSpinBox->setMaxValue(m_pOptions->iMaxVolume); |
1923 |
|
m_iVolumeChanging--; |
1924 |
|
#endif |
1925 |
|
|
1926 |
// Full channel list update... |
// Full channel list update... |
1927 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1928 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1971 |
|
|
1972 |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
1973 |
|
|
1974 |
|
// Make it look responsive...:) |
1975 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1976 |
|
|
1977 |
QMessageBox::critical(this, |
QMessageBox::critical(this, |
1978 |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
1979 |
} |
} |
1988 |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
1989 |
.arg(::lscp_client_get_result(m_pClient)) |
.arg(::lscp_client_get_result(m_pClient)) |
1990 |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
1991 |
|
|
1992 |
|
// Make it look responsive...:) |
1993 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1994 |
} |
} |
1995 |
|
|
1996 |
|
|
2065 |
|
|
2066 |
// Actual channel strip setup... |
// Actual channel strip setup... |
2067 |
pChannelStrip->setup(pChannel); |
pChannelStrip->setup(pChannel); |
2068 |
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
QObject::connect(pChannelStrip, |
2069 |
|
SIGNAL(channelChanged(qsamplerChannelStrip *)), |
2070 |
|
SLOT(channelStripChanged(qsamplerChannelStrip *))); |
2071 |
// Set some initial aesthetic options... |
// Set some initial aesthetic options... |
2072 |
if (m_pOptions) { |
if (m_pOptions) { |
2073 |
// Background display effect... |
// Background display effect... |
2274 |
m_pServer = new QProcess(this); |
m_pServer = new QProcess(this); |
2275 |
|
|
2276 |
// Setup stdout/stderr capture... |
// Setup stdout/stderr capture... |
2277 |
//if (m_pOptions->bStdoutCapture) { |
// if (m_pOptions->bStdoutCapture) { |
2278 |
m_pServer->setCommunication(QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr); |
m_pServer->setCommunication( |
2279 |
QObject::connect(m_pServer, SIGNAL(readyReadStdout()), this, SLOT(readServerStdout())); |
QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr); |
2280 |
QObject::connect(m_pServer, SIGNAL(readyReadStderr()), this, SLOT(readServerStdout())); |
QObject::connect(m_pServer, |
2281 |
//} |
SIGNAL(readyReadStdout()), |
2282 |
// The unforgiveable signal communication... |
SLOT(readServerStdout())); |
2283 |
QObject::connect(m_pServer, SIGNAL(processExited()), this, SLOT(processServerExit())); |
QObject::connect(m_pServer, |
2284 |
|
SIGNAL(readyReadStderr()), |
2285 |
|
SLOT(readServerStdout())); |
2286 |
|
// } |
2287 |
|
// The unforgiveable signal communication... |
2288 |
|
QObject::connect(m_pServer, |
2289 |
|
SIGNAL(processExited()), |
2290 |
|
SLOT(processServerExit())); |
2291 |
|
|
2292 |
// Build process arguments... |
// Build process arguments... |
2293 |
m_pServer->setArguments(QStringList::split(' ', m_pOptions->sServerCmdLine)); |
m_pServer->setArguments(QStringList::split(' ', m_pOptions->sServerCmdLine)); |