105 |
// Attributes |
// Attributes |
106 |
gig::Engine* pEngine; ///< Pointer to the sampler engine, to be able to access the event lists. |
gig::Engine* pEngine; ///< Pointer to the sampler engine, to be able to access the event lists. |
107 |
float Volume; ///< Volume level of the voice |
float Volume; ///< Volume level of the voice |
108 |
|
float CrossfadeVolume; ///< Current attenuation level caused by a crossfade (only if a crossfade is defined of course) |
109 |
double Pos; ///< Current playback position in sample |
double Pos; ///< Current playback position in sample |
110 |
double PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice |
double PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice |
111 |
double PitchBend; ///< Current pitch value of the pitchbend wheel |
double PitchBend; ///< Current pitch value of the pitchbend wheel |
112 |
::gig::Sample* pSample; ///< Pointer to the sample to be played back |
::gig::Sample* pSample; ///< Pointer to the sample to be played back |
113 |
::gig::Region* pRegion; ///< Pointer to the articulation information of the respective keyboard region of this voice |
::gig::Region* pRegion; ///< Pointer to the articulation information of the respective keyboard region of this voice |
114 |
|
::gig::DimensionRegion* pDimRgn; ///< Pointer to the articulation information of current dimension region of this voice |
115 |
bool Active; ///< If this voice object is currently in usage |
bool Active; ///< If this voice object is currently in usage |
116 |
playback_state_t PlaybackState; ///< When a sample will be triggered, it will be first played from RAM cache and after a couple of sample points it will switch to disk streaming and at the end of a disk stream we have to add null samples, so the interpolator can do it's work correctly |
playback_state_t PlaybackState; ///< When a sample will be triggered, it will be first played from RAM cache and after a couple of sample points it will switch to disk streaming and at the end of a disk stream we have to add null samples, so the interpolator can do it's work correctly |
117 |
bool DiskVoice; ///< If the sample is very short it completely fits into the RAM cache and doesn't need to be streamed from disk, in that case this flag is set to false |
bool DiskVoice; ///< If the sample is very short it completely fits into the RAM cache and doesn't need to be streamed from disk, in that case this flag is set to false |
226 |
this->Pos += pitch; |
this->Pos += pitch; |
227 |
} |
} |
228 |
|
|
229 |
|
inline float CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) { |
230 |
|
return (CrossfadeControllerValue <= pDimRgn->Crossfade.in_start) ? 0.0f |
231 |
|
: (CrossfadeControllerValue < pDimRgn->Crossfade.in_end) ? float(CrossfadeControllerValue - pDimRgn->Crossfade.in_start) / float(pDimRgn->Crossfade.in_end - pDimRgn->Crossfade.in_start) |
232 |
|
: (CrossfadeControllerValue <= pDimRgn->Crossfade.out_start) ? 1.0f |
233 |
|
: (CrossfadeControllerValue < pDimRgn->Crossfade.out_end) ? float(CrossfadeControllerValue - pDimRgn->Crossfade.out_start) / float(pDimRgn->Crossfade.out_end - pDimRgn->Crossfade.out_start) |
234 |
|
: 0.0f; |
235 |
|
} |
236 |
|
|
237 |
inline float Constrain(float ValueToCheck, float Min, float Max) { |
inline float Constrain(float ValueToCheck, float Min, float Max) { |
238 |
if (ValueToCheck > Max) ValueToCheck = Max; |
if (ValueToCheck > Max) ValueToCheck = Max; |
239 |
else if (ValueToCheck < Min) ValueToCheck = Min; |
else if (ValueToCheck < Min) ValueToCheck = Min; |