{ Отзывы присылать на склад нитроманита nitromanit@mail.ru

  Пример действующей программы записывающей звуковую волну
  при помощи моей утилиты SB.TPU
}

uses crt,sb,keyboard,profiler;

type TSoundBuf=array [0..60000] of byte;

var voice1,voice2,channel,key,valume,i,count,frec,first,d,mic:word;
    rvalume,lvalume,linervalume,linelvalume,fmrvalume,fmlvalume,CDvalume,
    dacrvalume,daclvalume,micvalume,recsourse:byte;
    stereomode:boolean;
    f:file;
    fname:string;
    buf1,buf2:^TSoundBuf;

procedure Rec;
begin
while key=KEYOFF do begin
    Recording(frec,buf1^,60000);
    blockwrite(f,buf1^,60000,d);
    key:=inkey;
    {move(Buf1^,Buf2^[(i-1)*10000],10000);}
    writeln('i= ',i,' Long= ',i*60,' Kbyte');
    inc(i);
    end;
end;

procedure Rec2;
begin
first:=0;
SBMode:=AsyncPlay;
InitDMA;
TransferDone:=1;
while key=KEYOFF do begin
    repeat
    until TransferDone=1;
    if first=1 then move(Buf1^,Buf2^,60000);
    Recording(frec,buf1^,60000);
    if first=1 then blockwrite(f,buf2^,60000,d);
    key:=inkey;
    writeln('i= ',i,' Long= ',i*60,' Kbyte');
    inc(i);
    first:=1;
    end;
end;

begin
if paramcount=0 then halt;
fname:=paramstr(1);
writeln('Recorder .voc');
writeln('1-4000 kHz');
writeln('2-11000 kHz');
writeln('3-22000 kHz');
writeln('4-44000 kHz');
writeln('5-Quit');
read(key);
  case key of
    1:frec:=4000;
    2:frec:=11000;
    3:frec:=22000;
    4:frec:=44000;
  else halt;
  end;
writeln('Input valume for "line in"(1..14):');
read(linervalume);
writeln('Input main valume for output(1..14):');
read(rvalume);
writeln('Input sourse for recording(1-for "line in" or 2-for microphon)');
read(mic);
getmem(buf1,sizeof(TSoundBuf));
getmem(buf2,sizeof(TSoundBuf));
assign(f,fname);{$i-}
rewrite(f,1);   {$i+}
i:=ioresult;
if i<>0 then halt;

clrscr;
InitMixer;
SetMainValume(rvalume,rvalume);
{SetDACValume(6,6);}
SetMono;
{SetStereo;}
if mic=1 then begin SetRecSourse(RecLine);SetLineValume(linervalume,linervalume);end
   else begin SetMicValume(linervalume);SetRecSourse(RecMic);end;

i:=1;
key:=inkey;
writeln('Recording to ',fname,' audio file...');
{while key=KEYOFF do begin
    Recording(frec,buf1^,60000);
    blockwrite(f,buf1^,60000,key);
    key:=inkey;
    writeln('i= ',i,' Long= ',i*60,' Kbyte');
    inc(i);
    end;}
Rec;
close(f);
freemem(buf2,sizeof(TSoundBuf));
freemem(buf1,sizeof(TSoundBuf));
end.