/[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 115 by capela, Mon Jun 7 21:41:43 2004 UTC revision 263 by capela, Wed Sep 29 09:01:35 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.8;      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.  
333    // Channel setup dialog slot.
334  void qsamplerChannelStrip::channelSetup (void)  void qsamplerChannelStrip::channelSetup (void)
335  {  {
336        showChannelSetup(false);
337    }
338    
339    
340    // Channel setup dialog.
341    void qsamplerChannelStrip::showChannelSetup ( bool bNew )
342    {
343      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);
344      if (pChannelForm) {      if (pChannelForm) {
345          pChannelForm->setup(this);          pChannelForm->setup(this, bNew);
346          if (pChannelForm->exec()) {          if (pChannelForm->exec()) {
347              updateChannelInfo();              updateChannelInfo();
348              emit channelChanged(this);              emit channelChanged(this);
# Line 352  void qsamplerChannelStrip::updateChannel Line 368  void qsamplerChannelStrip::updateChannel
368      lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);      lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);
369      if (pChannelInfo == NULL) {      if (pChannelInfo == NULL) {
370          appendMessagesClient("lscp_get_channel_info");              appendMessagesClient("lscp_get_channel_info");    
371      //  appendMessagesError(tr("Could not get channel information.\n\nSorry."));          appendMessagesError(tr("Could not get channel information.\n\nSorry."));
372      } else {      } else {
373          // Cache in channel information.          // Cache in channel information.
374          m_sEngineName     = pChannelInfo->engine_name;          m_sEngineName       = pChannelInfo->engine_name;
375          m_sInstrumentFile = pChannelInfo->instrument_file;          m_sInstrumentFile   = pChannelInfo->instrument_file;
376          m_iInstrumentNr   = pChannelInfo->instrument_nr;          m_iInstrumentNr     = pChannelInfo->instrument_nr;
377          m_iMidiDevice     = pChannelInfo->midi_device;          m_iInstrumentStatus = pChannelInfo->instrument_status;
378          m_iMidiPort       = pChannelInfo->midi_port;          m_iMidiDevice       = pChannelInfo->midi_device;
379          m_iMidiChannel    = pChannelInfo->midi_channel;          m_iMidiPort         = pChannelInfo->midi_port;
380          m_iAudioDevice    = pChannelInfo->audio_device;          m_iMidiChannel      = pChannelInfo->midi_channel;
381          m_fVolume         = pChannelInfo->volume;          m_iAudioDevice      = pChannelInfo->audio_device;
382            m_fVolume           = pChannelInfo->volume;
383            // Some sanity checks.
384            if (m_sEngineName == "NONE")
385                m_sEngineName = QString::null;
386            if (m_sInstrumentFile == "NONE")
387                m_sInstrumentFile = QString::null;
388      }      }
389    
390      // Set some proper display values.      // Set some proper display values.
391        const QString sIndent = " ";
392    
393      // Engine name...      // Engine name...
394      if (m_sEngineName.isEmpty())      if (m_sEngineName.isEmpty())
395          EngineNameTextLabel->setText(tr("(No engine)"));          EngineNameTextLabel->setText(sIndent + tr("(No engine)"));
396      else      else
397          EngineNameTextLabel->setText(m_sEngineName);          EngineNameTextLabel->setText(sIndent + m_sEngineName);
398    
399      // Instrument name...      // Instrument name...
400      if (m_sInstrumentFile.isEmpty())      if (m_sInstrumentFile.isEmpty())
401          InstrumentNameTextLabel->setText(tr("(No instrument)"));          InstrumentNameTextLabel->setText(sIndent + tr("(No instrument)"));
402      else      else
403          InstrumentNameTextLabel->setText(QString("%1 [%2]")          InstrumentNameTextLabel->setText(sIndent + QString("%1 [%2]")
404              .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr));              .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr));
405    
406        // Instrument status...
407        if (m_iInstrumentStatus < 0) {
408            InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
409            InstrumentStatusTextLabel->setText(tr("ERR%1").arg(m_iInstrumentStatus));
410        } else {
411            InstrumentStatusTextLabel->setPaletteForegroundColor(m_iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
412            InstrumentStatusTextLabel->setText(QString::number(m_iInstrumentStatus) + "%");
413        }
414    
415      // MIDI Port/Channel...      // MIDI Port/Channel...
416      MidiPortChannelTextLabel->setText(QString("%1 / %2")      if (m_iMidiChannel > 0)
417          .arg(m_iMidiPort).arg(m_iMidiChannel));          MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_iMidiPort).arg(m_iMidiChannel));
418                else
419            MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_iMidiPort));
420    
421      // And update the both GUI volume elements.      // And update the both GUI volume elements.
422      updateChannelVolume();      updateChannelVolume();
423  }  }
# Line 407  void qsamplerChannelStrip::updateChannel Line 441  void qsamplerChannelStrip::updateChannel
441  #endif  #endif
442    
443      // And clip...      // And clip...
444      if (iVolume > 100)      if (iVolume < 0)
         iVolume = 100;  
     else if (iVolume < 0)  
445          iVolume = 0;          iVolume = 0;
446    
447      // Flag it here, to avoid infinite recursion.      // Flag it here, to avoid infinite recursion.
# Line 426  void qsamplerChannelStrip::updateChannel Line 458  void qsamplerChannelStrip::updateChannel
458      if (client() == NULL)      if (client() == NULL)
459          return;          return;
460    
461        // Conditionally update whole channel status info.
462        if (m_iInstrumentStatus >= 0 && m_iInstrumentStatus < 100) {
463            updateChannelInfo();
464            // Once we get a complete instrument load, try a implied reset channel....
465            if (m_iInstrumentStatus == 100) {
466                if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK)
467                    appendMessagesClient("lscp_reset_channel");
468                else
469                    appendMessages(tr("Channel %1 reset.").arg(m_iChannelID));
470            }
471        }
472        // Leave, if we still have an erroneus or incomplete instrument load.
473        if (m_iInstrumentStatus < 100)
474            return;
475    
476      // Get current channel voice count.      // Get current channel voice count.
477      int iVoiceCount  = ::lscp_get_channel_voice_count(client(), m_iChannelID);      int iVoiceCount  = ::lscp_get_channel_voice_count(client(), m_iChannelID);
478      // Get current stream count.      // Get current stream count.
# Line 433  void qsamplerChannelStrip::updateChannel Line 480  void qsamplerChannelStrip::updateChannel
480      // Get current channel buffer fill usage.      // Get current channel buffer fill usage.
481      // As benno has suggested this is the percentage usage      // As benno has suggested this is the percentage usage
482      // of the least filled buffer stream...      // of the least filled buffer stream...
483      int iStreamUsage = 0;      int iStreamUsage = ::lscp_get_channel_stream_usage(client(), m_iChannelID);;
484      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;  
             }  
         }  
     }      
485      // Update the GUI elements...      // Update the GUI elements...
486      StreamUsageProgressBar->setProgress(iStreamUsage);      StreamUsageProgressBar->setProgress(iStreamUsage);
487      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));      StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount));
# Line 458  void qsamplerChannelStrip::volumeChanged Line 497  void qsamplerChannelStrip::volumeChanged
497    
498      // Convert and clip.      // Convert and clip.
499      float fVolume = (float) iVolume / 100.0;      float fVolume = (float) iVolume / 100.0;
500      if (fVolume > 1.0)      if (fVolume < 0.001)
         fVolume = 1.0;  
     else if (fVolume < 0.0)  
501          fVolume = 0.0;          fVolume = 0.0;
502    
503      // Update the GUI elements.      // Update the GUI elements.
# Line 498  void qsamplerChannelStrip::appendMessage Line 535  void qsamplerChannelStrip::appendMessage
535  }  }
536    
537    
538  // end of qsamplerChannelStrip.ui.h  // Context menu event handler.
539    void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
540    {
541        // We'll just show up the main form's edit menu.
542        m_pMainForm->contextMenuEvent(pEvent);
543    }
544    
545    
546    // Maximum volume slider accessors.
547    void qsamplerChannelStrip::setMaxVolume ( int iMaxVolume )
548    {
549        m_iDirtyChange++;
550        VolumeSlider->setRange(0, iMaxVolume);
551        VolumeSpinBox->setRange(0, iMaxVolume);
552        m_iDirtyChange--;
553    }
554    
555    
556    // end of qsamplerChannelStrip.ui.h

Legend:
Removed from v.115  
changed lines
  Added in v.263

  ViewVC Help
Powered by ViewVC