|Re: [hatari-devel] STe DMA sound -> new downsampling method|
[ Thread Index |
| More lists.tuxfamily.org/hatari-devel Archives
Le 15/04/2018 à 13:33, Nicolas Pomarède a écrit :
But in Hatari 2.1, ym2149 emulation is now cycle exact and produce a raw
250 kHz sound output, containing all frequencies/periods (which is
important to emulate some specific cases using low periods). The 250 kHz
sample is then downsampled to the audio card output freq (44.1 kHz for
This is the tricky part ; there're tons of ways to do this, some very
fast, some really slow (see audacity's quality parameter when
downsampling for some examples).
For now, Hatari uses 2 methods to downsamples :
- YM2149_Next_Resample_Nearest : simple "closest" sample choice, fast
but will give aliasing
- YM2149_Next_Resample_Weighted_Average_2 : interpolation of previous
and next sample. This works quite well for low periods, but not for very
low such as 1,2 or 3.
- YM2149_Next_Resample_Weighted_Average_N : this is the missing
function that was not available yet for Hatari 2.1 (no time to complete
at this time when 2.1 was released)
For example, with per=0, you need to average approx 6 input samples to
get 1 output sample. Weighted average on only 2 samples will not be
enough to filter correctly, which might explain the 7 kHz freq you see
in the result.
I will try to complete "Weighted_Average_N" in the next days/weeks, this
might fix the problem (in all cases doing an average on "n" samples is
needed for very low period, even if in most cases "n" will be 2 because
it's very rare that period <= 6 are used)
better later than never :) , I finally added the missing function that
average 'n' samples on the given interval.
Unlike the function currenltly used in Hatari 2.2.1 which used 2*44100
samples to create an output sound at 44.1 kHz, leaving approx 2/3 of the
250000 samples not taken into account, the new function will now use all
the 250000 input samples to compute the 441000 output samples, thus
leaving less artifacts when the input signal contains high freq YM sound.
I tried with "Lethal Xcess" and when using "effects only" I can hear a
difference at the end of a game when reaching the hall of fame part and
the digi drums are playing. The high sound that could be heard at the
same time (because per=0 on voice C) is now gone with this new
This method should use slightly more cpu, but in the end sound
processing is still rather small compared to the cpu and video
emulation, so I don't think this new method will slow down emulation in
a noticable way.
Vincent, could you give a try to the devel version of Hatari and
see/hear if this improves/fixes the problem you reported ?