/[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 757 by capela, Fri Aug 26 23:04:32 2005 UTC revision 996 by capela, Thu Dec 21 14:55:05 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    
# Line 102  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 186  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 204  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 214  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      m_pDeviceForm->setMainForm(this); // An important life immutable!  #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 251  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 291  bool qsamplerMainForm::queryClose (void) Line 321  bool qsamplerMainForm::queryClose (void)
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(m_pInstrumentListForm);
325                          m_pOptions->saveWidgetGeometry(this);                          m_pOptions->saveWidgetGeometry(this);
326                          // Close popup widgets.                          // Close popup widgets.
327                            if (m_pInstrumentListForm)
328                                    m_pInstrumentListForm->close();
329                          if (m_pDeviceForm)                          if (m_pDeviceForm)
330                                  m_pDeviceForm->close();                                  m_pDeviceForm->close();
331              // Stop client and/or server, gracefully.              // Stop client and/or server, gracefully.
# Line 351  void qsamplerMainForm::dropEvent ( QDrop Line 384  void qsamplerMainForm::dropEvent ( QDrop
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...
# Line 371  void qsamplerMainForm::dropEvent ( QDrop Line 404  void qsamplerMainForm::dropEvent ( QDrop
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 417  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 424  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 582  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 595  bool qsamplerMainForm::loadSessionFile ( Line 668  bool qsamplerMainForm::loadSessionFile (
668          return false;          return false;
669      }      }
670    
671            // Tell the world we'll take some time...
672            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
673    
674      // Read the file.      // Read the file.
675            int iLine = 0;
676      int iErrors = 0;      int iErrors = 0;
677      QTextStream ts(&file);      QTextStream ts(&file);
678      while (!ts.atEnd()) {      while (!ts.atEnd()) {
679          // Read the line.          // Read the line.
680          QString sCommand = ts.readLine().simplifyWhiteSpace();          QString sCommand = ts.readLine().stripWhiteSpace();
681                    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              appendMessagesColor(sCommand, "#996633");                          // HACK: A very special trap for the global RESET command...
685              // Remember that, no matter what,                          if (sCommand == "RESET") {
686              // all LSCP commands are CR/LF terminated.                                  // Do our own reset...
687              sCommand += "\r\n";                                  if (!resetSession())
688              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {                                          iErrors++;
689                  appendMessagesClient("lscp_client_query");                          } else {
690                  iErrors++;                                  // Remember that, no matter what,
691              }                                  // all LSCP commands are CR/LF terminated.
692                                    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 622  bool qsamplerMainForm::loadSessionFile ( Line 709  bool qsamplerMainForm::loadSessionFile (
709          // Now we'll try to create (update) the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
710          updateSession();          updateSession();
711    
712            // We're fornerly done.
713            QApplication::restoreOverrideCursor();
714    
715          // Have we any errors?          // Have we any errors?
716          if (iErrors > 0)          if (iErrors > 0)
717                  appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));                  appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));
# Line 645  bool qsamplerMainForm::loadSessionFile ( Line 735  bool qsamplerMainForm::loadSessionFile (
735  // Save current session to specific file path.  // Save current session to specific file path.
736  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )
737  {  {
738            if (m_pClient == NULL)
739                    return false;
740    
741            // Check whether server is apparently OK...
742            if (::lscp_get_channels(m_pClient) < 0) {
743                    appendMessagesClient("lscp_get_channels");
744                    return false;
745            }
746    
747      // Open and write into real file.      // Open and write into real file.
748      QFile file(sFilename);      QFile file(sFilename);
749      if (!file.open(IO_WriteOnly | IO_Truncate)) {      if (!file.open(IO_WriteOnly | IO_Truncate)) {
# Line 652  bool qsamplerMainForm::saveSessionFile ( Line 751  bool qsamplerMainForm::saveSessionFile (
751          return false;          return false;
752      }      }
753    
754            // Tell the world we'll take some time...
755            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
756    
757      // Write the file.      // Write the file.
758      int  iErrors = 0;      int  iErrors = 0;
759      QTextStream ts(&file);      QTextStream ts(&file);
# Line 668  bool qsamplerMainForm::saveSessionFile ( Line 770  bool qsamplerMainForm::saveSessionFile (
770         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
771      ts << "#"  << endl;      ts << "#"  << endl;
772      ts << endl;      ts << endl;
773    
774          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
775          // will be loaded from a complete          // will be loaded from a complete initialized server...
776          int *piDeviceIDs;          int *piDeviceIDs;
777          int  iDevice;          int  iDevice;
778          ts << "RESET" << endl;          ts << "RESET" << endl;
779    
780          // Audio device mapping.          // Audio device mapping.
781          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap;
782          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
783          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
784                  ts << endl;                  ts << endl;
785                  qsamplerDevice device(this, qsamplerDevice::Audio, piDeviceIDs[iDevice]);                  qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]);
786                  // Audio device specification...                  // Audio device specification...
787                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
788                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
# Line 710  bool qsamplerMainForm::saveSessionFile ( Line 814  bool qsamplerMainForm::saveSessionFile (
814                  }                  }
815                  // Audio device index/id mapping.                  // Audio device index/id mapping.
816                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap[device.deviceID()] = iDevice;
817          // Try to keep it snappy :)                  // Try to keep it snappy :)
818          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
819          }          }
820    
821          // MIDI device mapping.          // MIDI device mapping.
822          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap;
823          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
824          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
825                  ts << endl;                  ts << endl;
826                  qsamplerDevice device(this, qsamplerDevice::Midi, piDeviceIDs[iDevice]);                  qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]);
827                  // MIDI device specification...                  // MIDI device specification...
828                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
829                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
# Line 750  bool qsamplerMainForm::saveSessionFile ( Line 855  bool qsamplerMainForm::saveSessionFile (
855                  }                  }
856                  // MIDI device index/id mapping.                  // MIDI device index/id mapping.
857                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap[device.deviceID()] = iDevice;
858          // Try to keep it snappy :)                  // Try to keep it snappy :)
859          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
860          }          }
861          ts << endl;          ts << endl;
862    
863    #ifdef CONFIG_MIDI_INSTRUMENT
864            // MIDI instrument mapping...
865            QMap<int, int> midiInstrumentMap;
866            int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);
867            for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) {
868                    int iMidiMap = piMaps[iMap];
869                    const char *pszMapName
870                            = ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap);
871                    ts << "# " << tr("MIDI instrument map") << " " << iMap;
872                    if (pszMapName)
873                            ts << " - " << pszMapName;
874                    ts << endl;
875                    ts << "ADD MIDI_INSTRUMENT_MAP";
876                    if (pszMapName)
877                            ts << " '" << pszMapName << "'";
878                    ts << endl;
879                    // MIDI instrument mapping...
880                    lscp_midi_instrument_t *pInstrs
881                            = ::lscp_list_midi_instruments(m_pClient, iMidiMap);
882                    for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; iInstr++) {
883                            lscp_midi_instrument_info_t *pInstrInfo
884                                    = ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]);
885                            if (pInstrInfo) {
886                                    ts << "MAP MIDI_INSTRUMENT "
887                                            << iMap                        << " "
888                                            << pInstrs[iInstr].bank        << " "
889                                            << pInstrs[iInstr].prog        << " "
890                                            << pInstrInfo->engine_name     << " '"
891                                            << pInstrInfo->instrument_file << "' "
892                                            << pInstrInfo->instrument_nr   << " "
893                                            << pInstrInfo->volume          << " ";
894                                    switch (pInstrInfo->load_mode) {
895                                            case LSCP_LOAD_PERSISTENT:
896                                                    ts << "PERSISTENT";
897                                                    break;
898                                            case LSCP_LOAD_ON_DEMAND_HOLD:
899                                                    ts << "ON_DEMAND_HOLD";
900                                                    break;
901                                            case LSCP_LOAD_ON_DEMAND:
902                                            case LSCP_LOAD_DEFAULT:
903                                            default:
904                                                    ts << "ON_DEMAND";
905                                                    break;
906                                    }
907                                    if (pInstrInfo->name)
908                                            ts << " '" << pInstrInfo->name << "'";
909                                    ts << endl;
910                            }       // Check for errors...
911                            else if (::lscp_client_get_errno(m_pClient)) {
912                                    appendMessagesClient("lscp_get_midi_instrument_info");
913                                    iErrors++;
914                            }
915                            // MIDI device index/id mapping.
916                            midiInstrumentMap[iMidiMap] = iMap;
917                            // Try to keep it snappy :)
918                            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
919                    }
920                    // Check for errors...
921                    if (pInstrs)
922                            ts << endl;
923                    else if (::lscp_client_get_errno(m_pClient)) {
924                            appendMessagesClient("lscp_list_midi_instruments");
925                            iErrors++;
926                    }
927            }
928            // Check for errors...
929            if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {
930                    appendMessagesClient("lscp_list_midi_instrument_maps");
931                    iErrors++;
932            }
933    #endif  // CONFIG_MIDI_INSTRUMENT
934    
935          // Sampler channel mapping.          // Sampler channel mapping.
936      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
937      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
# Line 786  bool qsamplerMainForm::saveSessionFile ( Line 964  bool qsamplerMainForm::saveSessionFile (
964                      ts << pChannel->midiChannel();                      ts << pChannel->midiChannel();
965                  ts << endl;                  ts << endl;
966                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
967                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;                                  if (pChannel->instrumentStatus() < 100) ts << "# ";
968                  ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;                                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' "
969                  if (pChannel->channelMute())                                          << pChannel->instrumentNr() << " " << iChannel << endl;
970                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;                                  qsamplerChannelRoutingMap::ConstIterator audioRoute;
971                  if (pChannel->channelSolo())                                  for (audioRoute = pChannel->audioRouting().begin();
972                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;                                                  audioRoute != pChannel->audioRouting().end();
973                                                            ++audioRoute) {
974                                            ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel
975                                                    << " " << audioRoute.key()
976                                                    << " " << audioRoute.data() << endl;
977                                    }
978                                    ts << "SET CHANNEL VOLUME " << iChannel
979                                            << " " << pChannel->volume() << endl;
980                                    if (pChannel->channelMute())
981                                            ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
982                                    if (pChannel->channelSolo())
983                                            ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
984    #ifdef CONFIG_MIDI_INSTRUMENT
985                                    if (pChannel->midiMap() >= 0) {
986                                            ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel
987                                                    << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
988                                    }
989    #endif
990                  ts << endl;                  ts << endl;
991              }              }
992          }          }
# Line 802  bool qsamplerMainForm::saveSessionFile ( Line 997  bool qsamplerMainForm::saveSessionFile (
997      // Ok. we've wrote it.      // Ok. we've wrote it.
998      file.close();      file.close();
999    
1000            // We're fornerly done.
1001            QApplication::restoreOverrideCursor();
1002    
1003      // Have we any errors?      // Have we any errors?
1004      if (iErrors > 0)      if (iErrors > 0)
1005          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 893  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) && ::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."));
# Line 957  void qsamplerMainForm::editAddChannel (v Line 1156  void qsamplerMainForm::editAddChannel (v
1156          return;          return;
1157    
1158      // Just create the channel instance...      // Just create the channel instance...
1159      qsamplerChannel *pChannel = new qsamplerChannel(this);      qsamplerChannel *pChannel = new qsamplerChannel();
1160      if (pChannel == NULL)      if (pChannel == NULL)
1161          return;          return;
1162    
# Line 1120  void qsamplerMainForm::viewMessages ( bo Line 1319  void qsamplerMainForm::viewMessages ( bo
1319  }  }
1320    
1321    
1322    // Show/hide the MIDI instrument list-view form.
1323    void qsamplerMainForm::viewInstruments (void)
1324    {
1325            if (m_pOptions == NULL)
1326                    return;
1327    
1328            if (m_pInstrumentListForm) {
1329                    m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
1330                    if (m_pInstrumentListForm->isVisible()) {
1331                            m_pInstrumentListForm->hide();
1332                    } else {
1333                            m_pInstrumentListForm->show();
1334                            m_pInstrumentListForm->raise();
1335                            m_pInstrumentListForm->setActiveWindow();
1336                    }
1337            }
1338    }
1339    
1340    
1341  // Show/hide the device configurator form.  // Show/hide the device configurator form.
1342  void qsamplerMainForm::viewDevices (void)  void qsamplerMainForm::viewDevices (void)
1343  {  {
# Line 1128  void qsamplerMainForm::viewDevices (void Line 1346  void qsamplerMainForm::viewDevices (void
1346    
1347          if (m_pDeviceForm) {          if (m_pDeviceForm) {
1348                  m_pOptions->saveWidgetGeometry(m_pDeviceForm);                  m_pOptions->saveWidgetGeometry(m_pDeviceForm);
                 m_pDeviceForm->setClient(m_pClient);  
1349                  if (m_pDeviceForm->isVisible()) {                  if (m_pDeviceForm->isVisible()) {
1350                          m_pDeviceForm->hide();                          m_pDeviceForm->hide();
1351                  } else {                  } else {
# Line 1314  void qsamplerMainForm::helpAbout (void) Line 1531  void qsamplerMainForm::helpAbout (void)
1531      sText += tr("Sampler channel Mute/Solo support disabled.");      sText += tr("Sampler channel Mute/Solo support disabled.");
1532      sText += "</font></small><br />";      sText += "</font></small><br />";
1533  #endif  #endif
1534    #ifndef CONFIG_MIDI_INSTRUMENT
1535        sText += "<small><font color=\"red\">";
1536        sText += tr("MIDI instrument mapping support disabled.");
1537        sText += "</font></small><br />";
1538    #endif
1539      sText += "<br />\n";      sText += "<br />\n";
1540      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1541      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1349  void qsamplerMainForm::stabilizeForm (vo Line 1571  void qsamplerMainForm::stabilizeForm (vo
1571      // Update the main application caption...      // Update the main application caption...
1572      QString sSessionName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1573      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1574          sSessionName += '*';          sSessionName += " *";
1575      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1576    
1577      // Update the main menu state...      // Update the main menu state...
# Line 1368  void qsamplerMainForm::stabilizeForm (vo Line 1590  void qsamplerMainForm::stabilizeForm (vo
1590      editResetChannelAction->setEnabled(bHasChannel);      editResetChannelAction->setEnabled(bHasChannel);
1591      editResetAllChannelsAction->setEnabled(bHasChannel);      editResetAllChannelsAction->setEnabled(bHasChannel);
1592      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());
1593      viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible());  #ifdef CONFIG_MIDI_INSTRUMENT
1594            viewInstrumentsAction->setOn(m_pInstrumentListForm
1595                    && m_pInstrumentListForm->isVisible());
1596            viewInstrumentsAction->setEnabled(bHasClient);
1597    #endif
1598            viewDevicesAction->setOn(m_pDeviceForm
1599                    && m_pDeviceForm->isVisible());
1600      viewDevicesAction->setEnabled(bHasClient);      viewDevicesAction->setEnabled(bHasClient);
1601      channelsArrangeAction->setEnabled(bHasChannel);      channelsArrangeAction->setEnabled(bHasChannel);
1602    
# Line 1419  void qsamplerMainForm::channelStripChang Line 1647  void qsamplerMainForm::channelStripChang
1647  // Grab and restore current sampler channels session.  // Grab and restore current sampler channels session.
1648  void qsamplerMainForm::updateSession (void)  void qsamplerMainForm::updateSession (void)
1649  {  {
1650    #ifdef CONFIG_MIDI_INSTRUMENT
1651            // FIXME Make some room for default instrument maps...
1652            int iMaps = ::lscp_get_midi_instrument_maps(m_pClient);
1653            if (iMaps < 0)
1654                    appendMessagesClient("lscp_get_midi_instrument_maps");
1655            else if (iMaps < 1) {
1656                    ::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1());
1657                    ::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1());
1658            }
1659    #endif
1660    
1661          // Retrieve the current channel list.          // Retrieve the current channel list.
1662          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
1663          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 1426  void qsamplerMainForm::updateSession (vo Line 1665  void qsamplerMainForm::updateSession (vo
1665                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
1666                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1667                  }                  }
1668                  return;          } else {
1669                    // Try to (re)create each channel.
1670                    m_pWorkspace->setUpdatesEnabled(false);
1671                    for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1672                            // Check if theres already a channel strip for this one...
1673                            if (!channelStrip(piChannelIDs[iChannel]))
1674                                    createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel]));
1675                    }
1676                    m_pWorkspace->setUpdatesEnabled(true);
1677          }          }
1678    
1679          // Try to (re)create each channel.      // Do we auto-arrange?
1680          m_pWorkspace->setUpdatesEnabled(false);      if (m_pOptions && m_pOptions->bAutoArrange)
1681          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {          channelsArrange();
1682                  // Check if theres already a channel strip for this one...  
1683                  if (!channelStrip(piChannelIDs[iChannel]))          // Remember to refresh devices and instruments...
1684                          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));          if (m_pInstrumentListForm)
1685                  // Make it visibly responsive...              m_pInstrumentListForm->refreshInstruments();
                 QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);  
         }  
         m_pWorkspace->setUpdatesEnabled(true);  
           
         // Remember to refresh devices  
1686          if (m_pDeviceForm)          if (m_pDeviceForm)
1687              m_pDeviceForm->refreshDevices();              m_pDeviceForm->refreshDevices();
1688  }  }
# Line 1613  void qsamplerMainForm::appendMessagesErr Line 1855  void qsamplerMainForm::appendMessagesErr
1855    
1856      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");
1857    
1858            // Make it look responsive...:)
1859            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1860    
1861      QMessageBox::critical(this,      QMessageBox::critical(this,
1862                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));
1863  }  }
# Line 1627  void qsamplerMainForm::appendMessagesCli Line 1872  void qsamplerMainForm::appendMessagesCli
1872      appendMessagesColor(s + QString(": %1 (errno=%2)")      appendMessagesColor(s + QString(": %1 (errno=%2)")
1873          .arg(::lscp_client_get_result(m_pClient))          .arg(::lscp_client_get_result(m_pClient))
1874          .arg(::lscp_client_get_errno(m_pClient)), "#996666");          .arg(::lscp_client_get_errno(m_pClient)), "#996666");
1875    
1876            // Make it look responsive...:)
1877            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1878  }  }
1879    
1880    
# Line 2059  bool qsamplerMainForm::startClient (void Line 2307  bool qsamplerMainForm::startClient (void
2307      // Log success here.      // Log success here.
2308      appendMessages(tr("Client connected."));      appendMessages(tr("Client connected."));
2309    
2310          // Hard-notify device configuration form,          // Hard-notify instrumnet and device configuration forms,
2311          // if visible, that we're ready...          // if visible, that we're ready...
2312          if (m_pDeviceForm && m_pDeviceForm->isVisible())          if (m_pInstrumentListForm)
2313              m_pDeviceForm->setClient(m_pClient);              m_pInstrumentListForm->refreshInstruments();
2314            if (m_pDeviceForm)
2315                m_pDeviceForm->refreshDevices();
2316    
2317      // Is any session pending to be loaded?      // Is any session pending to be loaded?
2318      if (!m_pOptions->sSessionFile.isEmpty()) {      if (!m_pOptions->sSessionFile.isEmpty()) {
# Line 2084  void qsamplerMainForm::stopClient (void) Line 2334  void qsamplerMainForm::stopClient (void)
2334      if (m_pClient == NULL)      if (m_pClient == NULL)
2335          return;          return;
2336    
         // Hard-notify device configuration form,  
         // if visible, that we're running out...  
         if (m_pDeviceForm && m_pDeviceForm->isVisible())  
             m_pDeviceForm->setClient(NULL);  
   
2337      // Log prepare here.      // Log prepare here.
2338      appendMessages(tr("Client disconnecting..."));      appendMessages(tr("Client disconnecting..."));
2339    
# Line 2109  void qsamplerMainForm::stopClient (void) Line 2354  void qsamplerMainForm::stopClient (void)
2354      ::lscp_client_destroy(m_pClient);      ::lscp_client_destroy(m_pClient);
2355      m_pClient = NULL;      m_pClient = NULL;
2356    
2357            // Hard-notify instrumnet and device configuration forms,
2358            // if visible, that we're running out...
2359            if (m_pInstrumentListForm)
2360                m_pInstrumentListForm->refreshInstruments();
2361            if (m_pDeviceForm)
2362                m_pDeviceForm->refreshDevices();
2363    
2364      // Log final here.      // Log final here.
2365      appendMessages(tr("Client disconnected."));      appendMessages(tr("Client disconnected."));
2366    

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

  ViewVC Help
Powered by ViewVC