/[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 414 by capela, Tue Mar 1 10:31:09 2005 UTC revision 748 by capela, Wed Aug 17 23:03:26 2005 UTC
# Line 42  Line 42 
42  // Constructor.  // Constructor.
43  qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID )  qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID )
44  {  {
45      m_pMainForm  = pMainForm;          m_pMainForm  = pMainForm;
46      m_iChannelID = iChannelID;          m_iChannelID = iChannelID;
47    
48  //  m_sEngineName       = noEngineName();  //  m_sEngineName       = noEngineName();
49  //  m_sInstrumentName   = noInstrumentName();  //  m_sInstrumentName   = noInstrumentName();
50  //  m_sInstrumentFile   = m_sInstrumentName;  //  m_sInstrumentFile   = m_sInstrumentName;
51      m_iInstrumentNr     = -1;          m_iInstrumentNr     = -1;
52      m_iInstrumentStatus = -1;          m_iInstrumentStatus = -1;
53      m_sMidiDriver       = "Alsa";   // DEPRECATED.          m_sMidiDriver       = "ALSA";
54      m_iMidiDevice       = -1;          m_iMidiDevice       = -1;
55      m_iMidiPort         = -1;          m_iMidiPort         = -1;
56      m_iMidiChannel      = -1;          m_iMidiChannel      = -1;
57      m_sAudioDriver      = "Alsa";   // DEPRECATED.          m_sAudioDriver      = "ALSA";
58      m_iAudioDevice      = -1;          m_iAudioDevice      = -1;
59      m_fVolume           = 0.0;          m_fVolume           = 0.0;
60    
61  }  }
62    
# Line 66  qsamplerChannel::~qsamplerChannel (void) Line 66  qsamplerChannel::~qsamplerChannel (void)
66  }  }
67    
68    
69    // Main application form accessor.
70    qsamplerMainForm *qsamplerChannel::mainForm(void) const
71    {
72            return m_pMainForm;
73    }
74    
75    
76  // The global options settings delegated property.  // The global options settings delegated property.
77  qsamplerOptions *qsamplerChannel::options (void)  qsamplerOptions *qsamplerChannel::options (void) const
78  {  {
79      if (m_pMainForm == NULL)          if (m_pMainForm == NULL)
80          return NULL;                  return NULL;
81    
82      return m_pMainForm->options();          return m_pMainForm->options();
83  }  }
84    
85    
86  // The client descriptor delegated property.  // The client descriptor delegated property.
87  lscp_client_t *qsamplerChannel::client (void)  lscp_client_t *qsamplerChannel::client (void) const
88  {  {
89      if (m_pMainForm == NULL)          if (m_pMainForm == NULL)
90          return NULL;                  return NULL;
91    
92      return m_pMainForm->client();          return m_pMainForm->client();
93  }  }
94    
95    
96  // Create a new sampler channel, if not already.  // Create a new sampler channel, if not already.
97  bool qsamplerChannel::addChannel (void)  bool qsamplerChannel::addChannel (void)
98  {  {
99      if (client() == NULL)          if (client() == NULL)
100          return false;                  return false;
101    
102      // Are we a new channel?          // Are we a new channel?
103      if (m_iChannelID < 0) {          if (m_iChannelID < 0) {
104          m_iChannelID = ::lscp_add_channel(client());                  m_iChannelID = ::lscp_add_channel(client());
105          if (m_iChannelID < 0) {                  if (m_iChannelID < 0) {
106              appendMessagesClient("lscp_add_channel");                          appendMessagesClient("lscp_add_channel");
107              appendMessagesError(QObject::tr("Could not add channel.\n\nSorry."));                          appendMessagesError(QObject::tr("Could not add channel.\n\nSorry."));
108          }   // Otherwise it's created...                  }   // Otherwise it's created...
109          else appendMessages(QObject::tr("added."));                  else appendMessages(QObject::tr("added."));
110      }          }
111    
112      // Return whether we're a valid channel...          // Return whether we're a valid channel...
113      return (m_iChannelID >= 0);          return (m_iChannelID >= 0);
114  }  }
115    
116    
117  // Remove sampler channel.  // Remove sampler channel.
118  bool qsamplerChannel::removeChannel (void)  bool qsamplerChannel::removeChannel (void)
119  {  {
120      if (client() == NULL)          if (client() == NULL)
121          return false;                  return false;
122    
123      // Are we an existing channel?          // Are we an existing channel?
124      if (m_iChannelID >= 0) {          if (m_iChannelID >= 0) {
125          if (::lscp_remove_channel(client(), m_iChannelID) != LSCP_OK) {                  if (::lscp_remove_channel(client(), m_iChannelID) != LSCP_OK) {
126              appendMessagesClient("lscp_remove_channel");                          appendMessagesClient("lscp_remove_channel");
127              appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry."));                          appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry."));
128          } else {                  } else {
129              // Otherwise it's removed.                          // Otherwise it's removed.
130              appendMessages(QObject::tr("removed."));                          appendMessages(QObject::tr("removed."));
131              m_iChannelID = -1;                          m_iChannelID = -1;
132          }                  }
133      }          }
134        
135      // Return whether we've removed the channel...          // Return whether we've removed the channel...
136      return (m_iChannelID < 0);          return (m_iChannelID < 0);
137  }  }
138    
139    
140  // Channel-ID (aka Sammpler-Channel) accessors.  // Channel-ID (aka Sammpler-Channel) accessors.
141  int qsamplerChannel::channelID (void)  int qsamplerChannel::channelID (void) const
142  {  {
143      return m_iChannelID;          return m_iChannelID;
144  }  }
145    
146  void qsamplerChannel::setChannelID ( int iChannelID )  void qsamplerChannel::setChannelID ( int iChannelID )
147  {  {
148      m_iChannelID = iChannelID;          m_iChannelID = iChannelID;
149  }  }
150    
151    
152  // Readable channel name.  // Readable channel name.
153  QString qsamplerChannel::channelName (void)  QString qsamplerChannel::channelName (void) const
154  {  {
155      return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID));          return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID));
156  }  }
157    
158    
159  // Engine name accessors.  // Engine name accessors.
160  QString& qsamplerChannel::engineName (void)  const QString& qsamplerChannel::engineName (void) const
161  {  {
162      return m_sEngineName;          return m_sEngineName;
163  }  }
164    
165  bool qsamplerChannel::loadEngine ( const QString& sEngineName )  bool qsamplerChannel::loadEngine ( const QString& sEngineName )
166  {  {
167      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
168          return false;                  return false;
169          if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName)          if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName)
170              return true;                  return true;
171                
172      if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {          if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) {
173          appendMessagesClient("lscp_load_engine");                  appendMessagesClient("lscp_load_engine");
174          return false;                  return false;
175      }          }
176      appendMessages(QObject::tr("Engine: %1.").arg(sEngineName));          appendMessages(QObject::tr("Engine: %1.").arg(sEngineName));
177    
178      m_sEngineName = sEngineName;          m_sEngineName = sEngineName;
179      return true;          return true;
180  }  }
181    
182    
183  // Instrument filename accessor.  // Instrument filename accessor.
184  QString& qsamplerChannel::instrumentFile (void)  const QString& qsamplerChannel::instrumentFile (void) const
185  {  {
186      return m_sInstrumentFile;          return m_sInstrumentFile;
187  }  }
188    
189  // Instrument index accessor.  // Instrument index accessor.
190  int qsamplerChannel::instrumentNr (void)  int qsamplerChannel::instrumentNr (void) const
191  {  {
192      return m_iInstrumentNr;          return m_iInstrumentNr;
193  }  }
194    
195  // Instrument name accessor.  // Instrument name accessor.
196  QString& qsamplerChannel::instrumentName (void)  const QString& qsamplerChannel::instrumentName (void) const
197  {  {
198      return m_sInstrumentName;          return m_sInstrumentName;
199  }  }
200    
201  // Instrument status accessor.  // Instrument status accessor.
202  int qsamplerChannel::instrumentStatus (void)  int qsamplerChannel::instrumentStatus (void) const
203  {  {
204      return m_iInstrumentStatus;          return m_iInstrumentStatus;
205  }  }
206    
207  // Instrument file loader.  // Instrument file loader.
208  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )
209  {  {
210      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
211          return false;                  return false;
212          if (!isInstrumentFile(sInstrumentFile))          if (!isInstrumentFile(sInstrumentFile))
213              return false;                  return false;
214          if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr)          if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr)
215              return true;                  return true;
216    
217      if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {          if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {
218          appendMessagesClient("lscp_load_instrument");                  appendMessagesClient("lscp_load_instrument");
219          return false;                  return false;
220      }          }
221    
222      appendMessages(QObject::tr("Instrument: \"%1\" (%2).")          appendMessages(QObject::tr("Instrument: \"%1\" (%2).")
223                  .arg(sInstrumentFile).arg(iInstrumentNr));                  .arg(sInstrumentFile).arg(iInstrumentNr));
224                    
225      return setInstrument(sInstrumentFile, iInstrumentNr);          return setInstrument(sInstrumentFile, iInstrumentNr);
226  }  }
227    
228    
229  // Special instrument file/name/number settler.  // Special instrument file/name/number settler.
230  bool qsamplerChannel::setInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  bool qsamplerChannel::setInstrument ( const QString& sInstrumentFile, int iInstrumentNr )
231  {  {
232      m_sInstrumentFile = sInstrumentFile;          m_sInstrumentFile = sInstrumentFile;
233      m_iInstrumentNr = iInstrumentNr;          m_iInstrumentNr = iInstrumentNr;
234  #ifdef CONFIG_INSTRUMENT_NAME  #ifdef CONFIG_INSTRUMENT_NAME
235      m_sInstrumentName = QString::null;  // We'll get it, maybe later, on channel_info...          m_sInstrumentName = QString::null;  // We'll get it, maybe later, on channel_info...
236  #else  #else
237      m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true);          m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true);
238  #endif  #endif
239      m_iInstrumentStatus = 0;          m_iInstrumentStatus = 0;
240    
241          return true;          return true;
242  }  }
243    
244    
245  // MIDI driver type accessors (DEPRECATED).  // MIDI driver type accessors (DEPRECATED).
246  QString& qsamplerChannel::midiDriver (void)  const QString& qsamplerChannel::midiDriver (void) const
247  {  {
248      return m_sMidiDriver;          return m_sMidiDriver;
249  }  }
250    
251  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )
252  {  {
253      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
254          return false;                  return false;
255          if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver)          if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver)
256              return true;                  return true;
257    
258      if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) {          if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) {
259          appendMessagesClient("lscp_set_channel_midi_type");                  appendMessagesClient("lscp_set_channel_midi_type");
260          return false;                  return false;
261      }          }
262    
263      appendMessages(QObject::tr("MIDI driver: %1.").arg(sMidiDriver));          appendMessages(QObject::tr("MIDI driver: %1.").arg(sMidiDriver));
264    
265      m_sMidiDriver = sMidiDriver;          m_sMidiDriver = sMidiDriver;
266      return true;          return true;
267  }  }
268    
269    
270  // MIDI device accessors.  // MIDI device accessors.
271  int qsamplerChannel::midiDevice (void)  int qsamplerChannel::midiDevice (void) const
272  {  {
273      return m_iMidiDevice;          return m_iMidiDevice;
274  }  }
275    
276  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )
277  {  {
278      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
279          return false;                  return false;
280          if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice)          if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice)
281              return true;                  return true;
282    
283      if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) {          if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) {
284          appendMessagesClient("lscp_set_channel_midi_device");                  appendMessagesClient("lscp_set_channel_midi_device");
285          return false;                  return false;
286      }          }
287    
288      appendMessages(QObject::tr("MIDI device: %1.").arg(iMidiDevice));          appendMessages(QObject::tr("MIDI device: %1.").arg(iMidiDevice));
289    
290      m_iMidiDevice = iMidiDevice;          m_iMidiDevice = iMidiDevice;
291      return true;          return true;
292  }  }
293    
294    
295  // MIDI port number accessor.  // MIDI port number accessor.
296  int qsamplerChannel::midiPort (void)  int qsamplerChannel::midiPort (void) const
297  {  {
298      return m_iMidiPort;          return m_iMidiPort;
299  }  }
300    
301  bool qsamplerChannel::setMidiPort ( int iMidiPort )  bool qsamplerChannel::setMidiPort ( int iMidiPort )
302  {  {
303      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
304          return false;                  return false;
305          if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort)          if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort)
306              return true;                  return true;
307    
308      if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) {          if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) {
309          appendMessagesClient("lscp_set_channel_midi_port");                  appendMessagesClient("lscp_set_channel_midi_port");
310          return false;                  return false;
311      }          }
312    
313      appendMessages(QObject::tr("MIDI port: %1.").arg(iMidiPort));          appendMessages(QObject::tr("MIDI port: %1.").arg(iMidiPort));
314    
315      m_iMidiPort = iMidiPort;          m_iMidiPort = iMidiPort;
316      return true;          return true;
317  }  }
318    
319    
320  // MIDI channel accessor.  // MIDI channel accessor.
321  int qsamplerChannel::midiChannel (void)  int qsamplerChannel::midiChannel (void) const
322  {  {
323      return m_iMidiChannel;          return m_iMidiChannel;
324  }  }
325    
326  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )
327  {  {
328      if (client() == NULL || m_iChannelID < 0)          if (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(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      }          }
337    
338      appendMessages(QObject::tr("MIDI channel: %1.").arg(iMidiChannel));          appendMessages(QObject::tr("MIDI channel: %1.").arg(iMidiChannel));
339    
340      m_iMidiChannel = iMidiChannel;          m_iMidiChannel = iMidiChannel;
341      return true;          return true;
342  }  }
343    
344    
345  // Audio device accessor.  // Audio device accessor.
346  int qsamplerChannel::audioDevice (void)  int qsamplerChannel::audioDevice (void) const
347  {  {
348      return m_iAudioDevice;          return m_iAudioDevice;
349  }  }
350    
351  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )
352  {  {
353      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
354          return false;                  return false;
355          if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice)          if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice)
356              return true;                  return true;
357    
358      if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) {          if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) {
359          appendMessagesClient("lscp_set_channel_audio_device");                  appendMessagesClient("lscp_set_channel_audio_device");
360          return false;                  return false;
361      }          }
362    
363      appendMessages(QObject::tr("Audio device: %1.").arg(iAudioDevice));          appendMessages(QObject::tr("Audio device: %1.").arg(iAudioDevice));
364    
365      m_iAudioDevice = iAudioDevice;          m_iAudioDevice = iAudioDevice;
366      return true;          return true;
367  }  }
368    
369    
370  // Audio driver type accessors (DEPRECATED).  // Audio driver type accessors (DEPRECATED).
371  QString& qsamplerChannel::audioDriver (void)  const QString& qsamplerChannel::audioDriver (void) const
372  {  {
373      return m_sAudioDriver;          return m_sAudioDriver;
374  }  }
375    
376  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )
377  {  {
378      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
379          return false;                  return false;
380          if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver)          if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver)
381              return true;                  return true;
382    
383      if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) {          if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) {
384          appendMessagesClient("lscp_set_channel_audio_type");                  appendMessagesClient("lscp_set_channel_audio_type");
385          return false;                  return false;
386      }          }
387    
388      appendMessages(QObject::tr("Audio driver: %1.").arg(sAudioDriver));          appendMessages(QObject::tr("Audio driver: %1.").arg(sAudioDriver));
389    
390      m_sAudioDriver = sAudioDriver;          m_sAudioDriver = sAudioDriver;
391      return true;          return true;
392  }  }
393    
394    
395  // Channel volume accessors.  // Channel volume accessors.
396  float qsamplerChannel::volume (void)  float qsamplerChannel::volume (void) const
397  {  {
398      return m_fVolume;          return m_fVolume;
399  }  }
400    
401  bool qsamplerChannel::setVolume ( float fVolume )  bool qsamplerChannel::setVolume ( float fVolume )
402  {  {
403      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
404          return false;                  return false;
405          if (m_iInstrumentStatus == 100 && m_fVolume == fVolume)          if (m_iInstrumentStatus == 100 && m_fVolume == fVolume)
406              return true;                  return true;
407    
408      if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) {          if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) {
409          appendMessagesClient("lscp_set_channel_volume");                  appendMessagesClient("lscp_set_channel_volume");
410          return false;                  return false;
411      }          }
412    
413      appendMessages(QObject::tr("Volume: %1.").arg(fVolume));          appendMessages(QObject::tr("Volume: %1.").arg(fVolume));
414    
415      m_fVolume = fVolume;          m_fVolume = fVolume;
416      return true;          return true;
417  }  }
418    
419    
# Line 423  void qsamplerChannel::updateInstrumentNa Line 430  void qsamplerChannel::updateInstrumentNa
430  // Update whole channel info state.  // Update whole channel info state.
431  bool qsamplerChannel::updateChannelInfo (void)  bool qsamplerChannel::updateChannelInfo (void)
432  {  {
433      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
434          return false;                  return false;
435    
436      // Read channel information.          // Read channel information.
437      lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);          lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID);
438      if (pChannelInfo == NULL) {          if (pChannelInfo == NULL) {
439          appendMessagesClient("lscp_get_channel_info");                  appendMessagesClient("lscp_get_channel_info");
440          appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry."));                  appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry."));
441          return false;                  return false;
442      }          }
443    
444  #ifdef CONFIG_INSTRUMENT_NAME  #ifdef CONFIG_INSTRUMENT_NAME
445          // We got all actual instrument datum...          // We got all actual instrument datum...
# Line 450  bool qsamplerChannel::updateChannelInfo Line 457  bool qsamplerChannel::updateChannelInfo
457                  updateInstrumentName();                  updateInstrumentName();
458          }          }
459  #endif  #endif
460      // Cache in other channel information.          // Cache in other channel information.
461      m_sEngineName       = pChannelInfo->engine_name;          m_sEngineName       = pChannelInfo->engine_name;
462      m_iInstrumentStatus = pChannelInfo->instrument_status;          m_iInstrumentStatus = pChannelInfo->instrument_status;
463      m_iMidiDevice       = pChannelInfo->midi_device;          m_iMidiDevice       = pChannelInfo->midi_device;
464      m_iMidiPort         = pChannelInfo->midi_port;          m_iMidiPort         = pChannelInfo->midi_port;
465      m_iMidiChannel      = pChannelInfo->midi_channel;          m_iMidiChannel      = pChannelInfo->midi_channel;
466      m_iAudioDevice      = pChannelInfo->audio_device;          m_iAudioDevice      = pChannelInfo->audio_device;
467      m_fVolume           = pChannelInfo->volume;          m_fVolume           = pChannelInfo->volume;
468      // Some sanity checks.          // Some sanity checks.
469      if (m_sEngineName == "NONE" || m_sEngineName.isEmpty())          if (m_sEngineName == "NONE" || m_sEngineName.isEmpty())
470          m_sEngineName = QString::null;                  m_sEngineName = QString::null;
471      if (m_sInstrumentFile == "NONE" || m_sInstrumentFile.isEmpty()) {          if (m_sInstrumentFile == "NONE" || m_sInstrumentFile.isEmpty()) {
472          m_sInstrumentFile = QString::null;                  m_sInstrumentFile = QString::null;
473          m_sInstrumentName = QString::null;                  m_sInstrumentName = QString::null;
474          }          }
475            
476          // FIXME: DEPRECATED...          // Time for device info grabbing...
477          lscp_device_info_t *pDeviceInfo;          lscp_device_info_t *pDeviceInfo;
478          const QString sNone = QObject::tr("(none)");          const QString sNone = QObject::tr("(none)");
479          // Audio device driver type.          // Audio device driver type.
480          pDeviceInfo = ::lscp_get_audio_device_info(client(), m_iAudioDevice);          pDeviceInfo = ::lscp_get_audio_device_info(client(), m_iAudioDevice);
481          if (pDeviceInfo == NULL) {          if (pDeviceInfo == NULL) {
482          appendMessagesClient("lscp_get_audio_device_info");                  appendMessagesClient("lscp_get_audio_device_info");
483                  m_sAudioDriver = sNone;                  m_sAudioDriver = sNone;
484          } else {          } else {
485                  m_sAudioDriver = pDeviceInfo->driver;                  m_sAudioDriver = pDeviceInfo->driver;
# Line 480  bool qsamplerChannel::updateChannelInfo Line 487  bool qsamplerChannel::updateChannelInfo
487          // MIDI device driver type.          // MIDI device driver type.
488          pDeviceInfo = ::lscp_get_midi_device_info(client(), m_iMidiDevice);          pDeviceInfo = ::lscp_get_midi_device_info(client(), m_iMidiDevice);
489          if (pDeviceInfo == NULL) {          if (pDeviceInfo == NULL) {
490          appendMessagesClient("lscp_get_midi_device_info");                  appendMessagesClient("lscp_get_midi_device_info");
491                  m_sMidiDriver = sNone;                  m_sMidiDriver = sNone;
492          } else {          } else {
493                  m_sMidiDriver = pDeviceInfo->driver;                  m_sMidiDriver = pDeviceInfo->driver;
494          }          }
495    
496      return true;          return true;
497  }  }
498    
499    
500  // Reset channel method.  // Reset channel method.
501  bool qsamplerChannel::channelReset (void)  bool qsamplerChannel::channelReset (void)
502  {  {
503      if (client() == NULL || m_iChannelID < 0)          if (client() == NULL || m_iChannelID < 0)
504          return false;                  return false;
505    
506      if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) {          if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) {
507          appendMessagesClient("lscp_reset_channel");                  appendMessagesClient("lscp_reset_channel");
508          return false;                  return false;
509      }          }
510    
511      appendMessages(QObject::tr("reset."));          appendMessages(QObject::tr("reset."));
512    
513      return true;          return true;
514  }  }
515    
516    
517  // Channel setup dialog form.  // Channel setup dialog form.
518  bool qsamplerChannel::channelSetup ( QWidget *pParent )  bool qsamplerChannel::channelSetup ( QWidget *pParent )
519  {  {
520      bool bResult = false;          bool bResult = false;
521    
522      appendMessages(QObject::tr("setup..."));          appendMessages(QObject::tr("setup..."));
523        
524      qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent);          qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent);
525      if (pChannelForm) {          if (pChannelForm) {
526          pChannelForm->setup(this);                  pChannelForm->setup(this);
527          bResult = pChannelForm->exec();                  bResult = pChannelForm->exec();
528          delete pChannelForm;                  delete pChannelForm;
529      }          }
530    
531      return bResult;          return bResult;
532  }  }
533    
534    
535  // Redirected messages output methods.  // Redirected messages output methods.
536  void qsamplerChannel::appendMessages( const QString& s )  void qsamplerChannel::appendMessages( const QString& s ) const
537  {  {
538      if (m_pMainForm)          if (m_pMainForm)
539                  m_pMainForm->appendMessages(channelName() + ' ' + s);                  m_pMainForm->appendMessages(channelName() + ' ' + s);
540  }  }
541    
542  void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c )  void qsamplerChannel::appendMessagesColor( const QString& s,
543            const QString& c ) const
544  {  {
545      if (m_pMainForm)          if (m_pMainForm)
546                  m_pMainForm->appendMessagesColor(channelName() + ' ' + s, c);                  m_pMainForm->appendMessagesColor(channelName() + ' ' + s, c);
547  }  }
548    
549  void qsamplerChannel::appendMessagesText( const QString& s )  void qsamplerChannel::appendMessagesText( const QString& s ) const
550  {  {
551      if (m_pMainForm)          if (m_pMainForm)
552                  m_pMainForm->appendMessagesText(channelName() + ' ' + s);                  m_pMainForm->appendMessagesText(channelName() + ' ' + s);
553  }  }
554    
555  void qsamplerChannel::appendMessagesError( const QString& s )  void qsamplerChannel::appendMessagesError( const QString& s ) const
556  {  {
557      if (m_pMainForm)          if (m_pMainForm)
558                  m_pMainForm->appendMessagesError(channelName() + "\n\n" + s);                  m_pMainForm->appendMessagesError(channelName() + "\n\n" + s);
559  }  }
560    
561  void qsamplerChannel::appendMessagesClient( const QString& s )  void qsamplerChannel::appendMessagesClient( const QString& s ) const
562  {  {
563      if (m_pMainForm)          if (m_pMainForm)
564                  m_pMainForm->appendMessagesClient(channelName() + ' ' + s);                  m_pMainForm->appendMessagesClient(channelName() + ' ' + s);
565  }  }
566    
# Line 560  void qsamplerChannel::appendMessagesClie Line 568  void qsamplerChannel::appendMessagesClie
568  // Context menu event handler.  // Context menu event handler.
569  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )
570  {  {
571      if (m_pMainForm)          if (m_pMainForm)
572                  m_pMainForm->contextMenuEvent(pEvent);                  m_pMainForm->contextMenuEvent(pEvent);
573  }  }
574    
# Line 588  bool qsamplerChannel::isInstrumentFile ( Line 596  bool qsamplerChannel::isInstrumentFile (
596  QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile,  QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile,
597          bool bInstrumentNames )          bool bInstrumentNames )
598  {  {
599      QString sInstrumentName = QFileInfo(sInstrumentFile).fileName();          QString sInstrumentName = QFileInfo(sInstrumentFile).fileName();
600      QStringList instlist;          QStringList instlist;
601    
602      if (isInstrumentFile(sInstrumentFile)) {          if (isInstrumentFile(sInstrumentFile)) {
603  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
604                  if (bInstrumentNames) {                  if (bInstrumentNames) {
605                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1());
606                  gig::File  *pGig  = new gig::File(pRiff);                          gig::File  *pGig  = new gig::File(pRiff);
607                  gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
608                  while (pInstrument) {                          while (pInstrument) {
609                      instlist.append((pInstrument->pInfo)->Name.c_str());                                  instlist.append((pInstrument->pInfo)->Name.c_str());
610                      pInstrument = pGig->GetNextInstrument();                                  pInstrument = pGig->GetNextInstrument();
611                  }                          }
612                  delete pGig;                          delete pGig;
613                  delete pRiff;                          delete pRiff;
614                  }                  }
615                  else                  else
616  #endif  #endif
617          for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++)                  for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++)
618              instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]");                          instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]");
619      }          }
620      else instlist.append(noInstrumentName());          else instlist.append(noInstrumentName());
621    
622      return instlist;          return instlist;
623  }  }
624    
625    
# Line 619  QStringList qsamplerChannel::getInstrume Line 627  QStringList qsamplerChannel::getInstrume
627  QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile,  QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile,
628          int iInstrumentNr, bool bInstrumentNames )          int iInstrumentNr, bool bInstrumentNames )
629  {  {
630      QString sInstrumentName;          QString sInstrumentName;
631    
632      if (isInstrumentFile(sInstrumentFile)) {          if (isInstrumentFile(sInstrumentFile)) {
633                  sInstrumentName = QFileInfo(sInstrumentFile).fileName();                  sInstrumentName = QFileInfo(sInstrumentFile).fileName();
634  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
635                  if (bInstrumentNames) {                  if (bInstrumentNames) {
636                  RIFF::File *pRiff = new RIFF::File(sInstrumentFile);                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1());
637                  gig::File  *pGig  = new gig::File(pRiff);                          gig::File  *pGig  = new gig::File(pRiff);
638                  int iIndex = 0;                          int iIndex = 0;
639                  gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
640                  while (pInstrument) {                          while (pInstrument) {
641                      if (iIndex == iInstrumentNr) {                                  if (iIndex == iInstrumentNr) {
642                          sInstrumentName = (pInstrument->pInfo)->Name.c_str();                                          sInstrumentName = (pInstrument->pInfo)->Name.c_str();
643                          break;                                          break;
644                      }                                  }
645                      iIndex++;                                  iIndex++;
646                      pInstrument = pGig->GetNextInstrument();                                  pInstrument = pGig->GetNextInstrument();
647                  }                          }
648                  delete pGig;                          delete pGig;
649                  delete pRiff;                          delete pRiff;
650                  }                  }
651                  else                  else
652  #endif  #endif
653          sInstrumentName += " [" + QString::number(iInstrumentNr) + "]";                  sInstrumentName += " [" + QString::number(iInstrumentNr) + "]";
654      }          }
655      else sInstrumentName = noInstrumentName();          else sInstrumentName = noInstrumentName();
656    
657      return sInstrumentName;          return sInstrumentName;
658  }  }
659    
660    
# Line 661  QString qsamplerChannel::noInstrumentNam Line 669  QString qsamplerChannel::noInstrumentNam
669          return QObject::tr("(No instrument)");          return QObject::tr("(No instrument)");
670  }  }
671    
672    QString qsamplerChannel::loadingInstrument (void) {
673            return QObject::tr("(Loading instrument...)");
674    }
675    
676    
677  // end of qsamplerChannel.cpp  // end of qsamplerChannel.cpp

Legend:
Removed from v.414  
changed lines
  Added in v.748

  ViewVC Help
Powered by ViewVC