/[svn]/qsampler/trunk/src/qsamplerChannel.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 824 by capela, Fri Dec 23 01:40:56 2005 UTC revision 1366 by schoenebeck, Mon Oct 1 18:26:06 2007 UTC
# Line 1  Line 1 
1  // qsamplerChannel.cpp  // qsamplerChannel.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5    
6     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
7     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 13  Line 13 
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.     GNU General Public License for more details.
15    
16     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License along
17     along with this program; if not, write to the Free Software     with this program; if not, write to the Free Software Foundation, Inc.,
18     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19    
20  *****************************************************************************/  *****************************************************************************/
21    
# Line 40  Line 40 
40  //  //
41    
42  // Constructor.  // Constructor.
43  qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID )  qsamplerChannel::qsamplerChannel ( int iChannelID )
44  {  {
         m_pMainForm  = pMainForm;  
45          m_iChannelID = iChannelID;          m_iChannelID = iChannelID;
46    
47  //  m_sEngineName       = noEngineName();  //  m_sEngineName       = noEngineName();
# Line 54  qsamplerChannel::qsamplerChannel ( qsamp Line 53  qsamplerChannel::qsamplerChannel ( qsamp
53          m_iMidiDevice       = -1;          m_iMidiDevice       = -1;
54          m_iMidiPort         = -1;          m_iMidiPort         = -1;
55          m_iMidiChannel      = -1;          m_iMidiChannel      = -1;
56            m_iMidiMap          = -1;
57          m_sAudioDriver      = "ALSA";          m_sAudioDriver      = "ALSA";
58          m_iAudioDevice      = -1;          m_iAudioDevice      = -1;
59          m_fVolume           = 0.0;          m_fVolume           = 0.0;
# Line 67  qsamplerChannel::~qsamplerChannel (void) Line 67  qsamplerChannel::~qsamplerChannel (void)
67  }  }
68    
69    
 // Main application form accessor.  
 qsamplerMainForm *qsamplerChannel::mainForm(void) const  
 {  
         return m_pMainForm;  
 }  
   
   
 // The global options settings delegated property.  
 qsamplerOptions *qsamplerChannel::options (void) const  
 {  
         if (m_pMainForm == NULL)  
                 return NULL;  
   
         return m_pMainForm->options();  
 }  
   
   
 // The client descriptor delegated property.  
 lscp_client_t *qsamplerChannel::client (void) const  
 {  
         if (m_pMainForm == NULL)  
                 return NULL;  
   
         return m_pMainForm->client();  
 }  
   
   
70  // Create a new sampler channel, if not already.  // Create a new sampler channel, if not already.
71  bool qsamplerChannel::addChannel (void)  bool qsamplerChannel::addChannel (void)
72  {  {
73          if (client() == NULL)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
74            if (pMainForm == NULL)
75                    return false;
76            if (pMainForm->client() == NULL)
77                  return false;                  return false;
78    
79          // Are we a new channel?          // Are we a new channel?
80          if (m_iChannelID < 0) {          if (m_iChannelID < 0) {
81                  m_iChannelID = ::lscp_add_channel(client());                  m_iChannelID = ::lscp_add_channel(pMainForm->client());
82                  if (m_iChannelID < 0) {                  if (m_iChannelID < 0) {
83                          appendMessagesClient("lscp_add_channel");                          appendMessagesClient("lscp_add_channel");
84                          appendMessagesError(QObject::tr("Could not add channel.\n\nSorry."));                          appendMessagesError(
85                                    QObject::tr("Could not add channel.\n\nSorry."));
86                  }   // Otherwise it's created...                  }   // Otherwise it's created...
87                  else appendMessages(QObject::tr("added."));                  else appendMessages(QObject::tr("added."));
88          }          }
# Line 118  bool qsamplerChannel::addChannel (void) Line 95  bool qsamplerChannel::addChannel (void)
95  // Remove sampler channel.  // Remove sampler channel.
96  bool qsamplerChannel::removeChannel (void)  bool qsamplerChannel::removeChannel (void)
97  {  {
98          if (client() == NULL)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
99            if (pMainForm == NULL)
100                    return false;
101            if (pMainForm->client() == NULL)
102                  return false;                  return false;
103    
104          // Are we an existing channel?          // Are we an existing channel?
105          if (m_iChannelID >= 0) {          if (m_iChannelID >= 0) {
106                  if (::lscp_remove_channel(client(), m_iChannelID) != LSCP_OK) {                  if (::lscp_remove_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) {
107                          appendMessagesClient("lscp_remove_channel");                          appendMessagesClient("lscp_remove_channel");
108                          appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry."));                          appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry."));
109                  } else {                  } else {
# Line 165  const QString& qsamplerChannel::engineNa Line 145  const QString& qsamplerChannel::engineNa
145    
146  bool qsamplerChannel::loadEngine ( const QString& sEngineName )  bool qsamplerChannel::loadEngine ( const QString& sEngineName )
147  {  {
148          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
149            if (pMainForm == NULL)
150                    return false;
151            if (pMainForm->client() == NULL || m_iChannelID < 0)
152                  return false;                  return false;
153          if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName)          if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName)
154                  return true;                  return true;
155    
156          if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {          if (::lscp_load_engine(pMainForm->client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {
157                  appendMessagesClient("lscp_load_engine");                  appendMessagesClient("lscp_load_engine");
158                  return false;                  return false;
159          }          }
160    
161          appendMessages(QObject::tr("Engine: %1.").arg(sEngineName));          appendMessages(QObject::tr("Engine: %1.").arg(sEngineName));
162    
163          m_sEngineName = sEngineName;          m_sEngineName = sEngineName;
# Line 208  int qsamplerChannel::instrumentStatus (v Line 192  int qsamplerChannel::instrumentStatus (v
192  // Instrument file loader.  // Instrument file loader.
193  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )
194  {  {
195          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
196            if (pMainForm == NULL)
197                    return false;
198            if (pMainForm->client() == NULL || m_iChannelID < 0)
199                  return false;                  return false;
200          if (!isInstrumentFile(sInstrumentFile))          if (!isInstrumentFile(sInstrumentFile))
201                  return false;                  return false;
202          if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr)          if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr)
203                  return true;                  return true;
204    
205          if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {          if (::lscp_load_instrument_non_modal(pMainForm->client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {
206                  appendMessagesClient("lscp_load_instrument");                  appendMessagesClient("lscp_load_instrument");
207                  return false;                  return false;
208          }          }
# Line 251  const QString& qsamplerChannel::midiDriv Line 238  const QString& qsamplerChannel::midiDriv
238    
239  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )
240  {  {
241          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
242            if (pMainForm == NULL)
243                    return false;
244            if (pMainForm->client() == NULL || m_iChannelID < 0)
245                  return false;                  return false;
246          if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver)          if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver)
247                  return true;                  return true;
248    
249          if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) {          if (::lscp_set_channel_midi_type(pMainForm->client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) {
250                  appendMessagesClient("lscp_set_channel_midi_type");                  appendMessagesClient("lscp_set_channel_midi_type");
251                  return false;                  return false;
252          }          }
# Line 276  int qsamplerChannel::midiDevice (void) c Line 266  int qsamplerChannel::midiDevice (void) c
266    
267  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )
268  {  {
269          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
270            if (pMainForm == NULL)
271                    return false;
272            if (pMainForm->client() == NULL || m_iChannelID < 0)
273                  return false;                  return false;
274          if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice)          if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice)
275                  return true;                  return true;
276    
277          if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) {          if (::lscp_set_channel_midi_device(pMainForm->client(), m_iChannelID, iMidiDevice) != LSCP_OK) {
278                  appendMessagesClient("lscp_set_channel_midi_device");                  appendMessagesClient("lscp_set_channel_midi_device");
279                  return false;                  return false;
280          }          }
# Line 301  int qsamplerChannel::midiPort (void) con Line 294  int qsamplerChannel::midiPort (void) con
294    
295  bool qsamplerChannel::setMidiPort ( int iMidiPort )  bool qsamplerChannel::setMidiPort ( int iMidiPort )
296  {  {
297          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
298            if (pMainForm == NULL)
299                    return false;
300            if (pMainForm->client() == NULL || m_iChannelID < 0)
301                  return false;                  return false;
302          if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort)          if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort)
303                  return true;                  return true;
304    
305          if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) {          if (::lscp_set_channel_midi_port(pMainForm->client(), m_iChannelID, iMidiPort) != LSCP_OK) {
306                  appendMessagesClient("lscp_set_channel_midi_port");                  appendMessagesClient("lscp_set_channel_midi_port");
307                  return false;                  return false;
308          }          }
# Line 326  int qsamplerChannel::midiChannel (void) Line 322  int qsamplerChannel::midiChannel (void)
322    
323  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )
324  {  {
325          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
326            if (pMainForm == NULL)
327                    return false;
328            if (pMainForm->client() == NULL || m_iChannelID < 0)
329                  return false;                  return false;
330          if (m_iInstrumentStatus == 100 && m_iMidiChannel == iMidiChannel)          if (m_iInstrumentStatus == 100 && m_iMidiChannel == iMidiChannel)
331                  return true;                  return true;
332    
333          if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) {          if (::lscp_set_channel_midi_channel(pMainForm->client(), m_iChannelID, iMidiChannel) != LSCP_OK) {
334                  appendMessagesClient("lscp_set_channel_midi_channel");                  appendMessagesClient("lscp_set_channel_midi_channel");
335                  return false;                  return false;
336          }          }
# Line 343  bool qsamplerChannel::setMidiChannel ( i Line 342  bool qsamplerChannel::setMidiChannel ( i
342  }  }
343    
344    
345    // MIDI instrument map accessor.
346    int qsamplerChannel::midiMap (void) const
347    {
348            return m_iMidiMap;
349    }
350    
351    bool qsamplerChannel::setMidiMap ( int iMidiMap )
352    {
353            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
354            if (pMainForm == NULL)
355                    return false;
356            if (pMainForm->client() == NULL || m_iChannelID < 0)
357                    return false;
358            if (m_iInstrumentStatus == 100 && m_iMidiMap == iMidiMap)
359                    return true;
360    #ifdef CONFIG_MIDI_INSTRUMENT
361            if (::lscp_set_channel_midi_map(pMainForm->client(), m_iChannelID, iMidiMap) != LSCP_OK) {
362                    appendMessagesClient("lscp_set_channel_midi_map");
363                    return false;
364            }
365    #endif
366            appendMessages(QObject::tr("MIDI map: %1.").arg(iMidiMap));
367    
368            m_iMidiMap = iMidiMap;
369            return true;
370    }
371    
372    
373  // Audio device accessor.  // Audio device accessor.
374  int qsamplerChannel::audioDevice (void) const  int qsamplerChannel::audioDevice (void) const
375  {  {
# Line 351  int qsamplerChannel::audioDevice (void) Line 378  int qsamplerChannel::audioDevice (void)
378    
379  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )
380  {  {
381          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
382            if (pMainForm == NULL)
383                    return false;
384            if (pMainForm->client() == NULL || m_iChannelID < 0)
385                  return false;                  return false;
386          if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice)          if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice)
387                  return true;                  return true;
388    
389          if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) {          if (::lscp_set_channel_audio_device(pMainForm->client(), m_iChannelID, iAudioDevice) != LSCP_OK) {
390                  appendMessagesClient("lscp_set_channel_audio_device");                  appendMessagesClient("lscp_set_channel_audio_device");
391                  return false;                  return false;
392          }          }
# Line 376  const QString& qsamplerChannel::audioDri Line 406  const QString& qsamplerChannel::audioDri
406    
407  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )
408  {  {
409          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
410            if (pMainForm == NULL)
411                    return false;
412            if (pMainForm->client() == NULL || m_iChannelID < 0)
413                  return false;                  return false;
414          if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver)          if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver)
415                  return true;                  return true;
416    
417          if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) {          if (::lscp_set_channel_audio_type(pMainForm->client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) {
418                  appendMessagesClient("lscp_set_channel_audio_type");                  appendMessagesClient("lscp_set_channel_audio_type");
419                  return false;                  return false;
420          }          }
# Line 401  float qsamplerChannel::volume (void) con Line 434  float qsamplerChannel::volume (void) con
434    
435  bool qsamplerChannel::setVolume ( float fVolume )  bool qsamplerChannel::setVolume ( float fVolume )
436  {  {
437          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
438            if (pMainForm == NULL)
439                    return false;
440            if (pMainForm->client() == NULL || m_iChannelID < 0)
441                  return false;                  return false;
442          if (m_iInstrumentStatus == 100 && m_fVolume == fVolume)          if (m_iInstrumentStatus == 100 && m_fVolume == fVolume)
443                  return true;                  return true;
444    
445          if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) {          if (::lscp_set_channel_volume(pMainForm->client(), m_iChannelID, fVolume) != LSCP_OK) {
446                  appendMessagesClient("lscp_set_channel_volume");                  appendMessagesClient("lscp_set_channel_volume");
447                  return false;                  return false;
448          }          }
# Line 426  bool qsamplerChannel::channelMute (void) Line 462  bool qsamplerChannel::channelMute (void)
462    
463  bool qsamplerChannel::setChannelMute ( bool bMute )  bool qsamplerChannel::setChannelMute ( bool bMute )
464  {  {
465          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
466            if (pMainForm == NULL)
467                    return false;
468            if (pMainForm->client() == NULL || m_iChannelID < 0)
469                  return false;                  return false;
470          if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute)))          if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute)))
471                  return true;                  return true;
472    
473  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
474          if (::lscp_set_channel_mute(client(), m_iChannelID, bMute) != LSCP_OK) {          if (::lscp_set_channel_mute(pMainForm->client(), m_iChannelID, bMute) != LSCP_OK) {
475                  appendMessagesClient("lscp_set_channel_mute");                  appendMessagesClient("lscp_set_channel_mute");
476                  return false;                  return false;
477          }          }
# Line 453  bool qsamplerChannel::channelSolo (void) Line 492  bool qsamplerChannel::channelSolo (void)
492    
493  bool qsamplerChannel::setChannelSolo ( bool bSolo )  bool qsamplerChannel::setChannelSolo ( bool bSolo )
494  {  {
495          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
496            if (pMainForm == NULL)
497                    return false;
498            if (pMainForm->client() == NULL || m_iChannelID < 0)
499                  return false;                  return false;
500          if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo)))          if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo)))
501                  return true;                  return true;
502    
503  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
504          if (::lscp_set_channel_solo(client(), m_iChannelID, bSolo) != LSCP_OK) {          if (::lscp_set_channel_solo(pMainForm->client(), m_iChannelID, bSolo) != LSCP_OK) {
505                  appendMessagesClient("lscp_set_channel_solo");                  appendMessagesClient("lscp_set_channel_solo");
506                  return false;                  return false;
507          }          }
# Line 480  int qsamplerChannel::audioChannel ( int Line 522  int qsamplerChannel::audioChannel ( int
522    
523  bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn )  bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn )
524  {  {
525          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
526            if (pMainForm == NULL)
527                    return false;
528            if (pMainForm->client() == NULL || m_iChannelID < 0)
529                  return false;                  return false;
530          if (m_iInstrumentStatus == 100 &&          if (m_iInstrumentStatus == 100 &&
531                          m_audioRouting[iAudioOut] == iAudioIn)                          m_audioRouting[iAudioOut] == iAudioIn)
532                  return true;                  return true;
533    
534          if (::lscp_set_channel_audio_channel(client(),          if (::lscp_set_channel_audio_channel(pMainForm->client(),
535                          m_iChannelID, iAudioOut, iAudioIn) != LSCP_OK) {                          m_iChannelID, iAudioOut, iAudioIn) != LSCP_OK) {
536                  appendMessagesClient("lscp_set_channel_audio_channel");                  appendMessagesClient("lscp_set_channel_audio_channel");
537                  return false;                  return false;
# Line 519  void qsamplerChannel::updateInstrumentNa Line 564  void qsamplerChannel::updateInstrumentNa
564  // Update whole channel info state.  // Update whole channel info state.
565  bool qsamplerChannel::updateChannelInfo (void)  bool qsamplerChannel::updateChannelInfo (void)
566  {  {
567          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
568            if (pMainForm == NULL)
569                    return false;
570            if (pMainForm->client() == NULL || m_iChannelID < 0)
571                  return false;                  return false;
572    
573          // Read channel information.          // Read channel information.
574          lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);          lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(pMainForm->client(), m_iChannelID);
575          if (pChannelInfo == NULL) {          if (pChannelInfo == NULL) {
576                  appendMessagesClient("lscp_get_channel_info");                  appendMessagesClient("lscp_get_channel_info");
577                  appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry."));                  appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry."));
# Line 552  bool qsamplerChannel::updateChannelInfo Line 600  bool qsamplerChannel::updateChannelInfo
600          m_iMidiDevice       = pChannelInfo->midi_device;          m_iMidiDevice       = pChannelInfo->midi_device;
601          m_iMidiPort         = pChannelInfo->midi_port;          m_iMidiPort         = pChannelInfo->midi_port;
602          m_iMidiChannel      = pChannelInfo->midi_channel;          m_iMidiChannel      = pChannelInfo->midi_channel;
603    #ifdef CONFIG_MIDI_INSTRUMENT
604            m_iMidiMap          = pChannelInfo->midi_map;
605    #endif
606          m_iAudioDevice      = pChannelInfo->audio_device;          m_iAudioDevice      = pChannelInfo->audio_device;
607          m_fVolume           = pChannelInfo->volume;          m_fVolume           = pChannelInfo->volume;
608  #ifdef CONFIG_MUTE_SOLO  #ifdef CONFIG_MUTE_SOLO
# Line 570  bool qsamplerChannel::updateChannelInfo Line 621  bool qsamplerChannel::updateChannelInfo
621          lscp_device_info_t *pDeviceInfo;          lscp_device_info_t *pDeviceInfo;
622          const QString sNone = QObject::tr("(none)");          const QString sNone = QObject::tr("(none)");
623          // Audio device driver type.          // Audio device driver type.
624          pDeviceInfo = ::lscp_get_audio_device_info(client(), m_iAudioDevice);          pDeviceInfo = ::lscp_get_audio_device_info(pMainForm->client(), m_iAudioDevice);
625          if (pDeviceInfo == NULL) {          if (pDeviceInfo == NULL) {
626                  appendMessagesClient("lscp_get_audio_device_info");                  appendMessagesClient("lscp_get_audio_device_info");
627                  m_sAudioDriver = sNone;                  m_sAudioDriver = sNone;
# Line 578  bool qsamplerChannel::updateChannelInfo Line 629  bool qsamplerChannel::updateChannelInfo
629                  m_sAudioDriver = pDeviceInfo->driver;                  m_sAudioDriver = pDeviceInfo->driver;
630          }          }
631          // MIDI device driver type.          // MIDI device driver type.
632          pDeviceInfo = ::lscp_get_midi_device_info(client(), m_iMidiDevice);          pDeviceInfo = ::lscp_get_midi_device_info(pMainForm->client(), m_iMidiDevice);
633          if (pDeviceInfo == NULL) {          if (pDeviceInfo == NULL) {
634                  appendMessagesClient("lscp_get_midi_device_info");                  appendMessagesClient("lscp_get_midi_device_info");
635                  m_sMidiDriver = sNone;                  m_sMidiDriver = sNone;
# Line 588  bool qsamplerChannel::updateChannelInfo Line 639  bool qsamplerChannel::updateChannelInfo
639    
640          // Set the audio routing map.          // Set the audio routing map.
641          m_audioRouting.clear();          m_audioRouting.clear();
642          char **ppszRouting = pChannelInfo->audio_routing;  #ifdef CONFIG_AUDIO_ROUTING
643          for (int i = 0; ppszRouting && ppszRouting[i]; i++) {          int *piAudioRouting = pChannelInfo->audio_routing;
644                  m_audioRouting[i] = ::atoi(ppszRouting[i]);          for (int i = 0; piAudioRouting && piAudioRouting[i] >= 0; i++)
645          }                  m_audioRouting[i] = piAudioRouting[i];
646    #else
647            char **ppszAudioRouting = pChannelInfo->audio_routing;
648            for (int i = 0; ppszAudioRouting && ppszAudioRouting[i]; i++)
649                    m_audioRouting[i] = ::atoi(ppszAudioRouting[i]);
650    #endif
651    
652          return true;          return true;
653  }  }
# Line 600  bool qsamplerChannel::updateChannelInfo Line 656  bool qsamplerChannel::updateChannelInfo
656  // Reset channel method.  // Reset channel method.
657  bool qsamplerChannel::channelReset (void)  bool qsamplerChannel::channelReset (void)
658  {  {
659          if (client() == NULL || m_iChannelID < 0)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
660            if (pMainForm == NULL)
661                    return false;
662            if (pMainForm->client() == NULL || m_iChannelID < 0)
663                  return false;                  return false;
664    
665          if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) {          if (::lscp_reset_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) {
666                  appendMessagesClient("lscp_reset_channel");                  appendMessagesClient("lscp_reset_channel");
667                  return false;                  return false;
668          }          }
# Line 614  bool qsamplerChannel::channelReset (void Line 673  bool qsamplerChannel::channelReset (void
673  }  }
674    
675    
676    // Spawn instrument editor method.
677    bool qsamplerChannel::editChannel (void)
678    {
679    #ifdef CONFIG_EDIT_INSTRUMENT
680            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
681            if (pMainForm == NULL)
682                    return false;
683            if (pMainForm->client() == NULL || m_iChannelID < 0)
684                    return false;
685    
686            if (::lscp_edit_instrument(pMainForm->client(), m_iChannelID) != LSCP_OK) {
687                    appendMessagesClient("lscp_edit_instrument");
688                    appendMessagesError(
689                            "Could not launch an appropriate instrument editor for the\n"
690                            "given instrument! Make sure you have an appropriate\n"
691                            "instrument editor like 'gigedit' installed and that it placed\n"
692                            "its mandatory DLL file into the sampler's plugin directory."
693                    );
694                    return false;
695            }
696    
697            appendMessages(QObject::tr("edit instrument."));
698    
699            return true;
700    #else
701            appendMessagesError(
702                    "Sorry, QSampler was compiled for a version of liblscp which lacks\n"
703                    "this feature. You may want to update liblscp and recompile\n"
704                    "QSampler afterwards."
705            );
706            return false;
707    #endif
708    }
709    
710    
711  // Channel setup dialog form.  // Channel setup dialog form.
712  bool qsamplerChannel::channelSetup ( QWidget *pParent )  bool qsamplerChannel::channelSetup ( QWidget *pParent )
713  {  {
714            qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
715            if (pMainForm == NULL)
716                    return false;
717    
718          bool bResult = false;          bool bResult = false;
719    
720          appendMessages(QObject::tr("setup..."));          appendMessages(QObject::tr("setup..."));
# Line 635  bool qsamplerChannel::channelSetup ( QWi Line 733  bool qsamplerChannel::channelSetup ( QWi
733  // Redirected messages output methods.  // Redirected messages output methods.
734  void qsamplerChannel::appendMessages( const QString& s ) const  void qsamplerChannel::appendMessages( const QString& s ) const
735  {  {
736          if (m_pMainForm)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
737                  m_pMainForm->appendMessages(channelName() + ' ' + s);          if (pMainForm)
738                    pMainForm->appendMessages(channelName() + ' ' + s);
739  }  }
740    
741  void qsamplerChannel::appendMessagesColor( const QString& s,  void qsamplerChannel::appendMessagesColor( const QString& s,
742          const QString& c ) const          const QString& c ) const
743  {  {
744          if (m_pMainForm)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
745                  m_pMainForm->appendMessagesColor(channelName() + ' ' + s, c);          if (pMainForm)
746                    pMainForm->appendMessagesColor(channelName() + ' ' + s, c);
747  }  }
748    
749  void qsamplerChannel::appendMessagesText( const QString& s ) const  void qsamplerChannel::appendMessagesText( const QString& s ) const
750  {  {
751          if (m_pMainForm)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
752                  m_pMainForm->appendMessagesText(channelName() + ' ' + s);          if (pMainForm)
753                    pMainForm->appendMessagesText(channelName() + ' ' + s);
754  }  }
755    
756  void qsamplerChannel::appendMessagesError( const QString& s ) const  void qsamplerChannel::appendMessagesError( const QString& s ) const
757  {  {
758          if (m_pMainForm)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
759                  m_pMainForm->appendMessagesError(channelName() + "\n\n" + s);          if (pMainForm)
760                    pMainForm->appendMessagesError(channelName() + "\n\n" + s);
761  }  }
762    
763  void qsamplerChannel::appendMessagesClient( const QString& s ) const  void qsamplerChannel::appendMessagesClient( const QString& s ) const
764  {  {
765          if (m_pMainForm)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
766                  m_pMainForm->appendMessagesClient(channelName() + ' ' + s);          if (pMainForm)
767                    pMainForm->appendMessagesClient(channelName() + ' ' + s);
768  }  }
769    
770    
771  // Context menu event handler.  // Context menu event handler.
772  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )
773  {  {
774          if (m_pMainForm)          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
775                  m_pMainForm->contextMenuEvent(pEvent);          if (pMainForm)
776                    pMainForm->contextMenuEvent(pEvent);
777  }  }
778    
779    

Legend:
Removed from v.824  
changed lines
  Added in v.1366

  ViewVC Help
Powered by ViewVC