/[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 133 by capela, Fri Jun 18 14:29:02 2004 UTC revision 250 by schoenebeck, Mon Sep 20 00:31:13 2004 UTC
# Line 29  Line 29 
29  # warning Engine.h included  # warning Engine.h included
30  #endif // DEBUG_HEADERS  #endif // DEBUG_HEADERS
31    
32    #include <map>
33    
34  #include "../../common/RingBuffer.h"  #include "../../common/RingBuffer.h"
35  #include "../../common/RTELMemoryPool.h"  #include "../../common/RTELMemoryPool.h"
36  #include "../../common/ConditionServer.h"  #include "../../common/ConditionServer.h"
# Line 41  Line 43 
43    
44  #define PITCHBEND_SEMITONES             12  #define PITCHBEND_SEMITONES             12
45  #define MAX_AUDIO_VOICES                128  #define MAX_AUDIO_VOICES                128
46    #define SYSEX_BUFFER_SIZE               2048  // 2kB
47    #define VOICE_STEAL_ALGORITHM           voice_steal_algo_oldestkey  ///< @see voice_steal_algo_t for available voice stealing algorithms
48    
49  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
50    
51        using std::map;
52    
53      // just symbol prototyping      // just symbol prototyping
54      class Voice;      class Voice;
55      class DiskThread;      class DiskThread;
# Line 54  namespace LinuxSampler { namespace gig { Line 60  namespace LinuxSampler { namespace gig {
60       */       */
61      class gig::Engine : public LinuxSampler::Engine, public InstrumentConsumer {      class gig::Engine : public LinuxSampler::Engine, public InstrumentConsumer {
62          public:          public:
63                // types
64                enum voice_steal_algo_t {
65                    voice_steal_algo_none,
66                    voice_steal_algo_keymask,
67                    voice_steal_algo_oldestkey
68                };
69    
70              // methods              // methods
71              Engine();              Engine();
72             ~Engine();             ~Engine();
# Line 67  namespace LinuxSampler { namespace gig { Line 80  namespace LinuxSampler { namespace gig {
80              virtual void   SendNoteOff(uint8_t Key, uint8_t Velocity);              virtual void   SendNoteOff(uint8_t Key, uint8_t Velocity);
81              virtual void   SendPitchbend(int Pitch);              virtual void   SendPitchbend(int Pitch);
82              virtual void   SendControlChange(uint8_t Controller, uint8_t Value);              virtual void   SendControlChange(uint8_t Controller, uint8_t Value);
83                virtual void   SendSysex(void* pData, uint Size);
84              virtual float  Volume();              virtual float  Volume();
85              virtual void   Volume(float f);              virtual void   Volume(float f);
86                virtual uint   Channels();
87              virtual void   Connect(AudioOutputDevice* pAudioOut);              virtual void   Connect(AudioOutputDevice* pAudioOut);
88              virtual void   DisconnectAudioOutputDevice();              virtual void   DisconnectAudioOutputDevice();
89                virtual void   SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel);
90                virtual int    OutputChannel(uint EngineAudioChannel);
91              virtual int    RenderAudio(uint Samples);              virtual int    RenderAudio(uint Samples);
92              virtual uint   VoiceCount();              virtual uint   VoiceCount();
93              virtual uint   VoiceCountMax();              virtual uint   VoiceCountMax();
# Line 91  namespace LinuxSampler { namespace gig { Line 108  namespace LinuxSampler { namespace gig {
108              virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg);              virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg);
109          protected:          protected:
110              struct midi_key_info_t {              struct midi_key_info_t {
111                  RTEList<Voice>* pActiveVoices; ///< Contains the active voices associated with the MIDI key.                  RTEList<Voice>* pActiveVoices;  ///< Contains the active voices associated with the MIDI key.
112                  bool            KeyPressed;    ///< Is true if the respective MIDI key is currently pressed.                  bool            KeyPressed;     ///< Is true if the respective MIDI key is currently pressed.
113                  bool            Active;        ///< If the key contains active voices.                  bool            Active;         ///< If the key contains active voices.
114                  uint*           pSelf;         ///< hack to allow fast deallocation of the key from the list of active keys                  bool            ReleaseTrigger; ///< If we have to launch release triggered voice(s) when the key is released
115                  RTEList<Event>* pEvents;       ///< Key specific events (only Note-on, Note-off and sustain pedal currently)                  uint*           pSelf;          ///< hack to allow fast deallocation of the key from the list of active keys
116                    RTEList<Event>* pEvents;        ///< Key specific events (only Note-on, Note-off and sustain pedal currently)
117              };              };
118    
119              static InstrumentResourceManager Instruments;              static InstrumentResourceManager Instruments;
120    
121              AudioOutputDevice*      pAudioOutputDevice;              AudioOutputDevice*      pAudioOutputDevice;
122                float*                  pOutputLeft;           ///< Audio output channel buffer (left)
123                float*                  pOutputRight;          ///< Audio output channel buffer (right)
124                int                     AudioDeviceChannelLeft;  ///< audio device channel number to which the left channel is connected to
125                int                     AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to
126                uint                    SampleRate;            ///< Sample rate of the engines output audio signal (in Hz)
127                uint                    MaxSamplesPerCycle;    ///< Size of each audio output buffer
128              DiskThread*             pDiskThread;              DiskThread*             pDiskThread;
129              uint8_t                 ControllerTable[128];  ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel.              uint8_t                 ControllerTable[128];  ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel.
130              RingBuffer<Event>*      pEventQueue;           ///< Input event queue.              RingBuffer<Event>*      pEventQueue;           ///< Input event queue.
131                RingBuffer<uint8_t>*    pSysexBuffer;          ///< Input buffer for MIDI system exclusive messages.
132              midi_key_info_t         pMIDIKeyInfo[128];     ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key              midi_key_info_t         pMIDIKeyInfo[128];     ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key
133              RTELMemoryPool<Voice>*  pVoicePool;            ///< Contains all voices that can be activated.              RTELMemoryPool<Voice>*  pVoicePool;            ///< Contains all voices that can be activated.
134              RTELMemoryPool<uint>*   pActiveKeys;           ///< Holds all keys in it's allocation list with active voices.              RTELMemoryPool<uint>*   pActiveKeys;           ///< Holds all keys in it's allocation list with active voices.
135              RTELMemoryPool<Event>*  pEventPool;            ///< Contains all Event objects that can be used.              RTELMemoryPool<Event>*  pEventPool;            ///< Contains all Event objects that can be used.
136              EventGenerator*         pEventGenerator;              EventGenerator*         pEventGenerator;
137                RTEList<Event>*         pVoiceStealingQueue;   ///< All voice-launching events which had to be postponed due to free voice shortage.
138              RTEList<Event>*         pEvents;               ///< All events for the current audio fragment.              RTEList<Event>*         pEvents;               ///< All events for the current audio fragment.
139              RTEList<Event>*         pCCEvents;             ///< All control change events for the current audio fragment.              RTEList<Event>*         pCCEvents;             ///< All control change events for the current audio fragment.
140              RTEList<Event>*         pSynthesisEvents[Event::destination_count];     ///< Events directly affecting synthesis parameter (like pitch, volume and filter).              RTEList<Event>*         pSynthesisEvents[Event::destination_count];     ///< Events directly affecting synthesis parameter (like pitch, volume and filter).
141              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.
142              biquad_param_t*         pBasicFilterParameters; ///< Biquad parameters of the basic bandpass filter.              biquad_param_t*         pBasicFilterParameters; ///< Biquad parameters of the basic bandpass filter.
143              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).
144                map<uint,uint*>         ActiveKeyGroups;        ///< Contains active keys (in case they belong to a key group) ordered by key group ID.
145              RIFF::File*             pRIFF;              RIFF::File*             pRIFF;
146              ::gig::File*            pGig;              ::gig::File*            pGig;
147              ::gig::Instrument*      pInstrument;              ::gig::Instrument*      pInstrument;
# Line 128  namespace LinuxSampler { namespace gig { Line 155  namespace LinuxSampler { namespace gig {
155              String                  InstrumentFile;              String                  InstrumentFile;
156              int                     InstrumentIdx;              int                     InstrumentIdx;
157              int                     InstrumentStat;              int                     InstrumentStat;
158                int8_t                  ScaleTuning[12];       ///< contains optional detune factors (-64..+63 cents) for all 12 semitones of an octave
159                Voice*                  pLastStolenVoice;      ///< Only for voice stealing: points to the last voice which was theft in current audio fragment, NULL otherwise.
160                uint*                   puiLastStolenKey;      ///< Only for voice stealing: key number of last key on which the last voice was theft in current audio fragment, NULL otherwise.
161    
162              void ProcessNoteOn(Event* pNoteOnEvent);              void ProcessNoteOn(Event* pNoteOnEvent);
163              void ProcessNoteOff(Event* pNoteOffEvent);              void ProcessNoteOff(Event* pNoteOffEvent);
164              void ProcessPitchbend(Event* pPitchbendEvent);              void ProcessPitchbend(Event* pPitchbendEvent);
165              void ProcessControlChange(Event* pControlChangeEvent);              void ProcessControlChange(Event* pControlChangeEvent);
166              void KillVoice(Voice* pVoice);              void ProcessSysex(Event* pSysexEvent);
167                Voice* LaunchVoice(Event* pNoteOnEvent, int iLayer = 0, bool ReleaseTriggerVoice = false, bool VoiceStealing = true);
168                void StealVoice(Event* pNoteOnEvent, int iLayer, bool ReleaseTriggerVoice);
169                void KillVoiceImmediately(Voice* pVoice);
170              void ResetSynthesisParameters(Event::destination_t dst, float val);              void ResetSynthesisParameters(Event::destination_t dst, float val);
171              void ResetInternal();              void ResetInternal();
172    
# Line 145  namespace LinuxSampler { namespace gig { Line 178  namespace LinuxSampler { namespace gig {
178              friend class VCOManipulator;              friend class VCOManipulator;
179              friend class InstrumentResourceManager;              friend class InstrumentResourceManager;
180          private:          private:
181              void DisableAndLock();              void    DisableAndLock();
182                uint8_t GSCheckSum(const RingBuffer<uint8_t>::NonVolatileReader AddrReader, uint DataSize);
183                void    AdjustScale(int8_t ScaleTunes[12]);
184      };      };
185    
186  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.133  
changed lines
  Added in v.250

  ViewVC Help
Powered by ViewVC