--- linuxsampler/trunk/src/engines/gig/Voice.h 2004/05/31 19:28:09 97 +++ linuxsampler/trunk/src/engines/gig/Voice.h 2004/08/22 14:46:47 225 @@ -32,7 +32,7 @@ #include "../../common/RTMath.h" #include "../../common/RingBuffer.h" #include "../../common/RTELMemoryPool.h" -#include "../../audiodriver/AudioOutputDevice.h" +#include "../../drivers/audio/AudioOutputDevice.h" #include "../../lib/fileloader/libgig/gig.h" #include "../common/BiquadFilter.h" #include "Engine.h" @@ -105,10 +105,6 @@ // Attributes gig::Engine* pEngine; ///< Pointer to the sampler engine, to be able to access the event lists. float Volume; ///< Volume level of the voice - float* pOutputLeft; ///< Audio output channel buffer (left) - float* pOutputRight; ///< Audio output channel buffer (right) - uint SampleRate; ///< Sample rate of the engines output audio signal (in Hz) - uint MaxSamplesPerCycle; ///< Size of each audio output buffer double Pos; ///< Current playback position in sample double PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice double PitchBend; ///< Current pitch value of the pitchbend wheel @@ -159,14 +155,14 @@ #if USE_LINEAR_INTERPOLATION #if ENABLE_FILTER // left channel - pOutputLeft[i] += this->FilterLeft.Apply(&bq_base, &bq_main, effective_volume * (pSrc[pos_int] + pos_fract * (pSrc[pos_int+2] - pSrc[pos_int]))); + pEngine->pOutputLeft[i] += this->FilterLeft.Apply(&bq_base, &bq_main, effective_volume * (pSrc[pos_int] + pos_fract * (pSrc[pos_int+2] - pSrc[pos_int]))); // right channel - pOutputRight[i++] += this->FilterRight.Apply(&bq_base, &bq_main, effective_volume * (pSrc[pos_int+1] + pos_fract * (pSrc[pos_int+3] - pSrc[pos_int+1]))); + pEngine->pOutputRight[i++] += this->FilterRight.Apply(&bq_base, &bq_main, effective_volume * (pSrc[pos_int+1] + pos_fract * (pSrc[pos_int+3] - pSrc[pos_int+1]))); #else // no filter // left channel - pOutputLeft[i] += effective_volume * (pSrc[pos_int] + pos_fract * (pSrc[pos_int+2] - pSrc[pos_int])); + pEngine->pOutputLeft[i] += effective_volume * (pSrc[pos_int] + pos_fract * (pSrc[pos_int+2] - pSrc[pos_int])); // right channel - pOutputRight[i++] += effective_volume * (pSrc[pos_int+1] + pos_fract * (pSrc[pos_int+3] - pSrc[pos_int+1])); + pEngine->pOutputRight[i++] += effective_volume * (pSrc[pos_int+1] + pos_fract * (pSrc[pos_int+3] - pSrc[pos_int+1])); #endif // ENABLE_FILTER #else // polynomial interpolation // calculate left channel @@ -174,13 +170,13 @@ float x0 = pSrc[pos_int+2]; float x1 = pSrc[pos_int+4]; float x2 = pSrc[pos_int+6]; - float a = (3 * (x0 - x1) - xm1 + x2) / 2; - float b = 2 * x1 + xm1 - (5 * x0 + x2) / 2; - float c = (x1 - xm1) / 2; + float a = (3.0f * (x0 - x1) - xm1 + x2) * 0.5f; + float b = 2.0f * x1 + xm1 - (5.0f * x0 + x2) * 0.5f; + float c = (x1 - xm1) * 0.5f; #if ENABLE_FILTER - pOutputLeft[i] += this->FilterLeft.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); + pEngine->pOutputLeft[i] += this->FilterLeft.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); #else // no filter - pOutputLeft[i] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); + pEngine->pOutputLeft[i] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); #endif // ENABLE_FILTER //calculate right channel @@ -188,13 +184,13 @@ x0 = pSrc[pos_int+3]; x1 = pSrc[pos_int+5]; x2 = pSrc[pos_int+7]; - a = (3 * (x0 - x1) - xm1 + x2) / 2; - b = 2 * x1 + xm1 - (5 * x0 + x2) / 2; - c = (x1 - xm1) / 2; + a = (3.0f * (x0 - x1) - xm1 + x2) * 0.5f; + b = 2.0f * x1 + xm1 - (5.0f * x0 + x2) * 0.5f; + c = (x1 - xm1) * 0.5f; #if ENABLE_FILTER - pOutputRight[i++] += this->FilterRight.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); + pEngine->pOutputRight[i++] += this->FilterRight.Apply(&bq_base, &bq_main, effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0)); #else // no filter - pOutputRight[i++] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); + pEngine->pOutputRight[i++] += effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); #endif // ENABLE_FILTER #endif // USE_LINEAR_INTERPOLATION @@ -212,9 +208,9 @@ float x0 = pSrc[pos_int+1]; float x1 = pSrc[pos_int+2]; float x2 = pSrc[pos_int+3]; - float a = (3 * (x0 - x1) - xm1 + x2) / 2; - float b = 2 * x1 + xm1 - (5 * x0 + x2) / 2; - float c = (x1 - xm1) / 2; + float a = (3.0f * (x0 - x1) - xm1 + x2) * 0.5f; + float b = 2.0f * x1 + xm1 - (5.0f * x0 + x2) * 0.5f; + float c = (x1 - xm1) * 0.5f; float sample_point = effective_volume * ((((a * pos_fract) + b) * pos_fract + c) * pos_fract + x0); #endif // USE_LINEAR_INTERPOLATION @@ -222,8 +218,8 @@ sample_point = this->FilterLeft.Apply(&bq_base, &bq_main, sample_point); #endif // ENABLE_FILTER - pOutputLeft[i] += sample_point; - pOutputRight[i++] += sample_point; + pEngine->pOutputLeft[i] += sample_point; + pEngine->pOutputRight[i++] += sample_point; this->Pos += pitch; }