/[svn]/qsampler/trunk/src/qsamplerMainForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 995 by capela, Thu Dec 21 13:58:52 2006 UTC revision 996 by capela, Thu Dec 21 14:55:05 2006 UTC
# Line 625  bool qsamplerMainForm::closeSession ( bo Line 625  bool qsamplerMainForm::closeSession ( bo
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  {  {
# Line 651  bool qsamplerMainForm::loadSessionFile ( Line 681  bool qsamplerMainForm::loadSessionFile (
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);
# Line 1054  void qsamplerMainForm::fileReset (void) Line 1091  void qsamplerMainForm::fileReset (void)
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)) {          if (!resetSession())
1100  #ifdef CONFIG_MIDI_INSTRUMENT                  return;
                 // 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  
                 // 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;  
                 }  
     }  
1101    
1102      // Log this.      // Log this.
1103      appendMessages(tr("Sampler reset."));      appendMessages(tr("Sampler reset."));

Legend:
Removed from v.995  
changed lines
  Added in v.996

  ViewVC Help
Powered by ViewVC