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;
|
||||
|
||||
function readAudioFile(fname:string):SndBufPtr;
|
||||
var i,size:integer;
|
||||
c:char;
|
||||
var size:integer;
|
||||
buf:SndBufPtr;
|
||||
f:file;
|
||||
begin
|
||||
|
|
@ -44,13 +43,8 @@ begin
|
|||
size := FileSize(f);
|
||||
new(buf, size);
|
||||
|
||||
buf^ := '';
|
||||
write('Reading ', size, ' bytes from ', fname);
|
||||
for i := 1 to size do
|
||||
begin
|
||||
read(f,c);
|
||||
AppendChar(buf^,c);
|
||||
end;
|
||||
ReadSample(f, buf);
|
||||
|
||||
writeln;
|
||||
close(f);
|
||||
readAudioFile := buf;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
type SndBuf = string[32768];
|
||||
type SndBufPtr = ^SndBuf;
|
||||
|
||||
procedure ReadSample(aFile:file;buf:SndBufPtr); external;
|
||||
procedure PlaySample(buf:SndBufPtr;sampleRate:integer); external;
|
||||
procedure SampleQStart(buf:SndBufPtr;loop:boolean;sampleRate:integer); external;
|
||||
procedure SampleQStop; external;
|
||||
|
|
|
|||
|
|
@ -302,3 +302,22 @@ SMPLQ_I_XT2:
|
|||
DROP
|
||||
LOADREG IR ; jump via interrupt return register
|
||||
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