/[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 1507 by capela, Wed Nov 21 23:22:18 2007 UTC revision 2108 by capela, Thu Jul 15 08:03:32 2010 UTC
# Line 1  Line 1 
1  // qsamplerChannelStrip.cpp  // qsamplerChannelStrip.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2010, 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 <QFileInfo>
33    #include <QTimer>
34  #include <QUrl>  #include <QUrl>
35    
 #include <math.h>  
36    
37  // Channel status/usage usage limit control.  // Channel status/usage usage limit control.
38  #define QSAMPLER_ERROR_LIMIT    3  #define QSAMPLER_ERROR_LIMIT    3
39    
40    // Needed for lroundf()
41    #include <math.h>
42    
43    #ifndef CONFIG_ROUND
44    static inline long lroundf ( float x )
45    {
46            if (x >= 0.0f)
47                    return long(x + 0.5f);
48            else
49                    return long(x - 0.5f);
50    }
51    #endif
52    
53    
54  namespace QSampler {  namespace QSampler {
55    
56  ChannelStrip::ChannelStrip(QWidget* parent, Qt::WFlags f) : QWidget(parent, f) {  //-------------------------------------------------------------------------
57      ui.setupUi(this);  // QSampler::ChannelStrip -- Channel strip form implementation.
58    //
59    
60    // MIDI activity pixmap common resources.
61    int      ChannelStrip::g_iMidiActivityRefCount = 0;
62    QPixmap *ChannelStrip::g_pMidiActivityLedOn    = NULL;
63    QPixmap *ChannelStrip::g_pMidiActivityLedOff   = NULL;
64    
65    // Channel strip activation/selection.
66    ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL;
67    
68    ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags )
69            : QWidget(pParent, wflags)
70    {
71            m_ui.setupUi(this);
72    
73            // Initialize locals.
74            m_pChannel     = NULL;
75            m_iDirtyChange = 0;
76            m_iErrorCount  = 0;
77    
78            if (++g_iMidiActivityRefCount == 1) {
79                    g_pMidiActivityLedOn  = new QPixmap(":/images/ledon1.png");
80                    g_pMidiActivityLedOff = new QPixmap(":/images/ledoff1.png");
81            }
82    
83            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);
84    
85    #ifndef CONFIG_EVENT_CHANNEL_MIDI
86            m_ui.MidiActivityLabel->setToolTip("MIDI activity (disabled)");
87    #endif
88    
89            m_pMidiActivityTimer = new QTimer(this);
90            m_pMidiActivityTimer->setSingleShot(true);
91    
92      // Initialize locals.          QObject::connect(m_pMidiActivityTimer,
93      m_pChannel     = NULL;                  SIGNAL(timeout()),
94      m_iDirtyChange = 0;                  SLOT(midiActivityLedOff())
95      m_iErrorCount  = 0;          );
96    
97      // Try to restore normal window positioning.          // Try to restore normal window positioning.
98      adjustSize();          adjustSize();
99    
100          QObject::connect(ui.ChannelSetupPushButton,          QObject::connect(m_ui.ChannelSetupPushButton,
101                  SIGNAL(clicked()),                  SIGNAL(clicked()),
102                  SLOT(channelSetup()));                  SLOT(channelSetup()));
103          QObject::connect(ui.ChannelMutePushButton,          QObject::connect(m_ui.ChannelMutePushButton,
104                  SIGNAL(toggled(bool)),                  SIGNAL(toggled(bool)),
105                  SLOT(channelMute(bool)));                  SLOT(channelMute(bool)));
106          QObject::connect(ui.ChannelSoloPushButton,          QObject::connect(m_ui.ChannelSoloPushButton,
107                  SIGNAL(toggled(bool)),                  SIGNAL(toggled(bool)),
108                  SLOT(channelSolo(bool)));                  SLOT(channelSolo(bool)));
109          QObject::connect(ui.VolumeSlider,          QObject::connect(m_ui.VolumeSlider,
110                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
111                  SLOT(volumeChanged(int)));                  SLOT(volumeChanged(int)));
112          QObject::connect(ui.VolumeSpinBox,          QObject::connect(m_ui.VolumeSpinBox,
113                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
114                  SLOT(volumeChanged(int)));                  SLOT(volumeChanged(int)));
115          QObject::connect(ui.ChannelEditPushButton,          QObject::connect(m_ui.ChannelEditPushButton,
116                  SIGNAL(clicked()),                  SIGNAL(clicked()),
117                  SLOT(channelEdit()));                  SLOT(channelEdit()));
118            QObject::connect(m_ui.FxPushButton,
119                    SIGNAL(clicked()),
120                    SLOT(channelFxEdit()));
121    
122            setSelected(false);
123  }  }
124    
125  ChannelStrip::~ChannelStrip() {  
126      // Destroy existing channel descriptor.  ChannelStrip::~ChannelStrip (void)
127      if (m_pChannel)  {
128          delete m_pChannel;          setSelected(false);
129      m_pChannel = NULL;  
130            // Destroy existing channel descriptor.
131            if (m_pChannel)
132                    delete m_pChannel;
133            m_pChannel = NULL;
134    
135            if (--g_iMidiActivityRefCount == 0) {
136                    if (g_pMidiActivityLedOn)
137                            delete g_pMidiActivityLedOn;
138                    g_pMidiActivityLedOn = NULL;
139                    if (g_pMidiActivityLedOff)
140                            delete g_pMidiActivityLedOff;
141                    g_pMidiActivityLedOff = NULL;
142            }
143  }  }
144    
145    
# Line 89  void ChannelStrip::dragEnterEvent ( QDra Line 158  void ChannelStrip::dragEnterEvent ( QDra
158                          while (iter.hasNext()) {                          while (iter.hasNext()) {
159                                  const QString& sFilename = iter.next().toLocalFile();                                  const QString& sFilename = iter.next().toLocalFile();
160                                  if (!sFilename.isEmpty()) {                                  if (!sFilename.isEmpty()) {
161                                          bAccept = qsamplerChannel::isInstrumentFile(sFilename);                                  //      bAccept = Channel::isDlsInstrumentFile(sFilename);
162                                            bAccept = QFileInfo(sFilename).exists();
163                                          break;                                          break;
164                                  }                                  }
165                          }                          }
# Line 130  void ChannelStrip::dropEvent ( QDropEven Line 200  void ChannelStrip::dropEvent ( QDropEven
200    
201    
202  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
203  void ChannelStrip::setup ( qsamplerChannel *pChannel )  void ChannelStrip::setup ( Channel *pChannel )
204  {  {
205      // Destroy any previous channel descriptor;          // Destroy any previous channel descriptor;
206      // (remember that once setup we own it!)          // (remember that once setup we own it!)
207      if (m_pChannel)          if (m_pChannel)
208          delete m_pChannel;                  delete m_pChannel;
209    
210      // Set the new one...          // Set the new one...
211      m_pChannel = pChannel;          m_pChannel = pChannel;
212    
213      // Stabilize this around.          // Stabilize this around.
214      updateChannelInfo();          updateChannelInfo();
215    
216          // We'll accept drops from now on...          // We'll accept drops from now on...
217          if (m_pChannel)          if (m_pChannel)
218                  setAcceptDrops(true);                  setAcceptDrops(true);
219  }  }
220    
221    
222  // Channel secriptor accessor.  // Channel secriptor accessor.
223  qsamplerChannel *ChannelStrip::channel (void)  Channel *ChannelStrip::channel (void) const
224  {  {
225      return m_pChannel;          return m_pChannel;
226  }  }
227    
228    
229  // Messages view font accessors.  // Messages view font accessors.
230  QFont ChannelStrip::displayFont (void)  QFont ChannelStrip::displayFont (void) const
231  {  {
232      return ui.EngineNameTextLabel->font();          return m_ui.EngineNameTextLabel->font();
233  }  }
234    
235  void ChannelStrip::setDisplayFont ( const QFont & font )  void ChannelStrip::setDisplayFont ( const QFont & font )
236  {  {
237      ui.EngineNameTextLabel->setFont(font);          m_ui.EngineNameTextLabel->setFont(font);
238      ui.MidiPortChannelTextLabel->setFont(font);          m_ui.MidiPortChannelTextLabel->setFont(font);
239      ui.InstrumentNameTextLabel->setFont(font);          m_ui.InstrumentNameTextLabel->setFont(font);
240      ui.InstrumentStatusTextLabel->setFont(font);          m_ui.InstrumentStatusTextLabel->setFont(font);
241  }  }
242    
243    
# Line 175  void ChannelStrip::setDisplayEffect ( bo Line 246  void ChannelStrip::setDisplayEffect ( bo
246  {  {
247          QPalette pal;          QPalette pal;
248          pal.setColor(QPalette::Foreground, Qt::yellow);          pal.setColor(QPalette::Foreground, Qt::yellow);
249          ui.EngineNameTextLabel->setPalette(pal);          m_ui.EngineNameTextLabel->setPalette(pal);
250          ui.MidiPortChannelTextLabel->setPalette(pal);          m_ui.MidiPortChannelTextLabel->setPalette(pal);
251          pal.setColor(QPalette::Foreground, Qt::green);          pal.setColor(QPalette::Foreground, Qt::green);
252          if (bDisplayEffect) {          if (bDisplayEffect) {
253                  QPixmap pm(":/icons/displaybg1.png");                  QPixmap pm(":/images/displaybg1.png");
254                  pal.setBrush(QPalette::Background, QBrush(pm));                  pal.setBrush(QPalette::Background, QBrush(pm));
255          } else {          } else {
256                  pal.setColor(QPalette::Background, Qt::black);                  pal.setColor(QPalette::Background, Qt::black);
257          }          }
258          ui.ChannelInfoFrame->setPalette(pal);          m_ui.ChannelInfoFrame->setPalette(pal);
259          ui.StreamVoiceCountTextLabel->setPalette(pal);          m_ui.InstrumentNameTextLabel->setPalette(pal);
260            m_ui.StreamVoiceCountTextLabel->setPalette(pal);
261  }  }
262    
263    
264  // Maximum volume slider accessors.  // Maximum volume slider accessors.
265  void ChannelStrip::setMaxVolume ( int iMaxVolume )  void ChannelStrip::setMaxVolume ( int iMaxVolume )
266  {  {
267      m_iDirtyChange++;          m_iDirtyChange++;
268      ui.VolumeSlider->setRange(0, iMaxVolume);          m_ui.VolumeSlider->setRange(0, iMaxVolume);
269      ui.VolumeSpinBox->setRange(0, iMaxVolume);          m_ui.VolumeSpinBox->setRange(0, iMaxVolume);
270      m_iDirtyChange--;          m_iDirtyChange--;
271  }  }
272    
273    
# Line 256  void ChannelStrip::channelEdit (void) Line 328  void ChannelStrip::channelEdit (void)
328          m_pChannel->editChannel();          m_pChannel->editChannel();
329  }  }
330    
331    bool ChannelStrip::channelFxEdit (void)
332    {
333            MainForm *pMainForm = MainForm::getInstance();
334            if (!pMainForm || !channel())
335                    return false;
336    
337            pMainForm->appendMessages(QObject::tr("channel fx sends..."));
338    
339            bool bResult = false;
340    
341    #if CONFIG_FXSEND
342            ChannelFxForm *pChannelFxForm =
343                    new ChannelFxForm(channel(), parentWidget());
344            if (pChannelFxForm) {
345                    //pChannelForm->setup(this);
346                    bResult = pChannelFxForm->exec();
347                    delete pChannelFxForm;
348            }
349    #else // CONFIG_FXSEND
350            QMessageBox::critical(this,
351                    QSAMPLER_TITLE ": " + tr("Unavailable"),
352                            tr("Sorry, QSampler was built without FX send support!\n\n"
353                               "(Make sure you have a recent liblscp when recompiling QSampler)"));
354    #endif // CONFIG_FXSEND
355    
356            return bResult;
357    }
358    
359  // Channel reset slot.  // Channel reset slot.
360  bool ChannelStrip::channelReset (void)  bool ChannelStrip::channelReset (void)
# Line 285  bool ChannelStrip::updateInstrumentName Line 384  bool ChannelStrip::updateInstrumentName
384    
385          // Instrument name...          // Instrument name...
386          if (m_pChannel->instrumentName().isEmpty()) {          if (m_pChannel->instrumentName().isEmpty()) {
387                  if (m_pChannel->instrumentStatus() >= 0)                  if (m_pChannel->instrumentStatus() >= 0) {
388                          ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument());                          m_ui.InstrumentNameTextLabel->setText(
389                  else                                  ' ' + Channel::loadingInstrument());
390                          ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());                  } else {
391          } else                          m_ui.InstrumentNameTextLabel->setText(
392                  ui.InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());                                  ' ' + Channel::noInstrumentName());
393                    }
394            } else {
395                    m_ui.InstrumentNameTextLabel->setText(
396                            ' ' + m_pChannel->instrumentName());
397            }
398    
399          return true;          return true;
400  }  }
# Line 299  bool ChannelStrip::updateInstrumentName Line 403  bool ChannelStrip::updateInstrumentName
403  // Do the dirty volume change.  // Do the dirty volume change.
404  bool ChannelStrip::updateChannelVolume (void)  bool ChannelStrip::updateChannelVolume (void)
405  {  {
406      if (m_pChannel == NULL)          if (m_pChannel == NULL)
407          return false;                  return false;
   
     // Convert...  
 #ifdef CONFIG_ROUND  
     int iVolume = (int) ::round(100.0 * m_pChannel->volume());  
 #else  
     double fIPart = 0.0;  
     double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart);  
     int iVolume = (int) fIPart;  
     if (fFPart >= +0.5)  
         iVolume++;  
     else  
     if (fFPart <= -0.5)  
         iVolume--;  
 #endif  
408    
409      // And clip...          // Convert...
410      if (iVolume < 0)          int iVolume = ::lroundf(100.0f * m_pChannel->volume());
411          iVolume = 0;          // And clip...
412            if (iVolume < 0)
413      // Flag it here, to avoid infinite recursion.                  iVolume = 0;
414      m_iDirtyChange++;  
415      ui.VolumeSlider->setValue(iVolume);          // Flag it here, to avoid infinite recursion.
416      ui.VolumeSpinBox->setValue(iVolume);          m_iDirtyChange++;
417      m_iDirtyChange--;          m_ui.VolumeSlider->setValue(iVolume);
418            m_ui.VolumeSpinBox->setValue(iVolume);
419            m_iDirtyChange--;
420    
421      return true;          return true;
422  }  }
423    
424    
425  // Update whole channel info state.  // Update whole channel info state.
426  bool ChannelStrip::updateChannelInfo (void)  bool ChannelStrip::updateChannelInfo (void)
427  {  {
428      if (m_pChannel == NULL)          if (m_pChannel == NULL)
429          return false;                  return false;
430    
431          // Check for error limit/recycle...          // Check for error limit/recycle...
432          if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)          if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)
433                  return true;                  return true;
434    
435      // Update strip caption.          // Update strip caption.
436      QString sText = m_pChannel->channelName();          QString sText = m_pChannel->channelName();
437      setWindowTitle(sText);          setWindowTitle(sText);
438      ui.ChannelSetupPushButton->setText(sText);          m_ui.ChannelSetupPushButton->setText('&' + sText);
439    
440      // Check if we're up and connected.          // Check if we're up and connected.
441          MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
442          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
443                  return false;                  return false;
444    
445      // Read actual channel information.          // Read actual channel information.
446      m_pChannel->updateChannelInfo();          m_pChannel->updateChannelInfo();
447    
448      // Engine name...          // Engine name...
449      if (m_pChannel->engineName().isEmpty())          if (m_pChannel->engineName().isEmpty()) {
450          ui.EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());                  m_ui.EngineNameTextLabel->setText(
451      else                          ' ' + Channel::noEngineName());
452          ui.EngineNameTextLabel->setText(' ' + m_pChannel->engineName());          } else {
453                    m_ui.EngineNameTextLabel->setText(
454                            ' ' + m_pChannel->engineName());
455            }
456    
457          // Instrument name...          // Instrument name...
458          updateInstrumentName(false);          updateInstrumentName(false);
459    
460      // MIDI Port/Channel...          // MIDI Port/Channel...
461          QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / ";          QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / ";
462          if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)          if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
463                  sMidiPortChannel += tr("All");                  sMidiPortChannel += tr("All");
464          else          else
465                  sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1);                  sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1);
466          ui.MidiPortChannelTextLabel->setText(sMidiPortChannel);          m_ui.MidiPortChannelTextLabel->setText(sMidiPortChannel);
467    
468          // Common palette...          // Common palette...
469          QPalette pal;          QPalette pal;
470          const QColor& rgbFore = pal.color(QPalette::Foreground);          const QColor& rgbFore = pal.color(QPalette::Foreground);
471    
472      // Instrument status...          // Instrument status...
473      int iInstrumentStatus = m_pChannel->instrumentStatus();          int iInstrumentStatus = m_pChannel->instrumentStatus();
474      if (iInstrumentStatus < 0) {          if (iInstrumentStatus < 0) {
475                  pal.setColor(QPalette::Foreground, Qt::red);                  pal.setColor(QPalette::Foreground, Qt::red);
476                  ui.InstrumentStatusTextLabel->setPalette(pal);                  m_ui.InstrumentStatusTextLabel->setPalette(pal);
477          ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));                  m_ui.InstrumentStatusTextLabel->setText(
478          m_iErrorCount++;                          tr("ERR%1").arg(iInstrumentStatus));
479          return false;                  m_iErrorCount++;
480      }                  return false;
481      // All seems normal...          }
482            // All seems normal...
483          pal.setColor(QPalette::Foreground,          pal.setColor(QPalette::Foreground,
484                  iInstrumentStatus < 100 ? Qt::yellow : Qt::green);                  iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
485      ui.InstrumentStatusTextLabel->setPalette(pal);          m_ui.InstrumentStatusTextLabel->setPalette(pal);
486      ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');          m_ui.InstrumentStatusTextLabel->setText(
487      m_iErrorCount = 0;                  QString::number(iInstrumentStatus) + '%');
488            m_iErrorCount = 0;
489    
490  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
491      // Mute/Solo button state coloring...          // Mute/Solo button state coloring...
492      bool bMute = m_pChannel->channelMute();          bool bMute = m_pChannel->channelMute();
493          const QColor& rgbButton = pal.color(QPalette::Button);          const QColor& rgbButton = pal.color(QPalette::Button);
494            const QColor& rgbButtonText = pal.color(QPalette::ButtonText);
495          pal.setColor(QPalette::Foreground, rgbFore);          pal.setColor(QPalette::Foreground, rgbFore);
496          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);          pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton);
497          ui.ChannelMutePushButton->setPalette(pal);          pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText);
498          ui.ChannelMutePushButton->setDown(bMute);          m_ui.ChannelMutePushButton->setPalette(pal);
499      bool bSolo = m_pChannel->channelSolo();          m_ui.ChannelMutePushButton->setDown(bMute);
500            bool bSolo = m_pChannel->channelSolo();
501          pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);            pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton);  
502          ui.ChannelSoloPushButton->setPalette(pal);          pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText);
503          ui.ChannelSoloPushButton->setDown(bSolo);          m_ui.ChannelSoloPushButton->setPalette(pal);
504            m_ui.ChannelSoloPushButton->setDown(bSolo);
505  #else  #else
506          ui.ChannelMutePushButton->setEnabled(false);          m_ui.ChannelMutePushButton->setEnabled(false);
507          ui.ChannelSoloPushButton->setEnabled(false);          m_ui.ChannelSoloPushButton->setEnabled(false);
508  #endif  #endif
509    
510      // And update the both GUI volume elements;          // And update the both GUI volume elements;
511      // return success if, and only if, intrument is fully loaded...          // return success if, and only if, intrument is fully loaded...
512      return updateChannelVolume() && (iInstrumentStatus == 100);          return updateChannelVolume() && (iInstrumentStatus == 100);
513  }  }
514    
515    
516  // Update whole channel usage state.  // Update whole channel usage state.
517  bool ChannelStrip::updateChannelUsage (void)  bool ChannelStrip::updateChannelUsage (void)
518  {  {
519      if (m_pChannel == NULL)          if (m_pChannel == NULL)
520          return false;                  return false;
521    
522          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
523          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 425  bool ChannelStrip::updateChannelUsage (v Line 525  bool ChannelStrip::updateChannelUsage (v
525    
526          // This only makes sense on fully loaded channels...          // This only makes sense on fully loaded channels...
527          if (m_pChannel->instrumentStatus() < 100)          if (m_pChannel->instrumentStatus() < 100)
528              return false;                  return false;
529    
530      // Get current channel voice count.          // Get current channel voice count.
531      int iVoiceCount  = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID());          int iVoiceCount  = ::lscp_get_channel_voice_count(
532     // Get current stream count.                  pMainForm->client(), m_pChannel->channelID());
533      int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID());  // Get current stream count.
534      // Get current channel buffer fill usage.          int iStreamCount = ::lscp_get_channel_stream_count(
535      // As benno has suggested this is the percentage usage                  pMainForm->client(), m_pChannel->channelID());
536      // of the least filled buffer stream...          // Get current channel buffer fill usage.
537      int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());;          // As benno has suggested this is the percentage usage
538            // of the least filled buffer stream...
539      // Update the GUI elements...          int iStreamUsage = ::lscp_get_channel_stream_usage(
540      ui.StreamUsageProgressBar->setValue(iStreamUsage);                  pMainForm->client(), m_pChannel->channelID());;
541      ui.StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));  
542            // Update the GUI elements...
543            m_ui.StreamUsageProgressBar->setValue(iStreamUsage);
544            m_ui.StreamVoiceCountTextLabel->setText(
545                    QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
546    
547      // We're clean.          // We're clean.
548      return true;          return true;
549  }  }
550    
551    
552  // Volume change slot.  // Volume change slot.
553  void ChannelStrip::volumeChanged ( int iVolume )  void ChannelStrip::volumeChanged ( int iVolume )
554  {  {
555      if (m_pChannel == NULL)          if (m_pChannel == NULL)
556          return;                  return;
557    
558            // Avoid recursion.
559            if (m_iDirtyChange > 0)
560                    return;
561    
562      // Avoid recursion.          // Convert and clip.
563      if (m_iDirtyChange > 0)          float fVolume = (float) iVolume / 100.0f;
564          return;          if (fVolume < 0.001f)
565                    fVolume = 0.0f;
566      // Convert and clip.  
567      float fVolume = (float) iVolume / 100.0;          // Update the GUI elements.
568      if (fVolume < 0.001)          if (m_pChannel->setVolume(fVolume)) {
569          fVolume = 0.0;                  updateChannelVolume();
570                    emit channelChanged(this);
571      // Update the GUI elements.          }
     if (m_pChannel->setVolume(fVolume)) {  
         updateChannelVolume();  
         emit channelChanged(this);  
     }  
572  }  }
573    
574    
575  // Context menu event handler.  // Context menu event handler.
576  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
577  {  {
578      if (m_pChannel == NULL)          if (m_pChannel == NULL)
579          return;                  return;
580    
581      // We'll just show up the main form's edit menu (thru qsamplerChannel).          // We'll just show up the main form's edit menu (thru qsamplerChannel).
582      m_pChannel->contextMenuEvent(pEvent);          m_pChannel->contextMenuEvent(pEvent);
583    }
584    
585    
586    void ChannelStrip::midiActivityLedOn (void)
587    {
588            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOn);
589            m_pMidiActivityTimer->start(100);
590    }
591    
592    
593    void ChannelStrip::midiActivityLedOff (void)
594    {
595            m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff);
596  }  }
597    
598    
# Line 485  void ChannelStrip::resetErrorCount (void Line 602  void ChannelStrip::resetErrorCount (void
602          m_iErrorCount = 0;          m_iErrorCount = 0;
603  }  }
604    
605    
606    // Channel strip activation/selection.
607    void ChannelStrip::setSelected ( bool bSelected )
608    {
609            if (bSelected) {
610                    if (g_pSelectedStrip == this)
611                            return;
612                    if (g_pSelectedStrip)
613                            g_pSelectedStrip->setSelected(false);
614                    g_pSelectedStrip = this;
615            } else {
616                    if (g_pSelectedStrip == this)
617                            g_pSelectedStrip = NULL;
618            }
619    
620            QPalette pal;
621            if (bSelected) {
622                    const QColor& color = pal.midlight().color();
623                    pal.setColor(QPalette::Background, color.dark(150));
624                    pal.setColor(QPalette::Foreground, color.light(150));
625            }
626            QWidget::setPalette(pal);
627    }
628    
629    
630    bool ChannelStrip::isSelected (void) const
631    {
632            return (this == g_pSelectedStrip);
633    }
634    
635    
636  } // namespace QSampler  } // namespace QSampler
637    
638    

Legend:
Removed from v.1507  
changed lines
  Added in v.2108

  ViewVC Help
Powered by ViewVC