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-2010 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 * |
78 |
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. |
79 |
|
|
80 |
AudioOutputDevice* pAudioOutputDevice; |
AudioOutputDevice* pAudioOutputDevice; |
81 |
|
|
82 |
|
//TODO: should be protected |
83 |
|
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) |
84 |
|
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) |
85 |
|
|
86 |
friend class AbstractVoice; |
friend class AbstractVoice; |
87 |
friend class AbstractEngineChannel; |
friend class AbstractEngineChannel; |
96 |
EventGenerator* pEventGenerator; |
EventGenerator* pEventGenerator; |
97 |
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). |
98 |
Pool<Event>* pEventPool; ///< Contains all Event objects that can be used. |
Pool<Event>* pEventPool; ///< Contains all Event objects that can be used. |
99 |
RingBuffer<uint8_t,false>* pSysexBuffer; ///< Input buffer for MIDI system exclusive messages. |
RingBuffer<uint8_t,false>* pSysexBuffer; ///< Input buffer for MIDI system exclusive messages. |
100 |
uint SampleRate; ///< Sample rate of the engines output audio signal (in Hz) |
uint SampleRate; ///< Sample rate of the engines output audio signal (in Hz) |
101 |
uint MaxSamplesPerCycle; ///< Size of each audio output buffer |
uint MaxSamplesPerCycle; ///< Size of each audio output buffer |
102 |
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 |
103 |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
104 |
atomic_t ActiveVoiceCount; ///< number of currently active voices |
atomic_t ActiveVoiceCount; ///< number of currently active voices |
105 |
|
int VoiceSpawnsLeft; ///< We only allow CONFIG_MAX_VOICES voices to be spawned per audio fragment, we use this variable to ensure this limit. |
106 |
|
|
107 |
void RouteAudio(EngineChannel* pEngineChannel, uint Samples); |
void RouteAudio(EngineChannel* pEngineChannel, uint Samples); |
108 |
|
void RouteDedicatedVoiceChannels(EngineChannel* pEngineChannel, optional<float> FxSendLevels[2], uint Samples); |
109 |
void ClearEventLists(); |
void ClearEventLists(); |
110 |
void ImportEvents(uint Samples); |
void ImportEvents(uint Samples); |
111 |
void ProcessSysex(Pool<Event>::Iterator& itSysexEvent); |
void ProcessSysex(Pool<Event>::Iterator& itSysexEvent); |
119 |
|
|
120 |
uint8_t GSCheckSum(const RingBuffer<uint8_t,false>::NonVolatileReader AddrReader, uint DataSize); |
uint8_t GSCheckSum(const RingBuffer<uint8_t,false>::NonVolatileReader AddrReader, uint DataSize); |
121 |
|
|
122 |
|
float Random() { |
123 |
|
RandomSeed = RandomSeed * 1103515245 + 12345; // classic pseudo random number generator |
124 |
|
return RandomSeed / 4294967296.0f; |
125 |
|
} |
126 |
|
|
127 |
virtual void ResetInternal() = 0; |
virtual void ResetInternal() = 0; |
128 |
virtual void KillAllVoices(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itKillEvent) = 0; |
virtual void KillAllVoices(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itKillEvent) = 0; |
129 |
virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) = 0; |
virtual void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) = 0; |
133 |
|
|
134 |
private: |
private: |
135 |
static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines; |
static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines; |
136 |
|
uint32_t RandomSeed; ///< State of the random number generator used by the random dimension. |
137 |
|
|
138 |
static float* InitVolumeCurve(); |
static float* InitVolumeCurve(); |
139 |
static float* InitPanCurve(); |
static float* InitPanCurve(); |
141 |
static float* InitCurve(const float* segments, int size = 128); |
static float* InitCurve(const float* segments, int size = 128); |
142 |
|
|
143 |
void AdjustScale(int8_t ScaleTunes[12]); |
void AdjustScale(int8_t ScaleTunes[12]); |
144 |
|
bool RouteFxSend(FxSend* pFxSend, AudioChannel* ppSource[2], float FxSendLevel, uint Samples); |
145 |
}; |
}; |
146 |
|
|
147 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |