var WriteToWave : Boolean = false;
Mixer, mixfeed : DWORD;
recbuf : pbyte;
reclen : DWORD;
function FeederProc(
handle: HSTREAM; buf: Pointer; len: DWORD; user: DWORD): DWORD;
stdcall;
begin
if len >reclen
then len:= reclen;
CopyMemory(recbuf, buf, len);
recbuf^:= recbuf^ + len;
reclen:= reclen - len;
result:= len;
end;
function RecordingCallback(channel : HRECORD; buf:Pointer; len, user:DWORD): Boolean;
stdcall;
var mixbuf:
array[0..10000]
of Byte;
c : DWORD;
begin
recbuf:= Buf;
reclen:= len;
With FBassEngine
do
begin
if WriteToWave
then
begin
while true
do
begin
C:= BASS_ChannelGetData(mixer, @mixbuf, SizeOf(mixbuf));
BASS_Encode_Write(FChannel_Enc, @mixbuf, c);
end;
result:= true;
end;
end;
end;
//
Mixer:= BASS_Mixer_StreamCreate(32000, 2, BASS_STREAM_DECODE);
Mixfeed:= BASS_StreamCreate(44100, 2, BASS_STREAM_DECODE, @FeederProc, 0);
BASS_Mixer_StreamAddChannel(mixer, Mixfeed, 0);
FChannel_Enc:= BASS_Encode_Start(Mixer, Pchar(fOutStr + '
.wav'), Flag
or BASS_ENCODE_PCM, @EncoderCallback, 0);
if FChannel_Enc = 0
then
begin
//Error
Exit;
end;
BASS_ChannelPlay(mixfeed, false);
BASS_ChannelPlay(mixer, false);
if BASS_Encode_SetPaused(FChannel_Enc, False)
then
begin
WriteToWave:= true;