/[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 395 by capela, Sun Feb 20 19:13:33 2005 UTC
# 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>
# Line 34  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)
# 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    
72            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    // Window drag-n-drop event handlers.
91    void qsamplerChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
92    {
93            QString sInstrumentFile;
94            pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile));
95    }
96    
97    
98    void qsamplerChannelStrip::dropEvent ( QDropEvent* pDropEvent )
99    {
100            QString sInstrumentFile;
101    
102            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 strip setup formal initializer.  // Channel strip setup formal initializer.
112  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )  void qsamplerChannelStrip::setup ( qsamplerChannel *pChannel )
113  {  {
# Line 67  void qsamplerChannelStrip::setup ( qsamp Line 118  void qsamplerChannelStrip::setup ( qsamp
118    
119      // Set the new one...      // Set the new one...
120      m_pChannel = pChannel;      m_pChannel = pChannel;
121        
122      // Stabilize this around.      // Stabilize this around.
123      updateChannelInfo();      updateChannelInfo();
124    
125            // We'll accept drops from now on...
126            if (m_pChannel)
127                    setAcceptDrops(true);
128  }  }
129    
130  // Channel secriptor accessor.  // Channel secriptor accessor.
# Line 123  void qsamplerChannelStrip::setDisplayBac Line 178  void qsamplerChannelStrip::setDisplayBac
178  }  }
179    
180    
181    // Maximum volume slider accessors.
182    void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
183    {
184        m_iDirtyChange++;
185        VolumeSlider->setRange(0, iMaxVolume);
186        VolumeSpinBox->setRange(0, iMaxVolume);
187        m_iDirtyChange--;
188    }
189    
190    
191  // Channel setup dialog slot.  // Channel setup dialog slot.
192  bool qsamplerChannelStrip::channelSetup (void)  bool qsamplerChannelStrip::channelSetup (void)
193  {  {
194      bool bResult = m_pChannel->channelSetup(this);          // Invoke the channel setup dialog.
195            bool bResult = m_pChannel->channelSetup(this);
196    
197      if (bResult)          if (bResult) {
198          emit channelChanged(this);                  // Reset the error/cycle.
199                    m_iErrorCount = 0;
200                    // Notify that thie channel has changed.
201                    emit channelChanged(this);
202            }
203    
204      return bResult;          return bResult;
205  }  }
206    
207    
# Line 245  bool qsamplerChannelStrip::updateChannel Line 315  bool qsamplerChannelStrip::updateChannel
315      if (m_pChannel->client() == NULL)      if (m_pChannel->client() == NULL)
316          return false;          return false;
317    
318      // Update whole channel status info,          // Check for error limit/recycle...
319      // if instrument load is still pending...          if (m_iErrorCount > QSAMPLER_ERROR_LIMIT)
320      if (m_pChannel->instrumentStatus() < 100) {                  m_iErrorCount -= QSAMPLER_ERROR_CYCLE;
321          updateChannelInfo();          if (m_iErrorCount < 0) {
322          // Check (updated) status again...                  m_iErrorCount++;
323          if (m_pChannel->instrumentStatus() < 100)                  return false;
324              return false;          }
         // Once we get a complete instrument load,  
         // we'll try an implied channel reset...  
         m_pChannel->resetChannel();  
     }  
       
     // Check again that we're clean.  
     if (m_pChannel->instrumentStatus() < 100)  
         return false;  
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(m_pChannel->client(), m_pChannel->channelID());      int iVoiceCount  = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());
347      // Get current stream count.      // Get current stream count.
# Line 313  void qsamplerChannelStrip::contextMenuEv Line 394  void qsamplerChannelStrip::contextMenuEv
394  }  }
395    
396    
 // Maximum volume slider accessors.  
 void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )  
 {  
     m_iDirtyChange++;  
     VolumeSlider->setRange(0, iMaxVolume);  
     VolumeSpinBox->setRange(0, iMaxVolume);  
     m_iDirtyChange--;  
 }  
   
   
397  // end of qsamplerChannelStrip.ui.h  // end of qsamplerChannelStrip.ui.h

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

  ViewVC Help
Powered by ViewVC