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

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

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

revision 2297 by iliev, Fri Dec 9 15:04:55 2011 UTC revision 2611 by schoenebeck, Mon Jun 9 19:20:37 2014 UTC
# Line 4  Line 4 
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *
6   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7   *   Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev        *   *   Copyright (C) 2009-2013 Christian Schoenebeck and Grigor Iliev        *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
10   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 31  Line 31 
31  #include "../common/ConditionServer.h"  #include "../common/ConditionServer.h"
32  #include "../common/Pool.h"  #include "../common/Pool.h"
33  #include "../common/RingBuffer.h"  #include "../common/RingBuffer.h"
34    #include "../common/ChangeFlagRelaxed.h"
35    #include "../common/ResourceManager.h"
36  #include "../drivers/audio/AudioOutputDevice.h"  #include "../drivers/audio/AudioOutputDevice.h"
37  #include "common/Event.h"  #include "common/Event.h"
38  #include "common/SignalUnitRack.h"  #include "common/SignalUnitRack.h"
39    #include "common/InstrumentScriptVM.h"
40    
41  namespace LinuxSampler {  namespace LinuxSampler {
42    
# Line 51  namespace LinuxSampler { Line 54  namespace LinuxSampler {
54              virtual ~AbstractEngine();              virtual ~AbstractEngine();
55    
56              // implementation of abstract methods derived from class 'LinuxSampler::Engine'              // implementation of abstract methods derived from class 'LinuxSampler::Engine'
57              virtual void   SendSysex(void* pData, uint Size, MidiInputPort* pSender);              virtual void   SendSysex(void* pData, uint Size, MidiInputPort* pSender) OVERRIDE;
58              virtual void   Reset();              virtual void   Reset() OVERRIDE;
59              virtual void   Enable();              virtual void   Enable() OVERRIDE;
60              virtual void   Disable();              virtual void   Disable() OVERRIDE;
61              virtual uint   VoiceCount();              virtual uint   VoiceCount() OVERRIDE;
62              virtual uint   VoiceCountMax();              virtual uint   VoiceCountMax() OVERRIDE;
63              virtual String EngineName();              virtual String EngineName() OVERRIDE;
64                virtual void   AdjustScaleTuning(const int8_t ScaleTunes[12]) OVERRIDE;
65                virtual void   GetScaleTuning(int8_t* pScaleTunes) OVERRIDE;
66                virtual void   ResetScaleTuning() OVERRIDE;
67    
68              virtual Format GetEngineFormat() = 0;              virtual Format GetEngineFormat() = 0;
69              virtual void   Connect(AudioOutputDevice* pAudioOut) = 0;              virtual void   Connect(AudioOutputDevice* pAudioOut) = 0;
70              virtual void   DisableAndLock();              virtual void   DisableAndLock();
71    
72              void SetVoiceCount(uint Count);// Simple array wrapper just to make sure memory is freed              void SetVoiceCount(uint Count);
73              // when liblinuxsampler is unloaded  
74                /**
75                 * Returns event with the given event ID.
76                 */
77                RTList<Event>::Iterator EventByID(int id) {
78                    return pEventPool->fromID(id);
79                }
80    
81              float Random() {              float Random() {
82                  RandomSeed = RandomSeed * 1103515245 + 12345; // classic pseudo random number generator                  RandomSeed = RandomSeed * 1103515245 + 12345; // classic pseudo random number generator
83                  return RandomSeed / 4294967296.0f;                  return RandomSeed / 4294967296.0f;
84              }              }
85                
86                // Simple array wrapper just to make sure memory is freed
87                // when liblinuxsampler is unloaded
88              class FloatTable {              class FloatTable {
89              private:              private:
90                  const float* array;                  const float* array;
# Line 95  namespace LinuxSampler { Line 109  namespace LinuxSampler {
109              template<class V, class R, class I> friend class EngineChannelBase;              template<class V, class R, class I> friend class EngineChannelBase;
110              template<class EC, class R, class S, class D> friend class VoiceBase;              template<class EC, class R, class S, class D> friend class VoiceBase;
111    
112          protected:          //protected:
113              ArrayList<EngineChannel*>  engineChannels; ///< All engine channels of a Engine instance.              ArrayList<EngineChannel*>  engineChannels; ///< All engine channels of a Engine instance.
114              ConditionServer            EngineDisabled;              ConditionServer            EngineDisabled;
115              int8_t                     ScaleTuning[12];    ///< contains optional detune factors (-64..+63 cents) for all 12 semitones of an octave              int8_t                     ScaleTuning[12];    ///< contains optional detune factors (-64..+63 cents) for all 12 semitones of an octave
116                ChangeFlagRelaxed          ScaleTuningChanged; ///< Boolean flag indicating whenever ScaleTuning has been modified by a foreign thread (i.e. by API).
117              RingBuffer<Event,false>*   pEventQueue;        ///< Input event queue for engine global events (e.g. SysEx messages).              RingBuffer<Event,false>*   pEventQueue;        ///< Input event queue for engine global events (e.g. SysEx messages).
118              EventGenerator*            pEventGenerator;              EventGenerator*            pEventGenerator;
119              RTList<Event>*             pGlobalEvents;         ///< All engine global events for the current audio fragment (usually only SysEx messages).              RTList<Event>*             pGlobalEvents;         ///< All engine global events for the current audio fragment (usually only SysEx messages).
# Line 110  namespace LinuxSampler { Line 125  namespace LinuxSampler {
125              int                        ActiveVoiceCountMax;   ///< the maximum voice usage since application start              int                        ActiveVoiceCountMax;   ///< the maximum voice usage since application start
126              atomic_t                   ActiveVoiceCount;      ///< number of currently active voices              atomic_t                   ActiveVoiceCount;      ///< number of currently active voices
127              int                        VoiceSpawnsLeft;       ///< We only allow CONFIG_MAX_VOICES voices to be spawned per audio fragment, we use this variable to ensure this limit.              int                        VoiceSpawnsLeft;       ///< We only allow CONFIG_MAX_VOICES voices to be spawned per audio fragment, we use this variable to ensure this limit.
128              EqSupport*                 pEq;                   ///< Used for per voice equalization              InstrumentScriptVM*        pScriptVM; ///< Real-time instrument script virtual machine runner for this engine.
129    
130              void RouteAudio(EngineChannel* pEngineChannel, uint Samples);              void RouteAudio(EngineChannel* pEngineChannel, uint Samples);
131              void RouteDedicatedVoiceChannels(EngineChannel* pEngineChannel, optional<float> FxSendLevels[2], uint Samples);              void RouteDedicatedVoiceChannels(EngineChannel* pEngineChannel, optional<float> FxSendLevels[2], uint Samples);
132              void ClearEventLists();              void ClearEventLists();
133              void ImportEvents(uint Samples);              void ImportEvents(uint Samples);
134              void ProcessSysex(Pool<Event>::Iterator& itSysexEvent);              void ProcessSysex(Pool<Event>::Iterator& itSysexEvent);
             void ResetScaleTuning();  
135              void ProcessPitchbend(AbstractEngineChannel* pEngineChannel, Pool<Event>::Iterator& itPitchbendEvent);              void ProcessPitchbend(AbstractEngineChannel* pEngineChannel, Pool<Event>::Iterator& itPitchbendEvent);
136    
137              void ProcessFxSendControllers (              void ProcessFxSendControllers (
# Line 132  namespace LinuxSampler { Line 146  namespace LinuxSampler {
146              virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) = 0;              virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) = 0;
147              virtual void ProcessNoteOff(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOffEvent) = 0;              virtual void ProcessNoteOff(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOffEvent) = 0;
148              virtual void ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent) = 0;              virtual void ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent) = 0;
149                virtual void ProcessChannelPressure(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itChannelPressureEvent) = 0;
150                virtual void ProcessPolyphonicKeyPressure(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNotePressureEvent) = 0;
151              virtual int  GetMinFadeOutSamples() = 0;              virtual int  GetMinFadeOutSamples() = 0;
152                virtual void CreateInstrumentScriptVM();
153    
154          private:          private:
155              static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines;              static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines;
# Line 143  namespace LinuxSampler { Line 160  namespace LinuxSampler {
160              static float* InitCrossfadeCurve();              static float* InitCrossfadeCurve();
161              static float* InitCurve(const float* segments, int size = 128);              static float* InitCurve(const float* segments, int size = 128);
162    
             void AdjustScale(int8_t ScaleTunes[12]);  
163              bool RouteFxSend(FxSend* pFxSend, AudioChannel* ppSource[2], float FxSendLevel, uint Samples);              bool RouteFxSend(FxSend* pFxSend, AudioChannel* ppSource[2], float FxSendLevel, uint Samples);
164      };      };
165    

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

  ViewVC Help
Powered by ViewVC