/[svn]/qsampler/trunk/src/qsamplerChannel.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannel.cpp

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

revision 2107 by schoenebeck, Tue Feb 5 15:42:33 2008 UTC revision 2108 by capela, Thu Jul 15 08:03:32 2010 UTC
# Line 1  Line 1 
1  // qsamplerChannel.cpp  // qsamplerChannel.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 204  bool Channel::loadInstrument ( const QSt Line 204  bool Channel::loadInstrument ( const QSt
204                  return false;                  return false;
205          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
206                  return false;                  return false;
207          if (!isInstrumentFile(sInstrumentFile))          if (!QFileInfo(sInstrumentFile).exists())
208                  return false;                  return false;
209          if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr)          if (m_iInstrumentStatus == 100
210                    && m_sInstrumentFile == sInstrumentFile
211                    && m_iInstrumentNr == iInstrumentNr)
212                  return true;                  return true;
213    
214          if (          if (::lscp_load_instrument_non_modal(
                 ::lscp_load_instrument_non_modal(  
215                          pMainForm->client(),                          pMainForm->client(),
216                          qsamplerUtilities::lscpEscapePath(                          qsamplerUtilities::lscpEscapePath(
217                                  sInstrumentFile).toUtf8().constData(),                                  sInstrumentFile).toUtf8().constData(),
218                          iInstrumentNr, m_iChannelID                          iInstrumentNr, m_iChannelID
219                  ) != LSCP_OK                  ) != LSCP_OK) {
         ) {  
220                  appendMessagesClient("lscp_load_instrument");                  appendMessagesClient("lscp_load_instrument");
221                  return false;                  return false;
222          }          }
# Line 803  void Channel::contextMenuEvent( QContext Line 803  void Channel::contextMenuEvent( QContext
803  }  }
804    
805    
806  // FIXME: Check whether a given file is an instrument file.  // FIXME: Check whether a given file is an instrument file (DLS only).
807  bool Channel::isInstrumentFile ( const QString& sInstrumentFile )  bool Channel::isDlsInstrumentFile ( const QString& sInstrumentFile )
808  {  {
809          bool bResult = false;          bool bResult = false;
810    
# Line 826  bool Channel::isInstrumentFile ( const Q Line 826  bool Channel::isInstrumentFile ( const Q
826  QStringList Channel::getInstrumentList( const QString& sInstrumentFile,  QStringList Channel::getInstrumentList( const QString& sInstrumentFile,
827          bool bInstrumentNames )          bool bInstrumentNames )
828  {  {
         QString sInstrumentName = QFileInfo(sInstrumentFile).fileName();  
829          QStringList instlist;          QStringList instlist;
830    
831          if (isInstrumentFile(sInstrumentFile)) {          if (isDlsInstrumentFile(sInstrumentFile)) {
832  #ifdef CONFIG_LIBGIG          #ifdef CONFIG_LIBGIG
833                  if (bInstrumentNames) {                  if (bInstrumentNames) {
834                          RIFF::File *pRiff                          RIFF::File *pRiff
835                                  = new RIFF::File(sInstrumentFile.toUtf8().constData());                                  = new RIFF::File(sInstrumentFile.toUtf8().constData());
836                          gig::File  *pGig  = new gig::File(pRiff);                          gig::File  *pGig  = new gig::File(pRiff);
837  #if HAVE_LIBGIG_SETAUTOLOAD                  #if HAVE_LIBGIG_SETAUTOLOAD
838                          // prevent sleepy response time on large .gig files                          // prevent sleepy response time on large .gig files
839                          pGig->SetAutoLoad(false);                          pGig->SetAutoLoad(false);
840  #endif                  #endif
841                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
842                          while (pInstrument) {                          while (pInstrument) {
843                                  instlist.append((pInstrument->pInfo)->Name.c_str());                                  instlist.append((pInstrument->pInfo)->Name.c_str());
# Line 847  QStringList Channel::getInstrumentList( Line 846  QStringList Channel::getInstrumentList(
846                          delete pGig;                          delete pGig;
847                          delete pRiff;                          delete pRiff;
848                  }                  }
849                  else          #endif
850  #endif          }
851                  for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++)  
852                          instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]");          if (instlist.isEmpty()) {
853                    QFileInfo fi(sInstrumentFile);
854                    if (fi.exists()) {
855                            QString sInstrumentName = fi.fileName();
856                            int iInstrumentNr = 0;
857                            while (iInstrumentNr < QSAMPLER_INSTRUMENT_MAX) {
858                                    instlist.append(sInstrumentName
859                                            + " [" + QString::number(++iInstrumentNr) + "]");
860                            }
861                    }
862                    else instlist.append(noInstrumentName());
863          }          }
         else instlist.append(noInstrumentName());  
864    
865          return instlist;          return instlist;
866  }  }
# Line 864  QString Channel::getInstrumentName( cons Line 872  QString Channel::getInstrumentName( cons
872  {  {
873          QString sInstrumentName;          QString sInstrumentName;
874    
875          if (isInstrumentFile(sInstrumentFile)) {          if (isDlsInstrumentFile(sInstrumentFile)) {
876                  sInstrumentName = QFileInfo(sInstrumentFile).fileName();          #ifdef CONFIG_LIBGIG
 #ifdef CONFIG_LIBGIG  
877                  if (bInstrumentNames) {                  if (bInstrumentNames) {
878                          RIFF::File *pRiff                          RIFF::File *pRiff
879                                  = new RIFF::File(sInstrumentFile.toUtf8().constData());                                  = new RIFF::File(sInstrumentFile.toUtf8().constData());
880                          gig::File *pGig = new gig::File(pRiff);                          gig::File *pGig = new gig::File(pRiff);
881  #if HAVE_LIBGIG_SETAUTOLOAD                  #if HAVE_LIBGIG_SETAUTOLOAD
882                          // prevent sleepy response time on large .gig files                          // prevent sleepy response time on large .gig files
883                          pGig->SetAutoLoad(false);                          pGig->SetAutoLoad(false);
884  #endif                  #endif
885                          int iIndex = 0;                          int iIndex = 0;
886                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
887                          while (pInstrument) {                          while (pInstrument) {
# Line 888  QString Channel::getInstrumentName( cons Line 895  QString Channel::getInstrumentName( cons
895                          delete pGig;                          delete pGig;
896                          delete pRiff;                          delete pRiff;
897                  }                  }
898                  else          #endif
899  #endif          }
900                  sInstrumentName += " [" + QString::number(iInstrumentNr) + "]";  
901            if (sInstrumentName.isEmpty()) {
902                    QFileInfo fi(sInstrumentFile);
903                    if (fi.exists()) {
904                            sInstrumentName  = fi.fileName();
905                            sInstrumentName += " [" + QString::number(iInstrumentNr) + "]";
906                    }
907                    else sInstrumentName = noInstrumentName();
908          }          }
         else sInstrumentName = noInstrumentName();  
909    
910          return sInstrumentName;          return sInstrumentName;
911  }  }

Legend:
Removed from v.2107  
changed lines
  Added in v.2108

  ViewVC Help
Powered by ViewVC