625 |
} |
} |
626 |
|
|
627 |
|
|
628 |
|
// Reset current session. |
629 |
|
bool qsamplerMainForm::resetSession (void) |
630 |
|
{ |
631 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
632 |
|
// Reset all MIDI instrument mapping, if any. |
633 |
|
int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient); |
634 |
|
for (int iMap = 0; piMaps && piMaps[iMap] >= 0; ++iMap) { |
635 |
|
int iMidiMap = piMaps[iMap]; |
636 |
|
if (::lscp_clear_midi_instruments(m_pClient, iMidiMap) != LSCP_OK) |
637 |
|
appendMessagesClient("lscp_clear_midi_instruments"); |
638 |
|
if (::lscp_remove_midi_instrument_map(m_pClient, iMidiMap) != LSCP_OK) |
639 |
|
appendMessagesClient("lscp_remove_midi_instrument_map"); |
640 |
|
} |
641 |
|
// Check for errors... |
642 |
|
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) |
643 |
|
appendMessagesClient("lscp_list_midi_instrument_maps"); |
644 |
|
#endif // CONFIG_MIDI_INSTRUMENT |
645 |
|
|
646 |
|
// Do the actual sampler reset... |
647 |
|
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
648 |
|
appendMessagesClient("lscp_reset_sampler"); |
649 |
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
650 |
|
return false; |
651 |
|
} |
652 |
|
|
653 |
|
// Done. |
654 |
|
return true; |
655 |
|
} |
656 |
|
|
657 |
|
|
658 |
// Load a session from specific file path. |
// Load a session from specific file path. |
659 |
bool qsamplerMainForm::loadSessionFile ( const QString& sFilename ) |
bool qsamplerMainForm::loadSessionFile ( const QString& sFilename ) |
660 |
{ |
{ |
681 |
iLine++; |
iLine++; |
682 |
// If not empty, nor a comment, call the server... |
// If not empty, nor a comment, call the server... |
683 |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
684 |
// Remember that, no matter what, |
// HACK: A very special trap for the global RESET command... |
685 |
// all LSCP commands are CR/LF terminated. |
if (sCommand == "RESET") { |
686 |
sCommand += "\r\n"; |
// Do our own reset... |
687 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
if (!resetSession()) |
688 |
appendMessagesColor(QString("%1(%2): %3") |
iErrors++; |
689 |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
} else { |
690 |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
// Remember that, no matter what, |
691 |
appendMessagesClient("lscp_client_query"); |
// all LSCP commands are CR/LF terminated. |
692 |
iErrors++; |
sCommand += "\r\n"; |
693 |
} |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
694 |
|
appendMessagesColor(QString("%1(%2): %3") |
695 |
|
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
696 |
|
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
697 |
|
appendMessagesClient("lscp_client_query"); |
698 |
|
iErrors++; |
699 |
|
} |
700 |
|
} |
701 |
} |
} |
702 |
// Try to make it snappy :) |
// Try to make it snappy :) |
703 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
912 |
appendMessagesClient("lscp_get_midi_instrument_info"); |
appendMessagesClient("lscp_get_midi_instrument_info"); |
913 |
iErrors++; |
iErrors++; |
914 |
} |
} |
|
// MIDI device index/id mapping. |
|
|
midiInstrumentMap[iMidiMap] = iMap; |
|
915 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
916 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
917 |
} |
} |
922 |
appendMessagesClient("lscp_list_midi_instruments"); |
appendMessagesClient("lscp_list_midi_instruments"); |
923 |
iErrors++; |
iErrors++; |
924 |
} |
} |
925 |
|
// MIDI strument index/id mapping. |
926 |
|
midiInstrumentMap[iMidiMap] = iMap; |
927 |
} |
} |
928 |
// Check for errors... |
// Check for errors... |
929 |
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
930 |
appendMessagesClient("lscp_list_midi_instrument_maps"); |
appendMessagesClient("lscp_list_midi_instrument_maps"); |
931 |
iErrors++; |
iErrors++; |
932 |
} |
} |
933 |
#endif // CONFIG_MIDI_INSTRUMENT |
#endif // CONFIG_MIDI_INSTRUMENT |
934 |
|
|
935 |
// Sampler channel mapping. |
// Sampler channel mapping. |
936 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1091 |
tr("Reset"), tr("Cancel")) > 0) |
tr("Reset"), tr("Cancel")) > 0) |
1092 |
return; |
return; |
1093 |
|
|
1094 |
|
// Trye closing the current session, first... |
1095 |
|
if (!closeSession(true)) |
1096 |
|
return; |
1097 |
|
|
1098 |
// Just do the reset, after closing down current session... |
// Just do the reset, after closing down current session... |
1099 |
if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
if (!resetSession()) |
1100 |
appendMessagesClient("lscp_reset_sampler"); |
return; |
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
|
|
return; |
|
|
} |
|
1101 |
|
|
1102 |
// Log this. |
// Log this. |
1103 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |