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 Christian Schoenebeck * |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* 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 * |
122 |
int Trigger(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent, int PitchBend, ::gig::DimensionRegion* pDimRgn, type_t VoiceType, int iKeyGroup); |
int Trigger(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent, int PitchBend, ::gig::DimensionRegion* pDimRgn, type_t VoiceType, int iKeyGroup); |
123 |
inline bool IsActive() { return PlaybackState; } |
inline bool IsActive() { return PlaybackState; } |
124 |
inline bool IsStealable() { return !itKillEvent && PlaybackState >= playback_state_ram; } |
inline bool IsStealable() { return !itKillEvent && PlaybackState >= playback_state_ram; } |
125 |
|
void UpdatePortamentoPos(Pool<Event>::Iterator& itNoteOffEvent); |
126 |
|
|
127 |
//private: |
//private: |
128 |
// Types |
// Types |
129 |
enum playback_state_t { |
enum playback_state_t { |
140 |
float PanLeft; |
float PanLeft; |
141 |
float PanRight; |
float PanRight; |
142 |
float CrossfadeVolume; ///< Current attenuation level caused by a crossfade (only if a crossfade is defined of course) |
float CrossfadeVolume; ///< Current attenuation level caused by a crossfade (only if a crossfade is defined of course) |
143 |
//double Pos; ///< Current playback position in sample |
double Pos; ///< Current playback position in sample |
144 |
float PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice |
float PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice |
145 |
float PitchBend; ///< Current pitch value of the pitchbend wheel |
float PitchBend; ///< Current pitch value of the pitchbend wheel |
146 |
float CutoffBase; ///< Cutoff frequency before control change, EG and LFO are applied |
float CutoffBase; ///< Cutoff frequency before control change, EG and LFO are applied |
190 |
void processCrossFadeEvent(RTList<Event>::Iterator& itEvent); |
void processCrossFadeEvent(RTList<Event>::Iterator& itEvent); |
191 |
void processCutoffEvent(RTList<Event>::Iterator& itEvent); |
void processCutoffEvent(RTList<Event>::Iterator& itEvent); |
192 |
void processResonanceEvent(RTList<Event>::Iterator& itEvent); |
void processResonanceEvent(RTList<Event>::Iterator& itEvent); |
193 |
|
float getVolume(); |
194 |
|
|
195 |
inline float CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) { |
inline float CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) { |
196 |
float att = (!pDimRgn->Crossfade.out_end) ? CrossfadeControllerValue / 127.0f /* 0,0,0,0 means no crossfade defined */ |
uint8_t c = std::max(CrossfadeControllerValue, pDimRgn->AttenuationControllerThreshold); |
197 |
: (CrossfadeControllerValue < pDimRgn->Crossfade.in_end) ? |
float att = (!pDimRgn->Crossfade.out_end) ? c / 127.0f /* 0,0,0,0 means no crossfade defined */ |
198 |
((CrossfadeControllerValue <= pDimRgn->Crossfade.in_start) ? 0.0f |
: (c < pDimRgn->Crossfade.in_end) ? |
199 |
: float(CrossfadeControllerValue - pDimRgn->Crossfade.in_start) / float(pDimRgn->Crossfade.in_end - pDimRgn->Crossfade.in_start)) |
((c <= pDimRgn->Crossfade.in_start) ? 0.0f |
200 |
: (CrossfadeControllerValue <= pDimRgn->Crossfade.out_start) ? 1.0f |
: float(c - pDimRgn->Crossfade.in_start) / float(pDimRgn->Crossfade.in_end - pDimRgn->Crossfade.in_start)) |
201 |
: (CrossfadeControllerValue < pDimRgn->Crossfade.out_end) ? float(pDimRgn->Crossfade.out_end - CrossfadeControllerValue) / float(pDimRgn->Crossfade.out_end - pDimRgn->Crossfade.out_start) |
: (c <= pDimRgn->Crossfade.out_start) ? 1.0f |
202 |
|
: (c < pDimRgn->Crossfade.out_end) ? float(pDimRgn->Crossfade.out_end - c) / float(pDimRgn->Crossfade.out_end - pDimRgn->Crossfade.out_start) |
203 |
: 0.0f; |
: 0.0f; |
204 |
return pDimRgn->InvertAttenuationController ? 1 - att : att; |
return pDimRgn->InvertAttenuationController ? 1 - att : att; |
205 |
} |
} |