695 |
Pos -= int(Pos); |
Pos -= int(Pos); |
696 |
} |
} |
697 |
|
|
698 |
|
const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace(); |
699 |
|
|
700 |
// add silence sample at the end if we reached the end of the stream (for the interpolator) |
// add silence sample at the end if we reached the end of the stream (for the interpolator) |
701 |
if (DiskStreamRef.State == Stream::state_end && DiskStreamRef.pStream->GetReadSpace() < (pEngine->MaxSamplesPerCycle << MAX_PITCH) / pSample->Channels) { |
if (DiskStreamRef.State == Stream::state_end) { |
702 |
DiskStreamRef.pStream->WriteSilence((pEngine->MaxSamplesPerCycle << MAX_PITCH) / pSample->Channels); |
const int maxSampleWordsPerCycle = (pEngine->MaxSamplesPerCycle << MAX_PITCH) * pSample->Channels + 6; // +6 for the interpolator algorithm |
703 |
this->PlaybackState = playback_state_end; |
if (sampleWordsLeftToRead <= maxSampleWordsPerCycle) { |
704 |
|
DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead); |
705 |
|
} |
706 |
} |
} |
707 |
|
|
708 |
sample_t* ptr = DiskStreamRef.pStream->GetReadPtr(); // get the current read_ptr within the ringbuffer where we read the samples from |
sample_t* ptr = DiskStreamRef.pStream->GetReadPtr(); // get the current read_ptr within the ringbuffer where we read the samples from |
710 |
// render current audio fragment |
// render current audio fragment |
711 |
Synthesize(Samples, ptr, Delay); |
Synthesize(Samples, ptr, Delay); |
712 |
|
|
713 |
DiskStreamRef.pStream->IncrementReadPos(int(Pos) * pSample->Channels); |
const int iPos = (int) Pos; |
714 |
Pos -= int(Pos); |
const int readSampleWords = iPos * pSample->Channels; // amount of sample words actually been read |
715 |
|
DiskStreamRef.pStream->IncrementReadPos(readSampleWords); |
716 |
|
Pos -= iPos; // just keep fractional part of Pos |
717 |
|
|
718 |
|
// change state of voice to 'end' if we really reached the end of the sample data |
719 |
|
if (DiskStreamRef.State == Stream::state_end && readSampleWords >= sampleWordsLeftToRead) this->PlaybackState = playback_state_end; |
720 |
} |
} |
721 |
break; |
break; |
722 |
|
|