0
0

play this music (http://www.54nm.com/two_butterfly.mp3)(time:4:17)

but use function FSOUND_Stream_GetLengthMs get the time is error! why? (error time 6:18)

  • You must to post comments
0
0

are you openening the file with the mpeg_accurate flag? if not then you will get incorrect mp3 stream lengths especially with vbr files

  • You must to post comments
0
0

vbr files?sorry,I don’t know what’s this,pelese tell me,thank you!

[code:2ygqrrft]
procedure TfrmMain.PlayFile(filename:String);
var
Module: PFMusicModule;
Stream: PFSoundStream;
begin
if FSongs.Playing then PlayStop;
Module := FMUSIC_LoadSong(PChar(filename));
if Module = nil then
Stream := FSOUND_Stream_Open(PChar(filename), FSOUND_NORMAL or mpeg_accurate, 0, 0);
if (Module = nil) and (Stream = nil) then
begin
//Application.MessageBox(FMOD_ErrorString(FSOUND_GetError), ‘play error’, MB_OK or MB_ICONHAND);
exit;
end;
if Module <> nil then
begin
//FMUSIC_SetMasterVolume(Module, 255);
SetMusicVolume(252);
if (FMUSIC_GetType(Module) = FMUSIC_TYPE_MOD) or (FMUSIC_GetType(Module) = FMUSIC_TYPE_S3M) then
FMUSIC_SetPanSeperation(Module, 0.15); // 15% crossover
end;
FSongs.Module := Module;
FSongs.Stream := Stream;
if FSongs.Module<>nil then
begin
FSongs.Playing:=FMUSIC_PlaySong(FSongs.Module);
end
else if FSongs.Stream <> nil then
begin
FSongs.Channel := FSOUND_Stream_Play(FSOUND_FREE, FSongs.Stream);
FSongs.Playing := FSongs.Channel >= 0;
FSongLength:=FSOUND_Stream_GetLengthMs(FSongs.Stream);
Label2.Caption := format(’%2d:%2d’,[(FSongLength div 1000) div 60,(FSongLength div 1000) mod 60]);
if not FSongs.Playing then
begin
//Application.MessageBox(FMOD_ErrorString(FSOUND_GetError), ‘Play stream’, MB_OK or MB_ICONHAND);
end
else
begin
FSOUND_SetPan(FSongs.Channel, FSOUND_STEREOPAN);
//FSOUND_SetVolume(FSongs.Channel, 252);
end;
end;
imgPause.Enabled:=true;
imgStop.Enabled :=true;
timerPlay.Enabled:=true;
end;[/code:2ygqrrft]

  • You must to post comments
0
0

thank you very much!

open the file with FSOUND_MPEGACCURATE flag, It’s ok!

thank you! 😀

  • You must to post comments
0
0

vbr= variable bit rate

  • You must to post comments
0
0

thank you,I see.

  • You must to post comments
0
0

With a constant bitrate, it is possible to calculate the length in ms of a song by the filesize.
With a variable bitrate (you don’t know exactly how many bits are used for a second of sound) you will have to go through the complete file very quickly to get the length in ms.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.