Re: [hatari-devel] Sound lowpass filtering?

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Brad:
At some point the sound emulation moved to a 250kHz model of the YM sound,
but was still applying the same lowpass filters which were written with
coefficients for 44100-48000 Hz. This means that the effect of the lowpass
filter is essentially disabled, as the cutoff frequency is now 5x too high,
and out of the range of human hearing.

David:
I noticed this years ago, looked at the problem and other changes and thought
about it. Nobody seemed to notice much so I let it slide. Partly because there
was some other thing that I wanted to investigate but didn't get feedback on
which I had let slide also. Maybe I need to use my own ears to hear the
differences between my Atari ST and Hatari.

Brad:
The fix is simple, move the relevant lowpass filter code in sound.c into
YM2149_NextSample_250 where they can apply at the output audio rate
instead. This restores the previous behaviour of these filters as intended.

David:
Good.
Note that if the sample rate down-converting method is not good, the
'asymmetric' filter may be better left at 250 KHz (new coefficients required).

Brad:
However, this brings me to a second suggestion. The two lowpass filters
provided have very poor quality, extremely distorted sound. This is due to
them applying asymmetrically with a hard break point in the middle.

David:
The two lowpass filters are not low quality and are not distorted, nor do
they look or sound distorted. They produce separate exponential decay curves
for rising and falling edges of the square wave they filter. Not everything
is frequency domain, some is time domain.

Brad:
I assume this is modeled on some version of STF circuitry,

David:
Yes.

-------extra-------------

The sound code before the changes used AC analysis with the DC component
for audible frequencies, and DC analysis only for high frequencies. High
frequencies thus didn't need to be AC filtered if they were not there.

Beyond all of this is Hatari must now convert 250 KHz samples to 44.1 KHz
and 48 KHz, possibly with selectable methods. I've been thinking about this
also. I guess the sound is in for another round.



On Thu, Aug 31, 2023 at 1:01 PM Nicolas Pomarède <npomarede@xxxxxxxxxxxx> wrote:
Le 31/08/2023 à 20:04, Brad Smith a écrit :
> Hello. This is my first post to the mailing list, so I hope I have done
> this correctly.
>
>  > but it's sure very interesting to have an updated patch since going
> to 250 kHz, having better filtering can be a complicated task depending
> on which HW we try to emulate and how much CPU we want to dedicate to
> this part.
>
> The change made in my pull request actually lowers the CPU usage. It is
> not trying to produce a more complicated hardware model that would
> require extra computation, but rather the opposite.
>
> Summary:
> - Fix the lowpass filters which have been broken since the move to 250
> kHz. The audio output has essentially been unfiltered since that time.
> - Provide a simplified lowpass filter model as a default, because I
> believe the two existing ones are flawed and not representative of the
> hardware sound they attempt to model.
>
> Full details of the patch, with sound examples and explanation are here:
> https://github.com/hatari/hatari/pull/25
> <https://github.com/hatari/hatari/pull/25>

Hi

welcome to the list.

I still didn't have time to check the wav recordings you made as well as
the patches, but it's on the top of my todo list so it won't be forgotten ;)

In case David Savinkoff (who wrote the original sound filters for
Hatari) reads the list, maybe he can comment on your changes and the
differences / improvements you hear.

Nicolas





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/