/[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 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 2448 by schoenebeck, Fri May 3 14:26:32 2013 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
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-2009 Christian Schoenebeck                         *   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7   *   Copyright (C) 2009 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 "../drivers/audio/AudioOutputDevice.h"  #include "../drivers/audio/AudioOutputDevice.h"
36  #include "common/Event.h"  #include "common/Event.h"
37    #include "common/SignalUnitRack.h"
38    
39  namespace LinuxSampler {  namespace LinuxSampler {
40    
# Line 50  namespace LinuxSampler { Line 52  namespace LinuxSampler {
52              virtual ~AbstractEngine();              virtual ~AbstractEngine();
53    
54              // implementation of abstract methods derived from class 'LinuxSampler::Engine'              // implementation of abstract methods derived from class 'LinuxSampler::Engine'
55              virtual void   SendSysex(void* pData, uint Size, MidiInputPort* pSender);              virtual void   SendSysex(void* pData, uint Size, MidiInputPort* pSender) OVERRIDE;
56              virtual void   Reset();              virtual void   Reset() OVERRIDE;
57              virtual void   Enable();              virtual void   Enable() OVERRIDE;
58              virtual void   Disable();              virtual void   Disable() OVERRIDE;
59              virtual uint   VoiceCount();              virtual uint   VoiceCount() OVERRIDE;
60              virtual uint   VoiceCountMax();              virtual uint   VoiceCountMax() OVERRIDE;
61              virtual String EngineName();              virtual String EngineName() OVERRIDE;
62                virtual void   AdjustScaleTuning(const int8_t ScaleTunes[12]) OVERRIDE;
63                virtual void   GetScaleTuning(int8_t* pScaleTunes) OVERRIDE;
64                virtual void   ResetScaleTuning() OVERRIDE;
65    
66              virtual Format GetEngineFormat() = 0;              virtual Format GetEngineFormat() = 0;
67              virtual void   Connect(AudioOutputDevice* pAudioOut) = 0;              virtual void   Connect(AudioOutputDevice* pAudioOut) = 0;
68              virtual void   DisableAndLock();              virtual void   DisableAndLock();
69    
70              void SetVoiceCount(uint Count);// Simple array wrapper just to make sure memory is freed              void SetVoiceCount(uint Count);
71    
72                float Random() {
73                    RandomSeed = RandomSeed * 1103515245 + 12345; // classic pseudo random number generator
74                    return RandomSeed / 4294967296.0f;
75                }
76    
77                // Simple array wrapper just to make sure memory is freed
78              // when liblinuxsampler is unloaded              // when liblinuxsampler is unloaded
79              class FloatTable {              class FloatTable {
80              private:              private:
# Line 78  namespace LinuxSampler { Line 90  namespace LinuxSampler {
90              static const FloatTable CrossfadeCurve; ///< Table that maps crossfade control change values 0..127 to amplitude. Unity gain is at 127.              static const FloatTable CrossfadeCurve; ///< Table that maps crossfade control change values 0..127 to amplitude. Unity gain is at 127.
91    
92              AudioOutputDevice* pAudioOutputDevice;              AudioOutputDevice* pAudioOutputDevice;
93                
94                //TODO: should be protected
95                AudioChannel* pDedicatedVoiceChannelLeft;  ///< encapsulates a special audio rendering buffer (left) for rendering and routing audio on a per voice basis (this is a very special case and only used for voices which lie on a note which was set with individual, dedicated FX send level)
96                AudioChannel* pDedicatedVoiceChannelRight; ///< encapsulates a special audio rendering buffer (right) for rendering and routing audio on a per voice basis (this is a very special case and only used for voices which lie on a note which was set with individual, dedicated FX send level)
97    
98                friend class AbstractVoice;
99              friend class AbstractEngineChannel;              friend class AbstractEngineChannel;
100              template<class V, class R, class I> friend class EngineChannelBase;              template<class V, class R, class I> friend class EngineChannelBase;
101                template<class EC, class R, class S, class D> friend class VoiceBase;
102    
103          protected:          protected:
104              ArrayList<EngineChannel*>  engineChannels; ///< All engine channels of a Engine instance.              ArrayList<EngineChannel*>  engineChannels; ///< All engine channels of a Engine instance.
105              ConditionServer            EngineDisabled;              ConditionServer            EngineDisabled;
106              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
107                ChangeFlagRelaxed          ScaleTuningChanged; ///< Boolean flag indicating whenever ScaleTuning has been modified by a foreign thread (i.e. by API).
108              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).
109              EventGenerator*            pEventGenerator;              EventGenerator*            pEventGenerator;
110              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).
111              Pool<Event>*               pEventPool;            ///< Contains all Event objects that can be used.              Pool<Event>*               pEventPool;            ///< Contains all Event objects that can be used.
112              RingBuffer<uint8_t,false>* pSysexBuffer;       ///< Input buffer for MIDI system exclusive messages.              RingBuffer<uint8_t,false>* pSysexBuffer;          ///< Input buffer for MIDI system exclusive messages.
113              uint                       SampleRate;            ///< Sample rate of the engines output audio signal (in Hz)              uint                       SampleRate;            ///< Sample rate of the engines output audio signal (in Hz)
114              uint                       MaxSamplesPerCycle;    ///< Size of each audio output buffer              uint                       MaxSamplesPerCycle;    ///< Size of each audio output buffer
115              unsigned long              FrameTime; ///< Time in frames of the start of the current audio fragment              unsigned long              FrameTime;             ///< Time in frames of the start of the current audio fragment
116              int                        ActiveVoiceCountMax;   ///< the maximum voice usage since application start              int                        ActiveVoiceCountMax;   ///< the maximum voice usage since application start
117              atomic_t                   ActiveVoiceCount; ///< number of currently active voices              atomic_t                   ActiveVoiceCount;      ///< number of currently active voices
118                int                        VoiceSpawnsLeft;       ///< We only allow CONFIG_MAX_VOICES voices to be spawned per audio fragment, we use this variable to ensure this limit.
119    
120              void RouteAudio(EngineChannel* pEngineChannel, uint Samples);              void RouteAudio(EngineChannel* pEngineChannel, uint Samples);
121                void RouteDedicatedVoiceChannels(EngineChannel* pEngineChannel, optional<float> FxSendLevels[2], uint Samples);
122              void ClearEventLists();              void ClearEventLists();
123              void ImportEvents(uint Samples);              void ImportEvents(uint Samples);
124              void ProcessSysex(Pool<Event>::Iterator& itSysexEvent);              void ProcessSysex(Pool<Event>::Iterator& itSysexEvent);
             void ResetScaleTuning();  
125              void ProcessPitchbend(AbstractEngineChannel* pEngineChannel, Pool<Event>::Iterator& itPitchbendEvent);              void ProcessPitchbend(AbstractEngineChannel* pEngineChannel, Pool<Event>::Iterator& itPitchbendEvent);
126    
127              void ProcessFxSendControllers (              void ProcessFxSendControllers (
# Line 116  namespace LinuxSampler { Line 136  namespace LinuxSampler {
136              virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) = 0;              virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) = 0;
137              virtual void ProcessNoteOff(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOffEvent) = 0;              virtual void ProcessNoteOff(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOffEvent) = 0;
138              virtual void ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent) = 0;              virtual void ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent) = 0;
139                virtual int  GetMinFadeOutSamples() = 0;
140    
141          private:          private:
142              static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines;              static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines;
143                uint32_t RandomSeed; ///< State of the random number generator used by the random dimension.
144    
145              static float* InitVolumeCurve();              static float* InitVolumeCurve();
146              static float* InitPanCurve();              static float* InitPanCurve();
147              static float* InitCrossfadeCurve();              static float* InitCrossfadeCurve();
148              static float* InitCurve(const float* segments, int size = 128);              static float* InitCurve(const float* segments, int size = 128);
149    
150              void AdjustScale(int8_t ScaleTunes[12]);              bool RouteFxSend(FxSend* pFxSend, AudioChannel* ppSource[2], float FxSendLevel, uint Samples);
151      };      };
152    
153  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2012  
changed lines
  Added in v.2448

  ViewVC Help
Powered by ViewVC