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 |
142 |
// Make it an MDI workspace. |
// Make it an MDI workspace. |
143 |
m_pWorkspace = new QWorkspace(this); |
m_pWorkspace = new QWorkspace(this); |
144 |
m_pWorkspace->setScrollBarsEnabled(true); |
m_pWorkspace->setScrollBarsEnabled(true); |
145 |
// Set the activation connection. |
// Set the activation connection. |
146 |
QObject::connect(m_pWorkspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(stabilizeForm())); |
QObject::connect(m_pWorkspace, |
147 |
|
SIGNAL(windowActivated(QWidget *)), |
148 |
|
SLOT(stabilizeForm())); |
149 |
// Make it shine :-) |
// Make it shine :-) |
150 |
setCentralWidget(m_pWorkspace); |
setCentralWidget(m_pWorkspace); |
151 |
|
|
255 |
updateMessagesLimit(); |
updateMessagesLimit(); |
256 |
updateMessagesCapture(); |
updateMessagesCapture(); |
257 |
// Set the visibility signal. |
// Set the visibility signal. |
258 |
QObject::connect(m_pMessages, |
QObject::connect(m_pMessages, |
259 |
SIGNAL(visibilityChanged(bool)), |
SIGNAL(visibilityChanged(bool)), |
260 |
SLOT(stabilizeForm())); |
SLOT(stabilizeForm())); |
261 |
|
|
406 |
m_iDirtyCount++; |
m_iDirtyCount++; |
407 |
stabilizeForm(); |
stabilizeForm(); |
408 |
} // Otherwise, load an usual session file (LSCP script)... |
} // Otherwise, load an usual session file (LSCP script)... |
409 |
else if (closeSession(true)) |
else if (closeSession(true)) { |
410 |
loadSessionFile(sPath); |
loadSessionFile(sPath); |
411 |
|
break; |
412 |
|
} |
413 |
// Make it look responsive...:) |
// Make it look responsive...:) |
414 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
415 |
} |
} |
640 |
return false; |
return false; |
641 |
} |
} |
642 |
|
|
643 |
|
// Tell the world we'll take some time... |
644 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
645 |
|
|
646 |
// Read the file. |
// Read the file. |
647 |
|
int iLine = 0; |
648 |
int iErrors = 0; |
int iErrors = 0; |
649 |
QTextStream ts(&file); |
QTextStream ts(&file); |
650 |
while (!ts.atEnd()) { |
while (!ts.atEnd()) { |
651 |
// Read the line. |
// Read the line. |
652 |
QString sCommand = ts.readLine().stripWhiteSpace(); |
QString sCommand = ts.readLine().stripWhiteSpace(); |
653 |
|
iLine++; |
654 |
// If not empty, nor a comment, call the server... |
// If not empty, nor a comment, call the server... |
655 |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
656 |
appendMessagesColor(sCommand, "#996633"); |
// Remember that, no matter what, |
657 |
// Remember that, no matter what, |
// all LSCP commands are CR/LF terminated. |
658 |
// all LSCP commands are CR/LF terminated. |
sCommand += "\r\n"; |
659 |
sCommand += "\r\n"; |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
660 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
appendMessagesColor(QString("%1(%2): %3") |
661 |
appendMessagesClient("lscp_client_query"); |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
662 |
iErrors++; |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
663 |
} |
appendMessagesClient("lscp_client_query"); |
664 |
|
iErrors++; |
665 |
|
} |
666 |
} |
} |
667 |
// Try to make it snappy :) |
// Try to make it snappy :) |
668 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
674 |
// Now we'll try to create (update) the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
675 |
updateSession(); |
updateSession(); |
676 |
|
|
677 |
|
// We're fornerly done. |
678 |
|
QApplication::restoreOverrideCursor(); |
679 |
|
|
680 |
// Have we any errors? |
// Have we any errors? |
681 |
if (iErrors > 0) |
if (iErrors > 0) |
682 |
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
716 |
return false; |
return false; |
717 |
} |
} |
718 |
|
|
719 |
|
// Tell the world we'll take some time... |
720 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
721 |
|
|
722 |
// Write the file. |
// Write the file. |
723 |
int iErrors = 0; |
int iErrors = 0; |
724 |
QTextStream ts(&file); |
QTextStream ts(&file); |
872 |
if (pInstrInfo->name) |
if (pInstrInfo->name) |
873 |
ts << " '" << pInstrInfo->name << "'"; |
ts << " '" << pInstrInfo->name << "'"; |
874 |
ts << endl; |
ts << endl; |
875 |
|
} // Check for errors... |
876 |
|
else if (::lscp_client_get_errno(m_pClient)) { |
877 |
|
appendMessagesClient("lscp_get_midi_instrument_info"); |
878 |
|
iErrors++; |
879 |
} |
} |
|
// MIDI device index/id mapping. |
|
|
midiInstrumentMap[iMidiMap] = iMap; |
|
880 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
881 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
882 |
} |
} |
883 |
if (pInstrs) |
ts << endl; |
884 |
ts << endl; |
// Check for errors... |
885 |
|
if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) { |
886 |
|
appendMessagesClient("lscp_list_midi_instruments"); |
887 |
|
iErrors++; |
888 |
|
} |
889 |
|
// MIDI strument index/id mapping. |
890 |
|
midiInstrumentMap[iMidiMap] = iMap; |
891 |
|
} |
892 |
|
// Check for errors... |
893 |
|
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
894 |
|
appendMessagesClient("lscp_list_midi_instrument_maps"); |
895 |
|
iErrors++; |
896 |
} |
} |
897 |
#endif // CONFIG_MIDI_INSTRUMENT |
#endif // CONFIG_MIDI_INSTRUMENT |
898 |
|
|
899 |
|
#ifdef CONFIG_FXSEND |
900 |
|
int iFxSend = 0; |
901 |
|
#endif |
902 |
// Sampler channel mapping. |
// Sampler channel mapping. |
903 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
904 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
905 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip |
906 |
|
= static_cast<qsamplerChannelStrip *> (wlist.at(iChannel)); |
907 |
if (pChannelStrip) { |
if (pChannelStrip) { |
908 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
909 |
if (pChannel) { |
if (pChannel) { |
955 |
<< " " << midiInstrumentMap[pChannel->midiMap()] << endl; |
<< " " << midiInstrumentMap[pChannel->midiMap()] << endl; |
956 |
} |
} |
957 |
#endif |
#endif |
958 |
|
#ifdef CONFIG_FXSEND |
959 |
|
int iChannelID = pChannel->channelID(); |
960 |
|
int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID); |
961 |
|
for (int iFx = 0; piFxSends && piFxSends[iFx] >= 0; iFx++) { |
962 |
|
lscp_fxsend_info_t *pFxSendInfo |
963 |
|
= ::lscp_get_fxsend_info(m_pClient, iChannelID, piFxSends[iFx]); |
964 |
|
if (pFxSendInfo) { |
965 |
|
ts << "CREATE FX_SEND " << iChannel |
966 |
|
<< " " << pFxSendInfo->midi_controller; |
967 |
|
if (pFxSendInfo->name) |
968 |
|
ts << " '" << pFxSendInfo->name << "'"; |
969 |
|
ts << endl; |
970 |
|
int *piRouting = pFxSendInfo->audio_routing; |
971 |
|
for (int i = 0; piRouting && piRouting[i] >= 0; i++) { |
972 |
|
ts << "SET FX_SEND AUDIO_OUTPUT_CHANNEL " << iChannel |
973 |
|
<< " " << iFxSend |
974 |
|
<< " " << i << " " << piRouting[i] << endl; |
975 |
|
} |
976 |
|
// Increment logical FX send identifier... |
977 |
|
iFxSend++; |
978 |
|
} // Check for errors... |
979 |
|
else if (::lscp_client_get_errno(m_pClient)) { |
980 |
|
appendMessagesClient("lscp_get_fxsend_info"); |
981 |
|
iErrors++; |
982 |
|
} |
983 |
|
} |
984 |
|
#endif |
985 |
ts << endl; |
ts << endl; |
986 |
} |
} |
987 |
} |
} |
992 |
// Ok. we've wrote it. |
// Ok. we've wrote it. |
993 |
file.close(); |
file.close(); |
994 |
|
|
995 |
|
// We're fornerly done. |
996 |
|
QApplication::restoreOverrideCursor(); |
997 |
|
|
998 |
// Have we any errors? |
// Have we any errors? |
999 |
if (iErrors > 0) |
if (iErrors > 0) |
1000 |
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)); |
1086 |
tr("Reset"), tr("Cancel")) > 0) |
tr("Reset"), tr("Cancel")) > 0) |
1087 |
return; |
return; |
1088 |
|
|
1089 |
|
// Trye closing the current session, first... |
1090 |
|
if (!closeSession(true)) |
1091 |
|
return; |
1092 |
|
|
1093 |
// Just do the reset, after closing down current session... |
// Just do the reset, after closing down current session... |
1094 |
if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
// Do the actual sampler reset... |
1095 |
appendMessagesClient("lscp_reset_sampler"); |
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
1096 |
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
appendMessagesClient("lscp_reset_sampler"); |
1097 |
return; |
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
1098 |
} |
return; |
1099 |
|
} |
1100 |
|
|
1101 |
// Log this. |
// Log this. |
1102 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |
1530 |
sText += tr("Sampler channel Mute/Solo support disabled."); |
sText += tr("Sampler channel Mute/Solo support disabled."); |
1531 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1532 |
#endif |
#endif |
1533 |
|
#ifndef CONFIG_AUDIO_ROUTING |
1534 |
|
sText += "<small><font color=\"red\">"; |
1535 |
|
sText += tr("LSCP (liblscp) audio_routing support disabled."); |
1536 |
|
sText += "</font></small><br />"; |
1537 |
|
#endif |
1538 |
|
#ifndef CONFIG_FXSEND |
1539 |
|
sText += "<small><font color=\"red\">"; |
1540 |
|
sText += tr("Sampler channel Effect Sends support disabled."); |
1541 |
|
sText += "</font></small><br />"; |
1542 |
|
#endif |
1543 |
#ifndef CONFIG_MIDI_INSTRUMENT |
#ifndef CONFIG_MIDI_INSTRUMENT |
1544 |
sText += "<small><font color=\"red\">"; |
sText += "<small><font color=\"red\">"; |
1545 |
sText += tr("MIDI instrument mapping support disabled."); |
sText += tr("MIDI instrument mapping support disabled."); |
1657 |
void qsamplerMainForm::updateSession (void) |
void qsamplerMainForm::updateSession (void) |
1658 |
{ |
{ |
1659 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1660 |
// FIXME Make some room for default instrument maps... |
// FIXME: Make some room for default instrument maps... |
1661 |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
1662 |
if (iMaps < 0) |
if (iMaps < 0) |
1663 |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
1674 |
appendMessagesClient("lscp_list_channels"); |
appendMessagesClient("lscp_list_channels"); |
1675 |
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1676 |
} |
} |
1677 |
return; |
} else { |
1678 |
|
// Try to (re)create each channel. |
1679 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1680 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1681 |
|
// Check if theres already a channel strip for this one... |
1682 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1683 |
|
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
1684 |
|
} |
1685 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1686 |
} |
} |
1687 |
|
|
1688 |
// Try to (re)create each channel. |
// Do we auto-arrange? |
1689 |
m_pWorkspace->setUpdatesEnabled(false); |
if (m_pOptions && m_pOptions->bAutoArrange) |
1690 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
channelsArrange(); |
|
// 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); |
|
1691 |
|
|
1692 |
// Remember to refresh devices and instruments... |
// Remember to refresh devices and instruments... |
1693 |
if (m_pInstrumentListForm) |
if (m_pInstrumentListForm) |
1864 |
|
|
1865 |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
1866 |
|
|
1867 |
|
// Make it look responsive...:) |
1868 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1869 |
|
|
1870 |
QMessageBox::critical(this, |
QMessageBox::critical(this, |
1871 |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
1872 |
} |
} |
1881 |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
1882 |
.arg(::lscp_client_get_result(m_pClient)) |
.arg(::lscp_client_get_result(m_pClient)) |
1883 |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
1884 |
|
|
1885 |
|
// Make it look responsive...:) |
1886 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1887 |
} |
} |
1888 |
|
|
1889 |
|
|
1958 |
|
|
1959 |
// Actual channel strip setup... |
// Actual channel strip setup... |
1960 |
pChannelStrip->setup(pChannel); |
pChannelStrip->setup(pChannel); |
1961 |
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
QObject::connect(pChannelStrip, |
1962 |
|
SIGNAL(channelChanged(qsamplerChannelStrip *)), |
1963 |
|
SLOT(channelStripChanged(qsamplerChannelStrip *))); |
1964 |
// Set some initial aesthetic options... |
// Set some initial aesthetic options... |
1965 |
if (m_pOptions) { |
if (m_pOptions) { |
1966 |
// Background display effect... |
// Background display effect... |
2167 |
m_pServer = new QProcess(this); |
m_pServer = new QProcess(this); |
2168 |
|
|
2169 |
// Setup stdout/stderr capture... |
// Setup stdout/stderr capture... |
2170 |
//if (m_pOptions->bStdoutCapture) { |
// if (m_pOptions->bStdoutCapture) { |
2171 |
m_pServer->setCommunication(QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr); |
m_pServer->setCommunication( |
2172 |
QObject::connect(m_pServer, SIGNAL(readyReadStdout()), this, SLOT(readServerStdout())); |
QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr); |
2173 |
QObject::connect(m_pServer, SIGNAL(readyReadStderr()), this, SLOT(readServerStdout())); |
QObject::connect(m_pServer, |
2174 |
//} |
SIGNAL(readyReadStdout()), |
2175 |
// The unforgiveable signal communication... |
SLOT(readServerStdout())); |
2176 |
QObject::connect(m_pServer, SIGNAL(processExited()), this, SLOT(processServerExit())); |
QObject::connect(m_pServer, |
2177 |
|
SIGNAL(readyReadStderr()), |
2178 |
|
SLOT(readServerStdout())); |
2179 |
|
// } |
2180 |
|
// The unforgiveable signal communication... |
2181 |
|
QObject::connect(m_pServer, |
2182 |
|
SIGNAL(processExited()), |
2183 |
|
SLOT(processServerExit())); |
2184 |
|
|
2185 |
// Build process arguments... |
// Build process arguments... |
2186 |
m_pServer->setArguments(QStringList::split(' ', m_pOptions->sServerCmdLine)); |
m_pServer->setArguments(QStringList::split(' ', m_pOptions->sServerCmdLine)); |