/[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 388 by capela, Thu Feb 17 17:27:59 2005 UTC revision 1366 by schoenebeck, Mon Oct 1 18:26:06 2007 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-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, 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 14  Line 14 
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License along
18     along with this program; if not, write to the Free Software     with this program; if not, write to the Free Software Foundation, Inc.,
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20    
21  *****************************************************************************/  *****************************************************************************/
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>  #include <qobjectlist.h>
30    #include <qurl.h>
31    
32  #include <math.h>  #include <math.h>
33    
# Line 34  Line 36 
36    
37  #include "config.h"  #include "config.h"
38    
39    // Channel status/usage usage limit control.
40    #define QSAMPLER_ERROR_LIMIT    3
41    
42    
43  // Kind of constructor.  // Kind of constructor.
44  void qsamplerChannelStrip::init (void)  void qsamplerChannelStrip::init (void)
# Line 41  void qsamplerChannelStrip::init (void) Line 46  void qsamplerChannelStrip::init (void)
46      // Initialize locals.      // Initialize locals.
47      m_pChannel     = NULL;      m_pChannel     = NULL;
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 57  void qsamplerChannelStrip::destroy (void Line 63  void qsamplerChannelStrip::destroy (void
63  }  }
64    
65    
66    // Drag'n'drop file handler.
67    bool qsamplerChannelStrip::decodeDragFile ( const QMimeSource *pEvent, QString& sInstrumentFile )
68    {
69            if (m_pChannel == NULL)
70                    return false;
71            if (QTextDrag::canDecode(pEvent)) {
72                    QString sText;
73                    if (QTextDrag::decode(pEvent, sText)) {
74                            QStringList files = QStringList::split('\n', sText);
75                            for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
76                                    *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();
77                                    if (qsamplerChannel::isInstrumentFile(*iter)) {
78                                            sInstrumentFile = *iter;
79                                            return true;
80                                    }
81                            }
82                    }
83            }
84            // Fail.
85            return false;
86    }
87    
88    
89    // Window drag-n-drop event handlers.
90    void qsamplerChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
91    {
92            QString sInstrumentFile;
93            pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile));
94    }
95    
96    
97    void qsamplerChannelStrip::dropEvent ( QDropEvent* pDropEvent )
98    {
99            QString sInstrumentFile;
100    
101            if (decodeDragFile(pDropEvent, sInstrumentFile)) {
102                    // Go and set the dropped instrument filename...
103                    m_pChannel->setInstrument(sInstrumentFile, 0);
104                    // Open up the channel dialog.
105                    channelSetup();
106            }
107    }
108    
109    
110  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
111  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )
112  {  {
# Line 70  void qsamplerChannelStrip::setup ( qsamp Line 120  void qsamplerChannelStrip::setup ( qsamp
120    
121      // Stabilize this around.      // Stabilize this around.
122      updateChannelInfo();      updateChannelInfo();
123    
124            // We'll accept drops from now on...
125            if (m_pChannel)
126                    setAcceptDrops(true);
127  }  }
128    
129  // Channel secriptor accessor.  // Channel secriptor accessor.
# Line 117  void qsamplerChannelStrip::setDisplayBac Line 171  void qsamplerChannelStrip::setDisplayBac
171              pLabel->setPaletteBackgroundPixmap(pm);              pLabel->setPaletteBackgroundPixmap(pm);
172          delete pList;          delete pList;
173      }      }
174        
175      // And this standalone too.      // And this standalone too.
176      StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm);      StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm);
177  }  }
178    
179    
180    // Maximum volume slider accessors.
181    void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
182    {
183        m_iDirtyChange++;
184        VolumeSlider->setRange(0, iMaxVolume);
185        VolumeSpinBox->setRange(0, iMaxVolume);
186        m_iDirtyChange--;
187    }
188    
189    
190  // Channel setup dialog slot.  // Channel setup dialog slot.
191  bool qsamplerChannelStrip::channelSetup (void)  bool qsamplerChannelStrip::channelSetup (void)
192  {  {
193      bool bResult = m_pChannel->channelSetup(this);          if (m_pChannel == NULL)
194                    return false;
195                    
196            // Invoke the channel setup dialog.
197            bool bResult = m_pChannel->channelSetup(this);
198            // Notify that this channel has changed.
199            if (bResult)
200                    emit channelChanged(this);
201    
202            return bResult;
203    }
204    
     if (bResult)  
         emit channelChanged(this);  
205    
206      return bResult;  // Channel mute slot.
207    bool qsamplerChannelStrip::channelMute ( bool bMute )
208    {
209            if (m_pChannel == NULL)
210                    return false;
211    
212            // Invoke the channel mute method.
213            bool bResult = m_pChannel->setChannelMute(bMute);
214            // Notify that this channel has changed.
215            if (bResult)
216                    emit channelChanged(this);
217    
218            return bResult;
219  }  }
220    
221    
222  // Update the channel instrument name.  // Channel solo slot.
223  bool qsamplerChannelStrip::updateInstrumentName ( bool bForce )  bool qsamplerChannelStrip::channelSolo ( bool bSolo )
224  {  {
225          if (m_pChannel == NULL)          if (m_pChannel == NULL)
226                  return false;                  return false;
227    
228          // Do we refersh the actual name?          // Invoke the channel solo method.
229          if (bForce)          bool bResult = m_pChannel->setChannelSolo(bSolo);
230                  m_pChannel->updateInstrumentName();          // Notify that this channel has changed.
231            if (bResult)
232                    emit channelChanged(this);
233    
234          // Instrument name...          return bResult;
235          if (m_pChannel->instrumentName().isEmpty())  }
                 InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());  
         else  
                 InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());  
236    
237          return true;      
238    // Channel edit slot.
239    void qsamplerChannelStrip::channelEdit()
240    {
241            if (m_pChannel == NULL)
242                    return;
243    
244            m_pChannel->editChannel();
245  }  }
246    
247    
248  // Update whole channel info state.  // Channel reset slot.
249  bool qsamplerChannelStrip::updateChannelInfo (void)  bool qsamplerChannelStrip::channelReset (void)
250  {  {
251      if (m_pChannel == NULL)          if (m_pChannel == NULL)
252          return false;                  return false;
           
     // Update strip caption.  
     QString sText = m_pChannel->channelName();  
     setCaption(sText);  
     ChannelSetupPushButton->setText(sText);  
253    
254      // Check if we're up and connected.          // Invoke the channel reset method.
255      if (m_pChannel->client() == NULL)          bool bResult = m_pChannel->channelReset();
256          return false;          // Notify that this channel has changed.
257            if (bResult)
258                    emit channelChanged(this);
259    
260      // Read actual channel information.          return bResult;
261      m_pChannel->updateChannelInfo();  }
262    
     // Engine name...  
     if (m_pChannel->engineName().isEmpty())  
         EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());  
     else  
         EngineNameTextLabel->setText(' ' + m_pChannel->engineName());  
263    
264          // Instrument name...  // Update the channel instrument name.
265          updateInstrumentName(false);  bool qsamplerChannelStrip::updateInstrumentName ( bool bForce )
266    {
267            if (m_pChannel == NULL)
268                    return false;
269    
270      // Instrument status...          // Do we refresh the actual name?
271      int iInstrumentStatus = m_pChannel->instrumentStatus();          if (bForce)
272      if (iInstrumentStatus < 0) {                  m_pChannel->updateInstrumentName();
         InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);  
         InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));  
     } else {  
         InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);  
         InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%");  
     }  
273    
274      // MIDI Port/Channel...          // Instrument name...
275      if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)          if (m_pChannel->instrumentName().isEmpty()) {
276          MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));                  if (m_pChannel->instrumentStatus() >= 0)
277      else                          InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument());
278          MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1));                  else
279                            InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName());
280            } else
281                    InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName());
282    
283      // And update the both GUI volume elements.          return true;    
     return updateChannelVolume();  
284  }  }
285    
286    
# Line 232  bool qsamplerChannelStrip::updateChannel Line 313  bool qsamplerChannelStrip::updateChannel
313      VolumeSlider->setValue(iVolume);      VolumeSlider->setValue(iVolume);
314      VolumeSpinBox->setValue(iVolume);      VolumeSpinBox->setValue(iVolume);
315      m_iDirtyChange--;      m_iDirtyChange--;
316        
317      return true;      return true;
318  }  }
319    
320    
321  // Update whole channel usage state.  // Update whole channel info state.
322  bool qsamplerChannelStrip::updateChannelUsage (void)  bool qsamplerChannelStrip::updateChannelInfo (void)
323  {  {
324      if (m_pChannel == NULL)      if (m_pChannel == NULL)
325          return false;          return false;
     if (m_pChannel->client() == NULL)  
         return false;  
326    
327      // Update whole channel status info,          // Check for error limit/recycle...
328      // if instrument load is still pending...          if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)
329      if (m_pChannel->instrumentStatus() < 100) {                  return true;
330          updateChannelInfo();  
331          // Check (updated) status again...      // Update strip caption.
332          if (m_pChannel->instrumentStatus() < 100)      QString sText = m_pChannel->channelName();
333              return false;      setCaption(sText);
334          // Once we get a complete instrument load,      ChannelSetupPushButton->setText(sText);
335          // we'll try an implied channel reset...  
336          m_pChannel->resetChannel();      // Check if we're up and connected.
337            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
338            if (pMainForm->client() == NULL)
339                    return false;
340    
341        // Read actual channel information.
342        m_pChannel->updateChannelInfo();
343    
344        // Engine name...
345        if (m_pChannel->engineName().isEmpty())
346            EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName());
347        else
348            EngineNameTextLabel->setText(' ' + m_pChannel->engineName());
349    
350            // Instrument name...
351            updateInstrumentName(false);
352    
353        // MIDI Port/Channel...
354            QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / ";
355            if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
356                    sMidiPortChannel += tr("All");
357            else
358                    sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1);
359            MidiPortChannelTextLabel->setText(sMidiPortChannel);
360    
361        // Instrument status...
362        int iInstrumentStatus = m_pChannel->instrumentStatus();
363        if (iInstrumentStatus < 0) {
364            InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
365            InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
366            m_iErrorCount++;
367            return false;
368      }      }
369            // All seems normal...
370      // Check again that we're clean.      InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
371      if (m_pChannel->instrumentStatus() < 100)      InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%');
372        m_iErrorCount = 0;
373    
374    #ifdef CONFIG_MUTE_SOLO
375        // Mute/Solo button state coloring...
376        const QColor& rgbNormal = ChannelSetupPushButton->paletteBackgroundColor();
377        bool bMute = m_pChannel->channelMute();
378        ChannelMutePushButton->setPaletteBackgroundColor(bMute ? Qt::yellow : rgbNormal);
379        ChannelMutePushButton->setDown(bMute);
380        bool bSolo = m_pChannel->channelSolo();
381        ChannelSoloPushButton->setPaletteBackgroundColor(bSolo ? Qt::cyan : rgbNormal);
382        ChannelSoloPushButton->setDown(bSolo);
383    #else
384            ChannelMutePushButton->setEnabled(false);
385            ChannelSoloPushButton->setEnabled(false);
386    #endif
387    
388        // And update the both GUI volume elements;
389        // return success if, and only if, intrument is fully loaded...
390        return updateChannelVolume() && (iInstrumentStatus == 100);
391    }
392    
393    
394    // Update whole channel usage state.
395    bool qsamplerChannelStrip::updateChannelUsage (void)
396    {
397        if (m_pChannel == NULL)
398          return false;          return false;
399    
400            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
401            if (pMainForm->client() == NULL)
402                    return false;
403    
404            // This only makes sense on fully loaded channels...
405            if (m_pChannel->instrumentStatus() < 100)
406                return false;
407    
408      // Get current channel voice count.      // Get current channel voice count.
409      int iVoiceCount  = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());      int iVoiceCount  = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID());
410      // Get current stream count.      // Get current stream count.
411      int iStreamCount = ::lscp_get_channel_stream_count(m_pChannel->client(), m_pChannel->channelID());      int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID());
412      // Get current channel buffer fill usage.      // Get current channel buffer fill usage.
413      // As benno has suggested this is the percentage usage      // As benno has suggested this is the percentage usage
414      // of the least filled buffer stream...      // of the least filled buffer stream...
415      int iStreamUsage = ::lscp_get_channel_stream_usage(m_pChannel->client(), m_pChannel->channelID());;      int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());;
416    
417      // Update the GUI elements...      // Update the GUI elements...
418      StreamUsageProgressBar->setProgress(iStreamUsage);      StreamUsageProgressBar->setProgress(iStreamUsage);
419      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
420        
421      // We're clean.      // We're clean.
422      return true;      return true;
423  }  }
# Line 307  void qsamplerChannelStrip::contextMenuEv Line 451  void qsamplerChannelStrip::contextMenuEv
451  {  {
452      if (m_pChannel == NULL)      if (m_pChannel == NULL)
453          return;          return;
454            
455      // 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).
456      m_pChannel->contextMenuEvent(pEvent);      m_pChannel->contextMenuEvent(pEvent);
457  }  }
458    
459    
460  // Maximum volume slider accessors.  // Error count hackish accessors.
461  void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )  void qsamplerChannelStrip::resetErrorCount (void)
462  {  {
463      m_iDirtyChange++;          m_iErrorCount = 0;
     VolumeSlider->setRange(0, iMaxVolume);  
     VolumeSpinBox->setRange(0, iMaxVolume);  
     m_iDirtyChange--;  
464  }  }
465    
466    

Legend:
Removed from v.388  
changed lines
  Added in v.1366

  ViewVC Help
Powered by ViewVC