Author Topic: BASS_ChannelSetPosition problem  (Read 333 times)

nelson13

  • Posts: 20
BASS_ChannelSetPosition problem
« on: 27 Aug '23 - 20:50 »
Hello,
I ran into a problem that I understand is a bug in the library.
I need to go to an exact location of a song (The Intro time).
It works fine with mp3 files but with flac it is positioned several seconds before the specified time.

Chan := BASS_StreamCreateURL(PWideChar(AnsiString(Archivo)), 0, BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE, nil, nil);
BASS_ChannelPlay(chan, false);
BASS_ChannelSetPosition(Chan, (BASS_ChannelSeconds2Bytes(chan, 15.2)), BASS_POS_BYTE);

At this moment it is positioned at 11 seconds instead of 15.2

With a few flac tracks, the position is correct
any ideas?

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 25430
Re: BASS_ChannelSetPosition problem
« Reply #1 on: 28 Aug '23 - 13:00 »
Please confirm whether you're loading the BASSFLAC add-on via BASS_PluginLoad, and if so, does the stream's "ctype" value (from BASS_ChannelGetInfo) show that it's being used in this case? It should be BASS_CTYPE_STREAM_FLAC or BASS_CTYPE_STREAM_FLAC_OGG.

When streaming a file from the internet (using BASS_StreamCreateURL), note that BASS can only seek within the currently downloaded portion of the file, so it may be that the requested position isn't available yet if you try seeking right after stream creation. Check the BASS_ChannelSetPosition return value to confirm whether it was successful.

nelson13

  • Posts: 20
Re: BASS_ChannelSetPosition problem
« Reply #2 on: 28 Aug '23 - 14:56 »
Thanks, Ian
I just added the flac plugin, but it does the exact same thing
Code: [Select]
  if not BASS_Init(-1, 44100, 0, Handle, nil) then
    ShowMessage('Error al inicializar placa de audio!');
  BASS_PluginLoad('bassflac.dll', 0);

Code: [Select]
BASS_ChannelGetInfo(Chan, info);
if (BassFLAC.BASS_CTYPE_STREAM_FLAC = info.ctype) or (BassFLAC.BASS_CTYPE_STREAM_FLAC_OGG = info.ctype) then
  Showmessage('OK')
Else
Showmessage(info.ctype.tostring());
I throw the value 65544
It is neither of those two flags

BASS_ChannelSetPosition return ok!

It doesn't matter that it listens to the entire file, which should have been downloaded. It does not go to the configured position.

Any ideas?

Ian @ un4seen

  • Administrator
  • Posts: 25430
Re: BASS_ChannelSetPosition problem
« Reply #3 on: 28 Aug '23 - 15:50 »
65544 = 0x10008 = BASS_CTYPE_STREAM_MF. That means Media Foundation (not BASSFLAC) is being used to decode the file. Are you sure it's a FLAC file? Please upload (or link) the file to have a look at here:

   ftp.un4seen.com/incoming/

nelson13

  • Posts: 20
Re: BASS_ChannelSetPosition problem
« Reply #4 on: 28 Aug '23 - 16:16 »
This is an example.

https://musicone.com.ar/Dua%20Lipa%20-%20Dance%20The%20Night.flac

As I see it is a flac file, beyond the extension

Ian @ un4seen

  • Administrator
  • Posts: 25430
Re: BASS_ChannelSetPosition problem
« Reply #5 on: 28 Aug '23 - 17:09 »
I don't seem to be able to connect to that server from here (it just times-out). Perhaps it's geo-protected? Can you reupload the file to the FTP server above or a file sharing site?

nelson13

  • Posts: 20

Ian @ un4seen

  • Administrator
  • Posts: 25430
Re: BASS_ChannelSetPosition problem
« Reply #7 on: 29 Aug '23 - 12:30 »
Seeking to 15.2s in that file is working fine with BASSFLAC here. Here's a direct download link that can be streamed (passed to BASS_StreamCreateURL):

   https://drive.google.com/uc?export=download&id=1WBrQirOQbAlYhjzc9RvR0IV0H-xhL89L

If the "ctype" is still BASS_CTYPE_STREAM_MF there, please check the BASS_PluginLoad return value to confirm whether BASSFLAC was loaded. If that failed then also check the error code with BASS_ErrorGetCode to find out why.

nelson13

  • Posts: 20
Re: BASS_ChannelSetPosition problem
« Reply #8 on: 29 Aug '23 - 21:14 »
I get error 2, however the dll is next to the executable and the bass.dll file, it's strange.
Any ideas?
Thanks

Code: [Select]
if not BASS_Init(-1, 44100, 0, Handle, nil) then
      ShowMessage('Error al inicializar placa de audio!');
   pluginHandle := BASS_PluginLoad('bassflac.dll', 0);
    if pluginHandle = 0 then
    begin
      // Obtiene el código de error y muestra un mensaje de error
      errorCode := BASS_ErrorGetCode;
      MessageBox(0, PChar('Error al cargar el plugin. Código de error: ' + IntToStr(errorCode)),
        'Error', MB_ICONERROR);
      BASS_Free; // Libera los recursos de BASS
      Exit;
    end;

Chris

  • Posts: 2168
Re: BASS_ChannelSetPosition problem
« Reply #9 on: 30 Aug '23 - 08:44 »
Hi , which Delphi Version?
 if you are working with modern delphi versions then i suggest
Code: [Select]
pluginHandle := BASS_PluginLoad('bassflac.dll', BASS_UNICODE);

nelson13

  • Posts: 20
Re: BASS_ChannelSetPosition problem
« Reply #10 on: 30 Aug '23 - 23:09 »
That worked, thank you very much!
And it seems that it solved the problem according to a quick test  :D