View Single Post
Old 18 June 2013, 16:18   #1
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,712
Generating an accurate Paula period table

Hi,

I'm creating a small, portable MOD player in C and I want to generate the period table (36 notes, spanned over 16 finetunes, padded with a zero before the new finetune, totalling in 592 values) but all the routines I've found on the net seem to be -1/+1 off on certain periods. The reason I want to do this is because the table is 1184 bytes long. It's not that big but it'll shave off some bytes for very small packed intros.

I found periodtable.bas by Lars Hamre (?) but converting it to C makes rounding errors. I've tried to use floor(val + 0.5) and what not, nothing seems to work. I've tried for hours to change variables. One time I managed to get some of the red values correct, but then some other ones went off.
I thought at first that maybe the periods must not be even values, but there are both odd and even values in the original table.

Here's the table I want to generate: http://pastebin.com/6xVK2msR
Here's PERIODTA.BAS: http://pastebin.com/3GcVZFG8
Here's the C code that generates the table: http://pastebin.com/2KTibxBk
Here's the (wrongly) generated period table from the C code: http://pastebin.com/fSRqDZRm

Using my C-converted code, the first 36 notes with no finetune added is like this:
Code:
    856,808,763,720,679,641,605,571,539,509,480,453,
    428,404,381,360,340,321,303,286,270,254,240,227,
    214,202,191,180,170,160,151,143,135,127,120,113,0,
It's supposed to be like this:
Code:
    856,808,762,720,678,640,604,570,538,508,480,453,
    428,404,381,360,339,320,302,285,269,254,240,226,
    214,202,190,180,170,160,151,143,135,127,120,113,0,


Some helpers on the constants in the QuickBasic file:
fclk = 4433618.75#*1.6
this is PAL color clock carrier * 1.6, which yields 7093790Hz which is the Amiga PAL CPU clock.

fr=258.9731 * b
258.9731 is a hand-rounded value from (7093790 / (2 * (856 * 16)) which yields 258.9730578271028. 856 is the mid-C period value.

Last edited by 8bitbubsy; 18 June 2013 at 17:46.
8bitbubsy is offline  
 
Page generated in 0.05505 seconds with 11 queries