--- linuxsampler/trunk/src/engines/gig/Voice.cpp 2004/12/14 00:32:21 323 +++ linuxsampler/trunk/src/engines/gig/Voice.cpp 2004/12/29 01:14:15 330 @@ -61,6 +61,7 @@ // select synthesis implementation (currently either pure C++ or MMX+SSE(1)) SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, Features::supportsMMX() && Features::supportsSSE()); + SYNTHESIS_MODE_SET_PROFILING(SynthesisMode, true); } Voice::~Voice() { @@ -693,6 +694,7 @@ } DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (int(Pos) - MaxRAMPos)); Pos -= int(Pos); + RealSampleWordsLeftToRead = -1; // -1 means no silence has been added yet } const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace(); @@ -701,6 +703,8 @@ if (DiskStreamRef.State == Stream::state_end) { const int maxSampleWordsPerCycle = (pEngine->MaxSamplesPerCycle << MAX_PITCH) * pSample->Channels + 6; // +6 for the interpolator algorithm if (sampleWordsLeftToRead <= maxSampleWordsPerCycle) { + // remember how many sample words there are before any silence has been added + if (RealSampleWordsLeftToRead < 0) RealSampleWordsLeftToRead = sampleWordsLeftToRead; DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead); } } @@ -716,7 +720,10 @@ Pos -= iPos; // just keep fractional part of Pos // change state of voice to 'end' if we really reached the end of the sample data - if (DiskStreamRef.State == Stream::state_end && readSampleWords >= sampleWordsLeftToRead) this->PlaybackState = playback_state_end; + if (RealSampleWordsLeftToRead >= 0) { + RealSampleWordsLeftToRead -= readSampleWords; + if (RealSampleWordsLeftToRead <= 0) this->PlaybackState = playback_state_end; + } } break; @@ -955,19 +962,19 @@ //same as 'pEngine->pBasicFilterParameters[i] = bqbase;' bq = (float*) &pEngine->pBasicFilterParameters[i]; - bq[0] = bqbase.a1; - bq[1] = bqbase.a2; - bq[2] = bqbase.b0; - bq[3] = bqbase.b1; - bq[4] = bqbase.b2; + bq[0] = bqbase.b0; + bq[1] = bqbase.b1; + bq[2] = bqbase.b2; + bq[3] = bqbase.a1; + bq[4] = bqbase.a2; // same as 'pEngine->pMainFilterParameters[i] = bqmain;' bq = (float*) &pEngine->pMainFilterParameters[i]; - bq[0] = bqmain.a1; - bq[1] = bqmain.a2; - bq[2] = bqmain.b0; - bq[3] = bqmain.b1; - bq[4] = bqmain.b2; + bq[0] = bqmain.b0; + bq[1] = bqmain.b1; + bq[2] = bqmain.b2; + bq[3] = bqmain.a1; + bq[4] = bqmain.a2; } } @@ -979,18 +986,8 @@ * @param pSrc - pointer to input sample data * @param Skip - number of sample points to skip in output buffer */ - void Voice::Synthesize(uint Samples, sample_t* pSrc, int Skip) { - UpdateSynthesisMode(); - SynthesizeFragment_Fn* f = (SynthesizeFragment_Fn*) SynthesizeFragmentFnPtr; - f(*this, Samples, pSrc, Skip); - } - - /** - * Determine the respective synthesis function for the given synthesis - * mode. - */ - void Voice::UpdateSynthesisMode() { - SynthesizeFragmentFnPtr = GetSynthesisFunction(SynthesisMode); + void Voice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) { + RunSynthesisFunction(SynthesisMode, *this, Samples, pSrc, Skip); } /**