VGMStream plugin correctly fades channel counts other than stereo.
parent
5c25e3b071
commit
b3eb934a38
|
@ -77,14 +77,16 @@
|
||||||
long fadeStart = (framesLength > framesRead) ? framesLength : framesRead;
|
long fadeStart = (framesLength > framesRead) ? framesLength : framesRead;
|
||||||
long fadeEnd = (framesRead + frames) > totalFrames ? totalFrames : (framesRead + frames);
|
long fadeEnd = (framesRead + frames) > totalFrames ? totalFrames : (framesRead + frames);
|
||||||
long fadePos;
|
long fadePos;
|
||||||
|
long i;
|
||||||
|
|
||||||
int64_t fadeScale = (int64_t)(totalFrames - fadeStart) * INT_MAX / framesFade;
|
int64_t fadeScale = (int64_t)(totalFrames - fadeStart) * INT_MAX / framesFade;
|
||||||
int64_t fadeStep = INT_MAX / framesFade;
|
int64_t fadeStep = INT_MAX / framesFade;
|
||||||
sbuf += (fadeStart - framesRead) * 2;
|
sbuf += (fadeStart - framesRead) * channels;
|
||||||
for (fadePos = fadeStart; fadePos < fadeEnd; ++fadePos) {
|
for (fadePos = fadeStart; fadePos < fadeEnd; ++fadePos) {
|
||||||
sbuf[ 0 ] = (int16_t)((int64_t)(sbuf[ 0 ]) * fadeScale / INT_MAX);
|
for (i = 0; i < channels; ++i) {
|
||||||
sbuf[ 1 ] = (int16_t)((int64_t)(sbuf[ 1 ]) * fadeScale / INT_MAX);
|
sbuf[ i ] = (int16_t)((int64_t)(sbuf[ i ]) * fadeScale / INT_MAX);
|
||||||
sbuf += 2;
|
}
|
||||||
|
sbuf += channels;
|
||||||
fadeScale -= fadeStep;
|
fadeScale -= fadeStep;
|
||||||
if (fadeScale <= 0) break;
|
if (fadeScale <= 0) break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue