OtherCrashOverride / go-play

Retro emulation for the ODROID-GO
https://www.hardkernel.com/shop/odroid-go/
218 stars 72 forks source link

Suggestion: add quantisation to audio at reduced bit depth #39

Open DavidKnight247 opened 6 years ago

DavidKnight247 commented 6 years ago

I'm uncertain as to how much processing power this would require but it should help to improve sound quality to a degree at reduced bit depth.

Sample C++ code is available here though there are probably many other examples available online.

DavidKnight247 commented 6 years ago

Additionally Dither applied to the 16bit signal may improve sound quality at 8 bits.

https://en.wikipedia.org/wiki/Audio_bit_depth

OtherCrashOverride commented 6 years ago

The quantization is already taking place.

Since we are dealing with 2 bits of audio at lower volume levels, I do not think dithering would improve it. Feel free to conduct experiments and report your findings.

DavidKnight247 commented 6 years ago

Ok, I’ll try dithering the LSB with pseudorandom noise and report back.

DavidKnight247 commented 6 years ago

I added pseudo-random noise by changing the LSB of the variable dac0. The effect is hard to quantify and I don't feel there is much difference between the dither and no-dither settings. For those wishing to replicate my experiment I include the modified files to test. If anyone can suggest an improvement to my code please let me know.

odroid.tar.gz

dwillmore commented 6 years ago

What about using the 'remaining error' method? If you want to output value A, but, when truncated it is B, record the difference A-B and apply it to the next A sample before truncation. Keep doing that. It only involves a few simple operations and very little storage. @DavidKnight247 can you try this? I don't yet have a build environment set up.