pcmaudio: add routine/external procedure to read sample file
This commit is contained in:
parent
819c808c50
commit
0d9db023a1
3 changed files with 23 additions and 9 deletions
|
|
@ -35,8 +35,7 @@ var pic:PictData;
|
||||||
procedure WaitVSync; external;
|
procedure WaitVSync; external;
|
||||||
|
|
||||||
function readAudioFile(fname:string):SndBufPtr;
|
function readAudioFile(fname:string):SndBufPtr;
|
||||||
var i,size:integer;
|
var size:integer;
|
||||||
c:char;
|
|
||||||
buf:SndBufPtr;
|
buf:SndBufPtr;
|
||||||
f:file;
|
f:file;
|
||||||
begin
|
begin
|
||||||
|
|
@ -44,13 +43,8 @@ begin
|
||||||
size := FileSize(f);
|
size := FileSize(f);
|
||||||
new(buf, size);
|
new(buf, size);
|
||||||
|
|
||||||
buf^ := '';
|
ReadSample(f, buf);
|
||||||
write('Reading ', size, ' bytes from ', fname);
|
|
||||||
for i := 1 to size do
|
|
||||||
begin
|
|
||||||
read(f,c);
|
|
||||||
AppendChar(buf^,c);
|
|
||||||
end;
|
|
||||||
writeln;
|
writeln;
|
||||||
close(f);
|
close(f);
|
||||||
readAudioFile := buf;
|
readAudioFile := buf;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
type SndBuf = string[32768];
|
type SndBuf = string[32768];
|
||||||
type SndBufPtr = ^SndBuf;
|
type SndBufPtr = ^SndBuf;
|
||||||
|
|
||||||
|
procedure ReadSample(aFile:file;buf:SndBufPtr); external;
|
||||||
procedure PlaySample(buf:SndBufPtr;sampleRate:integer); external;
|
procedure PlaySample(buf:SndBufPtr;sampleRate:integer); external;
|
||||||
procedure SampleQStart(buf:SndBufPtr;loop:boolean;sampleRate:integer); external;
|
procedure SampleQStart(buf:SndBufPtr;loop:boolean;sampleRate:integer); external;
|
||||||
procedure SampleQStop; external;
|
procedure SampleQStop; external;
|
||||||
|
|
|
||||||
|
|
@ -302,3 +302,22 @@ SMPLQ_I_XT2:
|
||||||
DROP
|
DROP
|
||||||
LOADREG IR ; jump via interrupt return register
|
LOADREG IR ; jump via interrupt return register
|
||||||
JUMP
|
JUMP
|
||||||
|
|
||||||
|
; args: file ptr, ptr to SndBuf (i.e. a String)
|
||||||
|
READSAMPLE:
|
||||||
|
; buf ptr + 0: addr of cur size header field
|
||||||
|
; buf ptr + 4: addr of max size header field
|
||||||
|
; buf ptr + 8: start of raw data
|
||||||
|
|
||||||
|
; copy max size to current size header field of SndBuf
|
||||||
|
INC.S1.X2Y 4 ; [ file ptr, buf ptr, buf ptr+4 ]
|
||||||
|
LOADI ; [ file ptr, buf ptr, max size ]
|
||||||
|
STOREI 8 ; [ file ptr, buf ptr+8 ]
|
||||||
|
; put max size back on ToS
|
||||||
|
DUP ; [ file ptr, buf ptr+8, buf ptr+8]
|
||||||
|
DEC 4 ; [ file ptr, buf ptr+8, buf ptr+4]
|
||||||
|
LOADI ; [ file ptr, buf ptr+8, max size ]
|
||||||
|
|
||||||
|
LOADCP READFS
|
||||||
|
CALL
|
||||||
|
RET
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue