Fixed MIDI fading and stopping at the end
parent
bc9d9458b4
commit
16396ad20a
|
@ -127,17 +127,19 @@
|
||||||
float * buff = ( float * ) buf;
|
float * buff = ( float * ) buf;
|
||||||
|
|
||||||
float fadeScale = (float)(framesFade - (fadeStart - framesLength)) / framesFade;
|
float fadeScale = (float)(framesFade - (fadeStart - framesLength)) / framesFade;
|
||||||
float fadeStep = 1 / framesFade;
|
float fadeStep = 1.0 / (float)framesFade;
|
||||||
for (fadePos = fadeStart; fadePos < fadeEnd; ++fadePos) {
|
for (fadePos = fadeStart; fadePos < fadeEnd; ++fadePos) {
|
||||||
buff[ 0 ] *= fadeScale;
|
buff[ 0 ] *= fadeScale;
|
||||||
buff[ 1 ] *= fadeScale;
|
buff[ 1 ] *= fadeScale;
|
||||||
buff += 2;
|
buff += 2;
|
||||||
fadeScale -= fadeStep;
|
fadeScale -= fadeStep;
|
||||||
if (fadeScale < 0) break;
|
if (fadeScale < 0) {
|
||||||
|
fadeScale = 0;
|
||||||
|
fadeStep = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fadePos < totalFrames)
|
frames = (int)(fadeEnd - framesRead);
|
||||||
frames = (int)(fadePos - framesRead);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
frames = (int)(totalFrames - framesRead);
|
frames = (int)(totalFrames - framesRead);
|
||||||
|
|
Loading…
Reference in New Issue