/[svn]/qsampler/trunk/src/qsamplerChannelStrip.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannelStrip.ui.h

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

revision 118 by capela, Tue Jun 8 18:40:06 2004 UTC revision 395 by capela, Sun Feb 20 19:13:33 2005 UTC
# Line 2  Line 2 
2  //  //
3  // ui.h extension file, included from the uic-generated form implementation.  // ui.h extension file, included from the uic-generated form implementation.
4  /****************************************************************************  /****************************************************************************
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
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 22  Line 22 
22    
23  #include <qvalidator.h>  #include <qvalidator.h>
24  #include <qmessagebox.h>  #include <qmessagebox.h>
25    #include <qdragobject.h>
26  #include <qfileinfo.h>  #include <qfileinfo.h>
27  #include <qtooltip.h>  #include <qtooltip.h>
28  #include <qpopupmenu.h>  #include <qpopupmenu.h>
29    #include <qobjectlist.h>
30    
31  #include <math.h>  #include <math.h>
32    
# Line 33  Line 35 
35    
36  #include "config.h"  #include "config.h"
37    
38    // Channel status/usage usage limit control.
39    #define QSAMPLER_ERROR_LIMIT    3
40    #define QSAMPLER_ERROR_CYCLE    33
41    
42    
43  // Kind of constructor.  // Kind of constructor.
44  void qsamplerChannelStrip::init (void)  void qsamplerChannelStrip::init (void)
45  {  {
46      // Initialize locals.      // Initialize locals.
47      m_pMainForm  = NULL;      m_pChannel     = NULL;
     m_iChannelID = 0;  
       
 //  m_sEngineName     = "(No engine)";  
 //  m_sInstrumentFile = "(No instrument)";  
     m_iInstrumentNr   = 0;  
     m_sMidiDriver     = "ALSA"; // DEPRECATED.  
     m_iMidiDevice     = 0;  
     m_iMidiPort       = 0;  
     m_iMidiChannel    = 0;  
     m_sAudioDriver    = "ALSA"; // DEPRECATED.  
     m_iAudioDevice    = 0;  
     m_fVolume         = 0.8;  
       
48      m_iDirtyChange = 0;      m_iDirtyChange = 0;
49            m_iErrorCount  = 0;
50    
51      // Try to restore normal window positioning.      // Try to restore normal window positioning.
52      adjustSize();      adjustSize();
# Line 62  void qsamplerChannelStrip::init (void) Line 56  void qsamplerChannelStrip::init (void)
56  // Kind of destructor.  // Kind of destructor.
57  void qsamplerChannelStrip::destroy (void)  void qsamplerChannelStrip::destroy (void)
58  {  {
59        // Destroy existing channel descriptor.
60        if (m_pChannel)
61            delete m_pChannel;
62        m_pChannel = NULL;
63  }  }
64    
65    
66  // Channel strip setup formal initializer.  // Drag'n'drop file handler.
67  void qsamplerChannelStrip::setup ( qsamplerMainForm *pMainForm, int iChannelID )  bool qsamplerChannelStrip::decodeDragFile ( const QMimeSource *pEvent, QString& sInstrumentFile )
68  {  {
69      m_iDirtyChange = 0;          if (m_pChannel == NULL)
70      m_pMainForm = pMainForm;                  return false;
71    
72      setChannelID(iChannelID);          if (QTextDrag::canDecode(pEvent)) {
73                    QString sText;
74                    if (QTextDrag::decode(pEvent, sText)) {
75                            QStringList files = QStringList::split('\n', sText);
76                            for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
77                                    *iter = (*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null);
78                                    if (qsamplerChannel::isInstrumentFile(*iter)) {
79                                            sInstrumentFile = *iter;
80                                            return true;
81                                    }
82                            }
83                    }
84            }
85            // Fail.
86            return false;
87  }  }
88    
89    
90  // The global options settings delegated property.  // Window drag-n-drop event handlers.
91  qsamplerOptions *qsamplerChannelStrip::options (void)  void qsamplerChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
92  {  {
93      if (m_pMainForm == NULL)          QString sInstrumentFile;
94          return NULL;          pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile));
           
     return m_pMainForm->options();  
95  }  }
96    
97    
98  // The client descriptor delegated property.  void qsamplerChannelStrip::dropEvent ( QDropEvent* pDropEvent )
 lscp_client_t *qsamplerChannelStrip::client (void)  
99  {  {
100      if (m_pMainForm == NULL)          QString sInstrumentFile;
         return NULL;  
101    
102      return m_pMainForm->client();          if (decodeDragFile(pDropEvent, sInstrumentFile)) {
103                    // Go and set the dropped instrument filename...
104                    m_pChannel->setInstrument(sInstrumentFile, 0);
105                    // Open up the channel dialog.
106                    channelSetup();
107            }
108  }  }
109    
110    
111  // Channel-ID (aka Sammpler-Channel) accessors.  // Channel strip setup formal initializer.
112  int qsamplerChannelStrip::channelID (void)  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )
 {  
     return m_iChannelID;  
 }  
   
 void qsamplerChannelStrip::setChannelID ( int iChannelID )  
113  {  {
114      m_iChannelID = iChannelID;      // Destroy any previous channel descriptor;
115        // (remember that once setup we own it!)
116        if (m_pChannel)
117            delete m_pChannel;
118    
119        // Set the new one...
120        m_pChannel = pChannel;
121        
122        // Stabilize this around.
123      updateChannelInfo();      updateChannelInfo();
 }  
   
124    
125  // Engine name accessors.          // We'll accept drops from now on...
126  QString& qsamplerChannelStrip::engineName (void)          if (m_pChannel)
127  {                  setAcceptDrops(true);
     return m_sEngineName;  
128  }  }
129    
130  bool qsamplerChannelStrip::loadEngine ( const QString& sEngineName )  // Channel secriptor accessor.
131    qsamplerChannel *qsamplerChannelStrip::channel (void)
132  {  {
133      if (client() == NULL)      return m_pChannel;
         return false;  
   
     if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {  
         appendMessagesClient("lscp_load_engine");  
         return false;  
     }  
   
     m_sEngineName = sEngineName;  
     return true;  
134  }  }
135    
136    
137  // Instrument filename accessors.  // Messages view font accessors.
138  QString& qsamplerChannelStrip::instrumentFile (void)  QFont qsamplerChannelStrip::displayFont (void)
 {  
     return m_sInstrumentFile;  
 }  
   
 // Instrument index accessors.  
 int qsamplerChannelStrip::instrumentNr (void)  
 {  
     return m_iInstrumentNr;  
 }  
   
 bool qsamplerChannelStrip::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_load_instrument(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {  
         appendMessagesClient("lscp_load_instrument");  
         return false;  
     }  
   
     m_sInstrumentFile = sInstrumentFile;  
     m_iInstrumentNr = iInstrumentNr;  
     return true;  
 }  
   
   
 // MIDI driver type accessors (DEPRECATED).  
 QString& qsamplerChannelStrip::midiDriver (void)  
 {  
     return m_sMidiDriver;  
 }  
   
 bool qsamplerChannelStrip::setMidiDriver ( const QString& sMidiDriver )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) {  
         appendMessagesClient("lscp_set_channel_midi_type");  
         return false;  
     }  
   
     m_sMidiDriver = sMidiDriver;  
     return true;  
 }  
   
   
 // MIDI device accessors.  
 int qsamplerChannelStrip::midiDevice (void)  
139  {  {
140      return m_iMidiDevice;      return EngineNameTextLabel->font();
141  }  }
142    
143  bool qsamplerChannelStrip::setMidiDevice ( int iMidiDevice )  void qsamplerChannelStrip::setDisplayFont ( const QFont & font )
144  {  {
145      if (client() == NULL)      EngineNameTextLabel->setFont(font);
146          return false;      MidiPortChannelTextLabel->setFont(font);
147        InstrumentNameTextLabel->setFont(font);
148  //  FIXME: call this when LSCP becomes stable.      InstrumentStatusTextLabel->setFont(font);
 //  if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) {  
 //      appendMessagesClient("lscp_set_channel_midi_device");  
 //      return false;  
 //  }  
   
     m_iMidiDevice = iMidiDevice;  
     return true;  
149  }  }
150    
151    
152  // MIDI port number accessor.  // Channel display background effect.
153  int qsamplerChannelStrip::midiPort (void)  void qsamplerChannelStrip::setDisplayEffect ( bool bDisplayEffect )
 {  
     return m_iMidiPort;  
 }  
   
 bool qsamplerChannelStrip::setMidiPort ( int iMidiPort )  
154  {  {
155      if (client() == NULL)      QPixmap pm;
156          return false;      if (bDisplayEffect)
157            pm = QPixmap::fromMimeSource("displaybg1.png");
158  //  FIXME: call this when LSCP becomes stable.      setDisplayBackground(pm);
 //  if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) {  
 //      appendMessagesClient("lscp_set_channel_midi_port");  
 //      return false;  
 //  }  
   
     m_iMidiPort = iMidiPort;  
     return true;  
159  }  }
160    
161    
162  // MIDI channel accessor.  // Update main display background pixmap.
163  int qsamplerChannelStrip::midiChannel (void)  void qsamplerChannelStrip::setDisplayBackground ( const QPixmap& pm )
164  {  {
165      return m_iMidiChannel;      // Set the main origin...
166  }      ChannelInfoFrame->setPaletteBackgroundPixmap(pm);
   
 bool qsamplerChannelStrip::setMidiChannel ( int iMidiChannel )  
 {  
     if (client() == NULL)  
         return false;  
167    
168  //  FIXME: call this when LSCP becomes stable.      // Iterate for every child text label...
169  //  if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) {      QObjectList *pList = ChannelInfoFrame->queryList("QLabel");
170  //      appendMessagesClient("lscp_set_channel_midi_channel");      if (pList) {
171  //      return false;          for (QLabel *pLabel = (QLabel *) pList->first(); pLabel; pLabel = (QLabel *) pList->next())
172  //  }              pLabel->setPaletteBackgroundPixmap(pm);
173            delete pList;
174      m_iMidiChannel = iMidiChannel;      }
175      return true;      
176        // And this standalone too.
177        StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm);
178  }  }
179    
180    
181  // Audio device accessor.  // Maximum volume slider accessors.
182  int qsamplerChannelStrip::audioDevice (void)  void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
 {  
     return m_iAudioDevice;  
 }  
   
 bool qsamplerChannelStrip::setAudioDevice ( int iAudioDevice )  
183  {  {
184      if (client() == NULL)      m_iDirtyChange++;
185          return false;      VolumeSlider->setRange(0, iMaxVolume);
186        VolumeSpinBox->setRange(0, iMaxVolume);
187  //  FIXME: call this when LSCP becomes stable.      m_iDirtyChange--;
 //  if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) {  
 //      appendMessagesClient("lscp_set_channel_audio_device");  
 //      return false;  
 //  }  
   
     m_iAudioDevice = iAudioDevice;  
     return true;  
188  }  }
189    
190    
191  // Audio driver type accessors (DEPRECATED).  // Channel setup dialog slot.
192  QString& qsamplerChannelStrip::audioDriver (void)  bool qsamplerChannelStrip::channelSetup (void)
 {  
     return m_sAudioDriver;  
 }  
   
 bool qsamplerChannelStrip::setAudioDriver ( const QString& sAudioDriver )  
193  {  {
194      if (client() == NULL)          // Invoke the channel setup dialog.
195          return false;          bool bResult = m_pChannel->channelSetup(this);
196    
197      if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) {          if (bResult) {
198          appendMessagesClient("lscp_set_channel_audio_type");                  // Reset the error/cycle.
199          return false;                  m_iErrorCount = 0;
200      }                  // Notify that thie channel has changed.
201                    emit channelChanged(this);
202            }
203    
204      m_sAudioDriver = sAudioDriver;          return bResult;
     return true;  
205  }  }
206    
207    
208  // Channel volume accessors.  // Update the channel instrument name.
209  float qsamplerChannelStrip::volume (void)  bool qsamplerChannelStrip::updateInstrumentName ( bool bForce )
210  {  {
211      return m_fVolume;          if (m_pChannel == NULL)
212  }                  return false;
   
 bool qsamplerChannelStrip::setVolume ( float fVolume )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) {  
         appendMessagesClient("lscp_set_channel_volume");  
         return false;  
     }  
   
     m_fVolume = fVolume;  
     return true;  
 }  
213    
214            // Do we refersh the actual name?
215            if (bForce)
216                    m_pChannel->updateInstrumentName();
217    
218  // Messages view font accessors.          // Instrument name...
219  QFont qsamplerChannelStrip::displayFont (void)          if (m_pChannel->instrumentName().isEmpty())
220  {                  InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());
221      return EngineNameTextLabel->font();          else
222  }                  InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());
   
 void qsamplerChannelStrip::setDisplayFont ( const QFont & font )  
 {  
     EngineNameTextLabel->setFont(font);  
     InstrumentNameTextLabel->setFont(font);  
     MidiPortChannelTextLabel->setFont(font);  
 }  
223    
224  // Channel setup dialog.          return true;    
 void qsamplerChannelStrip::channelSetup (void)  
 {  
     qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);  
     if (pChannelForm) {  
         pChannelForm->setup(this);  
         if (pChannelForm->exec()) {  
             updateChannelInfo();  
             emit channelChanged(this);  
         }  
         delete pChannelForm;  
     }  
225  }  }
226    
227    
228  // Update whole channel info state.  // Update whole channel info state.
229  void qsamplerChannelStrip::updateChannelInfo (void)  bool qsamplerChannelStrip::updateChannelInfo (void)
230  {  {
231        if (m_pChannel == NULL)
232            return false;
233            
234      // Update strip caption.      // Update strip caption.
235      QString sText = tr("Channel %1").arg(m_iChannelID);      QString sText = m_pChannel->channelName();
236      setCaption(sText);      setCaption(sText);
237      ChannelSetupPushButton->setText(sText);      ChannelSetupPushButton->setText(sText);
238    
239      // Check if we're up and connected.      // Check if we're up and connected.
240      if (client() == NULL)      if (m_pChannel->client() == NULL)
241          return;          return false;
   
     // Read channel information.  
     lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);  
     if (pChannelInfo == NULL) {  
         appendMessagesClient("lscp_get_channel_info");      
     //  appendMessagesError(tr("Could not get channel information.\n\nSorry."));  
     } else {  
         // Cache in channel information.  
         m_sEngineName     = pChannelInfo->engine_name;  
         m_sInstrumentFile = pChannelInfo->instrument_file;  
         m_iInstrumentNr   = pChannelInfo->instrument_nr;  
         m_iMidiDevice     = pChannelInfo->midi_device;  
         m_iMidiPort       = pChannelInfo->midi_port;  
         m_iMidiChannel    = pChannelInfo->midi_channel;  
         m_iAudioDevice    = pChannelInfo->audio_device;  
         m_fVolume         = pChannelInfo->volume;  
     }  
242    
243      // Set some proper display values.      // Read actual channel information.
244        m_pChannel->updateChannelInfo();
245    
246      // Engine name...      // Engine name...
247      if (m_sEngineName.isEmpty())      if (m_pChannel->engineName().isEmpty())
248          EngineNameTextLabel->setText(tr("(No engine)"));          EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());
249      else      else
250          EngineNameTextLabel->setText(m_sEngineName);          EngineNameTextLabel->setText(' ' + m_pChannel->engineName());
251    
252      // Instrument name...          // Instrument name...
253      if (m_sInstrumentFile.isEmpty())          updateInstrumentName(false);
254          InstrumentNameTextLabel->setText(tr("(No instrument)"));  
255      else      // Instrument status...
256          InstrumentNameTextLabel->setText(QString("%1 [%2]")      int iInstrumentStatus = m_pChannel->instrumentStatus();
257              .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr));      if (iInstrumentStatus < 0) {
258            InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
259            InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
260        } else {
261            InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
262            InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%");
263        }
264    
265      // MIDI Port/Channel...      // MIDI Port/Channel...
266      MidiPortChannelTextLabel->setText(QString("%1 / %2")      if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
267          .arg(m_iMidiPort).arg(m_iMidiChannel));          MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));
268                else
269            MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1));
270    
271      // And update the both GUI volume elements.      // And update the both GUI volume elements.
272      updateChannelVolume();      return updateChannelVolume();
273  }  }
274    
275    
276  // Do the dirty volume change.  // Do the dirty volume change.
277  void qsamplerChannelStrip::updateChannelVolume (void)  bool qsamplerChannelStrip::updateChannelVolume (void)
278  {  {
279        if (m_pChannel == NULL)
280            return false;
281    
282      // Convert...      // Convert...
283  #ifdef CONFIG_ROUND  #ifdef CONFIG_ROUND
284      int iVolume = (int) ::round(100.0 * m_fVolume);      int iVolume = (int) ::round(100.0 * m_pChannel->volume());
285  #else  #else
286      double fIPart = 0.0;      double fIPart = 0.0;
287      double fFPart = ::modf(100.0 * m_fVolume, &fIPart);      double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart);
288      int iVolume = (int) fIPart;      int iVolume = (int) fIPart;
289      if (fFPart >= +0.5)      if (fFPart >= +0.5)
290          iVolume++;          iVolume++;
# Line 408  void qsamplerChannelStrip::updateChannel Line 294  void qsamplerChannelStrip::updateChannel
294  #endif  #endif
295    
296      // And clip...      // And clip...
297      if (iVolume > 100)      if (iVolume < 0)
         iVolume = 100;  
     else if (iVolume < 0)  
298          iVolume = 0;          iVolume = 0;
299    
300      // Flag it here, to avoid infinite recursion.      // Flag it here, to avoid infinite recursion.
# Line 418  void qsamplerChannelStrip::updateChannel Line 302  void qsamplerChannelStrip::updateChannel
302      VolumeSlider->setValue(iVolume);      VolumeSlider->setValue(iVolume);
303      VolumeSpinBox->setValue(iVolume);      VolumeSpinBox->setValue(iVolume);
304      m_iDirtyChange--;      m_iDirtyChange--;
305        
306        return true;
307  }  }
308    
309    
310  // Update whole channel usage state.  // Update whole channel usage state.
311  void qsamplerChannelStrip::updateChannelUsage (void)  bool qsamplerChannelStrip::updateChannelUsage (void)
312  {  {
313      if (client() == NULL)      if (m_pChannel == NULL)
314          return;          return false;
315        if (m_pChannel->client() == NULL)
316            return false;
317    
318            // Check for error limit/recycle...
319            if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)
320                    m_iErrorCount -= QSAMPLER_ERROR_CYCLE;
321            if (m_iErrorCount < 0) {
322                    m_iErrorCount++;
323                    return false;
324            }
325    
326            // Update whole channel status info,
327            // if instrument load is still pending...
328            if (m_pChannel->instrumentStatus() < 100) {
329                    // grab the whole sampler channel data...
330                    updateChannelInfo();
331                    // Check (updated) status again...
332                    int iInstrumentStatus = m_pChannel->instrumentStatus();
333                    if (iInstrumentStatus < 100) {
334                            if (iInstrumentStatus < 0)
335                                    m_iErrorCount++;
336                            return false;
337                    }
338                    // Once we get a complete instrument load,
339                    // we'll try an implied channel reset...
340                    m_pChannel->resetChannel();
341                    // Reset error count.
342                    m_iErrorCount = 0;
343            }
344        
345      // Get current channel voice count.      // Get current channel voice count.
346      int iVoiceCount  = ::lscp_get_channel_voice_count(client(), m_iChannelID);      int iVoiceCount  = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());
347      // Get current stream count.      // Get current stream count.
348      int iStreamCount = ::lscp_get_channel_stream_count(client(), m_iChannelID);      int iStreamCount = ::lscp_get_channel_stream_count(m_pChannel->client(), m_pChannel->channelID());
349      // Get current channel buffer fill usage.      // Get current channel buffer fill usage.
350      // As benno has suggested this is the percentage usage      // As benno has suggested this is the percentage usage
351      // of the least filled buffer stream...      // of the least filled buffer stream...
352      int iStreamUsage = 0;      int iStreamUsage = ::lscp_get_channel_stream_usage(m_pChannel->client(), m_pChannel->channelID());;
353      if (iStreamCount > 0) {  
         lscp_buffer_fill_t *pBufferFill = ::lscp_get_channel_buffer_fill(client(), LSCP_USAGE_PERCENTAGE, m_iChannelID);  
         if (pBufferFill) {  
             for (int iStream = 0; iStream < iStreamCount; iStream++) {  
                 if (iStreamUsage > (int) pBufferFill[iStream].stream_usage || iStream == 0)  
                     iStreamUsage = pBufferFill[iStream].stream_usage;  
             }  
         }  
     }      
354      // Update the GUI elements...      // Update the GUI elements...
355      StreamUsageProgressBar->setProgress(iStreamUsage);      StreamUsageProgressBar->setProgress(iStreamUsage);
356      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
357        
358        // We're clean.
359        return true;
360  }  }
361    
362    
363  // Volume change slot.  // Volume change slot.
364  void qsamplerChannelStrip::volumeChanged ( int iVolume )  void qsamplerChannelStrip::volumeChanged ( int iVolume )
365  {  {
366        if (m_pChannel == NULL)
367            return;
368    
369      // Avoid recursion.      // Avoid recursion.
370      if (m_iDirtyChange > 0)      if (m_iDirtyChange > 0)
371          return;          return;
372    
373      // Convert and clip.      // Convert and clip.
374      float fVolume = (float) iVolume / 100.0;      float fVolume = (float) iVolume / 100.0;
375      if (fVolume > 1.0)      if (fVolume < 0.001)
         fVolume = 1.0;  
     else if (fVolume < 0.0)  
376          fVolume = 0.0;          fVolume = 0.0;
377    
378      // Update the GUI elements.      // Update the GUI elements.
379      if (setVolume(fVolume)) {      if (m_pChannel->setVolume(fVolume)) {
380          updateChannelVolume();          updateChannelVolume();
381          emit channelChanged(this);          emit channelChanged(this);
382      }      }
383  }  }
384    
385    
 // Redirected messages output methods.  
 void qsamplerChannelStrip::appendMessages( const QString& s )  
 {  
     m_pMainForm->appendMessages(s);  
 }  
   
 void qsamplerChannelStrip::appendMessagesColor( const QString& s, const QString& c )  
 {  
     m_pMainForm->appendMessagesColor(s, c);  
 }  
   
 void qsamplerChannelStrip::appendMessagesText( const QString& s )  
 {  
     m_pMainForm->appendMessagesText(s);  
 }  
   
 void qsamplerChannelStrip::appendMessagesError( const QString& s )  
 {  
     m_pMainForm->appendMessagesError(s);  
 }  
   
 void qsamplerChannelStrip::appendMessagesClient( const QString& s )  
 {  
     m_pMainForm->appendMessagesClient(s);  
 }  
   
   
386  // Context menu event handler.  // Context menu event handler.
387  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
388  {  {
389      // We'll just show up the main form's edit menu.      if (m_pChannel == NULL)
390      m_pMainForm->stabilizeForm();          return;
391      m_pMainForm->editMenu->exec(pEvent->globalPos());          
392        // We'll just show up the main form's edit menu (thru qsamplerChannel).
393        m_pChannel->contextMenuEvent(pEvent);
394  }  }
395    
396    
397  // end of qsamplerChannelStrip.ui.h  // end of qsamplerChannelStrip.ui.h
   

Legend:
Removed from v.118  
changed lines
  Added in v.395

  ViewVC Help
Powered by ViewVC