/[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 109 by capela, Sat Jun 5 11:37:06 2004 UTC revision 182 by capela, Tue Jul 6 21:11:40 2004 UTC
# Line 24  Line 24 
24  #include <qmessagebox.h>  #include <qmessagebox.h>
25  #include <qfileinfo.h>  #include <qfileinfo.h>
26  #include <qtooltip.h>  #include <qtooltip.h>
27    #include <qpopupmenu.h>
28    
29  #include <math.h>  #include <math.h>
30    
# Line 40  void qsamplerChannelStrip::init (void) Line 41  void qsamplerChannelStrip::init (void)
41      m_pMainForm  = NULL;      m_pMainForm  = NULL;
42      m_iChannelID = 0;      m_iChannelID = 0;
43            
44  //  m_sEngineName     = "(No engine)";  //  m_sEngineName       = tr("(No engine)");
45  //  m_sInstrumentFile = "(No instrument)";  //  m_sInstrumentFile   = tr("(No instrument)");
46      m_iInstrumentNr   = 0;      m_iInstrumentNr     = -1;
47      m_sMidiDriver     = "ALSA"; // DEPRECATED.      m_iInstrumentStatus = -1;
48      m_iMidiDevice     = 0;      m_sMidiDriver       = "Alsa";   // DEPRECATED.
49      m_iMidiPort       = 0;      m_iMidiDevice       = -1;
50      m_iMidiChannel    = 0;      m_iMidiPort         = -1;
51      m_sAudioDriver    = "ALSA"; // DEPRECATED.      m_iMidiChannel      = -1;
52      m_iAudioDevice    = 0;      m_sAudioDriver      = "Alsa";   // DEPRECATED.
53      m_fVolume         = 0.0;      m_iAudioDevice      = -1;
54        m_fVolume           = 0.0;
55            
56      m_iDirtyChange = 0;      m_iDirtyChange = 0;
57    
# Line 129  bool qsamplerChannelStrip::loadEngine ( Line 131  bool qsamplerChannelStrip::loadEngine (
131  }  }
132    
133    
134  // Instrument filename accessors.  // Instrument filename accessor.
135  QString& qsamplerChannelStrip::instrumentFile (void)  QString& qsamplerChannelStrip::instrumentFile (void)
136  {  {
137      return m_sInstrumentFile;      return m_sInstrumentFile;
138  }  }
139    
140  // Instrument index accessors.  // Instrument index accessor.
141  int qsamplerChannelStrip::instrumentNr (void)  int qsamplerChannelStrip::instrumentNr (void)
142  {  {
143      return m_iInstrumentNr;      return m_iInstrumentNr;
144  }  }
145    
146    // Instrument status accessor.
147    int qsamplerChannelStrip::instrumentStatus (void)
148    {
149        return m_iInstrumentStatus;
150    }
151    
152    // Instrument file loader.
153  bool qsamplerChannelStrip::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  bool qsamplerChannelStrip::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )
154  {  {
155      if (client() == NULL)      if (client() == NULL)
156          return false;          return false;
157    
158      if (::lscp_load_instrument(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {      if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {
159          appendMessagesClient("lscp_load_instrument");          appendMessagesClient("lscp_load_instrument");
160          return false;          return false;
161      }      }
162    
163      m_sInstrumentFile = sInstrumentFile;      m_sInstrumentFile = sInstrumentFile;
164      m_iInstrumentNr = iInstrumentNr;      m_iInstrumentNr = iInstrumentNr;
165        m_iInstrumentStatus = 0;
166        
167      return true;      return true;
168  }  }
169    
# Line 189  bool qsamplerChannelStrip::setMidiDevice Line 200  bool qsamplerChannelStrip::setMidiDevice
200      if (client() == NULL)      if (client() == NULL)
201          return false;          return false;
202    
203  //  FIXME: call this when LSCP becomes stable.      if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) {
204  //  if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) {          appendMessagesClient("lscp_set_channel_midi_device");
205  //      appendMessagesClient("lscp_set_channel_midi_device");          return false;
206  //      return false;      }
 //  }  
207    
208      m_iMidiDevice = iMidiDevice;      m_iMidiDevice = iMidiDevice;
209      return true;      return true;
# Line 211  bool qsamplerChannelStrip::setMidiPort ( Line 221  bool qsamplerChannelStrip::setMidiPort (
221      if (client() == NULL)      if (client() == NULL)
222          return false;          return false;
223    
224  //  FIXME: call this when LSCP becomes stable.      if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) {
225  //  if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) {          appendMessagesClient("lscp_set_channel_midi_port");
226  //      appendMessagesClient("lscp_set_channel_midi_port");          return false;
227  //      return false;      }
 //  }  
228    
229      m_iMidiPort = iMidiPort;      m_iMidiPort = iMidiPort;
230      return true;      return true;
# Line 233  bool qsamplerChannelStrip::setMidiChanne Line 242  bool qsamplerChannelStrip::setMidiChanne
242      if (client() == NULL)      if (client() == NULL)
243          return false;          return false;
244    
245  //  FIXME: call this when LSCP becomes stable.      if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) {
246  //  if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) {          appendMessagesClient("lscp_set_channel_midi_channel");
247  //      appendMessagesClient("lscp_set_channel_midi_channel");          return false;
248  //      return false;      }
 //  }  
249    
250      m_iMidiChannel = iMidiChannel;      m_iMidiChannel = iMidiChannel;
251      return true;      return true;
# Line 255  bool qsamplerChannelStrip::setAudioDevic Line 263  bool qsamplerChannelStrip::setAudioDevic
263      if (client() == NULL)      if (client() == NULL)
264          return false;          return false;
265    
266  //  FIXME: call this when LSCP becomes stable.      if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) {
267  //  if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) {          appendMessagesClient("lscp_set_channel_audio_device");
268  //      appendMessagesClient("lscp_set_channel_audio_device");          return false;
269  //      return false;      }
 //  }  
270    
271      m_iAudioDevice = iAudioDevice;      m_iAudioDevice = iAudioDevice;
272      return true;      return true;
# Line 317  QFont qsamplerChannelStrip::displayFont Line 324  QFont qsamplerChannelStrip::displayFont
324  void qsamplerChannelStrip::setDisplayFont ( const QFont & font )  void qsamplerChannelStrip::setDisplayFont ( const QFont & font )
325  {  {
326      EngineNameTextLabel->setFont(font);      EngineNameTextLabel->setFont(font);
     InstrumentNameTextLabel->setFont(font);  
327      MidiPortChannelTextLabel->setFont(font);      MidiPortChannelTextLabel->setFont(font);
328        InstrumentNameTextLabel->setFont(font);
329        InstrumentStatusTextLabel->setFont(font);
330  }  }
331    
332  // Channel setup dialog.  // Channel setup dialog.
333  void qsamplerChannelStrip::channelSetup (void)  void qsamplerChannelStrip::channelSetup ( bool bNew )
334  {  {
335      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);
336      if (pChannelForm) {      if (pChannelForm) {
337          pChannelForm->setup(this);          pChannelForm->setup(this, bNew);
338          if (pChannelForm->exec()) {          if (pChannelForm->exec()) {
339              updateChannelInfo();              updateChannelInfo();
340              emit channelChanged(this);              emit channelChanged(this);
# Line 352  void qsamplerChannelStrip::updateChannel Line 360  void qsamplerChannelStrip::updateChannel
360      lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);      lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);
361      if (pChannelInfo == NULL) {      if (pChannelInfo == NULL) {
362          appendMessagesClient("lscp_get_channel_info");              appendMessagesClient("lscp_get_channel_info");    
363      //  appendMessagesError(tr("Could not get channel information.\n\nSorry."));          appendMessagesError(tr("Could not get channel information.\n\nSorry."));
364      } else {      } else {
365          // Cache in channel information.          // Cache in channel information.
366          m_sEngineName     = pChannelInfo->engine_name;          m_sEngineName       = pChannelInfo->engine_name;
367          m_sInstrumentFile = pChannelInfo->instrument_file;          m_sInstrumentFile   = pChannelInfo->instrument_file;
368          m_iInstrumentNr   = pChannelInfo->instrument_nr;          m_iInstrumentNr     = pChannelInfo->instrument_nr;
369          m_iMidiDevice     = pChannelInfo->midi_device;          m_iInstrumentStatus = pChannelInfo->instrument_status;
370          m_iMidiPort       = pChannelInfo->midi_port;          m_iMidiDevice       = pChannelInfo->midi_device;
371          m_iMidiChannel    = pChannelInfo->midi_channel;          m_iMidiPort         = pChannelInfo->midi_port;
372          m_iAudioDevice    = pChannelInfo->audio_device;          m_iMidiChannel      = pChannelInfo->midi_channel;
373          m_fVolume         = pChannelInfo->volume;          m_iAudioDevice      = pChannelInfo->audio_device;
374            m_fVolume           = pChannelInfo->volume;
375            // Some sanity checks.
376            if (m_sEngineName == "NONE")
377                m_sEngineName = QString::null;
378            if (m_sInstrumentFile == "NONE")
379                m_sInstrumentFile = QString::null;
380      }      }
381    
382      // Set some proper display values.      // Set some proper display values.
# Line 380  void qsamplerChannelStrip::updateChannel Line 394  void qsamplerChannelStrip::updateChannel
394          InstrumentNameTextLabel->setText(QString("%1 [%2]")          InstrumentNameTextLabel->setText(QString("%1 [%2]")
395              .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr));              .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr));
396    
397        // Instrument status...
398        if (m_iInstrumentStatus < 0) {
399            InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
400            InstrumentStatusTextLabel->setText(tr("ERR%1").arg(m_iInstrumentStatus));
401        } else {
402            InstrumentStatusTextLabel->setPaletteForegroundColor(m_iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
403            InstrumentStatusTextLabel->setText(QString::number(m_iInstrumentStatus) + "%");
404        }
405    
406      // MIDI Port/Channel...      // MIDI Port/Channel...
407      MidiPortChannelTextLabel->setText(QString("%1 / %2")      MidiPortChannelTextLabel->setText(QString("%1 / %2")
408          .arg(m_iMidiPort).arg(m_iMidiChannel));          .arg(m_iMidiPort).arg(m_iMidiChannel));
# Line 407  void qsamplerChannelStrip::updateChannel Line 430  void qsamplerChannelStrip::updateChannel
430  #endif  #endif
431    
432      // And clip...      // And clip...
433      if (iVolume > 100)      if (iVolume < 0)
         iVolume = 100;  
     else if (iVolume < 0)  
434          iVolume = 0;          iVolume = 0;
435    
436      // Flag it here, to avoid infinite recursion.      // Flag it here, to avoid infinite recursion.
# Line 426  void qsamplerChannelStrip::updateChannel Line 447  void qsamplerChannelStrip::updateChannel
447      if (client() == NULL)      if (client() == NULL)
448          return;          return;
449    
450        // Conditionally update whole channel status info.
451        if (m_iInstrumentStatus >= 0 && m_iInstrumentStatus < 100) {
452            updateChannelInfo();
453            // Once we get a complete instrument load, try a implied reset channel....
454            if (m_iInstrumentStatus == 100) {
455                if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK)
456                    appendMessagesClient("lscp_reset_channel");
457                else
458                    appendMessages(tr("Channel %1 reset.").arg(m_iChannelID));
459            }
460        }
461        // Leave, if we still have an erroneus or incomplete instrument load.
462        if (m_iInstrumentStatus < 100)
463            return;
464    
465      // Get current channel voice count.      // Get current channel voice count.
466      int iVoiceCount  = ::lscp_get_channel_voice_count(client(), m_iChannelID);      int iVoiceCount  = ::lscp_get_channel_voice_count(client(), m_iChannelID);
467      // Get current stream count.      // Get current stream count.
# Line 433  void qsamplerChannelStrip::updateChannel Line 469  void qsamplerChannelStrip::updateChannel
469      // Get current channel buffer fill usage.      // Get current channel buffer fill usage.
470      // As benno has suggested this is the percentage usage      // As benno has suggested this is the percentage usage
471      // of the least filled buffer stream...      // of the least filled buffer stream...
472      int iStreamUsage = 0;      int iStreamUsage = ::lscp_get_channel_stream_usage(client(), m_iChannelID);;
473      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;  
             }  
         }  
     }      
474      // Update the GUI elements...      // Update the GUI elements...
475      StreamUsageProgressBar->setProgress(iStreamUsage);      StreamUsageProgressBar->setProgress(iStreamUsage);
476      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
# Line 458  void qsamplerChannelStrip::volumeChanged Line 486  void qsamplerChannelStrip::volumeChanged
486    
487      // Convert and clip.      // Convert and clip.
488      float fVolume = (float) iVolume / 100.0;      float fVolume = (float) iVolume / 100.0;
489      if (fVolume > 1.0)      if (fVolume < 0.001)
         fVolume = 1.0;  
     else if (fVolume < 0.0)  
490          fVolume = 0.0;          fVolume = 0.0;
491    
492      // Update the GUI elements.      // Update the GUI elements.
# Line 498  void qsamplerChannelStrip::appendMessage Line 524  void qsamplerChannelStrip::appendMessage
524  }  }
525    
526    
527  // end of qsamplerChannelStrip.ui.h  // Context menu event handler.
528    void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
529    {
530        // We'll just show up the main form's edit menu.
531        m_pMainForm->contextMenuEvent(pEvent);
532    }
533    
534    
535    // Maximum volume slider accessors.
536    void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
537    {
538        m_iDirtyChange++;
539        VolumeSlider->setRange(0, iMaxVolume);
540        VolumeSpinBox->setRange(0, iMaxVolume);
541        m_iDirtyChange--;
542    }
543    
544    
545    // end of qsamplerChannelStrip.ui.h

Legend:
Removed from v.109  
changed lines
  Added in v.182

  ViewVC Help
Powered by ViewVC