/[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 1018 by capela, Wed Jan 10 19:39:00 2007 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-2007, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# 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 132  void qsamplerMainForm::init (void) Line 142  void qsamplerMainForm::init (void)
142      // Make it an MDI workspace.      // Make it an MDI workspace.
143      m_pWorkspace = new QWorkspace(this);      m_pWorkspace = new QWorkspace(this);
144      m_pWorkspace->setScrollBarsEnabled(true);      m_pWorkspace->setScrollBarsEnabled(true);
145      // Set the activation connection.          // Set the activation connection.
146      QObject::connect(m_pWorkspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(stabilizeForm()));          QObject::connect(m_pWorkspace,
147                    SIGNAL(windowActivated(QWidget *)),
148                    SLOT(stabilizeForm()));
149      // Make it shine :-)      // Make it shine :-)
150      setCentralWidget(m_pWorkspace);      setCentralWidget(m_pWorkspace);
151    
# Line 186  void qsamplerMainForm::destroy (void) Line 198  void qsamplerMainForm::destroy (void)
198      // Finally drop any widgets around...      // Finally drop any widgets around...
199      if (m_pDeviceForm)      if (m_pDeviceForm)
200          delete m_pDeviceForm;          delete m_pDeviceForm;
201        if (m_pInstrumentListForm)
202            delete m_pInstrumentListForm;
203      if (m_pMessages)      if (m_pMessages)
204          delete m_pMessages;          delete m_pMessages;
205      if (m_pWorkspace)      if (m_pWorkspace)
# Line 204  void qsamplerMainForm::destroy (void) Line 218  void qsamplerMainForm::destroy (void)
218      // Delete recentfiles menu.      // Delete recentfiles menu.
219      if (m_pRecentFilesMenu)      if (m_pRecentFilesMenu)
220          delete m_pRecentFilesMenu;          delete m_pRecentFilesMenu;
221    
222            // Pseudo-singleton reference shut-down.
223            g_pMainForm = NULL;
224  }  }
225    
226    
# Line 214  void qsamplerMainForm::setup ( qsamplerO Line 231  void qsamplerMainForm::setup ( qsamplerO
231      m_pOptions = pOptions;      m_pOptions = pOptions;
232    
233      // What style do we create these forms?      // What style do we create these forms?
234      WFlags wflags = Qt::WType_TopLevel;          Qt::WFlags wflags = Qt::WStyle_Customize
235                    | Qt::WStyle_NormalBorder
236                    | Qt::WStyle_Title
237                    | Qt::WStyle_SysMenu
238                    | Qt::WStyle_MinMax
239                    | Qt::WType_TopLevel;
240      if (m_pOptions->bKeepOnTop)      if (m_pOptions->bKeepOnTop)
241          wflags |= Qt::WStyle_Tool;          wflags |= Qt::WStyle_Tool;
242      // Some child forms are to be created right now.      // Some child forms are to be created right now.
243      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
244      m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags);      m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags);
245      m_pDeviceForm->setMainForm(this); // An important life immutable!  #ifdef CONFIG_MIDI_INSTRUMENT
246        m_pInstrumentListForm = new qsamplerInstrumentListForm(this, 0, wflags);
247            QObject::connect(m_pInstrumentListForm->InstrumentList,
248                    SIGNAL(instrumentsChanged()),
249                    SLOT(sessionDirty()));
250    #else
251            viewInstrumentsAction->setEnabled(false);
252    #endif
253      // Set message defaults...      // Set message defaults...
254      updateMessagesFont();      updateMessagesFont();
255      updateMessagesLimit();      updateMessagesLimit();
256      updateMessagesCapture();      updateMessagesCapture();
257      // Set the visibility signal.      // Set the visibility signal.
258      QObject::connect(m_pMessages, SIGNAL(visibilityChanged(bool)), this, SLOT(stabilizeForm()));          QObject::connect(m_pMessages,
259                    SIGNAL(visibilityChanged(bool)),
260                    SLOT(stabilizeForm()));
261    
262      // Initial decorations toggle state.      // Initial decorations toggle state.
263      viewMenubarAction->setOn(m_pOptions->bMenubar);      viewMenubarAction->setOn(m_pOptions->bMenubar);
# Line 251  void qsamplerMainForm::setup ( qsamplerO Line 282  void qsamplerMainForm::setup ( qsamplerO
282      }      }
283      // Try to restore old window positioning and initial visibility.      // Try to restore old window positioning and initial visibility.
284      m_pOptions->loadWidgetGeometry(this);      m_pOptions->loadWidgetGeometry(this);
285        m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);
286      m_pOptions->loadWidgetGeometry(m_pDeviceForm);      m_pOptions->loadWidgetGeometry(m_pDeviceForm);
287    
288      // Final startup stabilization...      // Final startup stabilization...
# Line 291  bool qsamplerMainForm::queryClose (void) Line 323  bool qsamplerMainForm::queryClose (void)
323              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);
324              // And the children, and the main windows state,.              // And the children, and the main windows state,.
325                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);
326                            m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
327                          m_pOptions->saveWidgetGeometry(this);                          m_pOptions->saveWidgetGeometry(this);
328                          // Close popup widgets.                          // Close popup widgets.
329                            if (m_pInstrumentListForm)
330                                    m_pInstrumentListForm->close();
331                          if (m_pDeviceForm)                          if (m_pDeviceForm)
332                                  m_pDeviceForm->close();                                  m_pDeviceForm->close();
333              // Stop client and/or server, gracefully.              // Stop client and/or server, gracefully.
# Line 351  void qsamplerMainForm::dropEvent ( QDrop Line 386  void qsamplerMainForm::dropEvent ( QDrop
386                  const QString& sPath = *iter;                  const QString& sPath = *iter;
387                  if (qsamplerChannel::isInstrumentFile(sPath)) {                  if (qsamplerChannel::isInstrumentFile(sPath)) {
388                          // Try to create a new channel from instrument file...                          // Try to create a new channel from instrument file...
389                          qsamplerChannel *pChannel = new qsamplerChannel(this);                          qsamplerChannel *pChannel = new qsamplerChannel();
390                          if (pChannel == NULL)                          if (pChannel == NULL)
391                                  return;                                  return;
392                          // Start setting the instrument filename...                          // Start setting the instrument filename...
# Line 371  void qsamplerMainForm::dropEvent ( QDrop Line 406  void qsamplerMainForm::dropEvent ( QDrop
406                          m_iDirtyCount++;                          m_iDirtyCount++;
407                          stabilizeForm();                          stabilizeForm();
408                  }   // Otherwise, load an usual session file (LSCP script)...                  }   // Otherwise, load an usual session file (LSCP script)...
409                  else if (closeSession(true))                  else if (closeSession(true)) {
410                          loadSessionFile(sPath);                          loadSessionFile(sPath);
411                            break;
412                    }
413                  // Make it look responsive...:)                  // Make it look responsive...:)
414                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
415          }          }
# Line 417  qsamplerOptions *qsamplerMainForm::optio Line 454  qsamplerOptions *qsamplerMainForm::optio
454      return m_pOptions;      return m_pOptions;
455  }  }
456    
457    
458  // The LSCP client descriptor property.  // The LSCP client descriptor property.
459  lscp_client_t *qsamplerMainForm::client (void)  lscp_client_t *qsamplerMainForm::client (void)
460  {  {
# Line 424  lscp_client_t *qsamplerMainForm::client Line 462  lscp_client_t *qsamplerMainForm::client
462  }  }
463    
464    
465    // The pseudo-singleton instance accessor.
466    qsamplerMainForm *qsamplerMainForm::getInstance (void)
467    {
468            return g_pMainForm;
469    }
470    
471    
472  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
473  // qsamplerMainForm -- Session file stuff.  // qsamplerMainForm -- Session file stuff.
474    
# Line 595  bool qsamplerMainForm::loadSessionFile ( Line 640  bool qsamplerMainForm::loadSessionFile (
640          return false;          return false;
641      }      }
642    
643            // Tell the world we'll take some time...
644            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
645    
646      // Read the file.      // Read the file.
647            int iLine = 0;
648      int iErrors = 0;      int iErrors = 0;
649      QTextStream ts(&file);      QTextStream ts(&file);
650      while (!ts.atEnd()) {      while (!ts.atEnd()) {
651          // Read the line.          // Read the line.
652          QString sCommand = ts.readLine().simplifyWhiteSpace();          QString sCommand = ts.readLine().stripWhiteSpace();
653                    iLine++;
654          // If not empty, nor a comment, call the server...          // If not empty, nor a comment, call the server...
655          if (!sCommand.isEmpty() && sCommand[0] != '#') {          if (!sCommand.isEmpty() && sCommand[0] != '#') {
656              appendMessagesColor(sCommand, "#996633");                          // Remember that, no matter what,
657              // Remember that, no matter what,                          // all LSCP commands are CR/LF terminated.
658              // all LSCP commands are CR/LF terminated.                          sCommand += "\r\n";
659              sCommand += "\r\n";                          if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
660              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {                                  appendMessagesColor(QString("%1(%2): %3")
661                  appendMessagesClient("lscp_client_query");                                          .arg(QFileInfo(sFilename).fileName()).arg(iLine)
662                  iErrors++;                                          .arg(sCommand.simplifyWhiteSpace()), "#996633");
663              }                                  appendMessagesClient("lscp_client_query");
664                                    iErrors++;
665                            }
666          }          }
667          // Try to make it snappy :)          // Try to make it snappy :)
668          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
# Line 622  bool qsamplerMainForm::loadSessionFile ( Line 674  bool qsamplerMainForm::loadSessionFile (
674          // Now we'll try to create (update) the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
675          updateSession();          updateSession();
676    
677            // We're fornerly done.
678            QApplication::restoreOverrideCursor();
679    
680          // Have we any errors?          // Have we any errors?
681          if (iErrors > 0)          if (iErrors > 0)
682                  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 700  bool qsamplerMainForm::loadSessionFile (
700  // Save current session to specific file path.  // Save current session to specific file path.
701  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )
702  {  {
703            if (m_pClient == NULL)
704                    return false;
705    
706            // Check whether server is apparently OK...
707            if (::lscp_get_channels(m_pClient) < 0) {
708                    appendMessagesClient("lscp_get_channels");
709                    return false;
710            }
711    
712      // Open and write into real file.      // Open and write into real file.
713      QFile file(sFilename);      QFile file(sFilename);
714      if (!file.open(IO_WriteOnly | IO_Truncate)) {      if (!file.open(IO_WriteOnly | IO_Truncate)) {
# Line 652  bool qsamplerMainForm::saveSessionFile ( Line 716  bool qsamplerMainForm::saveSessionFile (
716          return false;          return false;
717      }      }
718    
719            // Tell the world we'll take some time...
720            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
721    
722      // Write the file.      // Write the file.
723      int  iErrors = 0;      int  iErrors = 0;
724      QTextStream ts(&file);      QTextStream ts(&file);
# Line 668  bool qsamplerMainForm::saveSessionFile ( Line 735  bool qsamplerMainForm::saveSessionFile (
735         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
736      ts << "#"  << endl;      ts << "#"  << endl;
737      ts << endl;      ts << endl;
738    
739          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
740          // will be loaded from a complete          // will be loaded from a complete initialized server...
741          int *piDeviceIDs;          int *piDeviceIDs;
742          int  iDevice;          int  iDevice;
743          ts << "RESET" << endl;          ts << "RESET" << endl;
744    
745          // Audio device mapping.          // Audio device mapping.
746          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap;
747          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
748          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
749                  ts << endl;                  ts << endl;
750                  qsamplerDevice device(this, qsamplerDevice::Audio, piDeviceIDs[iDevice]);                  qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]);
751                  // Audio device specification...                  // Audio device specification...
752                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
753                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
# Line 710  bool qsamplerMainForm::saveSessionFile ( Line 779  bool qsamplerMainForm::saveSessionFile (
779                  }                  }
780                  // Audio device index/id mapping.                  // Audio device index/id mapping.
781                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap[device.deviceID()] = iDevice;
782          // Try to keep it snappy :)                  // Try to keep it snappy :)
783          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
784          }          }
785    
786          // MIDI device mapping.          // MIDI device mapping.
787          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap;
788          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
789          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
790                  ts << endl;                  ts << endl;
791                  qsamplerDevice device(this, qsamplerDevice::Midi, piDeviceIDs[iDevice]);                  qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]);
792                  // MIDI device specification...                  // MIDI device specification...
793                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
794                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
# Line 750  bool qsamplerMainForm::saveSessionFile ( Line 820  bool qsamplerMainForm::saveSessionFile (
820                  }                  }
821                  // MIDI device index/id mapping.                  // MIDI device index/id mapping.
822                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap[device.deviceID()] = iDevice;
823          // Try to keep it snappy :)                  // Try to keep it snappy :)
824          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
825          }          }
826          ts << endl;          ts << endl;
827    
828    #ifdef CONFIG_MIDI_INSTRUMENT
829            // MIDI instrument mapping...
830            QMap<int, int> midiInstrumentMap;
831            int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);
832            for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) {
833                    int iMidiMap = piMaps[iMap];
834                    const char *pszMapName
835                            = ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap);
836                    ts << "# " << tr("MIDI instrument map") << " " << iMap;
837                    if (pszMapName)
838                            ts << " - " << pszMapName;
839                    ts << endl;
840                    ts << "ADD MIDI_INSTRUMENT_MAP";
841                    if (pszMapName)
842                            ts << " '" << pszMapName << "'";
843                    ts << endl;
844                    // MIDI instrument mapping...
845                    lscp_midi_instrument_t *pInstrs
846                            = ::lscp_list_midi_instruments(m_pClient, iMidiMap);
847                    for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; iInstr++) {
848                            lscp_midi_instrument_info_t *pInstrInfo
849                                    = ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]);
850                            if (pInstrInfo) {
851                                    ts << "MAP MIDI_INSTRUMENT "
852                                            << iMap                        << " "
853                                            << pInstrs[iInstr].bank        << " "
854                                            << pInstrs[iInstr].prog        << " "
855                                            << pInstrInfo->engine_name     << " '"
856                                            << pInstrInfo->instrument_file << "' "
857                                            << pInstrInfo->instrument_nr   << " "
858                                            << pInstrInfo->volume          << " ";
859                                    switch (pInstrInfo->load_mode) {
860                                            case LSCP_LOAD_PERSISTENT:
861                                                    ts << "PERSISTENT";
862                                                    break;
863                                            case LSCP_LOAD_ON_DEMAND_HOLD:
864                                                    ts << "ON_DEMAND_HOLD";
865                                                    break;
866                                            case LSCP_LOAD_ON_DEMAND:
867                                            case LSCP_LOAD_DEFAULT:
868                                            default:
869                                                    ts << "ON_DEMAND";
870                                                    break;
871                                    }
872                                    if (pInstrInfo->name)
873                                            ts << " '" << pInstrInfo->name << "'";
874                                    ts << endl;
875                            }       // Check for errors...
876                            else if (::lscp_client_get_errno(m_pClient)) {
877                                    appendMessagesClient("lscp_get_midi_instrument_info");
878                                    iErrors++;
879                            }
880                            // Try to keep it snappy :)
881                            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
882                    }
883                    ts << endl;
884                    // Check for errors...
885                    if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) {
886                            appendMessagesClient("lscp_list_midi_instruments");
887                            iErrors++;
888                    }
889                    // MIDI strument index/id mapping.
890                    midiInstrumentMap[iMidiMap] = iMap;
891            }
892            // Check for errors...
893            if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {
894                    appendMessagesClient("lscp_list_midi_instrument_maps");
895                    iErrors++;
896            }
897    #endif  // CONFIG_MIDI_INSTRUMENT
898    
899          // Sampler channel mapping.          // Sampler channel mapping.
900      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
901      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
# Line 786  bool qsamplerMainForm::saveSessionFile ( Line 928  bool qsamplerMainForm::saveSessionFile (
928                      ts << pChannel->midiChannel();                      ts << pChannel->midiChannel();
929                  ts << endl;                  ts << endl;
930                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
931                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;                                  if (pChannel->instrumentStatus() < 100) ts << "# ";
932                  ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;                                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' "
933                  if (pChannel->channelMute())                                          << pChannel->instrumentNr() << " " << iChannel << endl;
934                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;                                  qsamplerChannelRoutingMap::ConstIterator audioRoute;
935                  if (pChannel->channelSolo())                                  for (audioRoute = pChannel->audioRouting().begin();
936                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;                                                  audioRoute != pChannel->audioRouting().end();
937                                                            ++audioRoute) {
938                                            ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel
939                                                    << " " << audioRoute.key()
940                                                    << " " << audioRoute.data() << endl;
941                                    }
942                                    ts << "SET CHANNEL VOLUME " << iChannel
943                                            << " " << pChannel->volume() << endl;
944                                    if (pChannel->channelMute())
945                                            ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
946                                    if (pChannel->channelSolo())
947                                            ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
948    #ifdef CONFIG_MIDI_INSTRUMENT
949                                    if (pChannel->midiMap() >= 0) {
950                                            ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel
951                                                    << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
952                                    }
953    #endif
954                  ts << endl;                  ts << endl;
955              }              }
956          }          }
# Line 802  bool qsamplerMainForm::saveSessionFile ( Line 961  bool qsamplerMainForm::saveSessionFile (
961      // Ok. we've wrote it.      // Ok. we've wrote it.
962      file.close();      file.close();
963    
964            // We're fornerly done.
965            QApplication::restoreOverrideCursor();
966    
967      // Have we any errors?      // Have we any errors?
968      if (iErrors > 0)      if (iErrors > 0)
969          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 1055  void qsamplerMainForm::fileReset (void)
1055          tr("Reset"), tr("Cancel")) > 0)          tr("Reset"), tr("Cancel")) > 0)
1056          return;          return;
1057    
1058            // Trye closing the current session, first...
1059            if (!closeSession(true))
1060                    return;
1061    
1062      // Just do the reset, after closing down current session...      // Just do the reset, after closing down current session...
1063      if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {          // Do the actual sampler reset...
1064          appendMessagesClient("lscp_reset_sampler");          if (::lscp_reset_sampler(m_pClient) != LSCP_OK) {
1065          appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));                  appendMessagesClient("lscp_reset_sampler");
1066          return;                  appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
1067      }                  return;
1068            }
1069    
1070      // Log this.      // Log this.
1071      appendMessages(tr("Sampler reset."));      appendMessages(tr("Sampler reset."));
# Line 957  void qsamplerMainForm::editAddChannel (v Line 1124  void qsamplerMainForm::editAddChannel (v
1124          return;          return;
1125    
1126      // Just create the channel instance...      // Just create the channel instance...
1127      qsamplerChannel *pChannel = new qsamplerChannel(this);      qsamplerChannel *pChannel = new qsamplerChannel();
1128      if (pChannel == NULL)      if (pChannel == NULL)
1129          return;          return;
1130    
# Line 1120  void qsamplerMainForm::viewMessages ( bo Line 1287  void qsamplerMainForm::viewMessages ( bo
1287  }  }
1288    
1289    
1290    // Show/hide the MIDI instrument list-view form.
1291    void qsamplerMainForm::viewInstruments (void)
1292    {
1293            if (m_pOptions == NULL)
1294                    return;
1295    
1296            if (m_pInstrumentListForm) {
1297                    m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
1298                    if (m_pInstrumentListForm->isVisible()) {
1299                            m_pInstrumentListForm->hide();
1300                    } else {
1301                            m_pInstrumentListForm->show();
1302                            m_pInstrumentListForm->raise();
1303                            m_pInstrumentListForm->setActiveWindow();
1304                    }
1305            }
1306    }
1307    
1308    
1309  // Show/hide the device configurator form.  // Show/hide the device configurator form.
1310  void qsamplerMainForm::viewDevices (void)  void qsamplerMainForm::viewDevices (void)
1311  {  {
# Line 1128  void qsamplerMainForm::viewDevices (void Line 1314  void qsamplerMainForm::viewDevices (void
1314    
1315          if (m_pDeviceForm) {          if (m_pDeviceForm) {
1316                  m_pOptions->saveWidgetGeometry(m_pDeviceForm);                  m_pOptions->saveWidgetGeometry(m_pDeviceForm);
                 m_pDeviceForm->setClient(m_pClient);  
1317                  if (m_pDeviceForm->isVisible()) {                  if (m_pDeviceForm->isVisible()) {
1318                          m_pDeviceForm->hide();                          m_pDeviceForm->hide();
1319                  } else {                  } else {
# Line 1314  void qsamplerMainForm::helpAbout (void) Line 1499  void qsamplerMainForm::helpAbout (void)
1499      sText += tr("Sampler channel Mute/Solo support disabled.");      sText += tr("Sampler channel Mute/Solo support disabled.");
1500      sText += "</font></small><br />";      sText += "</font></small><br />";
1501  #endif  #endif
1502    #ifndef CONFIG_MIDI_INSTRUMENT
1503        sText += "<small><font color=\"red\">";
1504        sText += tr("MIDI instrument mapping support disabled.");
1505        sText += "</font></small><br />";
1506    #endif
1507      sText += "<br />\n";      sText += "<br />\n";
1508      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1509      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1349  void qsamplerMainForm::stabilizeForm (vo Line 1539  void qsamplerMainForm::stabilizeForm (vo
1539      // Update the main application caption...      // Update the main application caption...
1540      QString sSessionName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1541      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1542          sSessionName += '*';          sSessionName += " *";
1543      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1544    
1545      // Update the main menu state...      // Update the main menu state...
# Line 1368  void qsamplerMainForm::stabilizeForm (vo Line 1558  void qsamplerMainForm::stabilizeForm (vo
1558      editResetChannelAction->setEnabled(bHasChannel);      editResetChannelAction->setEnabled(bHasChannel);
1559      editResetAllChannelsAction->setEnabled(bHasChannel);      editResetAllChannelsAction->setEnabled(bHasChannel);
1560      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());
1561      viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible());  #ifdef CONFIG_MIDI_INSTRUMENT
1562            viewInstrumentsAction->setOn(m_pInstrumentListForm
1563                    && m_pInstrumentListForm->isVisible());
1564            viewInstrumentsAction->setEnabled(bHasClient);
1565    #endif
1566            viewDevicesAction->setOn(m_pDeviceForm
1567                    && m_pDeviceForm->isVisible());
1568      viewDevicesAction->setEnabled(bHasClient);      viewDevicesAction->setEnabled(bHasClient);
1569      channelsArrangeAction->setEnabled(bHasChannel);      channelsArrangeAction->setEnabled(bHasChannel);
1570    
# Line 1419  void qsamplerMainForm::channelStripChang Line 1615  void qsamplerMainForm::channelStripChang
1615  // Grab and restore current sampler channels session.  // Grab and restore current sampler channels session.
1616  void qsamplerMainForm::updateSession (void)  void qsamplerMainForm::updateSession (void)
1617  {  {
1618    #ifdef CONFIG_MIDI_INSTRUMENT
1619            // FIXME: Make some room for default instrument maps...
1620            int iMaps = ::lscp_get_midi_instrument_maps(m_pClient);
1621            if (iMaps < 0)
1622                    appendMessagesClient("lscp_get_midi_instrument_maps");
1623            else if (iMaps < 1) {
1624                    ::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1());
1625                    ::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1());
1626            }
1627    #endif
1628    
1629          // Retrieve the current channel list.          // Retrieve the current channel list.
1630          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
1631          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 1426  void qsamplerMainForm::updateSession (vo Line 1633  void qsamplerMainForm::updateSession (vo
1633                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
1634                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1635                  }                  }
1636                  return;          } else {
1637                    // Try to (re)create each channel.
1638                    m_pWorkspace->setUpdatesEnabled(false);
1639                    for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1640                            // Check if theres already a channel strip for this one...
1641                            if (!channelStrip(piChannelIDs[iChannel]))
1642                                    createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel]));
1643                    }
1644                    m_pWorkspace->setUpdatesEnabled(true);
1645          }          }
1646    
1647          // Try to (re)create each channel.      // Do we auto-arrange?
1648          m_pWorkspace->setUpdatesEnabled(false);      if (m_pOptions && m_pOptions->bAutoArrange)
1649          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {          channelsArrange();
1650                  // Check if theres already a channel strip for this one...  
1651                  if (!channelStrip(piChannelIDs[iChannel]))          // Remember to refresh devices and instruments...
1652                          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));          if (m_pInstrumentListForm)
1653                  // Make it visibly responsive...              m_pInstrumentListForm->refreshInstruments();
                 QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);  
         }  
         m_pWorkspace->setUpdatesEnabled(true);  
           
         // Remember to refresh devices  
1654          if (m_pDeviceForm)          if (m_pDeviceForm)
1655              m_pDeviceForm->refreshDevices();              m_pDeviceForm->refreshDevices();
1656  }  }
# Line 1613  void qsamplerMainForm::appendMessagesErr Line 1823  void qsamplerMainForm::appendMessagesErr
1823    
1824      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");
1825    
1826            // Make it look responsive...:)
1827            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1828    
1829      QMessageBox::critical(this,      QMessageBox::critical(this,
1830                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));
1831  }  }
# Line 1627  void qsamplerMainForm::appendMessagesCli Line 1840  void qsamplerMainForm::appendMessagesCli
1840      appendMessagesColor(s + QString(": %1 (errno=%2)")      appendMessagesColor(s + QString(": %1 (errno=%2)")
1841          .arg(::lscp_client_get_result(m_pClient))          .arg(::lscp_client_get_result(m_pClient))
1842          .arg(::lscp_client_get_errno(m_pClient)), "#996666");          .arg(::lscp_client_get_errno(m_pClient)), "#996666");
1843    
1844            // Make it look responsive...:)
1845            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1846  }  }
1847    
1848    
# Line 1701  qsamplerChannelStrip *qsamplerMainForm:: Line 1917  qsamplerChannelStrip *qsamplerMainForm::
1917    
1918      // Actual channel strip setup...      // Actual channel strip setup...
1919      pChannelStrip->setup(pChannel);      pChannelStrip->setup(pChannel);
1920      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));          QObject::connect(pChannelStrip,
1921                    SIGNAL(channelChanged(qsamplerChannelStrip *)),
1922                    SLOT(channelStripChanged(qsamplerChannelStrip *)));
1923      // Set some initial aesthetic options...      // Set some initial aesthetic options...
1924      if (m_pOptions) {      if (m_pOptions) {
1925          // Background display effect...          // Background display effect...
# Line 1908  void qsamplerMainForm::startServer (void Line 2126  void qsamplerMainForm::startServer (void
2126      m_pServer = new QProcess(this);      m_pServer = new QProcess(this);
2127    
2128      // Setup stdout/stderr capture...      // Setup stdout/stderr capture...
2129      //if (m_pOptions->bStdoutCapture) {          //      if (m_pOptions->bStdoutCapture) {
2130          m_pServer->setCommunication(QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr);                  m_pServer->setCommunication(
2131          QObject::connect(m_pServer, SIGNAL(readyReadStdout()), this, SLOT(readServerStdout()));                          QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr);
2132          QObject::connect(m_pServer, SIGNAL(readyReadStderr()), this, SLOT(readServerStdout()));                  QObject::connect(m_pServer,
2133      //}                          SIGNAL(readyReadStdout()),
2134      // The unforgiveable signal communication...                          SLOT(readServerStdout()));
2135      QObject::connect(m_pServer, SIGNAL(processExited()), this, SLOT(processServerExit()));                  QObject::connect(m_pServer,
2136                            SIGNAL(readyReadStderr()),
2137                            SLOT(readServerStdout()));
2138            //      }
2139            // The unforgiveable signal communication...
2140            QObject::connect(m_pServer,
2141                    SIGNAL(processExited()),
2142                    SLOT(processServerExit()));
2143    
2144      // Build process arguments...      // Build process arguments...
2145      m_pServer->setArguments(QStringList::split(' ', m_pOptions->sServerCmdLine));      m_pServer->setArguments(QStringList::split(' ', m_pOptions->sServerCmdLine));
# Line 2059  bool qsamplerMainForm::startClient (void Line 2284  bool qsamplerMainForm::startClient (void
2284      // Log success here.      // Log success here.
2285      appendMessages(tr("Client connected."));      appendMessages(tr("Client connected."));
2286    
2287          // Hard-notify device configuration form,          // Hard-notify instrumnet and device configuration forms,
2288          // if visible, that we're ready...          // if visible, that we're ready...
2289          if (m_pDeviceForm && m_pDeviceForm->isVisible())          if (m_pInstrumentListForm)
2290              m_pDeviceForm->setClient(m_pClient);              m_pInstrumentListForm->refreshInstruments();
2291            if (m_pDeviceForm)
2292                m_pDeviceForm->refreshDevices();
2293    
2294      // Is any session pending to be loaded?      // Is any session pending to be loaded?
2295      if (!m_pOptions->sSessionFile.isEmpty()) {      if (!m_pOptions->sSessionFile.isEmpty()) {
# Line 2084  void qsamplerMainForm::stopClient (void) Line 2311  void qsamplerMainForm::stopClient (void)
2311      if (m_pClient == NULL)      if (m_pClient == NULL)
2312          return;          return;
2313    
         // Hard-notify device configuration form,  
         // if visible, that we're running out...  
         if (m_pDeviceForm && m_pDeviceForm->isVisible())  
             m_pDeviceForm->setClient(NULL);  
   
2314      // Log prepare here.      // Log prepare here.
2315      appendMessages(tr("Client disconnecting..."));      appendMessages(tr("Client disconnecting..."));
2316    
# Line 2109  void qsamplerMainForm::stopClient (void) Line 2331  void qsamplerMainForm::stopClient (void)
2331      ::lscp_client_destroy(m_pClient);      ::lscp_client_destroy(m_pClient);
2332      m_pClient = NULL;      m_pClient = NULL;
2333    
2334            // Hard-notify instrumnet and device configuration forms,
2335            // if visible, that we're running out...
2336            if (m_pInstrumentListForm)
2337                m_pInstrumentListForm->refreshInstruments();
2338            if (m_pDeviceForm)
2339                m_pDeviceForm->refreshDevices();
2340    
2341      // Log final here.      // Log final here.
2342      appendMessages(tr("Client disconnected."));      appendMessages(tr("Client disconnected."));
2343    

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

  ViewVC Help
Powered by ViewVC