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 * |
33 |
#include "../common/RingBuffer.h" |
#include "../common/RingBuffer.h" |
34 |
#include "../drivers/audio/AudioOutputDevice.h" |
#include "../drivers/audio/AudioOutputDevice.h" |
35 |
#include "common/Event.h" |
#include "common/Event.h" |
36 |
|
#include "common/SignalUnitRack.h" |
37 |
|
|
38 |
namespace LinuxSampler { |
namespace LinuxSampler { |
39 |
|
|
65 |
|
|
66 |
void SetVoiceCount(uint Count);// Simple array wrapper just to make sure memory is freed |
void SetVoiceCount(uint Count);// Simple array wrapper just to make sure memory is freed |
67 |
// when liblinuxsampler is unloaded |
// when liblinuxsampler is unloaded |
68 |
|
|
69 |
|
float Random() { |
70 |
|
RandomSeed = RandomSeed * 1103515245 + 12345; // classic pseudo random number generator |
71 |
|
return RandomSeed / 4294967296.0f; |
72 |
|
} |
73 |
|
|
74 |
class FloatTable { |
class FloatTable { |
75 |
private: |
private: |
76 |
const float* array; |
const float* array; |
85 |
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. |
86 |
|
|
87 |
AudioOutputDevice* pAudioOutputDevice; |
AudioOutputDevice* pAudioOutputDevice; |
88 |
|
|
89 |
|
//TODO: should be protected |
90 |
|
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) |
91 |
|
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) |
92 |
|
|
93 |
friend class AbstractVoice; |
friend class AbstractVoice; |
94 |
friend class AbstractEngineChannel; |
friend class AbstractEngineChannel; |
110 |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
111 |
atomic_t ActiveVoiceCount; ///< number of currently active voices |
atomic_t ActiveVoiceCount; ///< number of currently active voices |
112 |
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. |
113 |
|
EqSupport* pEq; ///< Used for per voice equalization |
114 |
|
|
115 |
void RouteAudio(EngineChannel* pEngineChannel, uint Samples); |
void RouteAudio(EngineChannel* pEngineChannel, uint Samples); |
116 |
|
void RouteDedicatedVoiceChannels(EngineChannel* pEngineChannel, optional<float> FxSendLevels[2], uint Samples); |
117 |
void ClearEventLists(); |
void ClearEventLists(); |
118 |
void ImportEvents(uint Samples); |
void ImportEvents(uint Samples); |
119 |
void ProcessSysex(Pool<Event>::Iterator& itSysexEvent); |
void ProcessSysex(Pool<Event>::Iterator& itSysexEvent); |
136 |
|
|
137 |
private: |
private: |
138 |
static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines; |
static std::map<Format, std::map<AudioOutputDevice*,AbstractEngine*> > engines; |
139 |
|
uint32_t RandomSeed; ///< State of the random number generator used by the random dimension. |
140 |
|
|
141 |
static float* InitVolumeCurve(); |
static float* InitVolumeCurve(); |
142 |
static float* InitPanCurve(); |
static float* InitPanCurve(); |
144 |
static float* InitCurve(const float* segments, int size = 128); |
static float* InitCurve(const float* segments, int size = 128); |
145 |
|
|
146 |
void AdjustScale(int8_t ScaleTunes[12]); |
void AdjustScale(int8_t ScaleTunes[12]); |
147 |
|
bool RouteFxSend(FxSend* pFxSend, AudioChannel* ppSource[2], float FxSendLevel, uint Samples); |
148 |
}; |
}; |
149 |
|
|
150 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |