stardot / b-em

An opensource BBC Micro emulator for Win32 and Linux
http://stardot.org.uk/forums/viewtopic.php?f=4&t=10823
GNU General Public License v2.0
118 stars 58 forks source link

sn76489 audio output sounds slightly grainy #16

Open hoglet67 opened 7 years ago

hoglet67 commented 7 years ago

This is a follow on from #11 (which we decided to make specific to Music 5000) and have since resolved.

These comments apply to official B-Em 2.2 release, as well as the current build. The problem seems to be present on Linux and Windows.

In very general terms, the sn74689 audio sounds slightly grainy. I really noticed this when I hooked up a decent amp and speakers, so that I could compare the B-Em sn76489 emulation with an FPGA hardware implementation (that uses a decent SPI DAC).

The difference was significant. My testy case was simply the ^G beep.

I think there are a few going on:

As a comparison, I tried the Beech emulator on Windows, and this sounded very clean in comparison.

Looking at the ^G waveform on a scope: image you can see there is one sample's worth of jitter.

I'm not sure if this is the problem, or if it's even avoidable. The real sn76489 runs at 4MHz/16 = 250KHz, which is 8x the audio sampling clock. So clearly some frequencies will jitter.

Oh, and the sn76489 code is much more complicated that I would expect: https://github.com/stardot/b-em/blob/master/src/sn76489.c I don't understand what sidcount is doing here!

I need to do some more investigation, but I would be interested in feedback from other people. Most people I suspect would not notice, unless the issue is pointed out to them.

fordp2002 commented 7 years ago

Coming from a different angle is there another emulation in MESS?

SteveFosdick commented 6 years ago

Returning to an old thread is this with the Internal filter on or off?

I have just been looking at the sound code and it seems it is feeding integer data into an IIR filter that expects floats by simply converting the data type and not the range, i.e. normally data in float format would vary fron -1 to +1 not from +32767 to -32768. I don't know enough to know if the IIR algorithm depends on the range of its input values but maybe worth considering.

SteveFosdick commented 5 years ago

Recording the output from B-Em with audacity gives this: cg This is on Linux and is recording the "monitor" output from pulse audio. It was certainly quiet - I had to normalise it to be able to see the waveform.