/[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 467 by capela, Tue Mar 15 23:54:14 2005 UTC revision 751 by capela, Fri Aug 19 17:10:16 2005 UTC
# Line 50  qsamplerChannel::qsamplerChannel ( qsamp Line 50  qsamplerChannel::qsamplerChannel ( qsamp
50  //  m_sInstrumentFile   = m_sInstrumentName;  //  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";
54          m_iMidiDevice       = -1;          m_iMidiDevice       = -1;
55          m_iMidiPort         = -1;          m_iMidiPort         = -1;
56          m_iMidiChannel      = -1;          m_iMidiChannel      = -1;
57          m_sAudioDriver      = "Alsa";   // DEPRECATED.          m_sAudioDriver      = "ALSA";
58          m_iAudioDevice      = -1;          m_iAudioDevice      = -1;
59          m_fVolume           = 0.0;          m_fVolume           = 0.0;
60            m_bMute             = false;
61            m_bSolo             = false;
62  }  }
63    
64  // Default destructor.  // Default destructor.
# Line 66  qsamplerChannel::~qsamplerChannel (void) Line 67  qsamplerChannel::~qsamplerChannel (void)
67  }  }
68    
69    
70    // Main application form accessor.
71    qsamplerMainForm *qsamplerChannel::mainForm(void) const
72    {
73            return m_pMainForm;
74    }
75    
76    
77  // The global options settings delegated property.  // The global options settings delegated property.
78  qsamplerOptions *qsamplerChannel::options (void)  qsamplerOptions *qsamplerChannel::options (void) const
79  {  {
80          if (m_pMainForm == NULL)          if (m_pMainForm == NULL)
81                  return NULL;                  return NULL;
# Line 77  qsamplerOptions *qsamplerChannel::option Line 85  qsamplerOptions *qsamplerChannel::option
85    
86    
87  // The client descriptor delegated property.  // The client descriptor delegated property.
88  lscp_client_t *qsamplerChannel::client (void)  lscp_client_t *qsamplerChannel::client (void) const
89  {  {
90          if (m_pMainForm == NULL)          if (m_pMainForm == NULL)
91                  return NULL;                  return NULL;
# Line 124  bool qsamplerChannel::removeChannel (voi Line 132  bool qsamplerChannel::removeChannel (voi
132                          m_iChannelID = -1;                          m_iChannelID = -1;
133                  }                  }
134          }          }
135            
136          // Return whether we've removed the channel...          // Return whether we've removed the channel...
137          return (m_iChannelID < 0);          return (m_iChannelID < 0);
138  }  }
139    
140    
141  // Channel-ID (aka Sammpler-Channel) accessors.  // Channel-ID (aka Sammpler-Channel) accessors.
142  int qsamplerChannel::channelID (void)  int qsamplerChannel::channelID (void) const
143  {  {
144          return m_iChannelID;          return m_iChannelID;
145  }  }
# Line 143  void qsamplerChannel::setChannelID ( int Line 151  void qsamplerChannel::setChannelID ( int
151    
152    
153  // Readable channel name.  // Readable channel name.
154  QString qsamplerChannel::channelName (void)  QString qsamplerChannel::channelName (void) const
155  {  {
156          return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID));          return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID));
157  }  }
158    
159    
160  // Engine name accessors.  // Engine name accessors.
161  QString& qsamplerChannel::engineName (void)  const QString& qsamplerChannel::engineName (void) const
162  {  {
163          return m_sEngineName;          return m_sEngineName;
164  }  }
# Line 161  bool qsamplerChannel::loadEngine ( const Line 169  bool qsamplerChannel::loadEngine ( const
169                  return false;                  return false;
170          if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName)          if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName)
171                  return true;                  return true;
172                    
173          if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {          if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {
174                  appendMessagesClient("lscp_load_engine");                  appendMessagesClient("lscp_load_engine");
175                  return false;                  return false;
# Line 174  bool qsamplerChannel::loadEngine ( const Line 182  bool qsamplerChannel::loadEngine ( const
182    
183    
184  // Instrument filename accessor.  // Instrument filename accessor.
185  QString& qsamplerChannel::instrumentFile (void)  const QString& qsamplerChannel::instrumentFile (void) const
186  {  {
187          return m_sInstrumentFile;          return m_sInstrumentFile;
188  }  }
189    
190  // Instrument index accessor.  // Instrument index accessor.
191  int qsamplerChannel::instrumentNr (void)  int qsamplerChannel::instrumentNr (void) const
192  {  {
193          return m_iInstrumentNr;          return m_iInstrumentNr;
194  }  }
195    
196  // Instrument name accessor.  // Instrument name accessor.
197  QString& qsamplerChannel::instrumentName (void)  const QString& qsamplerChannel::instrumentName (void) const
198  {  {
199          return m_sInstrumentName;          return m_sInstrumentName;
200  }  }
201    
202  // Instrument status accessor.  // Instrument status accessor.
203  int qsamplerChannel::instrumentStatus (void)  int qsamplerChannel::instrumentStatus (void) const
204  {  {
205          return m_iInstrumentStatus;          return m_iInstrumentStatus;
206  }  }
# Line 214  bool qsamplerChannel::loadInstrument ( c Line 222  bool qsamplerChannel::loadInstrument ( c
222    
223          appendMessages(QObject::tr("Instrument: \"%1\" (%2).")          appendMessages(QObject::tr("Instrument: \"%1\" (%2).")
224                  .arg(sInstrumentFile).arg(iInstrumentNr));                  .arg(sInstrumentFile).arg(iInstrumentNr));
225                    
226          return setInstrument(sInstrumentFile, iInstrumentNr);          return setInstrument(sInstrumentFile, iInstrumentNr);
227  }  }
228    
# Line 236  bool qsamplerChannel::setInstrument ( co Line 244  bool qsamplerChannel::setInstrument ( co
244    
245    
246  // MIDI driver type accessors (DEPRECATED).  // MIDI driver type accessors (DEPRECATED).
247  QString& qsamplerChannel::midiDriver (void)  const QString& qsamplerChannel::midiDriver (void) const
248  {  {
249          return m_sMidiDriver;          return m_sMidiDriver;
250  }  }
# Line 261  bool qsamplerChannel::setMidiDriver ( co Line 269  bool qsamplerChannel::setMidiDriver ( co
269    
270    
271  // MIDI device accessors.  // MIDI device accessors.
272  int qsamplerChannel::midiDevice (void)  int qsamplerChannel::midiDevice (void) const
273  {  {
274          return m_iMidiDevice;          return m_iMidiDevice;
275  }  }
# Line 286  bool qsamplerChannel::setMidiDevice ( in Line 294  bool qsamplerChannel::setMidiDevice ( in
294    
295    
296  // MIDI port number accessor.  // MIDI port number accessor.
297  int qsamplerChannel::midiPort (void)  int qsamplerChannel::midiPort (void) const
298  {  {
299          return m_iMidiPort;          return m_iMidiPort;
300  }  }
# Line 311  bool qsamplerChannel::setMidiPort ( int Line 319  bool qsamplerChannel::setMidiPort ( int
319    
320    
321  // MIDI channel accessor.  // MIDI channel accessor.
322  int qsamplerChannel::midiChannel (void)  int qsamplerChannel::midiChannel (void) const
323  {  {
324          return m_iMidiChannel;          return m_iMidiChannel;
325  }  }
# Line 336  bool qsamplerChannel::setMidiChannel ( i Line 344  bool qsamplerChannel::setMidiChannel ( i
344    
345    
346  // Audio device accessor.  // Audio device accessor.
347  int qsamplerChannel::audioDevice (void)  int qsamplerChannel::audioDevice (void) const
348  {  {
349          return m_iAudioDevice;          return m_iAudioDevice;
350  }  }
# Line 361  bool qsamplerChannel::setAudioDevice ( i Line 369  bool qsamplerChannel::setAudioDevice ( i
369    
370    
371  // Audio driver type accessors (DEPRECATED).  // Audio driver type accessors (DEPRECATED).
372  QString& qsamplerChannel::audioDriver (void)  const QString& qsamplerChannel::audioDriver (void) const
373  {  {
374          return m_sAudioDriver;          return m_sAudioDriver;
375  }  }
# Line 386  bool qsamplerChannel::setAudioDriver ( c Line 394  bool qsamplerChannel::setAudioDriver ( c
394    
395    
396  // Channel volume accessors.  // Channel volume accessors.
397  float qsamplerChannel::volume (void)  float qsamplerChannel::volume (void) const
398  {  {
399          return m_fVolume;          return m_fVolume;
400  }  }
# Line 410  bool qsamplerChannel::setVolume ( float Line 418  bool qsamplerChannel::setVolume ( float
418  }  }
419    
420    
421    // Sampler channel mute state.
422    bool qsamplerChannel::channelMute (void) const
423    {
424            return m_bMute;
425    }
426    
427    bool qsamplerChannel::setChannelMute ( bool bMute )
428    {
429            if (client() == NULL || m_iChannelID < 0)
430                    return false;
431            if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute)))
432                    return true;
433    
434    #ifdef CONFIG_MUTE_SOLO
435            if (::lscp_set_channel_mute(client(), m_iChannelID, bMute) != LSCP_OK) {
436                    appendMessagesClient("lscp_set_channel_mute");
437                    return false;
438            }
439            appendMessages(QObject::tr("Mute: %1.").arg((int) bMute));
440            m_bMute = bMute;
441            return true;
442    #else
443            return false;
444    #endif
445    }
446    
447    
448    // Sampler channel solo state.
449    bool qsamplerChannel::channelSolo (void) const
450    {
451            return m_bSolo;
452    }
453    
454    bool qsamplerChannel::setChannelSolo ( bool bSolo )
455    {
456            if (client() == NULL || m_iChannelID < 0)
457                    return false;
458            if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo)))
459                    return true;
460    
461    #ifdef CONFIG_MUTE_SOLO
462            if (::lscp_set_channel_solo(client(), m_iChannelID, bSolo) != LSCP_OK) {
463                    appendMessagesClient("lscp_set_channel_solo");
464                    return false;
465            }
466            appendMessages(QObject::tr("Solo: %1.").arg((int) bSolo));
467            m_bSolo = bSolo;
468            return true;
469    #else
470            return false;
471    #endif
472    }
473    
474    
475  // Istrument name remapper.  // Istrument name remapper.
476  void qsamplerChannel::updateInstrumentName (void)  void qsamplerChannel::updateInstrumentName (void)
477  {  {
# Line 458  bool qsamplerChannel::updateChannelInfo Line 520  bool qsamplerChannel::updateChannelInfo
520          m_iMidiChannel      = pChannelInfo->midi_channel;          m_iMidiChannel      = pChannelInfo->midi_channel;
521          m_iAudioDevice      = pChannelInfo->audio_device;          m_iAudioDevice      = pChannelInfo->audio_device;
522          m_fVolume           = pChannelInfo->volume;          m_fVolume           = pChannelInfo->volume;
523    #ifdef CONFIG_MUTE_SOLO
524            m_bMute             = pChannelInfo->mute;
525            m_bSolo             = pChannelInfo->solo;
526    #endif
527          // Some sanity checks.          // Some sanity checks.
528          if (m_sEngineName == "NONE" || m_sEngineName.isEmpty())          if (m_sEngineName == "NONE" || m_sEngineName.isEmpty())
529                  m_sEngineName = QString::null;                  m_sEngineName = QString::null;
# Line 465  bool qsamplerChannel::updateChannelInfo Line 531  bool qsamplerChannel::updateChannelInfo
531                  m_sInstrumentFile = QString::null;                  m_sInstrumentFile = QString::null;
532                  m_sInstrumentName = QString::null;                  m_sInstrumentName = QString::null;
533          }          }
534            
535          // FIXME: DEPRECATED...          // Time for device info grabbing...
536          lscp_device_info_t *pDeviceInfo;          lscp_device_info_t *pDeviceInfo;
537          const QString sNone = QObject::tr("(none)");          const QString sNone = QObject::tr("(none)");
538          // Audio device driver type.          // Audio device driver type.
# Line 513  bool qsamplerChannel::channelSetup ( QWi Line 579  bool qsamplerChannel::channelSetup ( QWi
579          bool bResult = false;          bool bResult = false;
580    
581          appendMessages(QObject::tr("setup..."));          appendMessages(QObject::tr("setup..."));
582            
583          qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent);          qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent);
584          if (pChannelForm) {          if (pChannelForm) {
585                  pChannelForm->setup(this);                  pChannelForm->setup(this);
# Line 526  bool qsamplerChannel::channelSetup ( QWi Line 592  bool qsamplerChannel::channelSetup ( QWi
592    
593    
594  // Redirected messages output methods.  // Redirected messages output methods.
595  void qsamplerChannel::appendMessages( const QString& s )  void qsamplerChannel::appendMessages( const QString& s ) const
596  {  {
597          if (m_pMainForm)          if (m_pMainForm)
598                  m_pMainForm->appendMessages(channelName() + ' ' + s);                  m_pMainForm->appendMessages(channelName() + ' ' + s);
599  }  }
600    
601  void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c )  void qsamplerChannel::appendMessagesColor( const QString& s,
602            const QString& c ) const
603  {  {
604          if (m_pMainForm)          if (m_pMainForm)
605                  m_pMainForm->appendMessagesColor(channelName() + ' ' + s, c);                  m_pMainForm->appendMessagesColor(channelName() + ' ' + s, c);
606  }  }
607    
608  void qsamplerChannel::appendMessagesText( const QString& s )  void qsamplerChannel::appendMessagesText( const QString& s ) const
609  {  {
610          if (m_pMainForm)          if (m_pMainForm)
611                  m_pMainForm->appendMessagesText(channelName() + ' ' + s);                  m_pMainForm->appendMessagesText(channelName() + ' ' + s);
612  }  }
613    
614  void qsamplerChannel::appendMessagesError( const QString& s )  void qsamplerChannel::appendMessagesError( const QString& s ) const
615  {  {
616          if (m_pMainForm)          if (m_pMainForm)
617                  m_pMainForm->appendMessagesError(channelName() + "\n\n" + s);                  m_pMainForm->appendMessagesError(channelName() + "\n\n" + s);
618  }  }
619    
620  void qsamplerChannel::appendMessagesClient( const QString& s )  void qsamplerChannel::appendMessagesClient( const QString& s ) const
621  {  {
622          if (m_pMainForm)          if (m_pMainForm)
623                  m_pMainForm->appendMessagesClient(channelName() + ' ' + s);                  m_pMainForm->appendMessagesClient(channelName() + ' ' + s);
# Line 594  QStringList qsamplerChannel::getInstrume Line 661  QStringList qsamplerChannel::getInstrume
661          if (isInstrumentFile(sInstrumentFile)) {          if (isInstrumentFile(sInstrumentFile)) {
662  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
663                  if (bInstrumentNames) {                  if (bInstrumentNames) {
664                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1());
665                          gig::File  *pGig  = new gig::File(pRiff);                          gig::File  *pGig  = new gig::File(pRiff);
666                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
667                          while (pInstrument) {                          while (pInstrument) {
# Line 625  QString qsamplerChannel::getInstrumentNa Line 692  QString qsamplerChannel::getInstrumentNa
692                  sInstrumentName = QFileInfo(sInstrumentFile).fileName();                  sInstrumentName = QFileInfo(sInstrumentFile).fileName();
693  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
694                  if (bInstrumentNames) {                  if (bInstrumentNames) {
695                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1());
696                          gig::File  *pGig  = new gig::File(pRiff);                          gig::File  *pGig  = new gig::File(pRiff);
697                          int iIndex = 0;                          int iIndex = 0;
698                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
# Line 661  QString qsamplerChannel::noInstrumentNam Line 728  QString qsamplerChannel::noInstrumentNam
728          return QObject::tr("(No instrument)");          return QObject::tr("(No instrument)");
729  }  }
730    
731    QString qsamplerChannel::loadingInstrument (void) {
732            return QObject::tr("(Loading instrument...)");
733    }
734    
735    
736  // end of qsamplerChannel.cpp  // end of qsamplerChannel.cpp

Legend:
Removed from v.467  
changed lines
  Added in v.751

  ViewVC Help
Powered by ViewVC