mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
prevent clipping in ADPCM samples
This commit is contained in:
parent
f32c2fa06b
commit
11478fbdfe
2 changed files with 7 additions and 1 deletions
|
@ -1367,6 +1367,8 @@ void DivEngine::renderSamples() {
|
|||
step=adSteps[index];
|
||||
|
||||
short sample=(j<s->rendLength)?((s->depth==16)?(s->rendData[j]>>4):(s->rendData[j]<<4)):0;
|
||||
if (sample>0x7d0) sample=0x7d0;
|
||||
if (sample<-0x7d0) sample=-0x7d0;
|
||||
diff=sample-predsample;
|
||||
if (diff>=0) {
|
||||
encoded=0;
|
||||
|
@ -1389,6 +1391,9 @@ void DivEngine::renderSamples() {
|
|||
if (diff>=tempstep) encoded|=1;
|
||||
|
||||
acc+=jediTable[decstep+encoded];
|
||||
if (acc>0x7ff || acc<-0x800) {
|
||||
logW("clipping! %d\n",acc);
|
||||
}
|
||||
acc&=0xfff;
|
||||
if (acc&0x800) acc|=~0xfff;
|
||||
decstep+=adStepSeek[encoded&7]*16;
|
||||
|
@ -1552,6 +1557,7 @@ void DivEngine::reset() {
|
|||
extValuePresent=0;
|
||||
speed1=song.speed1;
|
||||
speed2=song.speed2;
|
||||
globalPitch=0;
|
||||
dispatch->reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class DivEngine {
|
|||
bool extValuePresent;
|
||||
bool repeatPattern;
|
||||
int ticks, cycles, curRow, curOrder, remainingLoops, nextSpeed, clockDrift;
|
||||
int changeOrd, changePos, totalTicks, totalCmds, lastCmds, cmdsPerSecond;
|
||||
int changeOrd, changePos, totalTicks, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
|
||||
unsigned char extValue;
|
||||
unsigned char speed1, speed2;
|
||||
DivStatusView view;
|
||||
|
|
Loading…
Reference in a new issue