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 |
|
|
691 |
iLine++; |
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 |
// Remember that, no matter what, |
// Remember that, no matter what, |
695 |
// all LSCP commands are CR/LF terminated. |
// all LSCP commands are CR/LF terminated. |
696 |
sCommand += "\r\n"; |
sCommand += "\r\n"; |
697 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
698 |
appendMessagesColor(QString("%1(%2): %3") |
appendMessagesColor(QString("%1(%2): %3") |
699 |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
700 |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
701 |
appendMessagesClient("lscp_client_query"); |
appendMessagesClient("lscp_client_query"); |
702 |
iErrors++; |
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); |
915 |
appendMessagesClient("lscp_get_midi_instrument_info"); |
appendMessagesClient("lscp_get_midi_instrument_info"); |
916 |
iErrors++; |
iErrors++; |
917 |
} |
} |
|
// MIDI device index/id mapping. |
|
|
midiInstrumentMap[iMidiMap] = iMap; |
|
918 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
919 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
920 |
} |
} |
921 |
|
ts << endl; |
922 |
// Check for errors... |
// Check for errors... |
923 |
if (pInstrs) |
if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) { |
|
ts << endl; |
|
|
else if (::lscp_client_get_errno(m_pClient)) { |
|
924 |
appendMessagesClient("lscp_list_midi_instruments"); |
appendMessagesClient("lscp_list_midi_instruments"); |
925 |
iErrors++; |
iErrors++; |
926 |
} |
} |
927 |
|
// MIDI strument index/id mapping. |
928 |
|
midiInstrumentMap[iMidiMap] = iMap; |
929 |
} |
} |
930 |
// Check for errors... |
// Check for errors... |
931 |
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
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) { |
990 |
<< " " << midiInstrumentMap[pChannel->midiMap()] << endl; |
<< " " << midiInstrumentMap[pChannel->midiMap()] << endl; |
991 |
} |
} |
992 |
#endif |
#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_VOLUME |
1037 |
|
ts << "# " << tr("Global volume level") << endl; |
1038 |
|
ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << endl; |
1039 |
|
ts << endl; |
1040 |
|
#endif |
1041 |
|
|
1042 |
// Ok. we've wrote it. |
// Ok. we've wrote it. |
1043 |
file.close(); |
file.close(); |
1044 |
|
|
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)) { |
// Do the actual sampler reset... |
1145 |
#ifdef CONFIG_MIDI_INSTRUMENT |
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
1146 |
// Reset all MIDI instrument mapping, if any. |
appendMessagesClient("lscp_reset_sampler"); |
1147 |
int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient); |
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
1148 |
for (int iMap = 0; piMaps && piMaps[iMap] >= 0; ++iMap) { |
return; |
1149 |
int iMidiMap = piMaps[iMap]; |
} |
|
if (::lscp_clear_midi_instruments(m_pClient, iMidiMap) != LSCP_OK) |
|
|
appendMessagesClient("lscp_clear_midi_instruments"); |
|
|
if (::lscp_remove_midi_instrument_map(m_pClient, iMidiMap) != LSCP_OK) |
|
|
appendMessagesClient("lscp_remove_midi_instrument_map"); |
|
|
} |
|
|
// Check for errors... |
|
|
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) |
|
|
appendMessagesClient("lscp_list_midi_instrument_maps"); |
|
|
#endif // CONFIG_MIDI_INSTRUMENT |
|
|
// actually do the sampler reset... |
|
|
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
|
|
appendMessagesClient("lscp_reset_sampler"); |
|
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
|
|
return; |
|
|
} |
|
|
} |
|
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 |
#ifdef CONFIG_MIDI_INSTRUMENT |
1760 |
// FIXME Make some room for default instrument maps... |
// FIXME: Make some room for default instrument maps... |
1761 |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
1762 |
if (iMaps < 0) |
if (iMaps < 0) |
1763 |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
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()) |
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)); |