156 |
float pos_fract = this->Pos - pos_int; // fractional part of position |
float pos_fract = this->Pos - pos_int; // fractional part of position |
157 |
pos_int <<= 1; |
pos_int <<= 1; |
158 |
|
|
|
#if 0 //ENABLE_FILTER |
|
|
UpdateFilter_Stereo(cutoff + FILTER_CUTOFF_MIN, resonance); |
|
|
#endif // ENABLE_FILTER |
|
|
|
|
159 |
#if USE_LINEAR_INTERPOLATION |
#if USE_LINEAR_INTERPOLATION |
160 |
#if ENABLE_FILTER |
#if ENABLE_FILTER |
161 |
// left channel |
// left channel |
180 |
#if ENABLE_FILTER |
#if ENABLE_FILTER |
181 |
pOutputLeft[i] += this->FilterLeft.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); |
pOutputLeft[i] += this->FilterLeft.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); |
182 |
#else // no filter |
#else // no filter |
183 |
pOutputRight[i] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); |
pOutputLeft[i] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); |
184 |
#endif // ENABLE_FILTER |
#endif // ENABLE_FILTER |
185 |
|
|
186 |
//calculate right channel |
//calculate right channel |
192 |
b = 2 * x1 + xm1 - (5 * x0 + x2) / 2; |
b = 2 * x1 + xm1 - (5 * x0 + x2) / 2; |
193 |
c = (x1 - xm1) / 2; |
c = (x1 - xm1) / 2; |
194 |
#if ENABLE_FILTER |
#if ENABLE_FILTER |
195 |
pOutputLeft[i++] += this->FilterRight.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); |
pOutputRight[i++] += this->FilterRight.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); |
196 |
#else // no filter |
#else // no filter |
197 |
pOutputRight[i++] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); |
pOutputRight[i++] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); |
198 |
#endif // ENABLE_FILTER |
#endif // ENABLE_FILTER |
200 |
|
|
201 |
this->Pos += pitch; |
this->Pos += pitch; |
202 |
} |
} |
203 |
|
|
204 |
inline void InterpolateOneStep_Mono(sample_t* pSrc, int& i, float& effective_volume, float& pitch, biquad_param_t& bq_base, biquad_param_t& bq_main) { |
inline void InterpolateOneStep_Mono(sample_t* pSrc, int& i, float& effective_volume, float& pitch, biquad_param_t& bq_base, biquad_param_t& bq_main) { |
205 |
int pos_int = RTMath::DoubleToInt(this->Pos); // integer position |
int pos_int = RTMath::DoubleToInt(this->Pos); // integer position |
206 |
float pos_fract = this->Pos - pos_int; // fractional part of position |
float pos_fract = this->Pos - pos_int; // fractional part of position |
207 |
|
|
|
#if 0 //ENABLE_FILTER |
|
|
UpdateFilter_Mono(cutoff + FILTER_CUTOFF_MIN, resonance); |
|
|
#endif // ENABLE_FILTER |
|
|
|
|
208 |
#if USE_LINEAR_INTERPOLATION |
#if USE_LINEAR_INTERPOLATION |
209 |
float sample_point = effective_volume * (pSrc[pos_int] + pos_fract * (pSrc[pos_int+1] - pSrc[pos_int])); |
float sample_point = effective_volume * (pSrc[pos_int] + pos_fract * (pSrc[pos_int+1] - pSrc[pos_int])); |
210 |
#else // polynomial interpolation |
#else // polynomial interpolation |
227 |
|
|
228 |
this->Pos += pitch; |
this->Pos += pitch; |
229 |
} |
} |
230 |
#if 0 |
|
|
inline void UpdateFilter_Stereo(float cutoff, float& resonance) { |
|
|
if (!(++FilterUpdateCounter % FILTER_UPDATE_PERIOD) && (cutoff != FilterLeft.Cutoff() || resonance != FilterLeft.Resonance())) { |
|
|
FilterLeft.SetParameters(cutoff, resonance, SampleRate); |
|
|
FilterRight.SetParameters(cutoff, resonance, SampleRate); |
|
|
} |
|
|
} |
|
|
inline void UpdateFilter_Mono(float cutoff, float& resonance) { |
|
|
if (!(++FilterUpdateCounter % FILTER_UPDATE_PERIOD) && (cutoff != FilterLeft.Cutoff() || resonance != FilterLeft.Resonance())) { |
|
|
FilterLeft.SetParameters(cutoff, resonance, SampleRate); |
|
|
} |
|
|
} |
|
|
#endif |
|
231 |
inline float Constrain(float ValueToCheck, float Min, float Max) { |
inline float Constrain(float ValueToCheck, float Min, float Max) { |
232 |
if (ValueToCheck > Max) ValueToCheck = Max; |
if (ValueToCheck > Max) ValueToCheck = Max; |
233 |
else if (ValueToCheck < Min) ValueToCheck = Min; |
else if (ValueToCheck < Min) ValueToCheck = Min; |