/[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 263 by capela, Wed Sep 29 09:01:35 2004 UTC revision 264 by capela, Wed Sep 29 13:12:45 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;
   
 // MIDI driver type accessors (DEPRECATED).  
 QString& qsamplerChannelStrip::midiDriver (void)  
 {  
     return m_sMidiDriver;  
 }  
   
 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;  
 }  
   
69    
70  // MIDI port number accessor.      // Create a new one...
71  int qsamplerChannelStrip::midiPort (void)      m_pChannel = new qsamplerChannel(pMainForm);
72  {      // And set appropriate settings.
73      return m_iMidiPort;      if (m_pChannel) {
74  }          m_pChannel->setChannelID(iChannelID);
75            m_iDirtyChange = 0;
 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;  
     }  
   
     m_iMidiPort = iMidiPort;  
     return true;  
 }  
   
   
 // 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;  
76      }      }
   
     m_sAudioDriver = sAudioDriver;  
     return true;  
77  }  }
78    
79    // Channel secriptor accessor.
80  // Channel volume accessors.  qsamplerChannel *qsamplerChannelStrip::channel (void)
 float qsamplerChannelStrip::volume (void)  
81  {  {
82      return m_fVolume;      return m_pChannel;
 }  
   
 bool qsamplerChannelStrip::setVolume ( float fVolume )  
 {  
     if (client() == NULL)  
         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;  
83  }  }
84    
85    
# Line 342  void qsamplerChannelStrip::showChannelSe Line 110  void qsamplerChannelStrip::showChannelSe
110  {  {
111      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(this);
112      if (pChannelForm) {      if (pChannelForm) {
113          pChannelForm->setup(this, bNew);          pChannelForm->setup(m_pChannel, bNew);
114          if (pChannelForm->exec()) {          if (pChannelForm->exec()) {
115              updateChannelInfo();              updateChannelInfo();
116              emit channelChanged(this);              emit channelChanged(this);
# Line 355  void qsamplerChannelStrip::showChannelSe Line 123  void qsamplerChannelStrip::showChannelSe
123  // Update whole channel info state.  // Update whole channel info state.
124  void qsamplerChannelStrip::updateChannelInfo (void)  void qsamplerChannelStrip::updateChannelInfo (void)
125  {  {
126        if (m_pChannel == NULL)
127            return;
128            
129      // Update strip caption.      // Update strip caption.
130      QString sText = tr("Channel %1").arg(m_iChannelID);      QString sText = tr("Channel %1").arg(m_pChannel->channelID());
131      setCaption(sText);      setCaption(sText);
132      ChannelSetupPushButton->setText(sText);      ChannelSetupPushButton->setText(sText);
133    
134      // Check if we're up and connected.      // Check if we're up and connected.
135      if (client() == NULL)      if (m_pChannel->client() == NULL)
136          return;          return;
137    
138      // Read channel information.      // Read actual channel information.
139      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;  
     }  
140    
141      // Set some proper display values.      // Set some proper display values.
142      const QString sIndent = " ";      const QString sIndent = " ";
143    
144      // Engine name...      // Engine name...
145      if (m_sEngineName.isEmpty())      if (m_pChannel->engineName().isEmpty())
146          EngineNameTextLabel->setText(sIndent + tr("(No engine)"));          EngineNameTextLabel->setText(sIndent + tr("(No engine)"));
147      else      else
148          EngineNameTextLabel->setText(sIndent + m_sEngineName);          EngineNameTextLabel->setText(sIndent + m_pChannel->engineName());
149    
150      // Instrument name...      // Instrument name...
151      if (m_sInstrumentFile.isEmpty())      if (m_pChannel->instrumentFile().isEmpty())
152          InstrumentNameTextLabel->setText(sIndent + tr("(No instrument)"));          InstrumentNameTextLabel->setText(sIndent + tr("(No instrument)"));
153      else      else
154          InstrumentNameTextLabel->setText(sIndent + QString("%1 [%2]")          InstrumentNameTextLabel->setText(sIndent + QString("%1 [%2]")
155              .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr));              .arg(QFileInfo(m_pChannel->instrumentFile()).fileName()).arg(m_pChannel->instrumentNr()));
156    
157      // Instrument status...      // Instrument status...
158      if (m_iInstrumentStatus < 0) {      int iInstrumentStatus = m_pChannel->instrumentStatus();
159        if (iInstrumentStatus < 0) {
160          InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);          InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red);
161          InstrumentStatusTextLabel->setText(tr("ERR%1").arg(m_iInstrumentStatus));          InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus));
162      } else {      } else {
163          InstrumentStatusTextLabel->setPaletteForegroundColor(m_iInstrumentStatus < 100 ? Qt::yellow : Qt::green);          InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green);
164          InstrumentStatusTextLabel->setText(QString::number(m_iInstrumentStatus) + "%");          InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%");
165      }      }
166    
167      // MIDI Port/Channel...      // MIDI Port/Channel...
168      if (m_iMidiChannel > 0)      if (m_pChannel->midiChannel() > 0)
169          MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_iMidiPort).arg(m_iMidiChannel));          MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel()));
170      else      else
171          MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_iMidiPort));          MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort()));
172    
173      // And update the both GUI volume elements.      // And update the both GUI volume elements.
174      updateChannelVolume();      updateChannelVolume();
# Line 426  void qsamplerChannelStrip::updateChannel Line 178  void qsamplerChannelStrip::updateChannel
178  // Do the dirty volume change.  // Do the dirty volume change.
179  void qsamplerChannelStrip::updateChannelVolume (void)  void qsamplerChannelStrip::updateChannelVolume (void)
180  {  {
181        if (m_pChannel == NULL)
182            return;
183    
184      // Convert...      // Convert...
185  #ifdef CONFIG_ROUND  #ifdef CONFIG_ROUND
186      int iVolume = (int) ::round(100.0 * m_fVolume);      int iVolume = (int) ::round(100.0 * m_pChannel->volume());
187  #else  #else
188      double fIPart = 0.0;      double fIPart = 0.0;
189      double fFPart = ::modf(100.0 * m_fVolume, &fIPart);      double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart);
190      int iVolume = (int) fIPart;      int iVolume = (int) fIPart;
191      if (fFPart >= +0.5)      if (fFPart >= +0.5)
192          iVolume++;          iVolume++;
# Line 455  void qsamplerChannelStrip::updateChannel Line 210  void qsamplerChannelStrip::updateChannel
210  // Update whole channel usage state.  // Update whole channel usage state.
211  void qsamplerChannelStrip::updateChannelUsage (void)  void qsamplerChannelStrip::updateChannelUsage (void)
212  {  {
213      if (client() == NULL)      if (m_pChannel == NULL)
214            return;
215        if (m_pChannel->client() == NULL)
216          return;          return;
217    
218      // Conditionally update whole channel status info.      // Conditionally update whole channel status info.
219      if (m_iInstrumentStatus >= 0 && m_iInstrumentStatus < 100) {      if (m_pChannel->instrumentStatus() >= 0 && m_pChannel->instrumentStatus() < 100) {
220          updateChannelInfo();          updateChannelInfo();
221          // Once we get a complete instrument load, try a implied reset channel....          // Once we get a complete instrument load, try a implied reset channel....
222          if (m_iInstrumentStatus == 100) {          if (m_pChannel->instrumentStatus() == 100)
223              if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK)              m_pChannel->resetChannel();
                 appendMessagesClient("lscp_reset_channel");  
             else  
                 appendMessages(tr("Channel %1 reset.").arg(m_iChannelID));  
         }  
224      }      }
225      // Leave, if we still have an erroneus or incomplete instrument load.      // Leave, if we still have an erroneus or incomplete instrument load.
226      if (m_iInstrumentStatus < 100)      if (m_pChannel->instrumentStatus() < 100)
227          return;          return;
228    
229      // Get current channel voice count.      // Get current channel voice count.
230      int iVoiceCount  = ::lscp_get_channel_voice_count(client(), m_iChannelID);      int iVoiceCount  = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID());
231      // Get current stream count.      // Get current stream count.
232      int iStreamCount = ::lscp_get_channel_stream_count(client(), m_iChannelID);      int iStreamCount = ::lscp_get_channel_stream_count(m_pChannel->client(), m_pChannel->channelID());
233      // Get current channel buffer fill usage.      // Get current channel buffer fill usage.
234      // As benno has suggested this is the percentage usage      // As benno has suggested this is the percentage usage
235      // of the least filled buffer stream...      // of the least filled buffer stream...
236      int iStreamUsage = ::lscp_get_channel_stream_usage(client(), m_iChannelID);;      int iStreamUsage = ::lscp_get_channel_stream_usage(m_pChannel->client(), m_pChannel->channelID());;
237    
238      // Update the GUI elements...      // Update the GUI elements...
239      StreamUsageProgressBar->setProgress(iStreamUsage);      StreamUsageProgressBar->setProgress(iStreamUsage);
# Line 491  void qsamplerChannelStrip::updateChannel Line 244  void qsamplerChannelStrip::updateChannel
244  // Volume change slot.  // Volume change slot.
245  void qsamplerChannelStrip::volumeChanged ( int iVolume )  void qsamplerChannelStrip::volumeChanged ( int iVolume )
246  {  {
247        if (m_pChannel == NULL)
248            return;
249    
250      // Avoid recursion.      // Avoid recursion.
251      if (m_iDirtyChange > 0)      if (m_iDirtyChange > 0)
252          return;          return;
# Line 501  void qsamplerChannelStrip::volumeChanged Line 257  void qsamplerChannelStrip::volumeChanged
257          fVolume = 0.0;          fVolume = 0.0;
258    
259      // Update the GUI elements.      // Update the GUI elements.
260      if (setVolume(fVolume)) {      if (m_pChannel->setVolume(fVolume)) {
261          updateChannelVolume();          updateChannelVolume();
262          emit channelChanged(this);          emit channelChanged(this);
263      }      }
264  }  }
265    
266    
 // 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);  
 }  
   
   
267  // Context menu event handler.  // Context menu event handler.
268  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent )
269  {  {
270        if (m_pMainForm == NULL)
271            return;
272            
273      // We'll just show up the main form's edit menu.      // We'll just show up the main form's edit menu.
274      m_pMainForm->contextMenuEvent(pEvent);      m_pMainForm->contextMenuEvent(pEvent);
275  }  }

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

  ViewVC Help
Powered by ViewVC