/[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 456 by capela, Mon Mar 14 14:02:30 2005 UTC revision 995 by capela, Thu Dec 21 13:58:52 2006 UTC
# Line 2  Line 2 
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-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2006, 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
# Line 14  Line 14 
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License along
18     along with this program; if not, write to the Free Software     with this program; if not, write to the Free Software Foundation, Inc.,
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20    
21  *****************************************************************************/  *****************************************************************************/
22    
# Line 41  Line 41 
41  #include "qsamplerMessages.h"  #include "qsamplerMessages.h"
42    
43  #include "qsamplerChannelStrip.h"  #include "qsamplerChannelStrip.h"
44    #include "qsamplerInstrumentList.h"
45    
46    #include "qsamplerInstrumentListForm.h"
47  #include "qsamplerDeviceForm.h"  #include "qsamplerDeviceForm.h"
48  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
49    
 #include "config.h"  
   
50  #ifdef HAVE_SIGNAL_H  #ifdef HAVE_SIGNAL_H
51  #include <signal.h>  #include <signal.h>
52  #endif  #endif
53    
54    #ifdef CONFIG_LIBGIG
55    #include <gig.h>
56    #endif
57    
58  // Timer constant stuff.  // Timer constant stuff.
59  #define QSAMPLER_TIMER_MSECS    200  #define QSAMPLER_TIMER_MSECS    200
60    
# Line 100  private: Line 104  private:
104  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
105  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
106    
107    // Kind of singleton reference.
108    qsamplerMainForm *qsamplerMainForm::g_pMainForm = NULL;
109    
110    
111  // Kind of constructor.  // Kind of constructor.
112  void qsamplerMainForm::init (void)  void qsamplerMainForm::init (void)
113  {  {
114            // Pseudo-singleton reference setup.
115            g_pMainForm = this;
116    
117      // Initialize some pointer references.      // Initialize some pointer references.
118      m_pOptions = NULL;      m_pOptions = NULL;
119    
120      // All child forms are to be created later, not earlier than setup.      // All child forms are to be created later, not earlier than setup.
121      m_pMessages   = NULL;      m_pMessages = NULL;
122        m_pInstrumentListForm = NULL;
123      m_pDeviceForm = NULL;      m_pDeviceForm = NULL;
124    
125      // We'll start clean.      // We'll start clean.
# Line 184  void qsamplerMainForm::destroy (void) Line 196  void qsamplerMainForm::destroy (void)
196      // Finally drop any widgets around...      // Finally drop any widgets around...
197      if (m_pDeviceForm)      if (m_pDeviceForm)
198          delete m_pDeviceForm;          delete m_pDeviceForm;
199        if (m_pInstrumentListForm)
200            delete m_pInstrumentListForm;
201      if (m_pMessages)      if (m_pMessages)
202          delete m_pMessages;          delete m_pMessages;
203      if (m_pWorkspace)      if (m_pWorkspace)
# Line 202  void qsamplerMainForm::destroy (void) Line 216  void qsamplerMainForm::destroy (void)
216      // Delete recentfiles menu.      // Delete recentfiles menu.
217      if (m_pRecentFilesMenu)      if (m_pRecentFilesMenu)
218          delete m_pRecentFilesMenu;          delete m_pRecentFilesMenu;
219    
220            // Pseudo-singleton reference shut-down.
221            g_pMainForm = NULL;
222  }  }
223    
224    
# Line 212  void qsamplerMainForm::setup ( qsamplerO Line 229  void qsamplerMainForm::setup ( qsamplerO
229      m_pOptions = pOptions;      m_pOptions = pOptions;
230    
231      // What style do we create these forms?      // What style do we create these forms?
232      WFlags wflags = Qt::WType_TopLevel;          Qt::WFlags wflags = Qt::WStyle_Customize
233                    | Qt::WStyle_NormalBorder
234                    | Qt::WStyle_Title
235                    | Qt::WStyle_SysMenu
236                    | Qt::WStyle_MinMax
237                    | Qt::WType_TopLevel;
238      if (m_pOptions->bKeepOnTop)      if (m_pOptions->bKeepOnTop)
239          wflags |= Qt::WStyle_Tool;          wflags |= Qt::WStyle_Tool;
240      // Some child forms are to be created right now.      // Some child forms are to be created right now.
241      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
242      m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags);      m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags);
243    #ifdef CONFIG_MIDI_INSTRUMENT
244        m_pInstrumentListForm = new qsamplerInstrumentListForm(this, 0, wflags);
245            QObject::connect(m_pInstrumentListForm->InstrumentList,
246                    SIGNAL(instrumentsChanged()),
247                    SLOT(sessionDirty()));
248    #else
249            viewInstrumentsAction->setEnabled(false);
250    #endif
251      // Set message defaults...      // Set message defaults...
252      updateMessagesFont();      updateMessagesFont();
253      updateMessagesLimit();      updateMessagesLimit();
254      updateMessagesCapture();      updateMessagesCapture();
255      // Set the visibility signal.      // Set the visibility signal.
256      QObject::connect(m_pMessages, SIGNAL(visibilityChanged(bool)), this, SLOT(stabilizeForm()));      QObject::connect(m_pMessages,
257                    SIGNAL(visibilityChanged(bool)),
258                    SLOT(stabilizeForm()));
259    
260      // Initial decorations toggle state.      // Initial decorations toggle state.
261      viewMenubarAction->setOn(m_pOptions->bMenubar);      viewMenubarAction->setOn(m_pOptions->bMenubar);
# Line 248  void qsamplerMainForm::setup ( qsamplerO Line 280  void qsamplerMainForm::setup ( qsamplerO
280      }      }
281      // Try to restore old window positioning and initial visibility.      // Try to restore old window positioning and initial visibility.
282      m_pOptions->loadWidgetGeometry(this);      m_pOptions->loadWidgetGeometry(this);
283        m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);
284      m_pOptions->loadWidgetGeometry(m_pDeviceForm);      m_pOptions->loadWidgetGeometry(m_pDeviceForm);
285    
286      // Final startup stabilization...      // Final startup stabilization...
# Line 287  bool qsamplerMainForm::queryClose (void) Line 320  bool qsamplerMainForm::queryClose (void)
320              ostr << *this;              ostr << *this;
321              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);
322              // And the children, and the main windows state,.              // And the children, and the main windows state,.
323                  m_pOptions->saveWidgetGeometry(m_pDeviceForm);                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);
324              m_pOptions->saveWidgetGeometry(this);                          m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
325                  // Close popup widgets.                          m_pOptions->saveWidgetGeometry(this);
326                  if (m_pDeviceForm)                          // Close popup widgets.
327                      m_pDeviceForm->close();                          if (m_pInstrumentListForm)
328                                    m_pInstrumentListForm->close();
329                            if (m_pDeviceForm)
330                                    m_pDeviceForm->close();
331              // Stop client and/or server, gracefully.              // Stop client and/or server, gracefully.
332              stopServer();              stopServer();
333          }          }
# Line 344  void qsamplerMainForm::dropEvent ( QDrop Line 380  void qsamplerMainForm::dropEvent ( QDrop
380      if (!decodeDragFiles(pDropEvent, files))      if (!decodeDragFiles(pDropEvent, files))
381          return;          return;
382    
383      for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {          for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
384                  const QString& sPath = *iter;                  const QString& sPath = *iter;
385                  if (qsamplerChannel::isInstrumentFile(sPath)) {                  if (qsamplerChannel::isInstrumentFile(sPath)) {
386                          // Try to create a new channel from instrument file...                          // Try to create a new channel from instrument file...
387                      qsamplerChannel *pChannel = new qsamplerChannel(this);                          qsamplerChannel *pChannel = new qsamplerChannel();
388                      if (pChannel == NULL)                          if (pChannel == NULL)
389                          return;                                  return;
390                          // Start setting the instrument filename...                          // Start setting the instrument filename...
391                          pChannel->setInstrument(sPath, 0);                          pChannel->setInstrument(sPath, 0);
392                      // Before we show it up, may be we'll                          // Before we show it up, may be we'll
393                      // better ask for some initial values?                          // better ask for some initial values?
394                      if (!pChannel->channelSetup(this)) {                          if (!pChannel->channelSetup(this)) {
395                          delete pChannel;                                  delete pChannel;
396                          return;                                  return;
397                      }                          }
398                      // Finally, give it to a new channel strip...                          // Finally, give it to a new channel strip...
399                          if (!createChannelStrip(pChannel)) {                          if (!createChannelStrip(pChannel)) {
400                          delete pChannel;                                  delete pChannel;
401                          return;                                  return;
402                          }                          }
403                      // Make that an overall update.                          // Make that an overall update.
404                      m_iDirtyCount++;                          m_iDirtyCount++;
405                      stabilizeForm();                          stabilizeForm();
406                  }   // Otherwise, load an usual session file (LSCP script)...                  }   // Otherwise, load an usual session file (LSCP script)...
407                  else if (closeSession(true))                  else if (closeSession(true)) {
408                          loadSessionFile(sPath);                          loadSessionFile(sPath);
409                            break;
410                    }
411                  // Make it look responsive...:)                  // Make it look responsive...:)
412                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
413          }          }
# Line 382  void qsamplerMainForm::customEvent ( QCu Line 420  void qsamplerMainForm::customEvent ( QCu
420      // For the time being, just pump it to messages.      // For the time being, just pump it to messages.
421      if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {      if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
422          qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;          qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
423          appendMessagesColor(tr("Notify event: %1 data: %2")                  if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) {
424              .arg(::lscp_event_to_text(pEvent->event()))                          int iChannelID = pEvent->data().toInt();
425              .arg(pEvent->data()), "#996699");                          qsamplerChannelStrip *pChannelStrip = channelStrip(iChannelID);
426                            if (pChannelStrip)
427                                    channelStripChanged(pChannelStrip);
428                    } else {
429                            appendMessagesColor(tr("Notify event: %1 data: %2")
430                                    .arg(::lscp_event_to_text(pEvent->event()))
431                                    .arg(pEvent->data()), "#996699");
432                    }
433      }      }
434  }  }
435    
# Line 393  void qsamplerMainForm::customEvent ( QCu Line 438  void qsamplerMainForm::customEvent ( QCu
438  void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )
439  {  {
440      stabilizeForm();      stabilizeForm();
441        
442      editMenu->exec(pEvent->globalPos());      editMenu->exec(pEvent->globalPos());
443  }  }
444    
# Line 407  qsamplerOptions *qsamplerMainForm::optio Line 452  qsamplerOptions *qsamplerMainForm::optio
452      return m_pOptions;      return m_pOptions;
453  }  }
454    
455    
456  // The LSCP client descriptor property.  // The LSCP client descriptor property.
457  lscp_client_t *qsamplerMainForm::client (void)  lscp_client_t *qsamplerMainForm::client (void)
458  {  {
# Line 414  lscp_client_t *qsamplerMainForm::client Line 460  lscp_client_t *qsamplerMainForm::client
460  }  }
461    
462    
463    // The pseudo-singleton instance accessor.
464    qsamplerMainForm *qsamplerMainForm::getInstance (void)
465    {
466            return g_pMainForm;
467    }
468    
469    
470  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
471  // qsamplerMainForm -- Session file stuff.  // qsamplerMainForm -- Session file stuff.
472    
# Line 461  bool qsamplerMainForm::openSession (void Line 514  bool qsamplerMainForm::openSession (void
514    
515      // Ask for the filename to open...      // Ask for the filename to open...
516      QString sFilename = QFileDialog::getOpenFileName(      QString sFilename = QFileDialog::getOpenFileName(
517              m_pOptions->sSessionDir,                // Start here.                  m_pOptions->sSessionDir,                // Start here.
518              tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)                  tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)
519              this, 0,                                // Parent and name (none)                  this, 0,                                // Parent and name (none)
520              tr("Open Session")                      // Caption.                  QSAMPLER_TITLE ": " + tr("Open Session")        // Caption.
521      );      );
522    
523      // Have we cancelled?      // Have we cancelled?
# Line 495  bool qsamplerMainForm::saveSession ( boo Line 548  bool qsamplerMainForm::saveSession ( boo
548              sFilename = m_pOptions->sSessionDir;              sFilename = m_pOptions->sSessionDir;
549          // Prompt the guy...          // Prompt the guy...
550          sFilename = QFileDialog::getSaveFileName(          sFilename = QFileDialog::getSaveFileName(
551                  sFilename,                              // Start here.                          sFilename,                              // Start here.
552                  tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)                          tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)
553                  this, 0,                                // Parent and name (none)                          this, 0,                                // Parent and name (none)
554                  tr("Save Session")                      // Caption.                          QSAMPLER_TITLE ": " + tr("Save Session")        // Caption.
555          );          );
556          // Have we cancelled it?          // Have we cancelled it?
557          if (sFilename.isEmpty())          if (sFilename.isEmpty())
# Line 508  bool qsamplerMainForm::saveSession ( boo Line 561  bool qsamplerMainForm::saveSession ( boo
561              sFilename += ".lscp";              sFilename += ".lscp";
562          // Check if already exists...          // Check if already exists...
563          if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {          if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
564              if (QMessageBox::warning(this, tr("Warning"),              if (QMessageBox::warning(this,
565                                    QSAMPLER_TITLE ": " + tr("Warning"),
566                  tr("The file already exists:\n\n"                  tr("The file already exists:\n\n"
567                     "\"%1\"\n\n"                     "\"%1\"\n\n"
568                     "Do you want to replace it?")                     "Do you want to replace it?")
# Line 530  bool qsamplerMainForm::closeSession ( bo Line 584  bool qsamplerMainForm::closeSession ( bo
584    
585      // Are we dirty enough to prompt it?      // Are we dirty enough to prompt it?
586      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0) {
587          switch (QMessageBox::warning(this, tr("Warning"),          switch (QMessageBox::warning(this,
588                            QSAMPLER_TITLE ": " + tr("Warning"),
589              tr("The current session has been changed:\n\n"              tr("The current session has been changed:\n\n"
590              "\"%1\"\n\n"              "\"%1\"\n\n"
591              "Do you want to save the changes?")              "Do you want to save the changes?")
# Line 583  bool qsamplerMainForm::loadSessionFile ( Line 638  bool qsamplerMainForm::loadSessionFile (
638          return false;          return false;
639      }      }
640    
641            // Tell the world we'll take some time...
642            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
643    
644      // Read the file.      // Read the file.
645            int iLine = 0;
646      int iErrors = 0;      int iErrors = 0;
647      QTextStream ts(&file);      QTextStream ts(&file);
648      while (!ts.atEnd()) {      while (!ts.atEnd()) {
649          // Read the line.          // Read the line.
650          QString sCommand = ts.readLine().simplifyWhiteSpace();          QString sCommand = ts.readLine().stripWhiteSpace();
651                    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] != '#') {
             appendMessagesColor(sCommand, "#996633");  
654              // Remember that, no matter what,              // Remember that, no matter what,
655              // all LSCP commands are CR/LF terminated.              // all LSCP commands are CR/LF terminated.
656              sCommand += "\r\n";              sCommand += "\r\n";
657              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
658                                    appendMessagesColor(QString("%1(%2): %3")
659                                            .arg(QFileInfo(sFilename).fileName()).arg(iLine)
660                                            .arg(sCommand.simplifyWhiteSpace()), "#996633");
661                  appendMessagesClient("lscp_client_query");                  appendMessagesClient("lscp_client_query");
662                  iErrors++;                  iErrors++;
                 break;  
663              }              }
664          }          }
665          // Try to make it snappy :)          // Try to make it snappy :)
# Line 608  bool qsamplerMainForm::loadSessionFile ( Line 669  bool qsamplerMainForm::loadSessionFile (
669      // Ok. we've read it.      // Ok. we've read it.
670      file.close();      file.close();
671    
     // Have we any errors?  
     if (iErrors > 0)  
         appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename));  
   
672          // Now we'll try to create (update) the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
673          updateSession();          updateSession();
674    
675            // We're fornerly done.
676            QApplication::restoreOverrideCursor();
677    
678            // Have we any errors?
679            if (iErrors > 0)
680                    appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));
681    
682      // Save as default session directory.      // Save as default session directory.
683      if (m_pOptions)      if (m_pOptions)
684          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);
685      // We're not dirty anymore.          // We're not dirty anymore, if loaded without errors,
686      m_iDirtyCount = 0;          m_iDirtyCount = iErrors;
687      // Stabilize form...      // Stabilize form...
688      m_sFilename = sFilename;      m_sFilename = sFilename;
689      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
690      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
691        
692      // Make that an overall update.      // Make that an overall update.
693      stabilizeForm();      stabilizeForm();
694      return true;      return true;
# Line 634  bool qsamplerMainForm::loadSessionFile ( Line 698  bool qsamplerMainForm::loadSessionFile (
698  // Save current session to specific file path.  // Save current session to specific file path.
699  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )
700  {  {
701            if (m_pClient == NULL)
702                    return false;
703    
704            // Check whether server is apparently OK...
705            if (::lscp_get_channels(m_pClient) < 0) {
706                    appendMessagesClient("lscp_get_channels");
707                    return false;
708            }
709    
710      // Open and write into real file.      // Open and write into real file.
711      QFile file(sFilename);      QFile file(sFilename);
712      if (!file.open(IO_WriteOnly | IO_Truncate)) {      if (!file.open(IO_WriteOnly | IO_Truncate)) {
# Line 641  bool qsamplerMainForm::saveSessionFile ( Line 714  bool qsamplerMainForm::saveSessionFile (
714          return false;          return false;
715      }      }
716    
717            // Tell the world we'll take some time...
718            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
719    
720      // Write the file.      // Write the file.
721      int  iErrors = 0;      int  iErrors = 0;
722      QTextStream ts(&file);      QTextStream ts(&file);
# Line 657  bool qsamplerMainForm::saveSessionFile ( Line 733  bool qsamplerMainForm::saveSessionFile (
733         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
734      ts << "#"  << endl;      ts << "#"  << endl;
735      ts << endl;      ts << endl;
736    
737          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
738          // will be loaded from a complete          // will be loaded from a complete initialized server...
739          int *piDeviceIDs;          int *piDeviceIDs;
740          int  iDevice;          int  iDevice;
741          ts << "RESET" << endl;          ts << "RESET" << endl;
742    
743          // Audio device mapping.          // Audio device mapping.
744          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap;
745          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
746          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
                 qsamplerDevice device(m_pClient, qsamplerDevice::Audio, piDeviceIDs[iDevice]);  
747                  ts << endl;                  ts << endl;
748          ts << "# " << device.deviceTypeName() << " " << device.driverName()                  qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]);
749                     << " " << tr("Device") << " " << iDevice << endl;                  // Audio device specification...
750                    ts << "# " << device.deviceTypeName() << " " << device.driverName()
751                            << " " << tr("Device") << " " << iDevice << endl;
752                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
753                  qsamplerDeviceParamMap& params = device.params();                  qsamplerDeviceParamMap::ConstIterator deviceParam;
754                  qsamplerDeviceParamMap::ConstIterator iter;                  for (deviceParam = device.params().begin();
755                  for (iter = params.begin(); iter != params.end(); ++iter)                                  deviceParam != device.params().end();
756                          ts << " " << iter.key() << "='" << iter.data().value << "'";                                          ++deviceParam) {
757                            const qsamplerDeviceParam& param = deviceParam.data();
758                            if (param.value.isEmpty()) ts << "# ";
759                            ts << " " << deviceParam.key() << "='" << param.value << "'";
760                    }
761                  ts << endl;                  ts << endl;
762                    // Audio channel parameters...
763                    int iPort = 0;
764                    for (qsamplerDevicePort *pPort = device.ports().first();
765                                    pPort;
766                                            pPort = device.ports().next(), ++iPort) {
767                            qsamplerDeviceParamMap::ConstIterator portParam;
768                            for (portParam = pPort->params().begin();
769                                            portParam != pPort->params().end();
770                                                    ++portParam) {
771                                    const qsamplerDeviceParam& param = portParam.data();
772                                    if (param.fix || param.value.isEmpty()) ts << "# ";
773                                    ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice
774                                            << " " << iPort << " " << portParam.key()
775                                            << "='" << param.value << "'" << endl;
776                            }
777                    }
778                    // Audio device index/id mapping.
779                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap[device.deviceID()] = iDevice;
780          // Try to keep it snappy :)                  // Try to keep it snappy :)
781          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
782          }          }
783    
784          // MIDI device mapping.          // MIDI device mapping.
785          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap;
786          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
787          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
                 qsamplerDevice device(m_pClient, qsamplerDevice::Midi, piDeviceIDs[iDevice]);  
788                  ts << endl;                  ts << endl;
789          ts << "# " << device.deviceTypeName() << " " << device.driverName()                  qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]);
790                     << " " << tr("Device") << " " << iDevice << endl;                  // MIDI device specification...
791                    ts << "# " << device.deviceTypeName() << " " << device.driverName()
792                            << " " << tr("Device") << " " << iDevice << endl;
793                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
794                  qsamplerDeviceParamMap& params = device.params();                  qsamplerDeviceParamMap::ConstIterator deviceParam;
795                  qsamplerDeviceParamMap::ConstIterator iter;                  for (deviceParam = device.params().begin();
796                  for (iter = params.begin(); iter != params.end(); ++iter)                                  deviceParam != device.params().end();
797                          ts << " " << iter.key() << "='" << iter.data().value << "'";                                          ++deviceParam) {
798                            const qsamplerDeviceParam& param = deviceParam.data();
799                            if (param.value.isEmpty()) ts << "# ";
800                            ts << " " << deviceParam.key() << "='" << param.value << "'";
801                    }
802                  ts << endl;                  ts << endl;
803                    // MIDI port parameters...
804                    int iPort = 0;
805                    for (qsamplerDevicePort *pPort = device.ports().first();
806                                    pPort;
807                                            pPort = device.ports().next(), ++iPort) {
808                            qsamplerDeviceParamMap::ConstIterator portParam;
809                            for (portParam = pPort->params().begin();
810                                            portParam != pPort->params().end();
811                                                    ++portParam) {
812                                    const qsamplerDeviceParam& param = portParam.data();
813                                    if (param.fix || param.value.isEmpty()) ts << "# ";
814                                    ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice
815                                       << " " << iPort << " " << portParam.key()
816                                       << "='" << param.value << "'" << endl;
817                            }
818                    }
819                    // MIDI device index/id mapping.
820                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap[device.deviceID()] = iDevice;
821          // Try to keep it snappy :)                  // Try to keep it snappy :)
822          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
823          }          }
824          ts << endl;          ts << endl;
825    
826    #ifdef CONFIG_MIDI_INSTRUMENT
827            // MIDI instrument mapping...
828            QMap<int, int> midiInstrumentMap;
829            int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);
830            for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) {
831                    int iMidiMap = piMaps[iMap];
832                    const char *pszMapName
833                            = ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap);
834                    ts << "# " << tr("MIDI instrument map") << " " << iMap;
835                    if (pszMapName)
836                            ts << " - " << pszMapName;
837                    ts << endl;
838                    ts << "ADD MIDI_INSTRUMENT_MAP";
839                    if (pszMapName)
840                            ts << " '" << pszMapName << "'";
841                    ts << endl;
842                    // MIDI instrument mapping...
843                    lscp_midi_instrument_t *pInstrs
844                            = ::lscp_list_midi_instruments(m_pClient, iMidiMap);
845                    for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; iInstr++) {
846                            lscp_midi_instrument_info_t *pInstrInfo
847                                    = ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]);
848                            if (pInstrInfo) {
849                                    ts << "MAP MIDI_INSTRUMENT "
850                                            << iMap                        << " "
851                                            << pInstrs[iInstr].bank        << " "
852                                            << pInstrs[iInstr].prog        << " "
853                                            << pInstrInfo->engine_name     << " '"
854                                            << pInstrInfo->instrument_file << "' "
855                                            << pInstrInfo->instrument_nr   << " "
856                                            << pInstrInfo->volume          << " ";
857                                    switch (pInstrInfo->load_mode) {
858                                            case LSCP_LOAD_PERSISTENT:
859                                                    ts << "PERSISTENT";
860                                                    break;
861                                            case LSCP_LOAD_ON_DEMAND_HOLD:
862                                                    ts << "ON_DEMAND_HOLD";
863                                                    break;
864                                            case LSCP_LOAD_ON_DEMAND:
865                                            case LSCP_LOAD_DEFAULT:
866                                            default:
867                                                    ts << "ON_DEMAND";
868                                                    break;
869                                    }
870                                    if (pInstrInfo->name)
871                                            ts << " '" << pInstrInfo->name << "'";
872                                    ts << endl;
873                            }       // Check for errors...
874                            else if (::lscp_client_get_errno(m_pClient)) {
875                                    appendMessagesClient("lscp_get_midi_instrument_info");
876                                    iErrors++;
877                            }
878                            // MIDI device index/id mapping.
879                            midiInstrumentMap[iMidiMap] = iMap;
880                            // Try to keep it snappy :)
881                            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
882                    }
883                    // Check for errors...
884                    if (pInstrs)
885                            ts << endl;
886                    else if (::lscp_client_get_errno(m_pClient)) {
887                            appendMessagesClient("lscp_list_midi_instruments");
888                            iErrors++;
889                    }
890            }
891            // Check for errors...
892            if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {
893                    appendMessagesClient("lscp_list_midi_instrument_maps");
894                    iErrors++;
895            }
896    #endif  // CONFIG_MIDI_INSTRUMENT
897    
898          // Sampler channel mapping.          // Sampler channel mapping.
899      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
900      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
# Line 708  bool qsamplerMainForm::saveSessionFile ( Line 904  bool qsamplerMainForm::saveSessionFile (
904              if (pChannel) {              if (pChannel) {
905                  ts << "# " << tr("Channel") << " " << iChannel << endl;                  ts << "# " << tr("Channel") << " " << iChannel << endl;
906                  ts << "ADD CHANNEL" << endl;                  ts << "ADD CHANNEL" << endl;
907                  if (audioDeviceMap.isEmpty()) {                                  if (audioDeviceMap.isEmpty()) {
908                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel                                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel
909                                              << " " << pChannel->audioDriver() << endl;                                                  << " " << pChannel->audioDriver() << endl;
910                              } else {                                  } else {
911                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel
912                                             << " " << audioDeviceMap[pChannel->audioDevice()] << endl;                                                  << " " << audioDeviceMap[pChannel->audioDevice()] << endl;
913                                  }                                  }
914                  if (midiDeviceMap.isEmpty()) {                                  if (midiDeviceMap.isEmpty()) {
915                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel
916                                         << " " << pChannel->midiDriver() << endl;                                                  << " " << pChannel->midiDriver() << endl;
917                              } else {                                  } else {
918                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel
919                                             << " " << midiDeviceMap[pChannel->midiDevice()] << endl;                                                  << " " << midiDeviceMap[pChannel->midiDevice()] << endl;
920                              }                                  }
921                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel
922                                 << " " << pChannel->midiPort() << endl;                                          << " " << pChannel->midiPort() << endl;
923                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";
924                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
925                      ts << "ALL";                      ts << "ALL";
# Line 731  bool qsamplerMainForm::saveSessionFile ( Line 927  bool qsamplerMainForm::saveSessionFile (
927                      ts << pChannel->midiChannel();                      ts << pChannel->midiChannel();
928                  ts << endl;                  ts << endl;
929                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
930                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;                                  if (pChannel->instrumentStatus() < 100) ts << "# ";
931                  ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;                                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' "
932                                            << pChannel->instrumentNr() << " " << iChannel << endl;
933                                    qsamplerChannelRoutingMap::ConstIterator audioRoute;
934                                    for (audioRoute = pChannel->audioRouting().begin();
935                                                    audioRoute != pChannel->audioRouting().end();
936                                                            ++audioRoute) {
937                                            ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel
938                                                    << " " << audioRoute.key()
939                                                    << " " << audioRoute.data() << endl;
940                                    }
941                                    ts << "SET CHANNEL VOLUME " << iChannel
942                                            << " " << pChannel->volume() << endl;
943                                    if (pChannel->channelMute())
944                                            ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
945                                    if (pChannel->channelSolo())
946                                            ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
947    #ifdef CONFIG_MIDI_INSTRUMENT
948                                    if (pChannel->midiMap() >= 0) {
949                                            ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel
950                                                    << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
951                                    }
952    #endif
953                  ts << endl;                  ts << endl;
954              }              }
955          }          }
# Line 743  bool qsamplerMainForm::saveSessionFile ( Line 960  bool qsamplerMainForm::saveSessionFile (
960      // Ok. we've wrote it.      // Ok. we've wrote it.
961      file.close();      file.close();
962    
963            // We're fornerly done.
964            QApplication::restoreOverrideCursor();
965    
966      // Have we any errors?      // Have we any errors?
967      if (iErrors > 0)      if (iErrors > 0)
968          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));
# Line 824  void qsamplerMainForm::fileReset (void) Line 1044  void qsamplerMainForm::fileReset (void)
1044          return;          return;
1045    
1046      // Ask user whether he/she want's an internal sampler reset...      // Ask user whether he/she want's an internal sampler reset...
1047      if (QMessageBox::warning(this, tr("Warning"),      if (QMessageBox::warning(this,
1048                    QSAMPLER_TITLE ": " + tr("Warning"),
1049          tr("Resetting the sampler instance will close\n"          tr("Resetting the sampler instance will close\n"
1050             "all device and channel configurations.\n\n"             "all device and channel configurations.\n\n"
1051             "Please note that this operation may cause\n"             "Please note that this operation may cause\n"
1052             "temporary MIDI and Audio disruption\n\n"             "temporary MIDI and Audio disruption.\n\n"
1053             "Do you want to reset the sampler engine now?"),             "Do you want to reset the sampler engine now?"),
1054          tr("Reset"), tr("Cancel")) > 0)          tr("Reset"), tr("Cancel")) > 0)
1055          return;          return;
1056    
1057      // Just do the reset, after closing down current session...      // Just do the reset, after closing down current session...
1058      if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {      if (closeSession(true)) {
1059          appendMessagesClient("lscp_reset_sampler");  #ifdef CONFIG_MIDI_INSTRUMENT
1060          appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));                  // Reset all MIDI instrument mapping, if any.
1061          return;                  int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);
1062                    for (int iMap = 0; piMaps && piMaps[iMap] >= 0; ++iMap) {
1063                            int iMidiMap = piMaps[iMap];
1064                            if (::lscp_clear_midi_instruments(m_pClient, iMidiMap) != LSCP_OK)
1065                                    appendMessagesClient("lscp_clear_midi_instruments");
1066                            if (::lscp_remove_midi_instrument_map(m_pClient, iMidiMap) != LSCP_OK)
1067                                    appendMessagesClient("lscp_remove_midi_instrument_map");
1068                    }
1069                    // Check for errors...
1070                    if (piMaps == NULL && ::lscp_client_get_errno(m_pClient))
1071                            appendMessagesClient("lscp_list_midi_instrument_maps");
1072    #endif  // CONFIG_MIDI_INSTRUMENT
1073                    // actually do the sampler reset...
1074                    if (::lscp_reset_sampler(m_pClient) != LSCP_OK) {
1075                            appendMessagesClient("lscp_reset_sampler");
1076                            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
1077                            return;
1078                    }
1079      }      }
1080    
1081      // Log this.      // Log this.
# Line 853  void qsamplerMainForm::fileRestart (void Line 1091  void qsamplerMainForm::fileRestart (void
1091  {  {
1092      if (m_pOptions == NULL)      if (m_pOptions == NULL)
1093          return;          return;
1094            
1095      bool bRestart = true;      bool bRestart = true;
1096        
1097      // Ask user whether he/she want's a complete restart...      // Ask user whether he/she want's a complete restart...
1098      // (if we're currently up and running)      // (if we're currently up and running)
1099      if (bRestart && m_pClient) {      if (bRestart && m_pClient) {
1100          bRestart = (QMessageBox::warning(this, tr("Warning"),          bRestart = (QMessageBox::warning(this,
1101                            QSAMPLER_TITLE ": " + tr("Warning"),
1102              tr("New settings will be effective after\n"              tr("New settings will be effective after\n"
1103                 "restarting the client/server connection.\n\n"                 "restarting the client/server connection.\n\n"
1104                 "Please note that this operation may cause\n"                 "Please note that this operation may cause\n"
1105                 "temporary MIDI and Audio disruption\n\n"                 "temporary MIDI and Audio disruption.\n\n"
1106                 "Do you want to restart the connection now?"),                 "Do you want to restart the connection now?"),
1107              tr("Restart"), tr("Cancel")) == 0);              tr("Restart"), tr("Cancel")) == 0);
1108      }      }
# Line 896  void qsamplerMainForm::editAddChannel (v Line 1135  void qsamplerMainForm::editAddChannel (v
1135          return;          return;
1136    
1137      // Just create the channel instance...      // Just create the channel instance...
1138      qsamplerChannel *pChannel = new qsamplerChannel(this);      qsamplerChannel *pChannel = new qsamplerChannel();
1139      if (pChannel == NULL)      if (pChannel == NULL)
1140          return;          return;
1141    
# Line 906  void qsamplerMainForm::editAddChannel (v Line 1145  void qsamplerMainForm::editAddChannel (v
1145          delete pChannel;          delete pChannel;
1146          return;          return;
1147      }      }
1148        
1149      // And give it to the strip (will own the channel instance, if successful).      // And give it to the strip (will own the channel instance, if successful).
1150      if (!createChannelStrip(pChannel)) {      if (!createChannelStrip(pChannel)) {
1151          delete pChannel;          delete pChannel;
# Line 928  void qsamplerMainForm::editRemoveChannel Line 1167  void qsamplerMainForm::editRemoveChannel
1167      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1168      if (pChannelStrip == NULL)      if (pChannelStrip == NULL)
1169          return;          return;
1170            
1171      qsamplerChannel *pChannel = pChannelStrip->channel();      qsamplerChannel *pChannel = pChannelStrip->channel();
1172      if (pChannel == NULL)      if (pChannel == NULL)
1173          return;          return;
1174    
1175      // Prompt user if he/she's sure about this...      // Prompt user if he/she's sure about this...
1176      if (m_pOptions && m_pOptions->bConfirmRemove) {      if (m_pOptions && m_pOptions->bConfirmRemove) {
1177          if (QMessageBox::warning(this, tr("Warning"),          if (QMessageBox::warning(this,
1178                            QSAMPLER_TITLE ": " + tr("Warning"),
1179              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
1180                 "%1\n\n"                 "%1\n\n"
1181                 "Are you sure?")                 "Are you sure?")
# Line 950  void qsamplerMainForm::editRemoveChannel Line 1190  void qsamplerMainForm::editRemoveChannel
1190    
1191      // Just delete the channel strip.      // Just delete the channel strip.
1192      delete pChannelStrip;      delete pChannelStrip;
1193        
1194      // Do we auto-arrange?      // Do we auto-arrange?
1195      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
1196          channelsArrange();          channelsArrange();
# Line 994  void qsamplerMainForm::editResetChannel Line 1234  void qsamplerMainForm::editResetChannel
1234  // Reset all sampler channels.  // Reset all sampler channels.
1235  void qsamplerMainForm::editResetAllChannels (void)  void qsamplerMainForm::editResetAllChannels (void)
1236  {  {
1237      if (m_pClient == NULL)          if (m_pClient == NULL)
1238          return;                  return;
1239    
1240      // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
1241          // for all channels out there...          // for all channels out there...
1242      m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1243      QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1244      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1245          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1246          if (pChannelStrip)                  if (pChannelStrip)
1247                  pChannelStrip->channelReset();                          pChannelStrip->channelReset();
1248      }          }
1249      m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
1250  }  }
1251    
1252    
# Line 1058  void qsamplerMainForm::viewMessages ( bo Line 1298  void qsamplerMainForm::viewMessages ( bo
1298  }  }
1299    
1300    
1301    // Show/hide the MIDI instrument list-view form.
1302    void qsamplerMainForm::viewInstruments (void)
1303    {
1304            if (m_pOptions == NULL)
1305                    return;
1306    
1307            if (m_pInstrumentListForm) {
1308                    m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
1309                    if (m_pInstrumentListForm->isVisible()) {
1310                            m_pInstrumentListForm->hide();
1311                    } else {
1312                            m_pInstrumentListForm->show();
1313                            m_pInstrumentListForm->raise();
1314                            m_pInstrumentListForm->setActiveWindow();
1315                    }
1316            }
1317    }
1318    
1319    
1320  // Show/hide the device configurator form.  // Show/hide the device configurator form.
1321  void qsamplerMainForm::viewDevices (void)  void qsamplerMainForm::viewDevices (void)
1322  {  {
1323      if (m_pOptions == NULL)          if (m_pOptions == NULL)
1324          return;                  return;
1325    
1326      if (m_pDeviceForm) {          if (m_pDeviceForm) {
1327          m_pOptions->saveWidgetGeometry(m_pDeviceForm);                  m_pOptions->saveWidgetGeometry(m_pDeviceForm);
1328                  m_pDeviceForm->setClient(m_pClient);                  if (m_pDeviceForm->isVisible()) {
1329          if (m_pDeviceForm->isVisible()) {                          m_pDeviceForm->hide();
1330              m_pDeviceForm->hide();                  } else {
1331          } else {                          m_pDeviceForm->show();
1332              m_pDeviceForm->show();                          m_pDeviceForm->raise();
1333              m_pDeviceForm->raise();                          m_pDeviceForm->setActiveWindow();
1334              m_pDeviceForm->setActiveWindow();                  }
1335          }          }
     }  
1336  }  }
1337    
1338    
# Line 1118  void qsamplerMainForm::viewOptions (void Line 1376  void qsamplerMainForm::viewOptions (void
1376                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||
1377                  ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||                  ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||
1378                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)) {                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)) {
1379                  QMessageBox::information(this, tr("Information"),                  QMessageBox::information(this,
1380                                            QSAMPLER_TITLE ": " + tr("Information"),
1381                      tr("Some settings may be only effective\n"                      tr("Some settings may be only effective\n"
1382                         "next time you start this program."), tr("OK"));                         "next time you start this program."), tr("OK"));
1383                  updateMessagesCapture();                  updateMessagesCapture();
# Line 1192  void qsamplerMainForm::channelsArrange ( Line 1451  void qsamplerMainForm::channelsArrange (
1451          y += iHeight;          y += iHeight;
1452      }      }
1453      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1454        
1455      stabilizeForm();      stabilizeForm();
1456  }  }
1457    
# Line 1246  void qsamplerMainForm::helpAbout (void) Line 1505  void qsamplerMainForm::helpAbout (void)
1505      sText += tr("LSCP (liblscp) instrument_name support disabled.");      sText += tr("LSCP (liblscp) instrument_name support disabled.");
1506      sText += "</font></small><br />";      sText += "</font></small><br />";
1507  #endif  #endif
1508    #ifndef CONFIG_MUTE_SOLO
1509        sText += "<small><font color=\"red\">";
1510        sText += tr("Sampler channel Mute/Solo support disabled.");
1511        sText += "</font></small><br />";
1512    #endif
1513    #ifndef CONFIG_MIDI_INSTRUMENT
1514        sText += "<small><font color=\"red\">";
1515        sText += tr("MIDI instrument mapping support disabled.");
1516        sText += "</font></small><br />";
1517    #endif
1518      sText += "<br />\n";      sText += "<br />\n";
1519      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1520      sText += ::lscp_client_package();      sText += ::lscp_client_package();
1521      sText += " ";      sText += " ";
1522      sText += ::lscp_client_version();      sText += ::lscp_client_version();
1523    #ifdef CONFIG_LIBGIG
1524        sText += ", ";
1525        sText += gig::libraryName().c_str();
1526        sText += " ";
1527        sText += gig::libraryVersion().c_str();
1528    #endif
1529      sText += "<br />\n";      sText += "<br />\n";
1530      sText += "<br />\n";      sText += "<br />\n";
1531      sText += tr("Website") + ": <a href=\"" QSAMPLER_WEBSITE "\">" QSAMPLER_WEBSITE "</a><br />\n";      sText += tr("Website") + ": <a href=\"" QSAMPLER_WEBSITE "\">" QSAMPLER_WEBSITE "</a><br />\n";
# Line 1275  void qsamplerMainForm::stabilizeForm (vo Line 1550  void qsamplerMainForm::stabilizeForm (vo
1550      // Update the main application caption...      // Update the main application caption...
1551      QString sSessionName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1552      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1553          sSessionName += '*';          sSessionName += " *";
1554      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1555    
1556      // Update the main menu state...      // Update the main menu state...
# Line 1294  void qsamplerMainForm::stabilizeForm (vo Line 1569  void qsamplerMainForm::stabilizeForm (vo
1569      editResetChannelAction->setEnabled(bHasChannel);      editResetChannelAction->setEnabled(bHasChannel);
1570      editResetAllChannelsAction->setEnabled(bHasChannel);      editResetAllChannelsAction->setEnabled(bHasChannel);
1571      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());
1572      viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible());  #ifdef CONFIG_MIDI_INSTRUMENT
1573            viewInstrumentsAction->setOn(m_pInstrumentListForm
1574                    && m_pInstrumentListForm->isVisible());
1575            viewInstrumentsAction->setEnabled(bHasClient);
1576    #endif
1577            viewDevicesAction->setOn(m_pDeviceForm
1578                    && m_pDeviceForm->isVisible());
1579      viewDevicesAction->setEnabled(bHasClient);      viewDevicesAction->setEnabled(bHasClient);
1580      channelsArrangeAction->setEnabled(bHasChannel);      channelsArrangeAction->setEnabled(bHasChannel);
1581    
# Line 1330  void qsamplerMainForm::stabilizeForm (vo Line 1611  void qsamplerMainForm::stabilizeForm (vo
1611  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip )
1612  {  {
1613          // Add this strip to the changed list...          // Add this strip to the changed list...
1614          if (m_changedStrips.containsRef(pChannelStrip) == 0)          if (m_changedStrips.containsRef(pChannelStrip) == 0) {
1615                  m_changedStrips.append(pChannelStrip);                  m_changedStrips.append(pChannelStrip);
1616                    pChannelStrip->resetErrorCount();
1617            }
1618    
1619      // Just mark the dirty form.      // Just mark the dirty form.
1620      m_iDirtyCount++;      m_iDirtyCount++;
# Line 1343  void qsamplerMainForm::channelStripChang Line 1626  void qsamplerMainForm::channelStripChang
1626  // Grab and restore current sampler channels session.  // Grab and restore current sampler channels session.
1627  void qsamplerMainForm::updateSession (void)  void qsamplerMainForm::updateSession (void)
1628  {  {
1629    #ifdef CONFIG_MIDI_INSTRUMENT
1630            // FIXME Make some room for default instrument maps...
1631            int iMaps = ::lscp_get_midi_instrument_maps(m_pClient);
1632            if (iMaps < 0)
1633                    appendMessagesClient("lscp_get_midi_instrument_maps");
1634            else if (iMaps < 1) {
1635                    ::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1());
1636                    ::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1());
1637            }
1638    #endif
1639    
1640          // Retrieve the current channel list.          // Retrieve the current channel list.
1641          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
1642          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 1350  void qsamplerMainForm::updateSession (vo Line 1644  void qsamplerMainForm::updateSession (vo
1644                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
1645                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1646                  }                  }
1647                  return;          } else {
1648                    // Try to (re)create each channel.
1649                    m_pWorkspace->setUpdatesEnabled(false);
1650                    for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1651                            // Check if theres already a channel strip for this one...
1652                            if (!channelStrip(piChannelIDs[iChannel]))
1653                                    createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel]));
1654                    }
1655                    m_pWorkspace->setUpdatesEnabled(true);
1656          }          }
1657    
1658          // Try to (re)create each channel.      // Do we auto-arrange?
1659          m_pWorkspace->setUpdatesEnabled(false);      if (m_pOptions && m_pOptions->bAutoArrange)
1660          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {          channelsArrange();
1661                  // Check if theres already a channel strip for this one...  
1662                  if (!channelStrip(piChannelIDs[iChannel]))          // Remember to refresh devices and instruments...
1663                          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));          if (m_pInstrumentListForm)
1664                  // Make it visibly responsive...              m_pInstrumentListForm->refreshInstruments();
1665                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          if (m_pDeviceForm)
1666          }              m_pDeviceForm->refreshDevices();
         m_pWorkspace->setUpdatesEnabled(true);  
1667  }  }
1668    
1669    
# Line 1533  void qsamplerMainForm::appendMessagesErr Line 1834  void qsamplerMainForm::appendMessagesErr
1834    
1835      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");
1836    
1837      QMessageBox::critical(this, tr("Error"), s, tr("Cancel"));          // Make it look responsive...:)
1838            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1839    
1840        QMessageBox::critical(this,
1841                    QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));
1842  }  }
1843    
1844    
# Line 1546  void qsamplerMainForm::appendMessagesCli Line 1851  void qsamplerMainForm::appendMessagesCli
1851      appendMessagesColor(s + QString(": %1 (errno=%2)")      appendMessagesColor(s + QString(": %1 (errno=%2)")
1852          .arg(::lscp_client_get_result(m_pClient))          .arg(::lscp_client_get_result(m_pClient))
1853          .arg(::lscp_client_get_errno(m_pClient)), "#996666");          .arg(::lscp_client_get_errno(m_pClient)), "#996666");
1854    
1855            // Make it look responsive...:)
1856            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1857  }  }
1858    
1859    
# Line 1573  void qsamplerMainForm::updateMessagesLim Line 1881  void qsamplerMainForm::updateMessagesLim
1881          if (m_pOptions->bMessagesLimit)          if (m_pOptions->bMessagesLimit)
1882              m_pMessages->setMessagesLimit(m_pOptions->iMessagesLimitLines);              m_pMessages->setMessagesLimit(m_pOptions->iMessagesLimitLines);
1883          else          else
1884              m_pMessages->setMessagesLimit(0);              m_pMessages->setMessagesLimit(-1);
1885      }      }
1886  }  }
1887    
# Line 1617  qsamplerChannelStrip *qsamplerMainForm:: Line 1925  qsamplerChannelStrip *qsamplerMainForm::
1925      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1926      if (pChannelStrip == NULL)      if (pChannelStrip == NULL)
1927          return NULL;          return NULL;
1928            
1929      // Actual channel strip setup...      // Actual channel strip setup...
1930      pChannelStrip->setup(pChannel);      pChannelStrip->setup(pChannel);
1931      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
# Line 1675  qsamplerChannelStrip *qsamplerMainForm:: Line 1983  qsamplerChannelStrip *qsamplerMainForm::
1983          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1984          if (wlist.isEmpty())          if (wlist.isEmpty())
1985                  return NULL;                  return NULL;
1986            
1987          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1988                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1989                  if (pChannelStrip) {                  if (pChannelStrip) {
# Line 1756  void qsamplerMainForm::timerSlot (void) Line 2064  void qsamplerMainForm::timerSlot (void)
2064              }              }
2065          }          }
2066      }      }
2067        
2068          // Refresh each channel usage, on each period...          if (m_pClient) {
2069      if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) {                  // Update the channel information for each pending strip...
2070          m_iTimerSlot += QSAMPLER_TIMER_MSECS;                  if (m_changedStrips.count() > 0) {
2071          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {                          for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first();
2072              m_iTimerSlot = 0;                                          pChannelStrip; pChannelStrip = m_changedStrips.next()) {
             // Update the channel information for each pending strip...  
             for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first();  
                     pChannelStrip;  
                                                 pChannelStrip = m_changedStrips.next()) {  
2073                                  // If successfull, remove from pending list...                                  // If successfull, remove from pending list...
2074                                  if (pChannelStrip->updateChannelInfo())                                  if (pChannelStrip->updateChannelInfo())
2075                      m_changedStrips.remove(pChannelStrip);                                          m_changedStrips.remove(pChannelStrip);
2076                          }                          }
2077              // Update the channel stream usage for each strip...                  }
2078              QWidgetList wlist = m_pWorkspace->windowList();                  // Refresh each channel usage, on each period...
2079              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  if (m_pOptions->bAutoRefresh) {
2080                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);                          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
2081                  if (pChannelStrip && pChannelStrip->isVisible())                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {
2082                      pChannelStrip->updateChannelUsage();                                  m_iTimerSlot = 0;
2083              }                                  // Update the channel stream usage for each strip...
2084          }                                  QWidgetList wlist = m_pWorkspace->windowList();
2085      }                                  for (int iChannel = 0;
2086                                                    iChannel < (int) wlist.count(); iChannel++) {
2087                                            qsamplerChannelStrip *pChannelStrip
2088                                                    = (qsamplerChannelStrip *) wlist.at(iChannel);
2089                                            if (pChannelStrip && pChannelStrip->isVisible())
2090                                                    pChannelStrip->updateChannelUsage();
2091                                    }
2092                            }
2093                    }
2094            }
2095    
2096      // Register the next timer slot.      // Register the next timer slot.
2097      QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(timerSlot()));      QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(timerSlot()));
# Line 1800  void qsamplerMainForm::startServer (void Line 2113  void qsamplerMainForm::startServer (void
2113    
2114      // Is the server process instance still here?      // Is the server process instance still here?
2115      if (m_pServer) {      if (m_pServer) {
2116          switch (QMessageBox::warning(this, tr("Warning"),          switch (QMessageBox::warning(this,
2117                            QSAMPLER_TITLE ": " + tr("Warning"),
2118              tr("Could not start the LinuxSampler server.\n\n"              tr("Could not start the LinuxSampler server.\n\n"
2119                 "Maybe it ss already started."),                 "Maybe it ss already started."),
2120              tr("Stop"), tr("Kill"), tr("Cancel"))) {              tr("Stop"), tr("Kill"), tr("Cancel"))) {
# Line 1959  bool qsamplerMainForm::startClient (void Line 2273  bool qsamplerMainForm::startClient (void
2273      ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);      ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);
2274      appendMessages(tr("Client receive timeout is set to %1 msec.").arg(::lscp_client_get_timeout(m_pClient)));      appendMessages(tr("Client receive timeout is set to %1 msec.").arg(::lscp_client_get_timeout(m_pClient)));
2275    
2276            // Subscribe to channel info change notifications...
2277            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)
2278                    appendMessagesClient("lscp_client_subscribe");
2279    
2280      // We may stop scheduling around.      // We may stop scheduling around.
2281      stopSchedule();      stopSchedule();
2282    
# Line 1968  bool qsamplerMainForm::startClient (void Line 2286  bool qsamplerMainForm::startClient (void
2286      // Log success here.      // Log success here.
2287      appendMessages(tr("Client connected."));      appendMessages(tr("Client connected."));
2288    
2289          // Hard-notify device configuration form,          // Hard-notify instrumnet and device configuration forms,
2290          // if visible, that we're ready...          // if visible, that we're ready...
2291          if (m_pDeviceForm && m_pDeviceForm->isVisible())          if (m_pInstrumentListForm)
2292              m_pDeviceForm->setClient(m_pClient);              m_pInstrumentListForm->refreshInstruments();
2293                        if (m_pDeviceForm)
2294                m_pDeviceForm->refreshDevices();
2295    
2296      // Is any session pending to be loaded?      // Is any session pending to be loaded?
2297      if (!m_pOptions->sSessionFile.isEmpty()) {      if (!m_pOptions->sSessionFile.isEmpty()) {
2298          // Just load the prabably startup session...          // Just load the prabably startup session...
# Line 1993  void qsamplerMainForm::stopClient (void) Line 2313  void qsamplerMainForm::stopClient (void)
2313      if (m_pClient == NULL)      if (m_pClient == NULL)
2314          return;          return;
2315    
         // Hard-notify device configuration form,  
         // if visible, that we're running out...  
         if (m_pDeviceForm && m_pDeviceForm->isVisible())  
             m_pDeviceForm->setClient(NULL);  
   
2316      // Log prepare here.      // Log prepare here.
2317      appendMessages(tr("Client disconnecting..."));      appendMessages(tr("Client disconnecting..."));
2318    
# Line 2012  void qsamplerMainForm::stopClient (void) Line 2327  void qsamplerMainForm::stopClient (void)
2327      // channels from the back-end server.      // channels from the back-end server.
2328      m_iDirtyCount = 0;      m_iDirtyCount = 0;
2329      closeSession(false);      closeSession(false);
2330        
2331      // Close us as a client...      // Close us as a client...
2332      lscp_client_destroy(m_pClient);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
2333        ::lscp_client_destroy(m_pClient);
2334      m_pClient = NULL;      m_pClient = NULL;
2335    
2336            // Hard-notify instrumnet and device configuration forms,
2337            // if visible, that we're running out...
2338            if (m_pInstrumentListForm)
2339                m_pInstrumentListForm->refreshInstruments();
2340            if (m_pDeviceForm)
2341                m_pDeviceForm->refreshDevices();
2342    
2343      // Log final here.      // Log final here.
2344      appendMessages(tr("Client disconnected."));      appendMessages(tr("Client disconnected."));
2345    

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

  ViewVC Help
Powered by ViewVC