'
' Generation of the period table for the MegaTracker DSP Replay
'
' - The Period of the DO-4 is fixed to 428*256
'   because of the old DO-2 amiga period of 428
'   and because we need precision for the highest octaves
'   So periods are now stored as long values
' - 440 Hz is the frequence the A note (LA) and 261.6 Hz
'   is for the C note (DO)
' - The finetuning has a precision of 1/8 of semi-ton
'
'
DIM tablo%(8*12*16)
adr%=V:tablo%(0)
'
FOR fine_tune&=0 TO 7
  FOR octave&=0 TO 7
    FOR note&=0 TO 11
      '
      freq=440*2^((octave&-5)+(note&+3+fine_tune&/8)/12)
      period%=(256*428)*261.6255653/freq
      ' PRINT freq,HEX$(period%)
      ' ~INP(2)
      '
      LONG{adr%}=period%
      adr%=adr%+4
      '
    NEXT note&
  NEXT octave&
NEXT fine_tune&
'
FOR fine_tune&=-8 TO -1
  FOR octave&=0 TO 7
    FOR note&=0 TO 11
      '
      freq=440*2^((octave&-5)+(note&+3+fine_tune&/8)/12)
      period%=(256*428)*261.6255653/freq
      '      PRINT freq,HEX$(period%)
      '      ~INP(2)
      '
      LONG{adr%}=period%
      adr%=adr%+4
      '
    NEXT note&
  NEXT octave&
NEXT fine_tune&
'
BSAVE "PERIODS.TAB",V:tablo%(0),4*(8*12*16)
