33 |
#include "../../common/RingBuffer.h" |
#include "../../common/RingBuffer.h" |
34 |
#include "../../common/Pool.h" |
#include "../../common/Pool.h" |
35 |
#include "../../common/ArrayList.h" |
#include "../../common/ArrayList.h" |
36 |
|
#include "../../common/Condition.h" |
37 |
#include "../../common/ConditionServer.h" |
#include "../../common/ConditionServer.h" |
38 |
#include "../Engine.h" |
#include "../Engine.h" |
39 |
#include "../common/Event.h" |
#include "../common/Event.h" |
61 |
Engine(); |
Engine(); |
62 |
virtual ~Engine(); |
virtual ~Engine(); |
63 |
void Connect(AudioOutputDevice* pAudioOut); |
void Connect(AudioOutputDevice* pAudioOut); |
|
::gig::DimensionRegion** ChangeInstrument(EngineChannel* pEngineChannel, ::gig::Instrument* pInstrument); |
|
64 |
void SuspendAll(); |
void SuspendAll(); |
65 |
void ResumeAll(); |
void ResumeAll(); |
66 |
void Suspend(::gig::Region* pRegion); |
void Suspend(::gig::Region* pRegion); |
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); |
virtual int RenderAudio(uint Samples); |
71 |
virtual void SendSysex(void* pData, uint Size); |
virtual void SendSysex(void* pData, uint Size, MidiInputPort* pSender); |
72 |
virtual void Reset(); |
virtual void Reset(); |
73 |
virtual void Enable(); |
virtual void Enable(); |
74 |
virtual void Disable(); |
virtual void Disable(); |
84 |
virtual String EngineName(); |
virtual String EngineName(); |
85 |
virtual InstrumentManager* GetInstrumentManager(); |
virtual InstrumentManager* GetInstrumentManager(); |
86 |
|
|
87 |
|
void SetVoiceCount(uint Count); |
88 |
|
|
89 |
// Simple array wrapper just to make sure memory is freed |
// Simple array wrapper just to make sure memory is freed |
90 |
// when liblinuxsampler is unloaded |
// when liblinuxsampler is unloaded |
91 |
class FloatTable { |
class FloatTable { |
115 |
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). |
116 |
Pool<Event>* pEventPool; ///< Contains all Event objects that can be used. |
Pool<Event>* pEventPool; ///< Contains all Event objects that can be used. |
117 |
RingBuffer<uint8_t,false>* pSysexBuffer; ///< Input buffer for MIDI system exclusive messages. |
RingBuffer<uint8_t,false>* pSysexBuffer; ///< Input buffer for MIDI system exclusive messages. |
|
int ActiveVoiceCount; ///< number of currently active voices (this value will be returned for public calls) |
|
118 |
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) |
119 |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
120 |
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. |
126 |
bool SuspensionRequested; |
bool SuspensionRequested; |
127 |
ConditionServer EngineDisabled; |
ConditionServer EngineDisabled; |
128 |
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 |
129 |
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 MinFadeOutSamples; ///< The number of samples needed to make an instant fade out (e.g. for voice stealing) without leading to clicks. |
130 |
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. |
131 |
Mutex ResetInternalMutex; ///< Mutex to protect the ResetInternal function for concurrent usage (e.g. by the lscp and instrument loader threads). |
Mutex ResetInternalMutex; ///< Mutex to protect the ResetInternal function for concurrent usage (e.g. by the lscp and instrument loader threads). |
132 |
|
Pool< ::gig::DimensionRegion*>* pDimRegionPool[2]; ///< Double buffered pool, used by the engine channels to keep track of dimension regions in use. |
133 |
|
|
134 |
void ProcessEvents(EngineChannel* pEngineChannel, uint Samples); |
void ProcessEvents(EngineChannel* pEngineChannel, uint Samples); |
135 |
void RenderActiveVoices(EngineChannel* pEngineChannel, uint Samples); |
void RenderActiveVoices(EngineChannel* pEngineChannel, uint Samples); |
160 |
|
|
161 |
friend class Voice; |
friend class Voice; |
162 |
private: |
private: |
|
|
|
|
/// Command used by the instrument loader thread to |
|
|
/// request an instrument change on a channel. |
|
|
struct instrument_change_command_t { |
|
|
EngineChannel* pEngineChannel; |
|
|
::gig::Instrument* pInstrument; |
|
|
}; |
|
|
struct instrument_change_reply_t { |
|
|
int dummy; |
|
|
}; |
|
|
RingBuffer<instrument_change_command_t,false>* InstrumentChangeQueue; ///< Contains the instrument change command |
|
|
RingBuffer<instrument_change_reply_t,false>* InstrumentChangeReplyQueue; ///< Contains the acknowledge of an instrument change |
|
|
::gig::DimensionRegion** pDimRegionsInUse; ///< After an instrument change, this contains a list of dimension regions that are still in use by playing voices |
|
|
|
|
163 |
Pool< ::gig::Region*> SuspendedRegions; |
Pool< ::gig::Region*> SuspendedRegions; |
164 |
Mutex SuspendedRegionsMutex; |
Mutex SuspendedRegionsMutex; |
165 |
Condition SuspensionChangeOngoing; |
Condition SuspensionChangeOngoing; |
186 |
static float* InitCurve(const float* segments, int size = 128); |
static float* InitCurve(const float* segments, int size = 128); |
187 |
|
|
188 |
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 |
189 |
|
|
190 |
|
atomic_t ActiveVoiceCount; ///< number of currently active voices |
191 |
|
|
192 |
}; |
}; |
193 |
|
|
194 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |