BASS_ChannelSeconds2Bytes

Started by Dimitris,

Dimitris

I think that BASS_ChannelSeconds2Bytes does not behave correctly.
The seconds parameter is not seconds? but seconds/10 and yet the "jump" is not correct in to the mp3 stream.
I mean i say go to second 60 but it goes to 1:06 seconds and i cannot find a formula that works.
ver is 1.8 ???

Ian @ un4seen

I doubt that's a problem with BASS_ChannelSeconds2Bytes - it's a very simple function :)

Post the code you're using to set and get the position, maybe there's a problem in that.

Dimitris Touzozoglou

Let us suppose that the mp3 file does not have an ID3v2 tag. The following code tries to frab a section of that file but the output file is a bit longer than it should be.
---
procedure TForm1.Button1Click(Sender: TObject);
begin

  if not BASS_Init(-1, 44100, 0, handle) then begin
    ShowMessage('Could not initialize BASS');
    Exit;
  end;
  if not BASS_Start then begin
    ShowMessage('Could not start the BASS output');
    Exit;
  end;

  h := BASS_StreamCreateFile( false, Pchar('1.mp3'), 0,0,BASS_MP3_SETPOS and BASS_SAMPLE_FLOAT  );

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  BASS_Stop;
  BASS_Free;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  s,t: TFileStream;
  i: Cardinal;
begin

  i := BASS_ChannelSeconds2Bytes( h, StrToFloat( Edit1.text) );

  s := TFileStream.Create( '1.mp3', fmOpenRead      or fmShareDenyNone        );
  t := TFileStream.Create( '2.mp3', fmCreate             );

  s.Position := 0;
  t.Position := 0;

  t.CopyFrom( s, i );

  s.Free;
  t.Free;
end;

Ian @ un4seen

BASS_ChannelSeconds2Bytes translates a playback position in seconds into a playback position in bytes, to simplify things when using the BASS functions that require positions to be specified in bytes. It does not give the file position, which seems to be what you're expecting in the code above.

Dimitris Touzozoglou

I see. :(
It would be nice to have such a function though to convert a time code in to an absolute file position ( could be used in trim cut operations like the code i tried to use ).
Thanx for the reply.