[comp.lang.pascal] Any TurboPascal Sound Libraries

elder@wpafb-info2.arpa (04/12/89)

I am working on a war game written in Turbo Pascal 5.0.  Does anyone know of
any sound libraries for Turbo-Pascal, or books with code for making various
sounds on IBM-PC compatible machines.  In my game, I would like to make
sounds such as planes flying, bombs dropping/exploding, etc.  Right now I
have no real idea what frequency to set in the sound procedure to do something
like this.  The existance of source code demonstrating some of this would be
very helpful.

Thanks in advance.

Greg Elder
elder@wpafb-info7.arpa

dgr0093%ritcv@cs.rit.edu (340 Ok) (04/13/89)

In article <19093@adm.BRL.MIL> elder@wpafb-info2.arpa writes:
>I am working on a war game written in Turbo Pascal 5.0.  Does anyone know of
>any sound libraries for Turbo-Pascal, or books with code for making various
>sounds on IBM-PC compatible machines.

Here's a good demo from my archives. I didn't write it, but I like it for
certain applications. Yours sounds like it could use this.

I think this was originally from PC Magazine, but I couldn't tell you which one.


PROGRAM demo_for_noise;

uses crt;

var n: byte;

procedure noise (start, {starting freq}
                 stop,  {ending freq}
                 step,  {step size}
                 del,   {times per step}
                 times, {repeats of whole sound}
                 pause  {pause between repeats}
                 : integer);

var
  a, diff, z: integer;
begin
  a:= start;
  diff := 0;
  z:= 0;
  for z:= 1 to times do begin
   sound(a); delay(del); nosound;
   repeat
    if start > stop then begin
     dec (a, step);
     diff := a-stop
    end else begin
     inc (a, step);
     diff := stop-a
    end;
    sound(a); delay(del); nosound
   until diff<0;
   a:= start;
   delay(pause)
  end
end;

begin
  clrscr;
  writeln ('NOISE.PAS     By E. Kasey Kasemodel');
  write ('01 '); noise (100, 50, 1, 15, 5, 100); delay(1000);
  write ('02 '); noise (100, 250, 10, 50, 3, 100); delay(1000);
  write ('03 '); noise (2000, 250, 50, 5, 2, 100); delay(1000);
  write ('04 '); noise (50, 2500, 50, 5, 4, 50); delay(1000);
  write ('05 '); noise (4000, 1000, 150, 3, 3, 50);
                 noise (1000, 4000, 150, 3, 3, 50); delay(1000);
  write ('06 '); noise (1000, 6000, 100, 3, 5, 50);
                 noise (4000, 250, 80, 3, 2, 75);
                 noise (50, 5500, 133, 4, 2, 25);
                 noise (2000, 1000, 60, 3, 3, 50); delay(1000);
  write ('07 '); noise (2000, 2400, 2, 2, 2, 50); delay(1000);
  write ('08 '); for n:=1 to 8 do begin
                   noise (1000, 2000, 15, 2, 1, 0);
                   noise (2000, 1000, 15, 2, 1, 0)
                 end;                              delay(1000);
  write ('09 '); noise (1000, 2000, 500, 2, 200, 0)
end.


Good luck with your program!

Michelangelo Jones.