pcmaudio: set amplitude to biased zero at end
pcmtest2: small updates to the demo program
This commit is contained in:
parent
598ee8921f
commit
536c0adde7
2 changed files with 44 additions and 24 deletions
|
|
@ -1,32 +1,21 @@
|
|||
{$H1536}
|
||||
{$H2560}
|
||||
program pcmtest2;
|
||||
uses pcmaudio;
|
||||
|
||||
var filename:string;
|
||||
buf:SndBufPtr;
|
||||
f:file;
|
||||
size:integer;
|
||||
i:integer;
|
||||
c:char;
|
||||
sampleRate:integer;
|
||||
err:integer;
|
||||
done:boolean;
|
||||
c:char;
|
||||
|
||||
function readAudioFile(fname:string):SndBufPtr;
|
||||
var i,size:integer;
|
||||
c:char;
|
||||
buf:SndBufPtr;
|
||||
f:file;
|
||||
begin
|
||||
if ParamCount > 0 then
|
||||
filename := ParamStr(1)
|
||||
else
|
||||
begin
|
||||
write('Filename> ');
|
||||
readln(filename);
|
||||
end;
|
||||
|
||||
err := 1;
|
||||
if ParamCount > 1 then
|
||||
val(ParamStr(2), sampleRate, err);
|
||||
if err > 0 then
|
||||
sampleRate := 16000;
|
||||
|
||||
open(f, filename, ModeReadOnly);
|
||||
open(f, fname, ModeReadOnly);
|
||||
size := FileSize(f);
|
||||
new(buf, size);
|
||||
|
||||
|
|
@ -41,17 +30,42 @@ begin
|
|||
|
||||
close(f);
|
||||
|
||||
readAudioFile := buf;
|
||||
end;
|
||||
|
||||
begin
|
||||
if ParamCount > 0 then
|
||||
filename := ParamStr(1)
|
||||
else
|
||||
begin
|
||||
write('Filename> ');
|
||||
readln(filename);
|
||||
end;
|
||||
|
||||
err := 1;
|
||||
if ParamCount > 1 then
|
||||
val(ParamStr(2), sampleRate, err);
|
||||
if err > 0 then
|
||||
sampleRate := 32000;
|
||||
|
||||
buf := readAudioFile(filename);
|
||||
|
||||
SampleQStart(buf, sampleRate);
|
||||
|
||||
write('Press Q to stop> ');
|
||||
write('Press ESC to stop> ');
|
||||
done := false;
|
||||
while not done do
|
||||
begin
|
||||
read(c);
|
||||
if upcase(c) = 'Q' then
|
||||
done := true
|
||||
if c = #27 then
|
||||
begin
|
||||
done := true; writeln(';');
|
||||
end
|
||||
else
|
||||
writeln('Queue size: ', SampleQSize);
|
||||
if c = '?' then
|
||||
begin
|
||||
writeln; writeln('Queue: ', SampleQSize);
|
||||
end;
|
||||
end;
|
||||
|
||||
SampleQStop;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue