home *** CD-ROM | disk | FTP | other *** search
- program MakePitchTable;
-
- type
- PitchTable = array[0..127] of longint;
- var
- TheTable: PitchTable;
-
- procedure InitPitchTable (var TheTable: PitchTable);
- const
- SemiTone = 1.0594630943592953;
- HalfSampleRate = 22050.0;
- TwoPower23 = 8388608.0;
- MiddleA = 69;
- MiddleAPitch = 440.0;
- var
- APitch, NextPitch: double;
- i: integer;
- begin
- APitch := (MiddleAPitch / HalfSampleRate) * TwoPower23;
- TheTable[MiddleA] := Round(APitch);
-
- NextPitch := APitch;
- for i := MiddleA - 1 downto 0 do
- begin
- NextPitch := NextPitch / SemiTone;
- TheTable[i] := Round(NextPitch);
- end;
-
- NextPitch := APitch;
- for i := MiddleA + 1 to 127 do
- begin
- NextPitch := NextPitch * SemiTone;
- TheTable[i] := Round(NextPitch);
- end;
- end; {InitPitchTable}
-
- procedure WritePitchTable (var T: PitchTable);
- var
- F: text;
- i: integer;
- begin
- open(F, Newfilename('junk'));
- write(F, 'table ');
- for i := 0 to 127 do
- write(F, T[i] : 1, ' ');
- close(F);
- end;
-
- begin
- InitPitchTable(TheTable);
- WritePitchTable(TheTable);
- end.