/[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 343 by capela, Tue Jan 18 12:32:01 2005 UTC revision 344 by capela, Tue Jan 18 13:53:04 2005 UTC
# Line 38  Line 38 
38  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
39  // qsamplerChannel - Sampler channel structure.  // qsamplerChannel - Sampler channel structure.
40  //  //
 bool qsamplerChannel::g_bInstrumentNames = false;  
41    
42  // Constructor.  // Constructor.
43  qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID )  qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID )
# Line 47  qsamplerChannel::qsamplerChannel ( qsamp Line 46  qsamplerChannel::qsamplerChannel ( qsamp
46      m_iChannelID = iChannelID;      m_iChannelID = iChannelID;
47    
48  //  m_sEngineName       = QObject::tr("(No engine)");  //  m_sEngineName       = QObject::tr("(No engine)");
49  //  m_sInstrumentFile   = QObject::tr("(No instrument)");  //  m_sInstrumentName   = QObject::tr("(No instrument)");
50    //  m_sInstrumentFile   = m_sInstrumentName;
51      m_iInstrumentNr     = -1;      m_iInstrumentNr     = -1;
52      m_iInstrumentStatus = -1;      m_iInstrumentStatus = -1;
53      m_sMidiDriver       = "Alsa";   // DEPRECATED.      m_sMidiDriver       = "Alsa";   // DEPRECATED.
# Line 170  bool qsamplerChannel::loadEngine ( const Line 170  bool qsamplerChannel::loadEngine ( const
170  }  }
171    
172    
173    // Instrument name accessor.
174    QString& qsamplerChannel::instrumentName (void)
175    {
176        return m_sInstrumentName;
177    }
178    
179  // Instrument filename accessor.  // Instrument filename accessor.
180  QString& qsamplerChannel::instrumentFile (void)  QString& qsamplerChannel::instrumentFile (void)
181  {  {
# Line 199  bool qsamplerChannel::loadInstrument ( c Line 205  bool qsamplerChannel::loadInstrument ( c
205          return false;          return false;
206      }      }
207    
208        m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true);
209      m_sInstrumentFile = sInstrumentFile;      m_sInstrumentFile = sInstrumentFile;
210      m_iInstrumentNr = iInstrumentNr;      m_iInstrumentNr = iInstrumentNr;
211      m_iInstrumentStatus = 0;      m_iInstrumentStatus = 0;
# Line 368  bool qsamplerChannel::updateChannelInfo Line 375  bool qsamplerChannel::updateChannelInfo
375          return false;          return false;
376      }      }
377    
378      // Cache in channel information.      // First, check if intrument name has changed,
379        // taking care that instrument name lookup might be expensive,
380        // so we better make it only once and when really needed...
381        if ((m_sInstrumentFile != pChannelInfo->instrument_file) ||
382            (m_iInstrumentNr   != pChannelInfo->instrument_nr)) {
383            m_sInstrumentFile = pChannelInfo->instrument_file;
384            m_iInstrumentNr   = pChannelInfo->instrument_nr;
385                    m_sInstrumentName = getInstrumentName(m_sInstrumentFile,
386                            m_iInstrumentNr, (options() && options()->bInstrumentNames));
387            }
388        // Cache in other channel information.
389      m_sEngineName       = pChannelInfo->engine_name;      m_sEngineName       = pChannelInfo->engine_name;
     m_sInstrumentFile   = pChannelInfo->instrument_file;  
     m_iInstrumentNr     = pChannelInfo->instrument_nr;  
390      m_iInstrumentStatus = pChannelInfo->instrument_status;      m_iInstrumentStatus = pChannelInfo->instrument_status;
391      m_iMidiDevice       = pChannelInfo->midi_device;      m_iMidiDevice       = pChannelInfo->midi_device;
392      m_iMidiPort         = pChannelInfo->midi_port;      m_iMidiPort         = pChannelInfo->midi_port;
# Line 381  bool qsamplerChannel::updateChannelInfo Line 396  bool qsamplerChannel::updateChannelInfo
396      // Some sanity checks.      // Some sanity checks.
397      if (m_sEngineName == "NONE")      if (m_sEngineName == "NONE")
398          m_sEngineName = QString::null;          m_sEngineName = QString::null;
399      if (m_sInstrumentFile == "NONE")      if (m_sInstrumentFile == "NONE") {
400          m_sInstrumentFile = QString::null;          m_sInstrumentFile = QString::null;
401            m_sInstrumentName = QString::null;
402            }
403    
404      return true;      return true;
405  }  }
# Line 455  void qsamplerChannel::contextMenuEvent( Line 472  void qsamplerChannel::contextMenuEvent(
472    
473    
474  // Retrieve the instrument list of a instrument file (.gig).  // Retrieve the instrument list of a instrument file (.gig).
475  QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile )  QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile,
476            bool bInstrumentNames )
477  {  {
478      QFileInfo fileinfo(sInstrumentFile);      QFileInfo fileinfo(sInstrumentFile);
479      QString sInstrumentName = fileinfo.fileName();      QString sInstrumentName = fileinfo.fileName();
# Line 463  QStringList qsamplerChannel::getInstrume Line 481  QStringList qsamplerChannel::getInstrume
481    
482      if (fileinfo.exists()) {      if (fileinfo.exists()) {
483  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
484                  if (g_bInstrumentNames) {                  if (bInstrumentNames) {
485                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);
486                  gig::File  *pGig  = new gig::File(pRiff);                  gig::File  *pGig  = new gig::File(pRiff);
487                  gig::Instrument *pInstrument = pGig->GetFirstInstrument();                  gig::Instrument *pInstrument = pGig->GetFirstInstrument();
# Line 486  QStringList qsamplerChannel::getInstrume Line 504  QStringList qsamplerChannel::getInstrume
504    
505    
506  // Retrieve the spacific instrument name of a instrument file (.gig), given its index.  // Retrieve the spacific instrument name of a instrument file (.gig), given its index.
507  QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, int iInstrumentNr )  QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile,
508            int iInstrumentNr, bool bInstrumentNames )
509  {  {
510      QFileInfo fileinfo(sInstrumentFile);      QFileInfo fileinfo(sInstrumentFile);
511      QString sInstrumentName = fileinfo.fileName();      QString sInstrumentName = fileinfo.fileName();
512    
513      if (fileinfo.exists()) {      if (fileinfo.exists()) {
514  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
515                  if (g_bInstrumentNames) {                  if (bInstrumentNames) {
516                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);
517                  gig::File  *pGig  = new gig::File(pRiff);                  gig::File  *pGig  = new gig::File(pRiff);
518                  int iIndex = 0;                  int iIndex = 0;
# Line 518  QString qsamplerChannel::getInstrumentNa Line 537  QString qsamplerChannel::getInstrumentNa
537  }  }
538    
539    
 // Instrument name(s) retrieval mode--global option.  
 bool qsamplerChannel::instrumentNames (void)  
 {  
         return g_bInstrumentNames;  
 }  
   
 void qsamplerChannel::setInstrumentNames ( bool bInstrumentNames )  
 {  
         g_bInstrumentNames = bInstrumentNames;  
 }  
   
   
540  // end of qsamplerChannel.cpp  // end of qsamplerChannel.cpp

Legend:
Removed from v.343  
changed lines
  Added in v.344

  ViewVC Help
Powered by ViewVC