/[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 969 by capela, Wed Dec 6 19:38:02 2006 UTC revision 986 by capela, Mon Dec 18 16:51:50 2006 UTC
# Line 686  bool qsamplerMainForm::loadSessionFile ( Line 686  bool qsamplerMainForm::loadSessionFile (
686  // Save current session to specific file path.  // Save current session to specific file path.
687  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )  bool qsamplerMainForm::saveSessionFile ( const QString& sFilename )
688  {  {
689            if (m_pClient == NULL)
690                    return false;
691    
692            // Check whether server is apparently OK...
693            if (::lscp_get_channels(m_pClient) < 0) {
694                    appendMessagesClient("lscp_get_channels");
695                    return false;
696            }
697    
698      // Open and write into real file.      // Open and write into real file.
699      QFile file(sFilename);      QFile file(sFilename);
700      if (!file.open(IO_WriteOnly | IO_Truncate)) {      if (!file.open(IO_WriteOnly | IO_Truncate)) {
# Line 709  bool qsamplerMainForm::saveSessionFile ( Line 718  bool qsamplerMainForm::saveSessionFile (
718         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
719      ts << "#"  << endl;      ts << "#"  << endl;
720      ts << endl;      ts << endl;
721    
722          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
723          // will be loaded from a complete          // will be loaded from a complete initialized server...
724          int *piDeviceIDs;          int *piDeviceIDs;
725          int  iDevice;          int  iDevice;
726          ts << "RESET" << endl;          ts << "RESET" << endl;
727    
728          // Audio device mapping.          // Audio device mapping.
729          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap;
730          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
# Line 751  bool qsamplerMainForm::saveSessionFile ( Line 762  bool qsamplerMainForm::saveSessionFile (
762                  }                  }
763                  // Audio device index/id mapping.                  // Audio device index/id mapping.
764                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap[device.deviceID()] = iDevice;
765          // Try to keep it snappy :)                  // Try to keep it snappy :)
766          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
767          }          }
768    
769          // MIDI device mapping.          // MIDI device mapping.
770          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap;
771          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
# Line 791  bool qsamplerMainForm::saveSessionFile ( Line 803  bool qsamplerMainForm::saveSessionFile (
803                  }                  }
804                  // MIDI device index/id mapping.                  // MIDI device index/id mapping.
805                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap[device.deviceID()] = iDevice;
806          // Try to keep it snappy :)                  // Try to keep it snappy :)
807          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
808          }          }
809          ts << endl;          ts << endl;
810    
811    #ifdef CONFIG_MIDI_INSTRUMENT
812            // MIDI instrument mapping...
813            QMap<int, int> midiInstrumentMap;
814            int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);
815            for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) {
816                    int iMidiMap = piMaps[iMap];
817                    const char *pszMapName
818                            = ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap);
819                    ts << "# " << tr("MIDI instrument map") << " " << iMap;
820                    if (pszMapName)
821                            ts << " - " << pszMapName;
822                    ts << endl;
823                    ts << "ADD MIDI_INSTRUMENT_MAP";
824                    if (pszMapName)
825                            ts << " '" << pszMapName << "'";
826                    ts << endl;
827                    // MIDI instrument mapping...
828                    lscp_midi_instrument_t *pInstrs
829                            = ::lscp_list_midi_instruments(m_pClient, iMidiMap);
830                    for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; iInstr++) {
831                            lscp_midi_instrument_info_t *pInstrInfo
832                                    = ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]);
833                            if (pInstrInfo) {
834                                    ts << "MAP MIDI_INSTRUMENT "
835                                            << iMap                        << " "
836                                            << pInstrs[iInstr].bank        << " "
837                                            << pInstrs[iInstr].prog        << " "
838                                            << pInstrInfo->engine_name     << " '"
839                                            << pInstrInfo->instrument_file << "' "
840                                            << pInstrInfo->instrument_nr   << " "
841                                            << pInstrInfo->volume          << " ";
842                                    switch (pInstrInfo->load_mode) {
843                                            case LSCP_LOAD_PERSISTENT:
844                                                    ts << "PERSISTENT";
845                                                    break;
846                                            case LSCP_LOAD_ON_DEMAND_HOLD:
847                                                    ts << "ON_DEMAND_HOLD";
848                                                    break;
849                                            case LSCP_LOAD_ON_DEMAND:
850                                            case LSCP_LOAD_DEFAULT:
851                                            default:
852                                                    ts << "ON_DEMAND";
853                                                    break;
854                                    }
855                                    if (pInstrInfo->name)
856                                            ts << " '" << pInstrInfo->name << "'";
857                                    ts << endl;
858                            }
859                            // MIDI device index/id mapping.
860                            midiInstrumentMap[iMidiMap] = iMap;
861                            // Try to keep it snappy :)
862                            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
863                    }
864                    if (pInstrs)
865                            ts << endl;
866            }
867    #endif //  CONFIG_MIDI_INSTRUMENT
868    
869          // Sampler channel mapping.          // Sampler channel mapping.
870      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
871      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
# Line 827  bool qsamplerMainForm::saveSessionFile ( Line 898  bool qsamplerMainForm::saveSessionFile (
898                      ts << pChannel->midiChannel();                      ts << pChannel->midiChannel();
899                  ts << endl;                  ts << endl;
900                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
901                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;                                  if (pChannel->instrumentStatus() < 100) ts << "# ";
902                                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' "
903                                            << pChannel->instrumentNr() << " " << iChannel << endl;
904                                  qsamplerChannelRoutingMap::ConstIterator audioRoute;                                  qsamplerChannelRoutingMap::ConstIterator audioRoute;
905                                  for (audioRoute = pChannel->audioRouting().begin();                                  for (audioRoute = pChannel->audioRouting().begin();
906                                                  audioRoute != pChannel->audioRouting().end();                                                  audioRoute != pChannel->audioRouting().end();
# Line 836  bool qsamplerMainForm::saveSessionFile ( Line 909  bool qsamplerMainForm::saveSessionFile (
909                                                  << " " << audioRoute.key()                                                  << " " << audioRoute.key()
910                                                  << " " << audioRoute.data() << endl;                                                  << " " << audioRoute.data() << endl;
911                                  }                                  }
912                  ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;                                  ts << "SET CHANNEL VOLUME " << iChannel
913                                            << " " << pChannel->volume() << endl;
914                                  if (pChannel->channelMute())                                  if (pChannel->channelMute())
915                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
916                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
917                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
918    #ifdef CONFIG_MIDI_INSTRUMENT
919                                    if (pChannel->midiMap() >= 0) {
920                                            ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel
921                                                    << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
922                                    }
923    #endif
924                  ts << endl;                  ts << endl;
925              }              }
926          }          }
# Line 848  bool qsamplerMainForm::saveSessionFile ( Line 928  bool qsamplerMainForm::saveSessionFile (
928          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
929      }      }
930    
 #ifdef CONFIG_MIDI_INSTRUMENT  
         // MIDI instrument mapping...  
         lscp_midi_instrument_t *pInstrs = ::lscp_list_midi_instruments(m_pClient);  
         if (pInstrs)  
                 ts << "# " << tr("MIDI instrument mapping") << endl;  
         for (int iInstr = 0; pInstrs && pInstrs[iInstr].program >= 0; iInstr++) {  
                 lscp_midi_instrument_info_t *pInstrInfo  
                         = ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]);  
                 if (pInstrInfo) {  
                         ts << "MAP MIDI_INSTRUMENT "  
                                 << pInstrs[iInstr].bank_msb    << " "  
                                 << pInstrs[iInstr].bank_lsb    << " "  
                                 << pInstrs[iInstr].program     << " "  
                                 << pInstrInfo->engine_name     << " '"  
                                 << pInstrInfo->instrument_file << "' "  
                                 << pInstrInfo->instrument_nr   << " "  
                                 << pInstrInfo->volume          << " ";  
                         switch (pInstrInfo->load_mode) {  
                                 case LSCP_LOAD_PERSISTENT:  
                                         ts << "PERSISTENT";  
                                         break;  
                                 case LSCP_LOAD_ON_DEMAND_HOLD:  
                                         ts << "ON_DEMAND_HOLD";  
                                         break;  
                                 case LSCP_LOAD_ON_DEMAND:  
                                 case LSCP_LOAD_DEFAULT:  
                                 default:  
                                         ts << "ON_DEMAND";  
                                         break;  
                         }  
                         if (pInstrInfo->name)  
                                 ts << " '" << pInstrInfo->name << "'";  
                         ts << endl;  
                 }  
                 // Try to keep it snappy :)  
                 QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);  
         }  
         if (pInstrs)  
                 ts << endl;  
 #endif //  CONFIG_MIDI_INSTRUMENT  
   
931      // Ok. we've wrote it.      // Ok. we've wrote it.
932      file.close();      file.close();
933    
# Line 1538  void qsamplerMainForm::channelStripChang Line 1577  void qsamplerMainForm::channelStripChang
1577  // Grab and restore current sampler channels session.  // Grab and restore current sampler channels session.
1578  void qsamplerMainForm::updateSession (void)  void qsamplerMainForm::updateSession (void)
1579  {  {
1580    #ifdef CONFIG_MIDI_INSTRUMENT
1581            // FIXME Make some room for default instrument maps...
1582            int iMaps = ::lscp_get_midi_instrument_maps(m_pClient);
1583            if (iMaps < 0)
1584                    appendMessagesClient("lscp_get_midi_instrument_maps");
1585            else if (iMaps < 1) {
1586                    ::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1());
1587                    ::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1());
1588            }
1589    #endif
1590    
1591          // Retrieve the current channel list.          // Retrieve the current channel list.
1592          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
1593          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 1558  void qsamplerMainForm::updateSession (vo Line 1608  void qsamplerMainForm::updateSession (vo
1608                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1609          }          }
1610          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
1611            
1612          // Remember to refresh devices and instruments...          // Remember to refresh devices and instruments...
1613          if (m_pInstrumentListForm)          if (m_pInstrumentListForm)
1614              m_pInstrumentListForm->refreshInstruments();              m_pInstrumentListForm->refreshInstruments();

Legend:
Removed from v.969  
changed lines
  Added in v.986

  ViewVC Help
Powered by ViewVC