program soundeffect;

{ SoundEff.pas - Example program showing use of the tritone() function }

{$L ptrit_s}
uses crt;

var v1, v2, v3 : word;

procedure tritone(t,a,b,c,d:word); external;

function NextVal(var A:word):word;
begin
  if A >= 8191 then
	  NextVal := 1
  else
	  NextVal := A + 5;
end;

function PrevVal(var A:word):word;
begin
  if A <= 1 then
	  PrevVal := 8191
  else
	  PrevVal := A - 5;
end;

begin
	write('Press any key to quit... ');
   v1 := 1; v2 := 4050; v3 := 8191;
   while not ( KeyPressed ) do begin
      tritone( 512, v1, v2, v3, 6 );
      v1 := NextVal(v1);
      v2 := PrevVal(v2);             
      v3 := PrevVal(v3);             
   end;
end.
