0
0

I am having an intermittent problem with FMOD reading the length of an MP3 when I use this:

FSOUND2_Stream_GetLengthMs

I have a MP3 Tag Class which also has the ability of reading the length of a file and it get the seconds of the song with this function:

[code:3c5sxgv1]
Public Property Get PlayTime()
On Error Resume Next
If MyMP3.ValidHeader = False Then PlayTime = -1: Exit Function

MyMP3.PlayTime = (FileLen(MyMP3.FullName) * 8) / BitRate / 1000
MyMP3.PlayTime = Int((MyMP3.PlayTime + 0.05) * 100) / 100
PlayTime = MyMP3.PlayTime

End Property
[/code:3c5sxgv1]

This function reads the seconds of a song correctly all the time but FMOD on certain files will spit out a length of an MP3 of 25 mins or a length that is not the correct one.

This problem messes up my progress bar of a song.

What could be causing this?

Thanks

  • You must to post comments
0
0

yeah you’re are right 😳

  • You must to post comments
0
0

Ok everybody, I have uploaded a song for anyone to try out to post on here what length they receive with FMOD. I use the FMOD.exe example that is distributed and it reads it as 3:04 which is the same as Winamp. I use my player and load the song and I get a wild length of 18:30. I have tried the above suggestions and haven’t had any luck.

url=http://www.thehotmix.com/download/songs/01-beenie_man_-dude(yeah_remx)-sc.mp3:36wlzhqq Here is the link[/url:36wlzhqq]

Now get this I have a MP3 Direct Cut utility that I can take out dead sound in a song and I did it to the first 1 second of the above song and now Winamp reads the length of this newly modified file as 18:18 in its playlist and when I play the song the duration counter displays 3:03 while it is playing. The FMOD example reads it as 3:03 seconds all around and my player reads it as 3:03 seconds all around.

[url=http://www.thehotmix.com/download/songs/Track1.mp3:36wlzhqq](Cut 1 Second) Here is the link[/url:36wlzhqq]

The above function I posted for reading file lengths that isn’t associated with Winamp now also reads it as 18:18 like winamp does.

I hope I can figure out what is wrong with this thing!

Confusing!

Thanks all

  • You must to post comments
0
0

If you don’t think the file makes the difference then why the time changes after cutting the MP3 up?

Anyways your request is my command. Here is my code I use to load the file and calculate length.

I switched from MPEG Accurate back to FSOUND_2D because of memory consumption problems I am still trying to figure out and because it made no difference in reading the correct seconds.

[code:jj652nau]
PAStream = FSOUND_Stream_Open(sFile, FSOUND_2D Or FSOUND_ENABLEFX, 0, 0)

If PAStream = 0 Then
MsgBox "There was an error loading song!", vbCritical, "Error Loading"
Exit Sub
End If

    dblTime = FSOUND_Stream_GetLengthMs(PAStream) / 1000

    'dblTime = 1110.357 when loading this file

    sTime = SecondsToTime(dblTime)

    'sTime = 18:30.3 when loading this file

‘FUNCTION SECONDSTOTIME

Dim sTime As String
Dim iSeconds As Integer
Dim iMinutes As Integer
Dim iTenth As Double
Dim i As Integer
‘Dim iTempSeconds As Integer

iSeconds = Abs(Fix(lSeconds)) Mod 60
iMinutes = Fix(Abs(Fix(lSeconds)) / 60)

For i = 1 To Len(lSeconds)
    If Mid(lSeconds, i, 1) = "." Then
        iTenth = Mid(lSeconds, i + 1, 1)
    End If
Next

sTime = IIf(iMinutes < 10, "0", "") & iMinutes & ":" & IIf(iSeconds < 10, "0", "") & iSeconds & "." & iTenth

SecondsToTime = sTime

‘END FUNCTION
[/code:jj652nau]

After that the SecondsToTime spits out the

18:30 time

Thanks brett

  • You must to post comments
0
0

a) Are you absoulutely certain that your function is correct?

b) Is your code taking into account everytihng the MP3 File header size?

I am not saying that your code is incorrect just curious as to how you determined the f(x) to get your playtime. What is the playtime that winamp or medial player reports for these files? can you give a specific example.

As for the progress bar thing this is the code that I use.

“ProgressBar1.Value = (FmodPlayer.Position / FmodPlayer.StreamLength) * 100”

where progressbar min=0, max=100, FmodPlayer.position is the current playback position, FmodPlayer.StreamLength is the total length both values are in miliseconds.

I am going to try and recreate this problem also, it’s most curious.

  • You must to post comments
0
0

Like I said I tried the MPEG_ACCURATE and got the same results.

I am NOT having a problem with all of my files just certain ones. Why does FMOD return a correct length for certain ones and not for others if it doesn’t depend on the header information?

In my opinion it is the file that has the problem and my goal here is to possibly have someone look at the file and see why it is giving incorrect information to FMOD and to fix it. I have been using FMOD for the past 2 years and haven’t had this problem. Only recently with files that I am getting that are remixed songs. SO the end result is my code hasn’t changed for 2 years and now it is giving incorrect information so the only thing that changes frequently is the files.

Thank you.

  • You must to post comments
0
0

Thanks for the reply.

Brett, I have tried your suggestion as follows in the opening of my MP3 File and this is what I am using since I have FX enabled. This didn’t work for displaying the correct time.

[code:7hn86r2l]
PAStream = FSOUND_Stream_Open(sFile, FSOUND_ENABLEFX And FSOUND_HW3D And FSOUND_MPEGACCURATE, 0, 0)
[/code:7hn86r2l]

Also I checked out what Winamp says for length of a file compared to FMOD and my own mp3 class.

These are the results:

Winamp: 4:03
My Class: 4:36
FMOD: 18:03

Thanks

  • You must to post comments
0
0

Ok good point 😆

Here is my code I use from Init to Loading a file. Let me know if you see something I am doing wrong or I should change.

[code:1djnyin8]
‘===========INITIALIZE SOUND1======================
FSOUND_SetDriver (iPlayerADevice)
FSOUND_SetBufferSize (100)

If FSOUND_Init(44100, 32, FSOUND_INIT_ENABLEOUTPUTFX) = 0 Then
MsgBox "An error occured initializing device" & vbCrLf & FSOUND_GetErrorString(FSOUND_GetError)
End If

‘ACTIVATE DSP
FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1

‘LOAD A FILE FOR PLAYING
PAStream = FSOUND_Stream_Open(sFile, FSOUND_2D Or FSOUND_ENABLEFX, 0, 0)
[/code:1djnyin8]
After loading with this procedure I get the wild time lengths

Thanks

  • You must to post comments
0
0

I’m sorry but I tried the “Or”

Ex:

[code:1keaozs4]
PAStream = FSOUND_Stream_Open(sFile, FSOUND_ENABLEFX Or FSOUND_HW3D Or FSOUND_MPEGACCURATE, 0, 0)
[/code:1keaozs4]

And when I tried to load the song PAStream = “0” which means the file wasn’t loaded correctly.

Any other ideas?

  • You must to post comments
0
0

FSOUND_MPEGACCURATE !!!! (lol)

  • You must to post comments
0
0

I have changed it from 3D to 2D sound and my code now looks like this:

[code:zs5f48s7]PAStream = FSOUND_Stream_Open(sFile, FSOUND_MPEGACCURATE OR FSOUND_ENABLEFX Or FSOUND_2D , 0, 0)[/code:zs5f48s7]

This loads the file but still reads the length of the song wrong.

Would you like the link to the song so you can try it out yourself?

  • You must to post comments
0
0

I guess you can tell I’m trying not to use the MPEG accurate because I don’t want it to scan the whole file.

Since brett mentioned that the flag was not passed correctly then how would I load a file?

With this:

[code:1g6gg5k8]PAStream = FSOUND_Stream_Open(sFile, MPEG_ACCURATE Or FSOUND_ENABLEFX, 0, 0)[/code:1g6gg5k8]

Thanks and I’m sorry if people are getting inpatient with me but I’m just trying to understand this a bit more myself and avoid MPEG_ACCURATE.

  • You must to post comments
0
0

Ok I think I’m on crack.

I just got a wild hair up my you know what and tried the FMOD sample exe you get when you download and I loaded it and it shows the length correctly. What the heck am I doing wrong?

I guess that eliminates FMOD reading it wrong. :)

Well I guess I need to relook at my code. :)

Thanks for the help and sorry I didn’t try this first.

  • You must to post comments
0
0

[quote="Sentax":e21gr9tf]I guess you can tell I’m trying not to use the MPEG accurate because I don’t want it to scan the whole file.

Since brett mentioned that the flag was not passed correctly then how would I load a file?

With this:

[code:e21gr9tf]PAStream = FSOUND_Stream_Open(sFile, MPEG_ACCURATE Or FSOUND_ENABLEFX, 0, 0)[/code:e21gr9tf]

Thanks and I’m sorry if people are getting inpatient with me but I’m just trying to understand this a bit more myself and avoid MPEG_ACCURATE.[/quote:e21gr9tf]

[code:e21gr9tf]PAStream = FSOUND_Stream_Open(sFile, FSOUND_MPEGACCURATE Or FSOUND_ENABLEFX, 0, 0)[/code:e21gr9tf]

You will have to use FSOUND_MPEGACCURATE for corrupted OR variable bitrate (VBR) mp3’s. Even winamp will calculate the duration wrong if you use VBR files without a vbr-header. Because it doesn’t scan the file.

  • You must to post comments
0
0

FSOUND_Stream_GetLengthMs

  • You must to post comments
0
0

maybe you are converting ms -> time format wrong??

  • You must to post comments
0
0

[quote:1cb8njtg]maybe you are converting ms -> time format wrong??
[/quote:1cb8njtg]

I wish but wouldn’t that make every one of my songs lengths show up incorrectly?

  • You must to post comments
Showing 16 results
Your Answer

Please first to submit.