Author Topic: Bass as Decoder  (Read 232 times)

RedCat

  • Posts: 13
Bass as Decoder
« on: 19 Jan '18 - 15:18 »
Hello for all members! How i can use bass as decoder in DShow filter? I tried to use BASS_StreamPutData, but it not work :-[
Code: [Select]
constructor TSimpleTransform.Create(ObjName: String; Unk: IUnKnown; out hr: HRESULT);
begin
  inherited Create(ObjName, Unk, CLSID_SimpleTransform);
  BASS_Init(0,44100,  BASS_DEVICE_LATENCY, hr , nil);
  pchan := BASS_StreamCreate(44100, 2, BASS_STREAM_DECODE, STREAMPROC_PUSH, nil);
  crop_bottom := 100;
end;

function TSimpleTransform.Transform(pIn, pOut: IMediaSample): HRESULT;
var
   hr: HRESULT;
   y: Integer;
   pSourceBuffer, pDestBuffer : PBYTE;
   chan: DWORD;

begin
   // copy attributes
   hr := Copy(pIn, pOut);
   if (FAILED(hr)) then begin
      Result := hr;
      exit;
   end;


   pIn.GetPointer(pSourceBuffer);
   pOut.GetPointer(pDestBuffer);

    BASS_StreamPutData(pchan, pSourceBuffer, BASS_STREAMPROC_END);
    BASS_ChannelGetData(pchan,pDestBuffer,BASS_DATA_AVAILABLE);


   Result := S_OK;
end;
I think, this code wrong or not full, but i don't have more ideas ???
Sorry for my English, i'm from Uzbekistan.

Ian @ un4seen

  • Administrator
  • Posts: 20767
Re: Bass as Decoder
« Reply #1 on: 19 Jan '18 - 17:03 »
If you have encoded data, you will need to use BASS_StreamCreateFileUser rather than BASS_StreamCreate (which is only for PCM data). You would also then use BASS_StreamPutFileData instead of BASS_StreamPutData. Before you can use BASS_StreamPutFileData, you will need to provide some data to BASS_StreamCreateFileUser via a FILEREADPROC callback function, so that the data's format can be detected and the appropriate decoder initialized. Please see the BASS_StreamCreateFileUser and BASS_FILEPROCS documentation for details.

I'm not sure if they do exactly the same as what you want, but you could have a look at the source code of these existing projects for some ideas/pointers:

   http://dsp-worx.de/?n=15
   https://rwijnsma.home.xs4all.nl/dc-bsm/index.htm

RedCat

  • Posts: 13
Re: Bass as Decoder
« Reply #2 on: 19 Jan '18 - 17:34 »
Thank you very much, i will study the source code DCBassSource