In the "PITCH ADJUSTMENTS" section of apudsp.txt it shows how to calculate the pitch adjustment, then it shows the following:
After that it states:
And then it shows how to perform the gauss interpolation based on the current value of interpolation_index like so:
However, in the first code block it says that whenever interpolation_index>=0x4000 then you should interpolation_index -= 0x4000. If that is the case then it is impossible for interpolation_index >> 12 to produce an 'i' with the value 4. It would only be possible for 'i' to be 0-3 (since whenever the upper nibble >= 4 you immediately subtract 4).
What am I missing? I'm sure it's something obvious as usual...
UPDATE: I took a look through the bsnes source code and I can't find anywhere (unless I missed it) where byuu performs interpolation_index -= 0x4000. He does check for interpolation_index>=0x4000 but he never subtracts 0x4000 from interpolation_index.
Code:
if(voice[x].interpolation_index>=0x4000){
NextBRRGroup(x);
voice[x].interpolation_index -= 0x4000;
}
NextBRRGroup(x);
voice[x].interpolation_index -= 0x4000;
}
After that it states:
Code:
The samples in the BRR buffer are then interpolated using a 4-point gaussian interpolation.
And then it shows how to perform the gauss interpolation based on the current value of interpolation_index like so:
Code:
i = voice[x].interpolation_index >> 12; // 0 <= i <= 4
However, in the first code block it says that whenever interpolation_index>=0x4000 then you should interpolation_index -= 0x4000. If that is the case then it is impossible for interpolation_index >> 12 to produce an 'i' with the value 4. It would only be possible for 'i' to be 0-3 (since whenever the upper nibble >= 4 you immediately subtract 4).
What am I missing? I'm sure it's something obvious as usual...
UPDATE: I took a look through the bsnes source code and I can't find anywhere (unless I missed it) where byuu performs interpolation_index -= 0x4000. He does check for interpolation_index>=0x4000 but he never subtracts 0x4000 from interpolation_index.