#1  
Old 20th September 2017, 09:25 PM
Frank74's Avatar
Frank74 Frank74 is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Aug 2013
Location: UK
Posts: 828
Default AI emulation query

According to hcs doc:
Write to AI_DACRATE_REG this value: (video clock / frequency) -1

But audio plugins and FAT seem to do this instead:
Write to frequency this value: (video clock / ((dacrate & 0x3FFF) +1))

Any reason why?
Reply With Quote
  #2  
Old 21st September 2017, 12:19 AM
Frank74's Avatar
Frank74 Frank74 is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Aug 2013
Location: UK
Posts: 828
Default

I added some logging to get the frequency and AI_DACRATE_REG.

Super Smash Brothers using FAT, has a frequency of 32006, Dacrate is 1520.
48681812 / (Dacrate+1) = 32006.451.

But video clock divided by a "rounded" frequency gives us the correct Dacrate:
48681812 / 32000 - 1 = 1520.306

I know experiments with frequency rounding didn't work out too well though.

Slowing the ntsc video clock to 48,672,000, and then video clock / (Dacrate+1) = 32000.000.
Edit: this doesn't help anything.

Last edited by Frank74; 21st September 2017 at 01:54 AM.
Reply With Quote
  #3  
Old 21st September 2017, 05:18 AM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,245
Default

The DAC sample frequency is video_clock / (DAC_rate + 1).

So,
frequency = video_clock / (DAC_rate + 1)
(DAC_rate + 1) * frequency = video_clock
DAC_rate + 1 = video_clock / frequency
DAC_rate = (video_clock / frequency) - 1

Therefore, both the formula in use by audio plugins today as well as the one in LaC's doc are correct.
Reply With Quote
  #4  
Old 21st September 2017, 05:23 AM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,245
Default

If you want to round the frequency, my favorite way to do it was round it to the nearest 50 Hz.

It's better not to mess with the NTSC video clock constant because those are absolute.

The DAC rate I don't know about, but as AI_DACRATE_REG is an integer by nature of storage I think you're better off assuming both the video clock and DAC rate values are perfectly accurate (even if they're not...) as far as the RCP is concerned.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 08:40 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.