Author Topic: Opus Decode RecordChannel without write to File.  (Read 335 times)

nikos

  • Posts: 63
Code: [Select]
var
  rchan: HRECORD=0;
  playchan:HSTREAM = 0;
  EncodeChan:HENCODE=0;
  BASSProcs: BASS_FILEPROCS;
  writestream:TmemoryStream;






function RecordingCallback(channel: HRECORD; buffer: Pointer; length, user: DWORD): Boolean; stdcall;
begin
result:= Bool(BASS_Encode_IsActive(channel));
end;

procedure EncodeCallback(handle:HENCODE; channel:DWORD; buffer:Pointer; length:DWORD; user:Pointer) stdcall;
begin
writeStream.Write(buffer^, length); //i write into writeStream The Buffer of encoder
//or how i will feed the PLAYCHAN?
end;



Procedure Bass_Close(user: Pointer); stdcall;
Begin
End;

Function Bass_Length(user: Pointer): QWORD; stdcall;
Begin
result:=0;
End;

Function Bass_Read(buffer: Pointer; length: DWORD; user: Pointer): DWORD; stdcall;
begin
buffer:=writestream.Memory;
length:=writestream.size;
result:=writestream.size;
End;


procedure TForm1.Button1Click(Sender: TObject);
begin
writeStream:=TmemoryStream.create;

rchan := BASS_RecordStart(44100, 2, 0 , @RecordingCallback, 0); //start record
BASS_ChannelPlay(rchan, false);


EncodeChan:=BASS_Encode_OPUS_Start(rchan, nil,  BASS_ENCODE_AUTOFREE  , @EncodeCallback, nil); //start encoder with call back
BASS_ChannelPlay(EncodeChan, false);


//////////and here i am trying to listen The Stream but no luck
BASSProcs.close := Bass_Close;
BASSProcs.length := Bass_Length;
BASSProcs.read := Bass_Read;
BASSProcs.seek := nil;
playChan:=BASS_OPUS_StreamCreateFileUser(STREAMFILE_BUFFERPUSH, 0, BASSProcs, nil);

///---> here i get Error BASS_ERROR_FILEFORM

BASS_ChannelPlay(playChan, false);
end;


If i Write The WRITESTREAM to FIle i Can hear athe recorded Data but How i can Play them with bass?

« Last Edit: 12 Aug '19 - 14:01 by nikos »