ASIO + DSD output

Started by diystar,

diystar

        BASS_Init(0, 44100, 0, Application.Handle, nil);
        BASS_SetConfig(BASS_CONFIG_UPDATETHREADS, 0);

        ASIOInit:=BASS_ASIO_Init(0,BASS_ASIO_THREAD);
        if ASIOInit then
        begin
          cbDSDNative.Enabled:=BASS_ASIO_SetDSD(True);
          if cbDSDNative.Enabled then
          begin
            if not cbDSDNative.Checked then
            BASS_ASIO_SetDSD(False);
          end else
          begin
            BASS_ASIO_Free;
            ASIOInit:=BASS_ASIO_Init(0,BASS_ASIO_THREAD);
            cbDSDNative.Checked:=False;
          end;
        end;
       
        if ASIOInit then
        begin
          BASS_SetConfig(BASS_CONFIG_DSD_FREQ,Trunc(Bass_Asio_GetRate));

          f:=BASS_UNICODE or BASS_SAMPLE_FLOAT or BASS_STREAM_DECODE;
          if cbDSDNative.Checked and ((ExtCode='.dff;') or (ExtCode='.dsf;')) then
          stream := Bass_DSD_StreamCreateFile(BASS_FILE_NAME, pchar(FName), 0, 0, f or BASS_DSD_Raw, 0) else
          stream := Bass_StreamCreateFile(BASS_FILE_NAME, pchar(FName), 0, 0, f);

          BASS_ASIO_ChannelEnable(false, 0, @AsioProc, Pointer(Stream));
          BASS_ASIO_ChannelJoin(false, 1, 0);

          if cbDSDNative.Checked then
          begin
            BASS_ASIO_ChannelSetFormat(false, 0, BASS_ASIO_FORMAT_DSD_MSB);
            Bass_ChannelGetAttribute(Stream,Bass_Attrib_DSD_Rate,Rate);
            BASS_ASIO_ChannelSetRate(false, 0, Rate);
            Bass_Asio_SetRate(Rate);
          end else
          begin
            BASS_ASIO_ChannelSetFormat(false, 0, BASS_ASIO_FORMAT_Float);
            BASS_ChannelGetInfo(Stream, ChanInfo);
            BASS_ASIO_ChannelSetRate(false, 0, ChanInfo.freq);
            BASS_ASIO_SetRate(ChanInfo.freq);
          end;

          BASS_ASIO_Start(0,0);
        end;
         
......

function AsioProc(input: BOOL; channel: DWORD; buf: Pointer; length: DWORD; user: Pointer): DWORD; stdcall;
var
  c: dword;
begin
  c := Bass_ChannelGetData(DWORD(user), buf, length);
  if c = DWORD(-1) then c := 0;
  Result := c;
end;

This is my code. Is it correct? (Since I don't have the relevant hardware, I'm not sure if it's correct)

Ian @ un4seen

If you can read C code, you could have a look at the DSDTEST.C example included in the BASSASIO package (C\DSDTEST folder). Unfortunately, there isn't a Delphi version of that, but the BASS/BASSASIO calls will be much the same in any language.


diystar

#3
Please help me test it. Can it make sound normally w/ or w/o DSD mode?