{Scott Mitchell, (Late) 1995  :)

       I make no guarentees or warantees or anything like that.  This
       little program is neat, and tested, but I make no guarentees that it
       won't make your computer blow up or something.}
program SinSound;
uses crt,dos,graph;
const freq=3D1.5; Speed=3D1234;  {Freq is the Frequency, or the deviation=
 over
                                   the note frequency, which is set at 440
                                   Hz.  Bump either this or the note value=
 up
                                   and down to change the pitch.

                              Speed is the accuracy and speed with which the
                                   graph is drawn.  The greater the number,
                                   the more accurately the graph is drawn.
                                   I think 1234 is a happy medium between
                                   speed and accuracy.  Experiment with=
 other
                                   numbers for fun! :)   }
var loop,sample:real;
    note:word;
    gd,gm:^integer;

{---------------------------------------------------------------------------=
}

function Tan(x:real):real;
begin
     Tan:=3Dsin(x)/cos(x);
end;

{--------------------------------------------------------------------------}

function Sec(x:real):real;
begin
     Sec:=3D1/Cos(x);
end;

{--------------------------------------------------------------------------}

procedure DrawGraph(x,y:real);
var converty,convertx:real;
begin
     convertx:=3D3*pi;  converty:=3D154;
     PutPixel(trunc(x*convertx),trunc(460-y*converty),15);
end;

{---------------------------------------------------------------------------=
}

procedure MakeSound(equate,y:real);
begin
     equate:=3Dfreq+equate;
     sound(trunc(equate*note));
     DrawGraph(y,equate);
end;

{--------------------------------------------------------------------------}

procedure DrawEverything;
begin
     gd^:=3Ddetect;   InitGraph(gd^,gm^,'c:\tp\bgi\');
     setcolor(4);                line(0,230,640,230);
     setcolor(7);
     SetLineStyle(DottedLn, 0, NormWidth);
     Line(0,74,640,74);
     Line(0,382,640,382);
     Line(0,(74+230) div 2, 640, (74+230) div 2);   {Draws the Y=
 coordinates}
     Line(0,(230+382)div 2, 640, (230+382)div 2);   {in increments of 1}

     line(45,0,45,500);
     line(89,0,89,500);
     line(132,0,132,500);
     line(177,0,177,500);       {X coordinates  (in increments of pi)}
     line(221,0,221,500);
     line(266,0,266,500);
     line(311,0,311,500);
     line(355,0,355,500);
     line(399,0,399,500);
     line(444,0,444,500);
     line(488,0,488,500);
     line(532,0,532,500);
     line(576,0,576,500);
     line(621,0,621,500);

     setcolor(15);
     SetTextStyle(DefaultFont, HorizDir, 1);
     OutTextxy(620,72,'1');
     OutTextxy(620,379,'-1');    {Labels the Y coordinates}
     OutTextxy(620,227,'0');

     OutTextXY(35,7,'=E3');
     OutTExtXY(82,7,'2=E3');
     OutTextXY(125,7,'3=E3');
     OutTextXY(170,7,'4=E3');     {Labels the X coordinates}
     OutTextXY(214,7,'5=E3');
     OutTextXY(260,7,'6=E3');
     OutTextXY(304,7,'7=E3');
     OutTextXY(349,7,'8=E3');
     OutTextXY(393,7,'9=E3');
end;

{--------------------------------------------------------------------------}

begin
     clrscr;
     DrawEverything;
     loop:=3D0;
     note:=3D440;      {The base frequency.  I chose this number, b/c this=
 is
                     the frequency at which musicians tune their=
 instruments}
     repeat
           MakeSound(0.33*sin(loop)+0.75*sin(2*loop)+0.33*sin(3*loop)*
                     sin(2*loop)-0.25*sin(3*loop),loop);
           loop:=3Dloop+(pi/Speed);   {This determines the accuracy and=
 speed
                                          while drawing the graph}
     until keypressed;
     nosound;
end.

--=====================_837066557==_--

