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

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

  ViewVC Help
Powered by ViewVC