Author Topic: BASS ASIO e BASS MIXER - Error 38 with BASS_DECODE  (Read 155 times)

johnvantelli

  • Posts: 41
Hi Everybody
I've a problem with Bass ASIO e Mix initialization.
This is my init function that give be an error (38) when I call BASS_ChannelPlay.

ideas?


Code: [Select]
function InitSoundSystem: Boolean;
begin
  if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
    AddLog('Audio library wrong version');

  BASS_Free;
  BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, 0);
  // not playing anything via BASS, so don't need an update thread

  // init BASS (for the FX)
  if not BASS_Init(0, 44100, 0, 0, nil) then
    AddLog(concat('ERR: BASS INIT Error :', inttostr(BASS_ErrorGetCode)));

  if not BASS_ASIO_Init(0, 0) then
    AddLog(concat('ERR: ASIO INIT Error :', inttostr(BASS_ErrorGetCode)));

  if not BASS_ASIO_ChannelEnable(false, StreamMixer, @AsioProc, nil) then
    AddLog(concat('ERR: ASIO ENABLE CHANNEL Error :',
      inttostr(BASS_ErrorGetCode)));

  if not BASS_ASIO_ChannelJoin(false, 1, 0) then
    AddLog(concat('ERR: ASIO CHANNEL JOIN Error :',
      inttostr(BASS_ErrorGetCode)));

  if not BASS_ASIO_ChannelSetFormat(false, 0, BASS_ASIO_FORMAT_FLOAT) then
    AddLog(concat('ERR: ASIO CHANNEL SET FORMAT Error :',
      inttostr(BASS_ErrorGetCode)));

  if not BASS_ASIO_ChannelSetRate(false, 0, 44100) then
    AddLog(concat('ERR: ASIO CHANNEL SET RATE Error :',
      inttostr(BASS_ErrorGetCode)));

  if not BASS_ASIO_SetRate(44100) then
    AddLog(concat('ERR: ASIO SET RATE Error :', inttostr(BASS_ErrorGetCode)));

  if not BASS_ASIO_Start(0, 1) then
    AddLog(concat('ERR: ASIO START Error :', inttostr(BASS_ErrorGetCode)));

  // create a stereo mixer
  StreamMixer := BASS_Mixer_StreamCreate(44100, 2, 0 //
    or BASS_MIXER_BUFFER //
    or BASS_MIXER_NORAMPIN //
    or BASS_MIXER_NONSTOP //
    or BASS_SAMPLE_FLOAT //
    or BASS_STREAM_DECODE // (decode is necessary for asio)
{$IFDEF UNICODE} or BASS_UNICODE {$ENDIF}  //
    );

  if BASS_ErrorGetCode <> 0 then
    AddLog(concat('ERR: CREATING Mixer Error' + inttostr(BASS_ErrorGetCode)));

  if not BASS_ChannelPlay(StreamMixer, false) then
    AddLog(concat('ERR: BASS CHANNEL PLAY (Mixer) Error'));

  Result := (BASS_ErrorGetCode = 0);

  if Result then
    AddLog('SoundSystem init OK')
  else
    AddLog('ERR: SoundSystem init failed :' + inttostr(BASS_ErrorGetCode));

end;

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASS ASIO e BASS MIXER - Error 38 with BASS_DECODE
« Reply #1 on: 9 Feb '17 - 14:13 »
Error code 38 is BASS_ERROR_DECODE. When BASS_ChannelPlay generates that error code, it indicates that the channel is a "decoding channel" (using BASS_STREAM_DECODE), which can't be played (only decoded). When using ASIO output, you should instead call BASS_ChannelGetData on the channel handle in your ASIOPROC function. You should also really create the channel before calling BASS_ASIO_Start to start the ASIO device, so that it's ready for the BASS_ChannelGetData calls.