Re: [hatari-devel] Improved YM2149 cycle accuracy

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


Le 27/07/2021 à 19:31, David Savinkoff a écrit :


As for YM2149_Next_Resample_Nearest(), I don't think it will give the
best result, because it will downsample a 250 kHz input to 44.1 kHz for
example, using only 1 input sample every 250/44.1=5.66 samples, thus not
taking into account a big part of the input samples.

The IIR filter convolves many samples so that they are spread over each other.
The output has high frequencies attenuated at 6dB per octave
(not really enough for proper antialiasing).

[cc-ing hatari-devel to keep track of discussion]

Hi

even if IIR convolves many samples, it does so only every 5.66 input samples in the case of YM2149_Next_Resample_Nearest(), so you loose some information between those 5.66 samples that can be meaningful when period is <= 6.


This might be OK when emulating YM2149 for sound having period>=6, but
with very high freq sound, this gives bad results.

IIRC this was hearable in the game Lethal Xcess in STF mode where they
play digi sound by setting period=0 on one voice and modulating volume
for this voice. In that case YM2149_Next_Resample_Weighted_Average_N()
gives much better result as it uses all samples from the 250kHz input
signal.

Nicolas

 From the snippet of code from sound.c below:
- LowPassFilter(sample); is supposed to sound like a ST or STF
- PWMaliasFilter (sample); is supposed to sound like a STE

         /* Apply low pass filter ? */
         if ( YM2149_LPF_Filter == YM2149_LPF_FILTER_LPF_STF )
             sample = LowPassFilter ( sample );
         else if ( YM2149_LPF_Filter == YM2149_LPF_FILTER_PWM )
             sample = PWMaliasFilter ( sample );

 From what you say... I suppose that PWMaliasFilter(sample); is ineffective
and can be removed.

I'm not sure it should be removed. There's this part in audio.c

                if ( Config_IsMachineST() && nAudioFrequency >= 40000 )
                        YM2149_LPF_Filter = YM2149_LPF_FILTER_LPF_STF;
                else
                        YM2149_LPF_Filter = YM2149_LPF_FILTER_PWM;

so if PWMaliasFilter() is supposed to sound more like an STE, it should be kept.

However, LowPassFilter(sample); is supposed to give the charactistic ST
sound (less sharp). This is the same ST sound that everyone thought was OK
a few years ago. I'll calculate some sharper sounding coefficients soon.

I don't disagree, it's just that the change is hearable between hatari 2.3 and current devel version when I apply the patch you sent on 26/7/2021. Maybe sound was too "sharp" before, I can't tell, some YM2149 musicians could give their opinion on this compared to a real STF.

Nicolas




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