Re: [hatari-devel] 7an's Hi-Hats

[ Thread Index | Date Index | More Archives ]

Le 30/06/2017 à 02:45, David Savinkoff a écrit :
----- Nicolas Pomarède wrote:
Le 29/06/2017 à 22:01, David Savinkoff a écrit :

I was looking at hatari/src/sound.c :: YM2149_RndCompute()

This function must be executed at the same rate as the noise
frequency register in the YM2149.
YM2149_RndCompute() is, however, executed on a per sample
basis which is not the same. Thus, different sound.


do you mean in YM2149_NextSample_250() ? code is :

   if ( Noise_count >= Noise_per )
      Noise_count = 0;
      Noise_val = YM2149_RndCompute();                	

so it correctly updates noise output each time the counter reached the
current period.

And when comparing STF wav recording with Hatari's wav this gives indeed
similar wave signals and phase duration for noise.

Or did you mean sthg else ?

I mean the code here (although I had to look at older code because
of not working).

The problem is that:  if ( Noise_count >= Noise_per )
should be a for() loop because if someone chooses a frequency of
125kHz, YM2149_RndCompute() needs to be called 125000 times
per second. In this example, the noise generator makes frequencies
from 125kHz down to 125kHz/2^17 and some of these frequencies
are above the nyquist limit of the sampling rate.

Well, it's already theer : look above and there's a :

        while ( YM_Clock_Step < YM_ATARI_CLOCK_COUNTER )

You can see that YM_Clock_Step is incremented with YM_REPLAY_FREQ, so the while loop in ten guarantees that tone counter will be incremented 250.000 times per second (and 125.000 times for noise). When exiting the while loop, we take the latest values for tone/noise/env state. As always, when replay freq is below clock freq (44.1 kHz vs 250 kHz in that case), some frequencies will be altered. But for tone this means per<=6, which is really rarely used as it's nearly non audible on a real ST.

(Assuming 125kHz is possible with the registers - What is the highest frequency?)

Noise uses a base freq of 125 kHz and period can be between 1 and 31. So noise freq will be between 125 kHz and 4 kHz. This means that noise with period <= 3 will also be altered at a replay of 44.1 kHz.

But here also, this is not the reason for 7an sound being too loud.


Mail converted by MHonArc 2.6.19+