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" |
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 |
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 (this value will be returned for public calls) |
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) |
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 |
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. |
uint32_t RandomSeed; ///< State of the random number generator used by the random dimension. |
115 |
|
|
116 |
void RenderAudio(EngineChannel* pEngineChannel, uint Samples); |
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(); |
void ClearEventLists(); |
121 |
void ImportEvents(RingBuffer<Event>* pEventQueue, uint Samples); |
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); |
143 |
friend class VCFCManipulator; |
friend class VCFCManipulator; |
144 |
friend class VCOManipulator; |
friend class VCOManipulator; |
145 |
private: |
private: |
146 |
std::list<EngineChannel*> engineChannels; ///< All engine 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 |