/[svn]/qsampler/tags/qsampler_0_3_1/src/qsamplerChannelStrip.cpp
ViewVC logotype

Diff of /qsampler/tags/qsampler_0_3_1/src/qsamplerChannelStrip.cpp

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

revision 1510 by capela, Thu Nov 22 14:17:24 2007 UTC revision 1637 by capela, Mon Jan 7 20:00:13 2008 UTC
# Line 34  Line 34 
34  // Needed for lroundf()  // Needed for lroundf()
35  #include <math.h>  #include <math.h>
36    
 namespace QSampler {  
   
37  #ifndef CONFIG_ROUND  #ifndef CONFIG_ROUND
38  static inline long lroundf ( float x )  static inline long lroundf ( float x )
39  {  {
# Line 46  static inline long lroundf ( float x ) Line 44  static inline long lroundf ( float x )
44  }  }
45  #endif  #endif
46    
47    
48    namespace QSampler {
49    
50    //-------------------------------------------------------------------------
51    // QSampler::ChannelStrip -- Channel strip form implementation.
52    //
53    
54    // Channel strip activation/selection.
55    ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;
56    
57  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )
58          : QWidget(pParent, wflags)          : QWidget(pParent, wflags)
59  {  {
# Line 77  ChannelStrip::ChannelStrip ( QWidget* pP Line 85  ChannelStrip::ChannelStrip ( QWidget* pP
85          QObject::connect(m_ui.ChannelEditPushButton,          QObject::connect(m_ui.ChannelEditPushButton,
86                  SIGNAL(clicked()),                  SIGNAL(clicked()),
87                  SLOT(channelEdit()));                  SLOT(channelEdit()));
88    
89            setSelected(false);
90  }  }
91    
92  ChannelStrip::~ChannelStrip() {  
93    ChannelStrip::~ChannelStrip (void)
94    {
95            setSelected(false);
96    
97          // Destroy existing channel descriptor.          // Destroy existing channel descriptor.
98          if (m_pChannel)          if (m_pChannel)
99                  delete m_pChannel;                  delete m_pChannel;
# Line 102  void ChannelStrip::dragEnterEvent ( QDra Line 116  void ChannelStrip::dragEnterEvent ( QDra
116                          while (iter.hasNext()) {                          while (iter.hasNext()) {
117                                  const QString& sFilename = iter.next().toLocalFile();                                  const QString& sFilename = iter.next().toLocalFile();
118                                  if (!sFilename.isEmpty()) {                                  if (!sFilename.isEmpty()) {
119                                          bAccept = qsamplerChannel::isInstrumentFile(sFilename);                                          bAccept = Channel::isInstrumentFile(sFilename);
120                                          break;                                          break;
121                                  }                                  }
122                          }                          }
# Line 143  void ChannelStrip::dropEvent ( QDropEven Line 157  void ChannelStrip::dropEvent ( QDropEven
157    
158    
159  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
160  void ChannelStrip::setup ( qsamplerChannel *pChannel )  void ChannelStrip::setup ( Channel *pChannel )
161  {  {
162          // Destroy any previous channel descriptor;          // Destroy any previous channel descriptor;
163          // (remember that once setup we own it!)          // (remember that once setup we own it!)
# Line 161  void ChannelStrip::setup ( qsamplerChann Line 175  void ChannelStrip::setup ( qsamplerChann
175                  setAcceptDrops(true);                  setAcceptDrops(true);
176  }  }
177    
178    
179  // Channel secriptor accessor.  // Channel secriptor accessor.
180  qsamplerChannel *ChannelStrip::channel (void) const  Channel *ChannelStrip::channel (void) const
181  {  {
182          return m_pChannel;          return m_pChannel;
183  }  }
# Line 198  void ChannelStrip::setDisplayEffect ( bo Line 213  void ChannelStrip::setDisplayEffect ( bo
213                  pal.setColor(QPalette::Background, Qt::black);                  pal.setColor(QPalette::Background, Qt::black);
214          }          }
215          m_ui.ChannelInfoFrame->setPalette(pal);          m_ui.ChannelInfoFrame->setPalette(pal);
216            m_ui.InstrumentNameTextLabel->setPalette(pal);
217          m_ui.StreamVoiceCountTextLabel->setPalette(pal);          m_ui.StreamVoiceCountTextLabel->setPalette(pal);
218  }  }
219    
# Line 298  bool ChannelStrip::updateInstrumentName Line 314  bool ChannelStrip::updateInstrumentName
314    
315          // Instrument name...          // Instrument name...
316          if (m_pChannel->instrumentName().isEmpty()) {          if (m_pChannel->instrumentName().isEmpty()) {
317                  if (m_pChannel->instrumentStatus() >= 0)                  if (m_pChannel->instrumentStatus() >= 0) {
318                          m_ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument());                          m_ui.InstrumentNameTextLabel->setText(
319                  else                                  ' ' + Channel::loadingInstrument());
320                          m_ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());                  } else {
321          } else                          m_ui.InstrumentNameTextLabel->setText(
322                  m_ui.InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());                                  ' ' + Channel::noInstrumentName());
323                    }
324            } else {
325                    m_ui.InstrumentNameTextLabel->setText(
326                            ' ' + m_pChannel->instrumentName());
327            }
328    
329          return true;          return true;
330  }  }
# Line 344  bool ChannelStrip::updateChannelInfo (vo Line 365  bool ChannelStrip::updateChannelInfo (vo
365          // Update strip caption.          // Update strip caption.
366          QString sText = m_pChannel->channelName();          QString sText = m_pChannel->channelName();
367          setWindowTitle(sText);          setWindowTitle(sText);
368          m_ui.ChannelSetupPushButton->setText(sText);          m_ui.ChannelSetupPushButton->setText('&' + sText);
369    
370          // Check if we're up and connected.          // Check if we're up and connected.
371          MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
# Line 355  bool ChannelStrip::updateChannelInfo (vo Line 376  bool ChannelStrip::updateChannelInfo (vo
376          m_pChannel->updateChannelInfo();          m_pChannel->updateChannelInfo();
377    
378          // Engine name...          // Engine name...
379          if (m_pChannel->engineName().isEmpty())          if (m_pChannel->engineName().isEmpty()) {
380                  m_ui.EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());                  m_ui.EngineNameTextLabel->setText(
381          else                          ' ' + Channel::noEngineName());
382                  m_ui.EngineNameTextLabel->setText(' ' + m_pChannel->engineName());          } else {
383                    m_ui.EngineNameTextLabel->setText(
384                            ' ' + m_pChannel->engineName());
385            }
386    
387          // Instrument name...          // Instrument name...
388          updateInstrumentName(false);          updateInstrumentName(false);
# Line 380  bool ChannelStrip::updateChannelInfo (vo Line 404  bool ChannelStrip::updateChannelInfo (vo
404          if (iInstrumentStatus < 0) {          if (iInstrumentStatus < 0) {
405                  pal.setColor(QPalette::Foreground, Qt::red);                  pal.setColor(QPalette::Foreground, Qt::red);
406                  m_ui.InstrumentStatusTextLabel->setPalette(pal);                  m_ui.InstrumentStatusTextLabel->setPalette(pal);
407                  m_ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));                  m_ui.InstrumentStatusTextLabel->setText(
408                            tr("ERR%1").arg(iInstrumentStatus));
409                  m_iErrorCount++;                  m_iErrorCount++;
410                  return false;                  return false;
411          }          }
# Line 388  bool ChannelStrip::updateChannelInfo (vo Line 413  bool ChannelStrip::updateChannelInfo (vo
413          pal.setColor(QPalette::Foreground,          pal.setColor(QPalette::Foreground,
414                  iInstrumentStatus < 100 ? Qt::yellow : Qt::green);                  iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
415          m_ui.InstrumentStatusTextLabel->setPalette(pal);          m_ui.InstrumentStatusTextLabel->setPalette(pal);
416          m_ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');          m_ui.InstrumentStatusTextLabel->setText(
417                    QString::number(iInstrumentStatus) + '%');
418          m_iErrorCount = 0;          m_iErrorCount = 0;
419    
420  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
# Line 429  bool ChannelStrip::updateChannelUsage (v Line 455  bool ChannelStrip::updateChannelUsage (v
455                  return false;                  return false;
456    
457          // Get current channel voice count.          // Get current channel voice count.
458          int iVoiceCount  = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID());          int iVoiceCount  = ::lscp_get_channel_voice_count(
459                    pMainForm->client(), m_pChannel->channelID());
460  // Get current stream count.  // Get current stream count.
461          int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID());          int iStreamCount = ::lscp_get_channel_stream_count(
462                    pMainForm->client(), m_pChannel->channelID());
463          // Get current channel buffer fill usage.          // Get current channel buffer fill usage.
464          // As benno has suggested this is the percentage usage          // As benno has suggested this is the percentage usage
465          // of the least filled buffer stream...          // of the least filled buffer stream...
466          int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());;          int iStreamUsage = ::lscp_get_channel_stream_usage(
467                    pMainForm->client(), m_pChannel->channelID());;
468    
469          // Update the GUI elements...          // Update the GUI elements...
470          m_ui.StreamUsageProgressBar->setValue(iStreamUsage);          m_ui.StreamUsageProgressBar->setValue(iStreamUsage);
471          m_ui.StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));          m_ui.StreamVoiceCountTextLabel->setText(
472                    QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
473    
474          // We're clean.          // We're clean.
475          return true;          return true;
# Line 486  void ChannelStrip::resetErrorCount (void Line 516  void ChannelStrip::resetErrorCount (void
516          m_iErrorCount = 0;          m_iErrorCount = 0;
517  }  }
518    
519    
520    // Channel strip activation/selection.
521    void ChannelStrip::setSelected ( bool bSelected )
522    {
523            if (bSelected) {
524                    if (g_pSelectedStrip == this)
525                            return;
526                    if (g_pSelectedStrip)
527                            g_pSelectedStrip->setSelected(false);
528                    g_pSelectedStrip = this;
529            } else {
530                    if (g_pSelectedStrip == this)
531                            g_pSelectedStrip = NULL;
532            }
533    
534            QPalette pal;
535            if (bSelected) {
536                    const QColor& color = pal.midlight().color();
537                    pal.setColor(QPalette::Background, color.dark(150));
538                    pal.setColor(QPalette::Foreground, color.light(150));
539            }
540            QWidget::setPalette(pal);
541    }
542    
543    
544    bool ChannelStrip::isSelected (void) const
545    {
546            return (this == g_pSelectedStrip);
547    }
548    
549    
550  } // namespace QSampler  } // namespace QSampler
551    
552    

Legend:
Removed from v.1510  
changed lines
  Added in v.1637

  ViewVC Help
Powered by ViewVC