libevmu icon indicating copy to clipboard operation
libevmu copied to clipboard

audio emulation innacuracies

Open jvsTSX opened this issue 9 months ago • 0 comments

1 - the Timer 1 base clock comes from the CPU's clock making it go high pitched on RC clock mode and nearly supersonic on CF clock mode, the emulator just sets the Timer 1 base clock to quartz/6 always regardless of the CPU clock

  • fixing this should fix shenmue's goodies startup music and timing since Timer 0 and its prescaler follows this same behaviour, EVMU appears to treat it as a clock multiplier (?)

2 - the Timer 1 mode 3 is not implemented, with this mode you can set a clock double function by setting the enable bits to "01" making the range on quartz mode /6 to go from F-1 trough F-8 instead of F-1 trough F-7.

  • no game appears to use this behaviour

2.1 - additionally this mode adds another sound layer that makes a sort of strobe pattern, it's very audible on quartz mode and always follows the pitch of T1LR, setting T1HR has no effects on it unless you set it to $FF which will mute the pattern, the pattern have octaves that can be enabled or disabled trough the T1HC register, "1" bits will enable the octave while "0" bits will mask it out, up to 8 octaves can be heard assuming T1HR is below $80, the way the octaves stack is by each octave being around 90 degrees out of phase with each other, making a pattern like this octave 1 __|___|___|___|___|___|___|___|_ octave 0 ____|_______|_______|_______|___ result = __|_|_|___|_|_|___|_|_|___|_|_|_ the output appears to be ORed with the PWM output

  • no game appears uses this mode

3 - the sample rate output of the emulator assumes quartz output only, the hardware should emit up to 2MHz tones using the clock double mode

  • changing sample rate to a higher number and use resampling for higher tones should create an output closer to that of the real machine, however the VMU seems to have a strong high-pass on the ports even with direct speaker wire recordings

4 - direct sound mode is not emulated, toggling Port 1 bit 7 with the corresponding P1DDR set to "0" does not alter the sound output

  • i don't know of any games that use this

5 - the PWM comparator seems to compare itself on every timer cycle instead of only once

  • fixing this should allow pac-man to output audio

jvsTSX avatar May 23 '24 22:05 jvsTSX