/[svn]/linuxsampler/trunk/src/engines/EngineChannelBase.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/EngineChannelBase.h

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

revision 2427 by persson, Sat Mar 2 07:03:04 2013 UTC revision 2611 by schoenebeck, Mon Jun 9 19:20:37 2014 UTC
# Line 39  namespace LinuxSampler { Line 39  namespace LinuxSampler {
39              bool bChangeInstrument;       ///< Set to true by the loader when the channel should change instrument.              bool bChangeInstrument;       ///< Set to true by the loader when the channel should change instrument.
40              I* pInstrument;               ///< The new instrument. Also used by the loader to read the previously loaded instrument.              I* pInstrument;               ///< The new instrument. Also used by the loader to read the previously loaded instrument.
41              RTList<R*>* pRegionsInUse; ///< List of dimension regions in use by the currently loaded instrument. Continuously updated by the audio thread.              RTList<R*>* pRegionsInUse; ///< List of dimension regions in use by the currently loaded instrument. Continuously updated by the audio thread.
42                InstrumentScript* pScript; ///< Instrument script to be executed for this instrument, or NULL if instrument does not have a script.
43      };      };
44    
45      template<class R>      template<class R>
# Line 237  namespace LinuxSampler { Line 238  namespace LinuxSampler {
238               * we are currently using on this EngineChannel is going to be updated,               * we are currently using on this EngineChannel is going to be updated,
239               * so we can stop playback before that happens.               * so we can stop playback before that happens.
240               */               */
241              virtual void ResourceToBeUpdated(I* pResource, void*& pUpdateArg) {              virtual void ResourceToBeUpdated(I* pResource, void*& pUpdateArg) OVERRIDE {
242                  dmsg(3,("EngineChannelBase: Received instrument update message.\n"));                  dmsg(3,("EngineChannelBase: Received instrument update message.\n"));
243                  if (pEngine) pEngine->DisableAndLock();                  if (pEngine) pEngine->DisableAndLock();
244                  ResetInternal();                  ResetInternal();
# Line 248  namespace LinuxSampler { Line 249  namespace LinuxSampler {
249               * Will be called by the InstrumentResourceManager when the instrument               * Will be called by the InstrumentResourceManager when the instrument
250               * update process was completed, so we can continue with playback.               * update process was completed, so we can continue with playback.
251               */               */
252              virtual void ResourceUpdated(I* pOldResource, I* pNewResource, void* pUpdateArg) {              virtual void ResourceUpdated(I* pOldResource, I* pNewResource, void* pUpdateArg) OVERRIDE {
253                  this->pInstrument = pNewResource; //TODO: there are couple of engine parameters we should update here as well if the instrument was updated (see LoadInstrument())                  this->pInstrument = pNewResource; //TODO: there are couple of engine parameters we should update here as well if the instrument was updated (see LoadInstrument())
254                  if (pEngine) pEngine->Enable();                  if (pEngine) pEngine->Enable();
255                  bStatusChanged = true; // status of engine has changed, so set notify flag                  bStatusChanged = true; // status of engine has changed, so set notify flag
# Line 260  namespace LinuxSampler { Line 261  namespace LinuxSampler {
261               *               *
262               * @param fProgress - current progress as value between 0.0 and 1.0               * @param fProgress - current progress as value between 0.0 and 1.0
263               */               */
264              virtual void OnResourceProgress(float fProgress) {              virtual void OnResourceProgress(float fProgress) OVERRIDE {
265                  this->InstrumentStat = int(fProgress * 100.0f);                  this->InstrumentStat = int(fProgress * 100.0f);
266                  dmsg(7,("EngineChannelBase: progress %d%", InstrumentStat));                  dmsg(7,("EngineChannelBase: progress %d%", InstrumentStat));
267                  bStatusChanged = true; // status of engine has changed, so set notify flag                  bStatusChanged = true; // status of engine has changed, so set notify flag
# Line 289  namespace LinuxSampler { Line 290  namespace LinuxSampler {
290                      InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate();                      InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate();
291                      cmd.pRegionsInUse = NULL;                      cmd.pRegionsInUse = NULL;
292                      cmd.pInstrument = NULL;                      cmd.pInstrument = NULL;
293                        cmd.pScript = new InstrumentScript(this);
294                      cmd.bChangeInstrument = false;                      cmd.bChangeInstrument = false;
295                  }                  }
296                  {                  {
297                      InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig();                      InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig();
298                      cmd.pRegionsInUse = NULL;                      cmd.pRegionsInUse = NULL;
299                      cmd.pInstrument = NULL;                      cmd.pInstrument = NULL;
300                        cmd.pScript = new InstrumentScript(this);
301                      cmd.bChangeInstrument = false;                      cmd.bChangeInstrument = false;
302                  }                  }
303              }              }
304    
305              virtual ~EngineChannelBase() { }              virtual ~EngineChannelBase() {
306                    {
307                        InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate();
308                        if (cmd.pScript) delete cmd.pScript;
309                    }
310                    {
311                        InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig();
312                        if (cmd.pScript) delete cmd.pScript;
313                    }
314                }
315    
316              typedef typename RTList<V>::Iterator RTListVoiceIterator;              typedef typename RTList<V>::Iterator RTListVoiceIterator;
317    
# Line 352  namespace LinuxSampler { Line 364  namespace LinuxSampler {
364              }              }
365    
366              /**              /**
367                 * Load real-time instrument script and all its resources required
368                 * for the upcoming instrument change.
369                 *
370                 * @param text - source code of script
371                 */
372                void LoadInstrumentScript(const String& text) {
373                    InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate();
374                    // unload *PRE*-previous script
375                    cmd.pScript->reset(); //TODO: previous script should be freed as soon as the EngineBase switched the instrument, right now 2 scripts are kept in memory all the time, even though the old one is not used anymore
376                    // load the new script
377                    cmd.pScript->load(text);
378                }
379    
380                /**
381               * Changes the instrument for an engine channel.               * Changes the instrument for an engine channel.
382               *               *
383               * @param pInstrument - new instrument               * @param pInstrument - new instrument

Legend:
Removed from v.2427  
changed lines
  Added in v.2611

  ViewVC Help
Powered by ViewVC