Author Topic: error BASS_ChannelGetPosition  (Read 115 times)

Salvo

  • Posts: 162
error BASS_ChannelGetPosition
« on: 6 Sep '24 - 23:14 »
there is a bug on the position.
link is the demo with the mp3 file, but I think it does it with all mp3 files.

loading an mp3 file, the position is correct with the music being listened to.

But just listen to the first 30 seconds and then click on "GOTO TO 5 SEC", which once 30 seconds are reached the music is 2 seconds behind.

link are the test and mp3 files : https://www.karaoke5.com/public/download/test.zip

.........
if OpenDialog1.Execute then
  begin
    MemChan.Free;
    MemChan := TMemoryStream.Create;
    MemChan.LoadFromFile(PChar(OpenDialog1.FileName));
    BASS_ChannelStop(chan);
    Chan := BASS_StreamCreateFile(True, MemChan.memory, 0, MemChan.size, BASS_STREAM_DECODE);
    Chan := BASS_FX_TempoCreate(Chan, BASS_FX_FREESOURCE);
    BASS_ChannelPlay(chan, True);
    Timer1.Enabled:=True;
  end;

procedure TForm17.Timer1Timer(Sender: TObject);
var posi:Integer;
begin
      posi := Trunc(BASS_ChannelBytes2Seconds(Chan, BASS_ChannelGetPosition(Chan, BASS_POS_BYTE)) * 1000);
      Label1.Text := FormatDateTime('hh:nn:ss.zzz', posi / CostanteM);
end;
.......................

Button "GOTO TO 5 SEC" :
BASS_ChannelSetPosition(chan, BASS_ChannelSeconds2Bytes(chan, 5), BASS_POS_BYTE);

Salvo

  • Posts: 162
Re: error BASS_ChannelGetPosition
« Reply #1 on: 7 Sep '24 - 10:14 »

Chan := BASS_StreamCreateFile(True, MemChan.memory, 0, MemChan.size, 0);
Even taking off
///Chan := BASS_FX_TempoCreate(Chan, BASS_FX_FREESOURCE);
It gives the same problem.

It does it with this mp3 file zipped on the link.
https://www.karaoke5.com/public/download/test.zip
« Last Edit: 7 Sep '24 - 10:26 by Salvo »

MB_SOFT

  • Posts: 496
Re: error BASS_ChannelGetPosition
« Reply #2 on: 7 Sep '24 - 13:03 »
use BASS_STREAM_PRESCAN flag in the BASS_StreamCreateFile call

Salvo

  • Posts: 162
Re: error BASS_ChannelGetPosition
« Reply #3 on: 7 Sep '24 - 20:37 »
use BASS_STREAM_PRESCAN flag in the BASS_StreamCreateFile call

It works great.

Thank you