Converting Turbo Pascal SOUND command to FireMonkey


I am converting a 30+ year old Turbo Pascal program to FireMonkey. One of the things that appears to have no equivalent is the SOUND command. I found elsewhere on StackOverflow that it can be replaced with the Windows beep (in VCL), but I need a solution that works for FireMonkey on Android. My program displays lyrics along with each sound, so I can’t just record the sound and play MP3 files. I also want to maintain that clunky one-note 8-bit sound of the SOUND command in Turbo Pascal. The main command is Sound(Round(Frequency)). Any idea how to mimic that in FireMonkey? Here is the original code for playing each note, in case it helps:

procedure Playnote(speed,Octave,Note,Duration: integer);
Frequency : real;
I : integer;
if note = 0 then sleep(speed*duration) // was “delay” in Turboo Pascal
else begin
Frequency := 32.625;
for I := 1 to Octave do Frequency := Frequency * 2;
for I := 1 to Note – 1 do Frequency := Frequency * 1.059463094;
if Duration <> 0 then begin
if soundon then Sound(Round(Frequency));
sleep(speed*Duration); // was “delay” in Turboo Pascal
else if soundon then Sound(Round(Frequency));
end; {end PLAYNOTE }

For a little more background, it’s a text adventure game. There is a saloon with a jukebox. Playing songs on the jukebox gives you clues from the lyrics, which display as the song plays.

Comments are closed.