home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG039.ARC
/
TUNE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
2KB
|
51 lines
PROGRAM Tune ; { Change 'PROGRAM' to 'PROCEDURE' for your program }
VAR Tone : ARRAY[1..24] OF integer ;
PROCEDURE NoteCalc ; { Calculates 24 note periods and
puts them in array 'Tone' }
VAR i : integer ;
period, n : real ;
BEGIN
period := 161.0 ; n := 1.0585 ; { period = 161 for lowest note (A) }
FOR i := 1 TO 24 DO
BEGIN
Tone[i] := Round(period) ;
period := period / n ; { calculate succeeding periods }
n := n + 0.00046
END
END ;
PROCEDURE P(note, time : integer) ; { Play 'note' for 'time' }
VAR duration, up, down, i, j : integer ;
BEGIN
IF note = 0 THEN
Delay(time * (1000 DIV 8)) { Rest }
ELSE
BEGIN
duration := time * (4210 DIV Tone[note]) ;è up := Tone[note] DIV 2 ;
down := Tone[note] - up ;
FOR i := 1 TO duration DO
BEGIN
inline ($3E/$F8/ { LD A,248 }
$D3/$02); { OUT (2),A } { Speaker bit 'up'}
FOR j := 1 TO up DO ; { up time }
inline ($3E/$B8/ { LD A,184 }
$D3/$02); { OUT (2),A } { Speaker bit 'down'}
FOR j := 1 TO down DO ; { down time }
END
END
END ;
BEGIN { Tune }
NoteCalc ;
{ 'SAINTS...' }
P(4,2); P(8,2); P(9,2); P(11,8); P(4,2); P(8,2); P(9,2); P(11,8);
P(4,2); P(8,2); P(9,2); P(11,4); P(8,4); P(4,2); P(8,4); P(6,8); P(0,2);
P(8,2); P(8,2); P(6,2); P(4,8); P(8,4); P(11,4); P(11,2); P(9,8); P(0,2);
P(8,2); P(9,2); P(11,4); P(8,4); P(4,4); P(6,4); P(4,10);
END. { *** Dont forget to change '.' to ';' *** }