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 - 2007 Christian Schoenebeck * |
* Copyright (C) 2005 - 2012 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 * |
55 |
template<bool INTERPOLATE,bool BITDEPTH24> |
template<bool INTERPOLATE,bool BITDEPTH24> |
56 |
class Resampler { |
class Resampler { |
57 |
public: |
public: |
58 |
inline static float GetNextSampleMonoCPP(sample_t* pSrc, double* Pos, float& Pitch) { |
inline static float GetNextSampleMonoCPP(sample_t* __restrict pSrc, double* __restrict Pos, float& Pitch) { |
59 |
if (INTERPOLATE) return Interpolate1StepMonoCPP(pSrc, Pos, Pitch); |
if (INTERPOLATE) return Interpolate1StepMonoCPP(pSrc, Pos, Pitch); |
60 |
else { // no pitch, so no interpolation necessary |
else { // no pitch, so no interpolation necessary |
61 |
int pos_int = (int) *Pos; |
int pos_int = (int) *Pos; |
64 |
} |
} |
65 |
} |
} |
66 |
|
|
67 |
inline static stereo_sample_t GetNextSampleStereoCPP(sample_t* pSrc, double* Pos, float& Pitch) { |
inline static stereo_sample_t GetNextSampleStereoCPP(sample_t* __restrict pSrc, double* __restrict Pos, float& Pitch) { |
68 |
if (INTERPOLATE) return Interpolate1StepStereoCPP(pSrc, Pos, Pitch); |
if (INTERPOLATE) return Interpolate1StepStereoCPP(pSrc, Pos, Pitch); |
69 |
else { // no pitch, so no interpolation necessary |
else { // no pitch, so no interpolation necessary |
70 |
int pos_int = (int) *Pos; |
int pos_int = (int) *Pos; |
149 |
|
|
150 |
protected: |
protected: |
151 |
|
|
152 |
inline static int32_t getSample(sample_t* src, int pos) { |
inline static int32_t getSample(sample_t* __restrict src, int pos) { |
153 |
if (BITDEPTH24) { |
if (BITDEPTH24) { |
154 |
pos *= 3; |
pos *= 3; |
155 |
#if WORDS_BIGENDIAN |
#if WORDS_BIGENDIAN |
165 |
} |
} |
166 |
} |
} |
167 |
|
|
168 |
inline static float Interpolate1StepMonoCPP(sample_t* pSrc, double* Pos, float& Pitch) { |
inline static float Interpolate1StepMonoCPP(sample_t* __restrict pSrc, double* __restrict Pos, float& Pitch) { |
169 |
int pos_int = (int) *Pos; // integer position |
int pos_int = (int) *Pos; // integer position |
170 |
float pos_fract = *Pos - pos_int; // fractional part of position |
float pos_fract = *Pos - pos_int; // fractional part of position |
171 |
|
|
188 |
return samplePoint; |
return samplePoint; |
189 |
} |
} |
190 |
|
|
191 |
inline static stereo_sample_t Interpolate1StepStereoCPP(sample_t* pSrc, double* Pos, float& Pitch) { |
inline static stereo_sample_t Interpolate1StepStereoCPP(sample_t* __restrict pSrc, double* __restrict Pos, float& Pitch) { |
192 |
int pos_int = (int) *Pos; // integer position |
int pos_int = (int) *Pos; // integer position |
193 |
float pos_fract = *Pos - pos_int; // fractional part of position |
float pos_fract = *Pos - pos_int; // fractional part of position |
194 |
pos_int <<= 1; |
pos_int <<= 1; |