255 |
CrossfadeVolume = 1.0f; |
CrossfadeVolume = 1.0f; |
256 |
} |
} |
257 |
|
|
258 |
|
PanLeft = float(RTMath::Max(pDimRgn->Pan, 0)) / -64.0f; |
259 |
|
PanRight = float(RTMath::Min(pDimRgn->Pan, 0)) / 63.0f; |
260 |
|
|
261 |
pSample = pDimRgn->pSample; // sample won't change until the voice is finished |
pSample = pDimRgn->pSample; // sample won't change until the voice is finished |
262 |
|
|
263 |
Pos = pDimRgn->SampleStartOffset; // offset where we should start playback of sample (0 - 2000 sample points) |
Pos = pDimRgn->SampleStartOffset; // offset where we should start playback of sample (0 - 2000 sample points) |
660 |
|
|
661 |
case playback_state_ram: { |
case playback_state_ram: { |
662 |
if (RAMLoop) InterpolateAndLoop(Samples, (sample_t*) pSample->GetCache().pStart, Delay); |
if (RAMLoop) InterpolateAndLoop(Samples, (sample_t*) pSample->GetCache().pStart, Delay); |
663 |
else Interpolate(Samples, (sample_t*) pSample->GetCache().pStart, Delay); |
else InterpolateNoLoop(Samples, (sample_t*) pSample->GetCache().pStart, Delay); |
664 |
if (DiskVoice) { |
if (DiskVoice) { |
665 |
// check if we reached the allowed limit of the sample RAM cache |
// check if we reached the allowed limit of the sample RAM cache |
666 |
if (Pos > MaxRAMPos) { |
if (Pos > MaxRAMPos) { |
694 |
} |
} |
695 |
|
|
696 |
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 |
697 |
Interpolate(Samples, ptr, Delay); |
InterpolateNoLoop(Samples, ptr, Delay); |
698 |
DiskStreamRef.pStream->IncrementReadPos(RTMath::DoubleToInt(Pos) * pSample->Channels); |
DiskStreamRef.pStream->IncrementReadPos(RTMath::DoubleToInt(Pos) * pSample->Channels); |
699 |
Pos -= RTMath::DoubleToInt(Pos); |
Pos -= RTMath::DoubleToInt(Pos); |
700 |
} |
} |
948 |
#endif // ENABLE_FILTER |
#endif // ENABLE_FILTER |
949 |
|
|
950 |
/** |
/** |
951 |
* Interpolates the input audio data (no loop). |
* Interpolates the input audio data (without looping). |
952 |
* |
* |
953 |
* @param Samples - number of sample points to be rendered in this audio |
* @param Samples - number of sample points to be rendered in this audio |
954 |
* fragment cycle |
* fragment cycle |
955 |
* @param pSrc - pointer to input sample data |
* @param pSrc - pointer to input sample data |
956 |
* @param Skip - number of sample points to skip in output buffer |
* @param Skip - number of sample points to skip in output buffer |
957 |
*/ |
*/ |
958 |
void Voice::Interpolate(uint Samples, sample_t* pSrc, uint Skip) { |
void Voice::InterpolateNoLoop(uint Samples, sample_t* pSrc, uint Skip) { |
959 |
int i = Skip; |
int i = Skip; |
960 |
|
|
961 |
// FIXME: assuming either mono or stereo |
// FIXME: assuming either mono or stereo |
962 |
if (this->pSample->Channels == 2) { // Stereo Sample |
if (this->pSample->Channels == 2) { // Stereo Sample |
963 |
while (i < Samples) { |
while (i < Samples) InterpolateStereo(pSrc, i); |
|
InterpolateOneStep_Stereo(pSrc, i, |
|
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
|
} |
|
964 |
} |
} |
965 |
else { // Mono Sample |
else { // Mono Sample |
966 |
while (i < Samples) { |
while (i < Samples) InterpolateMono(pSrc, i); |
|
InterpolateOneStep_Mono(pSrc, i, |
|
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
|
} |
|
967 |
} |
} |
968 |
} |
} |
969 |
|
|
983 |
if (pSample->LoopPlayCount) { |
if (pSample->LoopPlayCount) { |
984 |
// render loop (loop count limited) |
// render loop (loop count limited) |
985 |
while (i < Samples && LoopCyclesLeft) { |
while (i < Samples && LoopCyclesLeft) { |
986 |
InterpolateOneStep_Stereo(pSrc, i, |
InterpolateStereo(pSrc, i); |
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
987 |
if (Pos > pSample->LoopEnd) { |
if (Pos > pSample->LoopEnd) { |
988 |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize);; |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize);; |
989 |
LoopCyclesLeft--; |
LoopCyclesLeft--; |
990 |
} |
} |
991 |
} |
} |
992 |
// render on without loop |
// render on without loop |
993 |
while (i < Samples) { |
while (i < Samples) InterpolateStereo(pSrc, i); |
|
InterpolateOneStep_Stereo(pSrc, i, |
|
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
|
} |
|
994 |
} |
} |
995 |
else { // render loop (endless loop) |
else { // render loop (endless loop) |
996 |
while (i < Samples) { |
while (i < Samples) { |
997 |
InterpolateOneStep_Stereo(pSrc, i, |
InterpolateStereo(pSrc, i); |
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
998 |
if (Pos > pSample->LoopEnd) { |
if (Pos > pSample->LoopEnd) { |
999 |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize); |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize); |
1000 |
} |
} |
1005 |
if (pSample->LoopPlayCount) { |
if (pSample->LoopPlayCount) { |
1006 |
// render loop (loop count limited) |
// render loop (loop count limited) |
1007 |
while (i < Samples && LoopCyclesLeft) { |
while (i < Samples && LoopCyclesLeft) { |
1008 |
InterpolateOneStep_Mono(pSrc, i, |
InterpolateMono(pSrc, i); |
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
1009 |
if (Pos > pSample->LoopEnd) { |
if (Pos > pSample->LoopEnd) { |
1010 |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize);; |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize);; |
1011 |
LoopCyclesLeft--; |
LoopCyclesLeft--; |
1012 |
} |
} |
1013 |
} |
} |
1014 |
// render on without loop |
// render on without loop |
1015 |
while (i < Samples) { |
while (i < Samples) InterpolateMono(pSrc, i); |
|
InterpolateOneStep_Mono(pSrc, i, |
|
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
|
} |
|
1016 |
} |
} |
1017 |
else { // render loop (endless loop) |
else { // render loop (endless loop) |
1018 |
while (i < Samples) { |
while (i < Samples) { |
1019 |
InterpolateOneStep_Mono(pSrc, i, |
InterpolateMono(pSrc, i); |
|
pEngine->pSynthesisParameters[Event::destination_vca][i], |
|
|
pEngine->pSynthesisParameters[Event::destination_vco][i], |
|
|
pEngine->pBasicFilterParameters[i], |
|
|
pEngine->pMainFilterParameters[i]); |
|
1020 |
if (Pos > pSample->LoopEnd) { |
if (Pos > pSample->LoopEnd) { |
1021 |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize);; |
Pos = pSample->LoopStart + fmod(Pos - pSample->LoopEnd, pSample->LoopSize);; |
1022 |
} |
} |