/[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 342 by capela, Tue Jan 18 11:56:33 2005 UTC revision 371 by capela, Fri Feb 11 15:36:06 2005 UTC
# Line 30  Line 30 
30    
31  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
32  #include "gig.h"  #include "gig.h"
 #else  
 #define QSAMPLER_INSTRUMENT_MAX 8  
33  #endif  #endif
34    
35    #define QSAMPLER_INSTRUMENT_MAX 8
36    
37    
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 354  bool qsamplerChannel::setVolume ( float Line 361  bool qsamplerChannel::setVolume ( float
361  }  }
362    
363    
364    // Istrument name remapper.
365    void qsamplerChannel::updateInstrumentName (void)
366    {
367            m_sInstrumentName = getInstrumentName(m_sInstrumentFile,
368                    m_iInstrumentNr, (options() && options()->bInstrumentNames));
369    }
370    
371    
372  // Update whole channel info state.  // Update whole channel info state.
373  bool qsamplerChannel::updateChannelInfo (void)  bool qsamplerChannel::updateChannelInfo (void)
374  {  {
# Line 368  bool qsamplerChannel::updateChannelInfo Line 383  bool qsamplerChannel::updateChannelInfo
383          return false;          return false;
384      }      }
385    
386      // Cache in channel information.          // First, check if intrument name has changed,
387            // taking care that instrument name lookup might be expensive,
388            // so we better make it only once and when really needed...
389            if ((m_sInstrumentFile != pChannelInfo->instrument_file) ||
390                    (m_iInstrumentNr   != pChannelInfo->instrument_nr)) {
391                    m_sInstrumentFile = pChannelInfo->instrument_file;
392                    m_iInstrumentNr   = pChannelInfo->instrument_nr;
393                    updateInstrumentName();
394            }
395        // Cache in other channel information.
396      m_sEngineName       = pChannelInfo->engine_name;      m_sEngineName       = pChannelInfo->engine_name;
     m_sInstrumentFile   = pChannelInfo->instrument_file;  
     m_iInstrumentNr     = pChannelInfo->instrument_nr;  
397      m_iInstrumentStatus = pChannelInfo->instrument_status;      m_iInstrumentStatus = pChannelInfo->instrument_status;
398      m_iMidiDevice       = pChannelInfo->midi_device;      m_iMidiDevice       = pChannelInfo->midi_device;
399      m_iMidiPort         = pChannelInfo->midi_port;      m_iMidiPort         = pChannelInfo->midi_port;
# Line 381  bool qsamplerChannel::updateChannelInfo Line 403  bool qsamplerChannel::updateChannelInfo
403      // Some sanity checks.      // Some sanity checks.
404      if (m_sEngineName == "NONE")      if (m_sEngineName == "NONE")
405          m_sEngineName = QString::null;          m_sEngineName = QString::null;
406      if (m_sInstrumentFile == "NONE")      if (m_sInstrumentFile == "NONE") {
407          m_sInstrumentFile = QString::null;          m_sInstrumentFile = QString::null;
408            m_sInstrumentName = QString::null;
409            }
410    
411      return true;      return true;
412  }  }
# Line 455  void qsamplerChannel::contextMenuEvent( Line 479  void qsamplerChannel::contextMenuEvent(
479    
480    
481  // Retrieve the instrument list of a instrument file (.gig).  // Retrieve the instrument list of a instrument file (.gig).
482  QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile )  QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile,
483            bool bInstrumentNames )
484  {  {
485      QFileInfo fileinfo(sInstrumentFile);      QFileInfo fileinfo(sInstrumentFile);
486      QString sInstrumentName = fileinfo.fileName();      QString sInstrumentName = fileinfo.fileName();
# Line 463  QStringList qsamplerChannel::getInstrume Line 488  QStringList qsamplerChannel::getInstrume
488    
489      if (fileinfo.exists()) {      if (fileinfo.exists()) {
490  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
491                  if (g_bInstrumentNames) {                  if (bInstrumentNames) {
492                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);
493                  gig::File  *pGig  = new gig::File(pRiff);                  gig::File  *pGig  = new gig::File(pRiff);
494                  gig::Instrument *pInstrument = pGig->GetFirstInstrument();                  gig::Instrument *pInstrument = pGig->GetFirstInstrument();
# Line 486  QStringList qsamplerChannel::getInstrume Line 511  QStringList qsamplerChannel::getInstrume
511    
512    
513  // 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.
514  QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, int iInstrumentNr )  QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile,
515            int iInstrumentNr, bool bInstrumentNames )
516  {  {
517      QFileInfo fileinfo(sInstrumentFile);      QFileInfo fileinfo(sInstrumentFile);
518      QString sInstrumentName = fileinfo.fileName();      QString sInstrumentName = fileinfo.fileName();
519    
520      if (fileinfo.exists()) {      if (fileinfo.exists()) {
521  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
522                  if (g_bInstrumentNames) {                  if (bInstrumentNames) {
523                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);
524                  gig::File  *pGig  = new gig::File(pRiff);                  gig::File  *pGig  = new gig::File(pRiff);
525                  int iIndex = 0;                  int iIndex = 0;
# Line 518  QString qsamplerChannel::getInstrumentNa Line 544  QString qsamplerChannel::getInstrumentNa
544  }  }
545    
546    
 // Instrument name(s) retrieval mode--global option.  
 bool qsamplerChannel::instrumentNames (void)  
 {  
         return g_bInstrumentNames;  
 }  
   
 void qsamplerChannel::setInstrumentNames ( bool bInstrumentNames )  
 {  
         g_bInstrumentNames = bInstrumentNames;  
 }  
   
   
547  // end of qsamplerChannel.cpp  // end of qsamplerChannel.cpp

Legend:
Removed from v.342  
changed lines
  Added in v.371

  ViewVC Help
Powered by ViewVC