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
/
MBUG013.ARC
/
SCALE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
2KB
|
55 lines
program SCALE;
{ Demonstration program in Turbo Pascal for the
MicroBee, which simulates the PLAY command in
MicroWorld BASIC, developed by Bob Burt from
an algorithm developed by Alan Burt }
const
note_name = 'A A#B C C#D D#E F F#G G#';
var
count,cycles,interval,frequency,duration : integer;
tone_length,freq1,freq2,dur1,dur2 : byte;
{$I sound.pro}
procedure play;
begin
mem[addr(sound)+39] := freq1;
mem[addr(sound)+40] := freq2;
mem[addr(sound)+41] := dur1;
mem[addr(sound)+42] := dur2;
sound
end; {procedure play}
begin {main}
clrscr;
write('Enter Tone Length (1/8 ths of second) : ');
readln(tone_length);
count := 1; interval := -11;
while interval < 48 do
begin
while count <24 do
begin
frequency := round(exp(ln(440)+(interval-13)/12*ln(2)));
duration := round(exp(ln(144)+(13-interval)/12*ln(2.028)));
cycles := (frequency*tone_length) div 8;
write('Play ',interval:3,',',tone_length,' ');
write(copy(note_name,count,2),' ');
write(frequency:4,' Hz ');
freq1 := cycles;
freq2 := cycles div 256;
dur1 := duration;
dur2 := duration div 256;
write(cycles:4,' Cycles ');
writeln(duration:4,' Delay');
play;
interval := interval + 1; count := count + 2
end; {while count}
count := 1
end {while interval}
end. {main}