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

Diff of /linuxsampler/trunk/src/engines/gig/Engine.h

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

revision 411 by schoenebeck, Sat Feb 26 02:01:14 2005 UTC revision 475 by schoenebeck, Thu Mar 17 23:56:56 2005 UTC
# Line 35  Line 35 
35  #include "EngineGlobals.h"  #include "EngineGlobals.h"
36  #include "../../common/RingBuffer.h"  #include "../../common/RingBuffer.h"
37  #include "../../common/Pool.h"  #include "../../common/Pool.h"
38    #include "../../common/ArrayList.h"
39  #include "../../common/ConditionServer.h"  #include "../../common/ConditionServer.h"
40  #include "../common/Engine.h"  #include "../common/Engine.h"
41  #include "../common/Event.h"  #include "../common/Event.h"
# Line 43  Line 44 
44  #include "../../network/lscp.h"  #include "../../network/lscp.h"
45  #include "EngineChannel.h"  #include "EngineChannel.h"
46    
47    // identifier of this sampler engine
48    #define LS_GIG_ENGINE_NAME "GigEngine"
49    
50  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
51    
52      // just symbol prototyping      // just symbol prototyping
# Line 56  namespace LinuxSampler { namespace gig { Line 60  namespace LinuxSampler { namespace gig {
60       * Sampler engine for the Gigasampler format.       * Sampler engine for the Gigasampler format.
61       */       */
62      class Engine : public LinuxSampler::Engine {      class Engine : public LinuxSampler::Engine {
63          public:                    public:
64              // methods              // methods
65              Engine();              Engine();
66             ~Engine();             ~Engine();
             int  RenderAudio(LinuxSampler::gig::EngineChannel* pEngineChannel, uint Samples);  
67              void Connect(AudioOutputDevice* pAudioOut);              void Connect(AudioOutputDevice* pAudioOut);
68    
69              // implementation of abstract methods derived from class 'LinuxSampler::Engine'              // implementation of abstract methods derived from class 'LinuxSampler::Engine'
70                virtual int    RenderAudio(uint Samples);
71              virtual void   SendSysex(void* pData, uint Size);              virtual void   SendSysex(void* pData, uint Size);
72              virtual void   Reset();              virtual void   Reset();
73              virtual void   Enable();              virtual void   Enable();
# Line 78  namespace LinuxSampler { namespace gig { Line 82  namespace LinuxSampler { namespace gig {
82              virtual String Description();              virtual String Description();
83              virtual String Version();              virtual String Version();
84              virtual String EngineName();              virtual String EngineName();
85                            
86          //protected:                      //protected:
87              static InstrumentResourceManager instruments;              static InstrumentResourceManager instruments;
88    
89              AudioOutputDevice*      pAudioOutputDevice;              AudioOutputDevice*      pAudioOutputDevice;
90              uint                    SampleRate;            ///< Sample rate of the engines output audio signal (in Hz)              uint                    SampleRate;            ///< Sample rate of the engines output audio signal (in Hz)
91              uint                    MaxSamplesPerCycle;    ///< Size of each audio output buffer              uint                    MaxSamplesPerCycle;    ///< Size of each audio output buffer
92              DiskThread*             pDiskThread;                        DiskThread*             pDiskThread;
93              RingBuffer<Event>*      pEventQueue;           ///< Input event queue for engine global events (e.g. SysEx messages).              RingBuffer<Event>*      pEventQueue;           ///< Input event queue for engine global events (e.g. SysEx messages).
94              Pool<Voice>*            pVoicePool;            ///< Contains all voices that can be activated.                                                  Pool<Voice>*            pVoicePool;            ///< Contains all voices that can be activated.
95              EventGenerator*         pEventGenerator;                          EventGenerator*         pEventGenerator;
96              RTList<Event>*          pVoiceStealingQueue;   ///< All voice-launching events which had to be postponed due to free voice shortage.              RTList<Event>*          pVoiceStealingQueue;   ///< All voice-launching events which had to be postponed due to free voice shortage.
97              RTList<Event>*          pEvents;               ///< All events for the current audio fragment.              RTList<Event>*          pGlobalEvents;         ///< All engine global events for the current audio fragment (usually only SysEx messages).
98              Pool<Event>*            pEventPool;            ///< Contains all Event objects that can be used.              Pool<Event>*            pEventPool;            ///< Contains all Event objects that can be used.
             RTList<Event>*          pCCEvents;             ///< All control change events for the current audio fragment.  
99              RingBuffer<uint8_t>*    pSysexBuffer;          ///< Input buffer for MIDI system exclusive messages.              RingBuffer<uint8_t>*    pSysexBuffer;          ///< Input buffer for MIDI system exclusive messages.
             RTList<Event>*          pSynthesisEvents[Event::destination_count];     ///< Events directly affecting synthesis parameter (like pitch, volume and filter).  
100              float*                  pSynthesisParameters[Event::destination_count]; ///< Matrix with final synthesis parameters for the current audio fragment which will be used in the main synthesis loop.              float*                  pSynthesisParameters[Event::destination_count]; ///< Matrix with final synthesis parameters for the current audio fragment which will be used in the main synthesis loop.
101              biquad_param_t*         pBasicFilterParameters; ///< Biquad parameters of the basic bandpass filter.              biquad_param_t*         pBasicFilterParameters; ///< Biquad parameters of the basic bandpass filter.
102              biquad_param_t*         pMainFilterParameters;  ///< Main biquad parameters of the individual filter (lowpass / bandpass / highpass).              biquad_param_t*         pMainFilterParameters;  ///< Main biquad parameters of the individual filter (lowpass / bandpass / highpass).
103              int                     ActiveVoiceCount;      ///< number of currently active voices              int                     ActiveVoiceCount;      ///< number of currently active voices (this value will be returned for public calls)
104                int                     ActiveVoiceCountTemp;  ///< number of currently active voices (for internal usage, will be used for incrementation)
105              int                     ActiveVoiceCountMax;   ///< the maximum voice usage since application start              int                     ActiveVoiceCountMax;   ///< the maximum voice usage since application start
106                int                     VoiceTheftsLeft;       ///< We only allow MAX_AUDIO_VOICES voices to be stolen per audio fragment, we use this variable to ensure this limit.
107                RTList<Voice>::Iterator itLastStolenVoice;     ///< Only for voice stealing: points to the last voice which was theft in current audio fragment, NULL otherwise.
108                RTList<uint>::Iterator  iuiLastStolenKey;      ///< Only for voice stealing: key number of last key on which the last voice was theft in current audio fragment, NULL otherwise.
109                EngineChannel*          pLastStolenChannel;    ///< Only for voice stealing: points to the engine channel on which the previous voice was stolen in this audio fragment.
110              bool                    SuspensionRequested;              bool                    SuspensionRequested;
111              ConditionServer         EngineDisabled;              ConditionServer         EngineDisabled;
112              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
             RTList<Voice>::Iterator itLastStolenVoice;      ///< Only for voice stealing: points to the last voice which was theft in current audio fragment, NULL otherwise.  
             RTList<uint>::Iterator  iuiLastStolenKey;      ///< Only for voice stealing: key number of last key on which the last voice was theft in current audio fragment, NULL otherwise.  
113              int                     MaxFadeOutPos;         ///< The last position in an audio fragment to allow an instant fade out (e.g. for voice stealing) without leading to clicks.              int                     MaxFadeOutPos;         ///< The last position in an audio fragment to allow an instant fade out (e.g. for voice stealing) without leading to clicks.
114                uint32_t                RandomSeed;            ///< State of the random number generator used by the random dimension.
115    
116                void ProcessEvents(EngineChannel* pEngineChannel, uint Samples);
117                void RenderActiveVoices(EngineChannel* pEngineChannel, uint Samples);
118                void RenderStolenVoices(uint Samples);
119                void PostProcess(EngineChannel* pEngineChannel);
120                void ClearEventLists();
121                void ImportEvents(uint Samples);
122              void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent);              void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent);
123              void ProcessNoteOff(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOffEvent);              void ProcessNoteOff(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOffEvent);
124              void ProcessPitchbend(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itPitchbendEvent);              void ProcessPitchbend(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itPitchbendEvent);
125              void ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent);              void ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent);
126              void ProcessSysex(Pool<Event>::Iterator& itSysexEvent);              void ProcessSysex(Pool<Event>::Iterator& itSysexEvent);
127              Pool<Voice>::Iterator LaunchVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing);              Pool<Voice>::Iterator LaunchVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing);
128              void StealVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent);              int  StealVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent);
129              void FreeVoice(EngineChannel* pEngineChannel, Pool<Voice>::Iterator& itVoice);              void FreeVoice(EngineChannel* pEngineChannel, Pool<Voice>::Iterator& itVoice);
130              void FreeKey(EngineChannel* pEngineChannel, midi_key_info_t* pKey);              void FreeKey(EngineChannel* pEngineChannel, midi_key_info_t* pKey);
131              void ResetSynthesisParameters(Event::destination_t dst, float val);              void ResetSynthesisParameters(Event::destination_t dst, float val);
# Line 129  namespace LinuxSampler { namespace gig { Line 141  namespace LinuxSampler { namespace gig {
141              friend class EGDecay;              friend class EGDecay;
142              friend class VCAManipulator;              friend class VCAManipulator;
143              friend class VCFCManipulator;              friend class VCFCManipulator;
144              friend class VCOManipulator;                          friend class VCOManipulator;
145          private:          private:
146              std::list<EngineChannel*> samplerChannels; ///< All sampler channels of a gig::Engine instance.              ArrayList<EngineChannel*> engineChannels; ///< All engine channels of a gig::Engine instance.
147                            
148              static std::map<AudioOutputDevice*,Engine*> engines; ///< All instances of gig::Engine.              static std::map<AudioOutputDevice*,Engine*> engines; ///< All instances of gig::Engine.
149                            
150              uint8_t GSCheckSum(const RingBuffer<uint8_t>::NonVolatileReader AddrReader, uint DataSize);              uint8_t GSCheckSum(const RingBuffer<uint8_t>::NonVolatileReader AddrReader, uint DataSize);
151              void    AdjustScale(int8_t ScaleTunes[12]);              void    AdjustScale(int8_t ScaleTunes[12]);
152                void    ReleaseAllVoices(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itReleaseEvent);
153                void    KillAllVoices(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itKillEvent);
154      };      };
155    
156  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.411  
changed lines
  Added in v.475

  ViewVC Help
Powered by ViewVC