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 |
625 |
} |
} |
626 |
|
|
627 |
|
|
|
// Reset current session. |
|
|
bool qsamplerMainForm::resetSession (void) |
|
|
{ |
|
|
#ifdef CONFIG_MIDI_INSTRUMENT |
|
|
// Reset all MIDI instrument mapping, if any. |
|
|
int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient); |
|
|
for (int iMap = 0; piMaps && piMaps[iMap] >= 0; ++iMap) { |
|
|
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 |
|
|
|
|
|
// Do the actual sampler reset... |
|
|
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
|
|
appendMessagesClient("lscp_reset_sampler"); |
|
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
|
|
return false; |
|
|
} |
|
|
|
|
|
// Done. |
|
|
return true; |
|
|
} |
|
|
|
|
|
|
|
628 |
// Load a session from specific file path. |
// Load a session from specific file path. |
629 |
bool qsamplerMainForm::loadSessionFile ( const QString& sFilename ) |
bool qsamplerMainForm::loadSessionFile ( const QString& sFilename ) |
630 |
{ |
{ |
651 |
iLine++; |
iLine++; |
652 |
// If not empty, nor a comment, call the server... |
// If not empty, nor a comment, call the server... |
653 |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
654 |
// HACK: A very special trap for the global RESET command... |
// Remember that, no matter what, |
655 |
if (sCommand == "RESET") { |
// all LSCP commands are CR/LF terminated. |
656 |
// Do our own reset... |
sCommand += "\r\n"; |
657 |
if (!resetSession()) |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
658 |
iErrors++; |
appendMessagesColor(QString("%1(%2): %3") |
659 |
} else { |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
660 |
// Remember that, no matter what, |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
661 |
// all LSCP commands are CR/LF terminated. |
appendMessagesClient("lscp_client_query"); |
662 |
sCommand += "\r\n"; |
iErrors++; |
|
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
|
|
appendMessagesColor(QString("%1(%2): %3") |
|
|
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
|
|
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
|
|
appendMessagesClient("lscp_client_query"); |
|
|
iErrors++; |
|
|
} |
|
663 |
} |
} |
664 |
} |
} |
665 |
// Try to make it snappy :) |
// Try to make it snappy :) |
878 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
879 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
880 |
} |
} |
881 |
|
ts << endl; |
882 |
// Check for errors... |
// Check for errors... |
883 |
if (pInstrs) |
if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) { |
|
ts << endl; |
|
|
else if (::lscp_client_get_errno(m_pClient)) { |
|
884 |
appendMessagesClient("lscp_list_midi_instruments"); |
appendMessagesClient("lscp_list_midi_instruments"); |
885 |
iErrors++; |
iErrors++; |
886 |
} |
} |
1058 |
return; |
return; |
1059 |
|
|
1060 |
// Just do the reset, after closing down current session... |
// Just do the reset, after closing down current session... |
1061 |
if (!resetSession()) |
// Do the actual sampler reset... |
1062 |
|
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
1063 |
|
appendMessagesClient("lscp_reset_sampler"); |
1064 |
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
1065 |
return; |
return; |
1066 |
|
} |
1067 |
|
|
1068 |
// Log this. |
// Log this. |
1069 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |
1614 |
void qsamplerMainForm::updateSession (void) |
void qsamplerMainForm::updateSession (void) |
1615 |
{ |
{ |
1616 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1617 |
// FIXME Make some room for default instrument maps... |
// FIXME: Make some room for default instrument maps... |
1618 |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
1619 |
if (iMaps < 0) |
if (iMaps < 0) |
1620 |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
appendMessagesClient("lscp_get_midi_instrument_maps"); |