694 |
} |
} |
695 |
DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (int(Pos) - MaxRAMPos)); |
DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (int(Pos) - MaxRAMPos)); |
696 |
Pos -= int(Pos); |
Pos -= int(Pos); |
697 |
|
RealSampleWordsLeftToRead = -1; // -1 means no silence has been added yet |
698 |
} |
} |
699 |
|
|
700 |
const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace(); |
const int sampleWordsLeftToRead = DiskStreamRef.pStream->GetReadSpace(); |
703 |
if (DiskStreamRef.State == Stream::state_end) { |
if (DiskStreamRef.State == Stream::state_end) { |
704 |
const int maxSampleWordsPerCycle = (pEngine->MaxSamplesPerCycle << MAX_PITCH) * pSample->Channels + 6; // +6 for the interpolator algorithm |
const int maxSampleWordsPerCycle = (pEngine->MaxSamplesPerCycle << MAX_PITCH) * pSample->Channels + 6; // +6 for the interpolator algorithm |
705 |
if (sampleWordsLeftToRead <= maxSampleWordsPerCycle) { |
if (sampleWordsLeftToRead <= maxSampleWordsPerCycle) { |
706 |
|
// remember how many sample words there are before any silence has been added |
707 |
|
if (RealSampleWordsLeftToRead < 0) RealSampleWordsLeftToRead = sampleWordsLeftToRead; |
708 |
DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead); |
DiskStreamRef.pStream->WriteSilence(maxSampleWordsPerCycle - sampleWordsLeftToRead); |
709 |
} |
} |
710 |
} |
} |
720 |
Pos -= iPos; // just keep fractional part of Pos |
Pos -= iPos; // just keep fractional part of Pos |
721 |
|
|
722 |
// change state of voice to 'end' if we really reached the end of the sample data |
// change state of voice to 'end' if we really reached the end of the sample data |
723 |
if (DiskStreamRef.State == Stream::state_end && readSampleWords >= sampleWordsLeftToRead) this->PlaybackState = playback_state_end; |
if (RealSampleWordsLeftToRead >= 0) { |
724 |
|
RealSampleWordsLeftToRead -= readSampleWords; |
725 |
|
if (RealSampleWordsLeftToRead <= 0) this->PlaybackState = playback_state_end; |
726 |
|
} |
727 |
} |
} |
728 |
break; |
break; |
729 |
|
|