pvnick / project64

Automatically exported from code.google.com/p/project64
0 stars 0 forks source link

Something about Audio sample rate and high school algebra #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Iconoclast just sent me this rant on msn

(8:56 AM) Iconoclast: Goddamn I can't stop laughing, years of confusion by Jabo 
and LaC why their audio plugins log WAV files from games at slightly off 
frequencies (32,006 Hertz instead of 32,000 Hz, 44,095 Hz instead of 44.1 kHz) 
(8:57 AM) Iconoclast: were all zilmar's fault for his original plugin system 
code
all I had to do was like, High School algebra, rather than reverse-engineering 
anything
to obtain the correct values XD 

Original issue reported on code.google.com by danialho...@gmail.com on 2 Sep 2012 at 4:53

GoogleCodeExporter commented 9 years ago
Hmmmm, that is interesting to know

Original comment by death2dr...@gmail.com on 3 Sep 2012 at 1:40

GoogleCodeExporter commented 9 years ago
It's just tracking down where the actual calculation occurs that's annoying at 
the moment. XD The code needs a serious clean and commenting

Original comment by death2dr...@gmail.com on 5 Sep 2012 at 1:47

GoogleCodeExporter commented 9 years ago
*oh yeah, and my rewrite of zilmar's audio plugin shows that 1.0-1.6 kept 
reporting SYSTEM_NTSC for every game, while all the other emulators and only pj 
1.7 report SYSTEM_PAL or SYSTEM_PAL, guess he just blindly fixed that

Original comment by danialho...@gmail.com on 5 Sep 2012 at 8:34

GoogleCodeExporter commented 9 years ago
Ahhhh :P, yeah had a look at the code, it seems they didn't even bother with it 
reporting anything other than SYSTEM_NTSC. Its a simple fix so ill be uploading 
it tonight :), Thank you for that

Original comment by death2dr...@gmail.com on 7 Sep 2012 at 6:31

GoogleCodeExporter commented 9 years ago
Fixed in commit r9, Ill have a look into the wrong frequency reporting stuff 
sometime

Original comment by death2dr...@gmail.com on 7 Sep 2012 at 7:51

GoogleCodeExporter commented 9 years ago
Trying to find out where the actual frequency calculation is being handled, im 
guessing its done emulator side and not plugin side?

Original comment by death2dr...@gmail.com on 7 Sep 2012 at 3:26

GoogleCodeExporter commented 9 years ago
(2:01 AM) Iconoclast: the frequency is defined in AiDacrateChanged() of the 
audio plugin system
in that function is called when AI_DACRATE_REG is changed, and the new 
frequency is calculated based off the DAC rate 

Original comment by danialho...@gmail.com on 7 Sep 2012 at 4:30

GoogleCodeExporter commented 9 years ago
Ahhh I see, for a pal system, it seems that they tend to report back
1551 for the DAC Rate
Which from looking at Azimers plugin source code this equals to
49656530 / (1551 + 1)
= 31995
So 5 hertz off what it should actually be, you could just be lazy and round it 
to the nearest thousand XD

Would you mine asking him what the high school maths he used to get a proper 
calculation. Seeing as how to get exactly 32,000 hertz from the PAL value you 
would have to divide by 1551.7665625 (Worked out by just 49656530 / 32,000)

Original comment by death2dr...@gmail.com on 8 Sep 2012 at 1:56

GoogleCodeExporter commented 9 years ago
Iconoclast says (12:10 PM):
*actually the DAC rate is calculated before the frequency, so a PAL game 
requesting 32 kHz would use an approximate DAC rate of 1551. but it could still 
be a different DAC rate than that even for PAL if the resulting requested 
frequency is different
Iconoclast says (12:11 PM):
*and originally I used High School algebra to solve for the "correct" video 
clock numerator to divide by (DAC_rate + 1) to return 32,000 Hertz, but this 
only worked for games requesting just that frequency
Iconoclast says (12:12 PM):
*in fact some of Nintendo's documentation suggests through the use of a 
function, that the game developer requests the "requested frequency" while the 
function returns the "actual frequency", so there is a chance that offbeat 
freqs like 32006 and 31995 might be correct in that context
Iconoclast says (12:14 PM):
*currently, as an experiment just in case the correct behavior is to never have 
weird frequencies like that, I define a modulo base of fifty for rounding to 
the nearest frequency
*from what I've seen, 50 is the greatest common factor of every requested 
Nintendo frequency I've seen written down, such as the min. and max. frequency 
limits Nintendo documented
Iconoclast says (12:15 PM):
*there is another formula to calculate the frequency based on the audio bus 
half-period register, but it doesn't seem to be updated nearly enough as much 
as Nintendo says...the register is usually set to either 0 or 15, for a bitrate 
of 1 or 16 b/sample

Original comment by danialho...@gmail.com on 8 Sep 2012 at 2:19

GoogleCodeExporter commented 9 years ago
ahhhhhh again rather interesting, starting to sound like its not actually a 
problem with the core though.
Just out of interest, does any other emulator produce these odd frequencies?

Original comment by death2dr...@gmail.com on 8 Sep 2012 at 3:16

GoogleCodeExporter commented 9 years ago
Some games actually seem to have some really odd DAC Rate values :S

Original comment by death2dr...@gmail.com on 8 Sep 2012 at 4:05

GoogleCodeExporter commented 9 years ago
Apparently my copy of mario kart 64 using 26,807 hertz

Original comment by death2dr...@gmail.com on 8 Sep 2012 at 4:14

GoogleCodeExporter commented 9 years ago

Original comment by death2dr...@gmail.com on 8 Sep 2012 at 1:19

GoogleCodeExporter commented 9 years ago
I might suggest contacting someone who worked on USFs, they would be more 
familiar with the odd frequencies.

Original comment by Truth.Unknown.AS on 23 Oct 2012 at 11:35