/[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 176 by capela, Tue Jul 6 10:54:45 2004 UTC revision 265 by capela, Wed Sep 29 16:05:24 2004 UTC
# Line 38  Line 38 
38  void qsamplerChannelStrip::init (void)  void qsamplerChannelStrip::init (void)
39  {  {
40      // Initialize locals.      // Initialize locals.
41      m_pMainForm  = NULL;      m_pMainForm    = NULL;
42      m_iChannelID = 0;      m_pChannel     = NULL;
       
 //  m_sEngineName       = tr("(No engine)");  
 //  m_sInstrumentFile   = tr("(No instrument)");  
     m_iInstrumentNr     = -1;  
     m_iInstrumentStatus = -1;  
     m_sMidiDriver       = "Alsa";   // DEPRECATED.  
     m_iMidiDevice       = -1;  
     m_iMidiPort         = -1;  
     m_iMidiChannel      = -1;  
     m_sAudioDriver      = "Alsa";   // DEPRECATED.  
     m_iAudioDevice      = -1;  
     m_fVolume           = 0.0;  
       
43      m_iDirtyChange = 0;      m_iDirtyChange = 0;
44    
45      // Try to restore normal window positioning.      // Try to restore normal window positioning.
# Line 63  void qsamplerChannelStrip::init (void) Line 50  void qsamplerChannelStrip::init (void)
50  // Kind of destructor.  // Kind of destructor.
51  void qsamplerChannelStrip::destroy (void)  void qsamplerChannelStrip::destroy (void)
52  {  {
53        // Destroy existing channel descriptor.
54        if (m_pChannel)
55            delete m_pChannel;
56        m_pChannel = NULL;
57  }  }
58    
59    
60  // Channel strip setup formal initializer.  // Channel strip setup formal initializer.
61  void qsamplerChannelStrip::setup ( qsamplerMainForm *pMainForm, int iChannelID )  void qsamplerChannelStrip::setup ( qsamplerMainForm *pMainForm, int iChannelID )
62  {  {
63      m_iDirtyChange = 0;      // Set main form reference.
64      m_pMainForm = pMainForm;      m_pMainForm = pMainForm;
   
     setChannelID(iChannelID);  
 }  
   
   
 // The global options settings delegated property.  
 qsamplerOptions *qsamplerChannelStrip::options (void)  
 {  
     if (m_pMainForm == NULL)  
         return NULL;  
           
     return m_pMainForm->options();  
 }  
   
   
 // The client descriptor delegated property.  
 lscp_client_t *qsamplerChannelStrip::client (void)  
 {  
     if (m_pMainForm == NULL)  
         return NULL;  
   
     return m_pMainForm->client();  
 }  
   
   
 // Channel-ID (aka Sammpler-Channel) accessors.  
 int qsamplerChannelStrip::channelID (void)  
 {  
     return m_iChannelID;  
 }  
   
 void qsamplerChannelStrip::setChannelID ( int iChannelID )  
 {  
     m_iChannelID = iChannelID;  
   
     updateChannelInfo();  
 }  
   
   
 // Engine name accessors.  
 QString& qsamplerChannelStrip::engineName (void)  
 {  
     return m_sEngineName;  
 }  
   
 bool qsamplerChannelStrip::loadEngine ( const QString& sEngineName )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {  
         appendMessagesClient("lscp_load_engine");  
         return false;  
     }  
   
     m_sEngineName = sEngineName;  
     return true;  
 }  
   
   
 // Instrument filename accessor.  
 QString& qsamplerChannelStrip::instrumentFile (void)  
 {  
     return m_sInstrumentFile;  
 }  
   
 // Instrument index accessor.  
 int qsamplerChannelStrip::instrumentNr (void)  
 {  
     return m_iInstrumentNr;  
 }  
   
 // Instrument status accessor.  
 int qsamplerChannelStrip::instrumentStatus (void)  
 {  
     return m_iInstrumentStatus;  
 }  
   
 // Instrument file loader.  
 bool qsamplerChannelStrip::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {  
         appendMessagesClient("lscp_load_instrument");  
         return false;  
     }  
   
     m_sInstrumentFile = sInstrumentFile;  
     m_iInstrumentNr = iInstrumentNr;  
     m_iInstrumentStatus = 0;  
65            
66      return true;      // Destroy any previous channel descriptor.
67  }      if (m_pChannel)
68            delete m_pChannel;
69    
70  // MIDI driver type accessors (DEPRECATED).      // Create a new one...
71  QString& qsamplerChannelStrip::midiDriver (void)      m_pChannel = new qsamplerChannel(pMainForm);
72  {      // And set appropriate settings.
73      return m_sMidiDriver;      if (m_pChannel) {
74  }          m_pChannel->setChannelID(iChannelID);
75            m_iDirtyChange = 0;
 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)  
 {  
     return m_iMidiDevice;  
 }  
   
 bool qsamplerChannelStrip::setMidiDevice ( int iMidiDevice )  
 {  
     if (client() == NULL)  
         return false;  
   
     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;  
 }  
   
   
 // MIDI port number accessor.  
 int qsamplerChannelStrip::midiPort (void)  
 {  
     return m_iMidiPort;  
 }  
   
 bool qsamplerChannelStrip::setMidiPort ( int iMidiPort )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) {  
         appendMessagesClient("lscp_set_channel_midi_port");  
         return false;  
76      }      }
77        
78      m_iMidiPort = iMidiPort;      // Stabilize this around.
79      return true;      updateChannelInfo();
 }  
   
   
 // MIDI channel accessor.  
 int qsamplerChannelStrip::midiChannel (void)  
 {  
     return m_iMidiChannel;  
 }  
   
 bool qsamplerChannelStrip::setMidiChannel ( int iMidiChannel )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) {  
         appendMessagesClient("lscp_set_channel_midi_channel");  
         return false;  
     }  
   
     m_iMidiChannel = iMidiChannel;  
     return true;  
 }  
   
   
 // Audio device accessor.  
 int qsamplerChannelStrip::audioDevice (void)  
 {  
     return m_iAudioDevice;  
 }  
   
 bool qsamplerChannelStrip::setAudioDevice ( int iAudioDevice )  
 {  
     if (client() == NULL)  
         return false;  
   
     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;  
 }  
   
   
 // Audio driver type accessors (DEPRECATED).  
 QString& qsamplerChannelStrip::audioDriver (void)  
 {  
     return m_sAudioDriver;  
 }  
   
 bool qsamplerChannelStrip::setAudioDriver ( const QString& sAudioDriver )  
 {  
     if (client() == NULL)  
         return false;  
   
     if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) {  
         appendMessagesClient("lscp_set_channel_audio_type");  
         return false;  
     }  
   
     m_sAudioDriver = sAudioDriver;  
     return true;  
 }  
   
   
 // Channel volume accessors.  
 float qsamplerChannelStrip::volume (void)  
 {  
     return m_fVolume;  
80  }  }
81    
82  bool qsamplerChannelStrip::setVolume ( float fVolume )  // Channel secriptor accessor.
83    qsamplerChannel *qsamplerChannelStrip::channel (void)
84  {  {
85      if (client() == NULL)      return m_pChannel;
         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;  
86  }  }
87    
88    
# Line 329  void qsamplerChannelStrip::setDisplayFon Line 100  void qsamplerChannelStrip::setDisplayFon
100      InstrumentStatusTextLabel->setFont(font);      InstrumentStatusTextLabel->setFont(font);
101  }  }
102    
103    
104    // Channel setup dialog slot.
105    void qsamplerChannelStrip::channelSetup (void)
106    {
107        showChannelSetup(false);
108    }
109    
110    
111  // Channel setup dialog.  // Channel setup dialog.
112  void qsamplerChannelStrip::channelSetup ( bool bNew )  void qsamplerChannelStrip::showChannelSetup ( bool bNew )
113  {  {
114      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);
115      if (pChannelForm) {      if (pChannelForm) {
116          pChannelForm->setup(this, bNew);          pChannelForm->setup(m_pChannel, bNew);
117          if (pChannelForm->exec()) {          if (pChannelForm->exec()) {
118              updateChannelInfo();              updateChannelInfo();
119              emit channelChanged(this);              emit channelChanged(this);
# Line 347  void qsamplerChannelStrip::channelSetup Line 126  void qsamplerChannelStrip::channelSetup
126  // Update whole channel info state.  // Update whole channel info state.
127  void qsamplerChannelStrip::updateChannelInfo (void)  void qsamplerChannelStrip::updateChannelInfo (void)
128  {  {
129        if (m_pChannel == NULL)
130            return;
131            
132      // Update strip caption.      // Update strip caption.
133      QString sText = tr("Channel %1").arg(m_iChannelID);      QString sText = tr("Channel %1").arg(m_pChannel->channelID());
134      setCaption(sText);      setCaption(sText);
135      ChannelSetupPushButton->setText(sText);      ChannelSetupPushButton->setText(sText);
136    
137      // Check if we're up and connected.      // Check if we're up and connected.
138      if (client() == NULL)      if (m_pChannel->client() == NULL)
139          return;          return;
140    
141      // Read channel information.      // Read actual channel information.
142      lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);      m_pChannel->updateChannelInfo();
     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_iInstrumentStatus = pChannelInfo->instrument_status;  
         m_iMidiDevice       = pChannelInfo->midi_device;  
         m_iMidiPort         = pChannelInfo->midi_port;  
         m_iMidiChannel      = pChannelInfo->midi_channel;  
         m_iAudioDevice      = pChannelInfo->audio_device;  
         m_fVolume           = pChannelInfo->volume;  
         // Some sanity checks.  
         if (m_sEngineName == "NONE")  
             m_sEngineName = QString::null;  
         if (m_sInstrumentFile == "NONE")  
             m_sInstrumentFile = QString::null;  
     }  
143    
144      // Set some proper display values.      // Set some proper display values.
145        const QString sIndent = " ";
146    
147      // Engine name...      // Engine name...
148      if (m_sEngineName.isEmpty())      if (m_pChannel->engineName().isEmpty())
149          EngineNameTextLabel->setText(tr("(No engine)"));          EngineNameTextLabel->setText(sIndent + tr("(No engine)"));
150      else      else
151          EngineNameTextLabel->setText(m_sEngineName);          EngineNameTextLabel->setText(sIndent + m_pChannel->engineName());
152    
153      // Instrument name...      // Instrument name...
154      if (m_sInstrumentFile.isEmpty())      if (m_pChannel->instrumentFile().isEmpty())
155          InstrumentNameTextLabel->setText(tr("(No instrument)"));          InstrumentNameTextLabel->setText(sIndent + tr("(No instrument)"));
156      else      else
157          InstrumentNameTextLabel->setText(QString("%1 [%2]")          InstrumentNameTextLabel->setText(sIndent + QString("%1 [%2]")
158              .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr));              .arg(QFileInfo(m_pChannel->instrumentFile()).fileName()).arg(m_pChannel->instrumentNr()));
159    
160      // Instrument status...      // Instrument status...
161      if (m_iInstrumentStatus < 0) {      int iInstrumentStatus = m_pChannel->instrumentStatus();
162        if (iInstrumentStatus < 0) {
163          InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);          InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
164          InstrumentStatusTextLabel->setText(tr("ERR%1").arg(m_iInstrumentStatus));          InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
165      } else {      } else {
166          InstrumentStatusTextLabel->setPaletteForegroundColor(m_iInstrumentStatus < 100 ? Qt::yellow : Qt::green);          InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
167          InstrumentStatusTextLabel->setText(QString::number(m_iInstrumentStatus) + "%");          InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%");
168      }      }
169    
170      // MIDI Port/Channel...      // MIDI Port/Channel...
171      MidiPortChannelTextLabel->setText(QString("%1 / %2")      if (m_pChannel->midiChannel() > 0)
172          .arg(m_iMidiPort).arg(m_iMidiChannel));          MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel()));
173                else
174            MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));
175    
176      // And update the both GUI volume elements.      // And update the both GUI volume elements.
177      updateChannelVolume();      updateChannelVolume();
178  }  }
# Line 415  void qsamplerChannelStrip::updateChannel Line 181  void qsamplerChannelStrip::updateChannel
181  // Do the dirty volume change.  // Do the dirty volume change.
182  void qsamplerChannelStrip::updateChannelVolume (void)  void qsamplerChannelStrip::updateChannelVolume (void)
183  {  {
184        if (m_pChannel == NULL)
185            return;
186    
187      // Convert...      // Convert...
188  #ifdef CONFIG_ROUND  #ifdef CONFIG_ROUND
189      int iVolume = (int) ::round(100.0 * m_fVolume);      int iVolume = (int) ::round(100.0 * m_pChannel->volume());
190  #else  #else
191      double fIPart = 0.0;      double fIPart = 0.0;
192      double fFPart = ::modf(100.0 * m_fVolume, &fIPart);      double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart);
193      int iVolume = (int) fIPart;      int iVolume = (int) fIPart;
194      if (fFPart >= +0.5)      if (fFPart >= +0.5)
195          iVolume++;          iVolume++;
# Line 444  void qsamplerChannelStrip::updateChannel Line 213  void qsamplerChannelStrip::updateChannel
213  // Update whole channel usage state.  // Update whole channel usage state.
214  void qsamplerChannelStrip::updateChannelUsage (void)  void qsamplerChannelStrip::updateChannelUsage (void)
215  {  {
216      if (client() == NULL)      if (m_pChannel == NULL)
217            return;
218        if (m_pChannel->client() == NULL)
219          return;          return;
220    
221      // Conditionally update whole channel status info.      // Conditionally update whole channel status info.
222      if (m_iInstrumentStatus >= 0 && m_iInstrumentStatus < 100) {      if (m_pChannel->instrumentStatus() >= 0 && m_pChannel->instrumentStatus() < 100) {
223          updateChannelInfo();          updateChannelInfo();
224          // Once we get a complete instrument load, try a implied reset channel....          // Once we get a complete instrument load, try a implied reset channel....
225          if (m_iInstrumentStatus == 100) {          if (m_pChannel->instrumentStatus() == 100)
226              if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK)              m_pChannel->resetChannel();
                 appendMessagesClient("lscp_reset_channel");  
         }  
227      }      }
228      // Leave, if we still have an erroneus or incomplete instrument load.      // Leave, if we still have an erroneus or incomplete instrument load.
229      if (m_iInstrumentStatus < 100)      if (m_pChannel->instrumentStatus() < 100)
230          return;          return;
231    
232      // Get current channel voice count.      // Get current channel voice count.
233      int iVoiceCount  = ::lscp_get_channel_voice_count(client(), m_iChannelID);      int iVoiceCount  = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());
234      // Get current stream count.      // Get current stream count.
235      int iStreamCount = ::lscp_get_channel_stream_count(client(), m_iChannelID);      int iStreamCount = ::lscp_get_channel_stream_count(m_pChannel->client(), m_pChannel->channelID());
236      // Get current channel buffer fill usage.      // Get current channel buffer fill usage.
237      // As benno has suggested this is the percentage usage      // As benno has suggested this is the percentage usage
238      // of the least filled buffer stream...      // of the least filled buffer stream...
239      int iStreamUsage = ::lscp_get_channel_stream_usage(client(), m_iChannelID);;      int iStreamUsage = ::lscp_get_channel_stream_usage(m_pChannel->client(), m_pChannel->channelID());;
240    
241      // Update the GUI elements...      // Update the GUI elements...
242      StreamUsageProgressBar->setProgress(iStreamUsage);      StreamUsageProgressBar->setProgress(iStreamUsage);
# Line 478  void qsamplerChannelStrip::updateChannel Line 247  void qsamplerChannelStrip::updateChannel
247  // Volume change slot.  // Volume change slot.
248  void qsamplerChannelStrip::volumeChanged ( int iVolume )  void qsamplerChannelStrip::volumeChanged ( int iVolume )
249  {  {
250        if (m_pChannel == NULL)
251            return;
252    
253      // Avoid recursion.      // Avoid recursion.
254      if (m_iDirtyChange > 0)      if (m_iDirtyChange > 0)
255          return;          return;
# Line 488  void qsamplerChannelStrip::volumeChanged Line 260  void qsamplerChannelStrip::volumeChanged
260          fVolume = 0.0;          fVolume = 0.0;
261    
262      // Update the GUI elements.      // Update the GUI elements.
263      if (setVolume(fVolume)) {      if (m_pChannel->setVolume(fVolume)) {
264          updateChannelVolume();          updateChannelVolume();
265          emit channelChanged(this);          emit channelChanged(this);
266      }      }
267  }  }
268    
269    
 // 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);  
 }  
   
   
270  // Context menu event handler.  // Context menu event handler.
271  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
272  {  {
273        if (m_pMainForm == NULL)
274            return;
275            
276      // We'll just show up the main form's edit menu.      // We'll just show up the main form's edit menu.
277      m_pMainForm->contextMenuEvent(pEvent);      m_pMainForm->contextMenuEvent(pEvent);
278  }  }
# Line 541  void qsamplerChannelStrip::setMaxVolume Line 289  void qsamplerChannelStrip::setMaxVolume
289    
290    
291  // end of qsamplerChannelStrip.ui.h  // end of qsamplerChannelStrip.ui.h
   

Legend:
Removed from v.176  
changed lines
  Added in v.265

  ViewVC Help
Powered by ViewVC