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

Diff of /qsampler/trunk/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 1668 by schoenebeck, Tue Feb 5 15:42:33 2008 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 25  Line 25 
25    
26  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
27    
28    #include "qsamplerChannelFxForm.h"
29    
30    #include <QMessageBox>
31  #include <QDragEnterEvent>  #include <QDragEnterEvent>
32  #include <QUrl>  #include <QUrl>
33    
# Line 34  Line 37 
37  // Needed for lroundf()  // Needed for lroundf()
38  #include <math.h>  #include <math.h>
39    
 namespace QSampler {  
   
40  #ifndef CONFIG_ROUND  #ifndef CONFIG_ROUND
41  static inline long lroundf ( float x )  static inline long lroundf ( float x )
42  {  {
# Line 46  static inline long lroundf ( float x ) Line 47  static inline long lroundf ( float x )
47  }  }
48  #endif  #endif
49    
50    
51    namespace QSampler {
52    
53    //-------------------------------------------------------------------------
54    // QSampler::ChannelStrip -- Channel strip form implementation.
55    //
56    
57    // Channel strip activation/selection.
58    ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;
59    
60  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )  ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )
61          : QWidget(pParent, wflags)          : QWidget(pParent, wflags)
62  {  {
# Line 77  ChannelStrip::ChannelStrip ( QWidget* pP Line 88  ChannelStrip::ChannelStrip ( QWidget* pP
88          QObject::connect(m_ui.ChannelEditPushButton,          QObject::connect(m_ui.ChannelEditPushButton,
89                  SIGNAL(clicked()),                  SIGNAL(clicked()),
90                  SLOT(channelEdit()));                  SLOT(channelEdit()));
91            QObject::connect(m_ui.FxPushButton,
92                    SIGNAL(clicked()),
93                    SLOT(channelFxEdit()));
94    
95            setSelected(false);
96  }  }
97    
98  ChannelStrip::~ChannelStrip() {  
99    ChannelStrip::~ChannelStrip (void)
100    {
101            setSelected(false);
102    
103          // Destroy existing channel descriptor.          // Destroy existing channel descriptor.
104          if (m_pChannel)          if (m_pChannel)
105                  delete m_pChannel;                  delete m_pChannel;
# Line 102  void ChannelStrip::dragEnterEvent ( QDra Line 122  void ChannelStrip::dragEnterEvent ( QDra
122                          while (iter.hasNext()) {                          while (iter.hasNext()) {
123                                  const QString& sFilename = iter.next().toLocalFile();                                  const QString& sFilename = iter.next().toLocalFile();
124                                  if (!sFilename.isEmpty()) {                                  if (!sFilename.isEmpty()) {
125                                          bAccept = qsamplerChannel::isInstrumentFile(sFilename);                                          bAccept = Channel::isInstrumentFile(sFilename);
126                                          break;                                          break;
127                                  }                                  }
128                          }                          }
# Line 143  void ChannelStrip::dropEvent ( QDropEven Line 163  void ChannelStrip::dropEvent ( QDropEven
163    
164    
165  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
166  void ChannelStrip::setup ( qsamplerChannel *pChannel )  void ChannelStrip::setup ( Channel *pChannel )
167  {  {
168          // Destroy any previous channel descriptor;          // Destroy any previous channel descriptor;
169          // (remember that once setup we own it!)          // (remember that once setup we own it!)
# Line 161  void ChannelStrip::setup ( qsamplerChann Line 181  void ChannelStrip::setup ( qsamplerChann
181                  setAcceptDrops(true);                  setAcceptDrops(true);
182  }  }
183    
184    
185  // Channel secriptor accessor.  // Channel secriptor accessor.
186  qsamplerChannel *ChannelStrip::channel (void) const  Channel *ChannelStrip::channel (void) const
187  {  {
188          return m_pChannel;          return m_pChannel;
189  }  }
# Line 198  void ChannelStrip::setDisplayEffect ( bo Line 219  void ChannelStrip::setDisplayEffect ( bo
219                  pal.setColor(QPalette::Background, Qt::black);                  pal.setColor(QPalette::Background, Qt::black);
220          }          }
221          m_ui.ChannelInfoFrame->setPalette(pal);          m_ui.ChannelInfoFrame->setPalette(pal);
222            m_ui.InstrumentNameTextLabel->setPalette(pal);
223          m_ui.StreamVoiceCountTextLabel->setPalette(pal);          m_ui.StreamVoiceCountTextLabel->setPalette(pal);
224  }  }
225    
# Line 269  void ChannelStrip::channelEdit (void) Line 291  void ChannelStrip::channelEdit (void)
291          m_pChannel->editChannel();          m_pChannel->editChannel();
292  }  }
293    
294    bool ChannelStrip::channelFxEdit (void)
295    {
296            MainForm *pMainForm = MainForm::getInstance();
297            if (!pMainForm || !channel())
298                    return false;
299    
300            pMainForm->appendMessages(QObject::tr("channel fx sends..."));
301    
302            bool bResult = false;
303    
304    #if CONFIG_FXSEND
305            ChannelFxForm *pChannelFxForm =
306                    new ChannelFxForm(channel(), parentWidget());
307            if (pChannelFxForm) {
308                    //pChannelForm->setup(this);
309                    bResult = pChannelFxForm->exec();
310                    delete pChannelFxForm;
311            }
312    #else // CONFIG_FXSEND
313            QMessageBox::critical(this,
314                    QSAMPLER_TITLE ": " + tr("Unavailable"),
315                            tr("Sorry, QSampler was built without FX send support!\n\n"
316                               "(Make sure you have a recent liblscp when recompiling QSampler)"));
317    #endif // CONFIG_FXSEND
318    
319            return bResult;
320    }
321    
322  // Channel reset slot.  // Channel reset slot.
323  bool ChannelStrip::channelReset (void)  bool ChannelStrip::channelReset (void)
# Line 298  bool ChannelStrip::updateInstrumentName Line 347  bool ChannelStrip::updateInstrumentName
347    
348          // Instrument name...          // Instrument name...
349          if (m_pChannel->instrumentName().isEmpty()) {          if (m_pChannel->instrumentName().isEmpty()) {
350                  if (m_pChannel->instrumentStatus() >= 0)                  if (m_pChannel->instrumentStatus() >= 0) {
351                          m_ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument());                          m_ui.InstrumentNameTextLabel->setText(
352                  else                                  ' ' + Channel::loadingInstrument());
353                          m_ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());                  } else {
354          } else                          m_ui.InstrumentNameTextLabel->setText(
355                  m_ui.InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());                                  ' ' + Channel::noInstrumentName());
356                    }
357            } else {
358                    m_ui.InstrumentNameTextLabel->setText(
359                            ' ' + m_pChannel->instrumentName());
360            }
361    
362          return true;          return true;
363  }  }
# Line 344  bool ChannelStrip::updateChannelInfo (vo Line 398  bool ChannelStrip::updateChannelInfo (vo
398          // Update strip caption.          // Update strip caption.
399          QString sText = m_pChannel->channelName();          QString sText = m_pChannel->channelName();
400          setWindowTitle(sText);          setWindowTitle(sText);
401          m_ui.ChannelSetupPushButton->setText(sText);          m_ui.ChannelSetupPushButton->setText('&' + sText);
402    
403          // Check if we're up and connected.          // Check if we're up and connected.
404          MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
# Line 355  bool ChannelStrip::updateChannelInfo (vo Line 409  bool ChannelStrip::updateChannelInfo (vo
409          m_pChannel->updateChannelInfo();          m_pChannel->updateChannelInfo();
410    
411          // Engine name...          // Engine name...
412          if (m_pChannel->engineName().isEmpty())          if (m_pChannel->engineName().isEmpty()) {
413                  m_ui.EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());                  m_ui.EngineNameTextLabel->setText(
414          else                          ' ' + Channel::noEngineName());
415                  m_ui.EngineNameTextLabel->setText(' ' + m_pChannel->engineName());          } else {
416                    m_ui.EngineNameTextLabel->setText(
417                            ' ' + m_pChannel->engineName());
418            }
419    
420          // Instrument name...          // Instrument name...
421          updateInstrumentName(false);          updateInstrumentName(false);
# Line 380  bool ChannelStrip::updateChannelInfo (vo Line 437  bool ChannelStrip::updateChannelInfo (vo
437          if (iInstrumentStatus < 0) {          if (iInstrumentStatus < 0) {
438                  pal.setColor(QPalette::Foreground, Qt::red);                  pal.setColor(QPalette::Foreground, Qt::red);
439                  m_ui.InstrumentStatusTextLabel->setPalette(pal);                  m_ui.InstrumentStatusTextLabel->setPalette(pal);
440                  m_ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));                  m_ui.InstrumentStatusTextLabel->setText(
441                            tr("ERR%1").arg(iInstrumentStatus));
442                  m_iErrorCount++;                  m_iErrorCount++;
443                  return false;                  return false;
444          }          }
# Line 388  bool ChannelStrip::updateChannelInfo (vo Line 446  bool ChannelStrip::updateChannelInfo (vo
446          pal.setColor(QPalette::Foreground,          pal.setColor(QPalette::Foreground,
447                  iInstrumentStatus < 100 ? Qt::yellow : Qt::green);                  iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
448          m_ui.InstrumentStatusTextLabel->setPalette(pal);          m_ui.InstrumentStatusTextLabel->setPalette(pal);
449          m_ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');          m_ui.InstrumentStatusTextLabel->setText(
450                    QString::number(iInstrumentStatus) + '%');
451          m_iErrorCount = 0;          m_iErrorCount = 0;
452    
453  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
# Line 429  bool ChannelStrip::updateChannelUsage (v Line 488  bool ChannelStrip::updateChannelUsage (v
488                  return false;                  return false;
489    
490          // Get current channel voice count.          // Get current channel voice count.
491          int iVoiceCount  = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID());          int iVoiceCount  = ::lscp_get_channel_voice_count(
492                    pMainForm->client(), m_pChannel->channelID());
493  // Get current stream count.  // Get current stream count.
494          int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID());          int iStreamCount = ::lscp_get_channel_stream_count(
495                    pMainForm->client(), m_pChannel->channelID());
496          // Get current channel buffer fill usage.          // Get current channel buffer fill usage.
497          // As benno has suggested this is the percentage usage          // As benno has suggested this is the percentage usage
498          // of the least filled buffer stream...          // of the least filled buffer stream...
499          int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());;          int iStreamUsage = ::lscp_get_channel_stream_usage(
500                    pMainForm->client(), m_pChannel->channelID());;
501    
502          // Update the GUI elements...          // Update the GUI elements...
503          m_ui.StreamUsageProgressBar->setValue(iStreamUsage);          m_ui.StreamUsageProgressBar->setValue(iStreamUsage);
504          m_ui.StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));          m_ui.StreamVoiceCountTextLabel->setText(
505                    QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
506    
507          // We're clean.          // We're clean.
508          return true;          return true;
# Line 486  void ChannelStrip::resetErrorCount (void Line 549  void ChannelStrip::resetErrorCount (void
549          m_iErrorCount = 0;          m_iErrorCount = 0;
550  }  }
551    
552    
553    // Channel strip activation/selection.
554    void ChannelStrip::setSelected ( bool bSelected )
555    {
556            if (bSelected) {
557                    if (g_pSelectedStrip == this)
558                            return;
559                    if (g_pSelectedStrip)
560                            g_pSelectedStrip->setSelected(false);
561                    g_pSelectedStrip = this;
562            } else {
563                    if (g_pSelectedStrip == this)
564                            g_pSelectedStrip = NULL;
565            }
566    
567            QPalette pal;
568            if (bSelected) {
569                    const QColor& color = pal.midlight().color();
570                    pal.setColor(QPalette::Background, color.dark(150));
571                    pal.setColor(QPalette::Foreground, color.light(150));
572            }
573            QWidget::setPalette(pal);
574    }
575    
576    
577    bool ChannelStrip::isSelected (void) const
578    {
579            return (this == g_pSelectedStrip);
580    }
581    
582    
583  } // namespace QSampler  } // namespace QSampler
584    
585    

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

  ViewVC Help
Powered by ViewVC