mIRC Home    About    Download    Register    News    Help

Print Thread
#125076 14/07/05 03:43 AM
Joined: Mar 2005
Posts: 46
P
Pariah Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2005
Posts: 46
I'm not sure if this a bug or not, and I dont really understand why it returns what it does but, when playing an mp3 with a variable bitrate $insong.length returns a number much greater than $sound($insong.fname).length returns. Other files I tested that were not VBR were all within 1 number of eachother. If anybody can explain this I'd love to know why this occurs.

#125077 14/07/05 06:15 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
(Disclaimer: I didn't test this function, nor do I know much about $insong)

I think the real clue here is the fact that you mentioned the two values were not always equal to each other. This implies that one of these values is an approximation, or they both are (but I doubt that). Now, the one approximation I know to get song length is to multiply the bitrate by filesize (or some similar formula, don't quote me on this). I'm guessing, for a variable bitrate file, mIRC will take the "first" bitrate is sees, thinking it is the only one available (in other words, mIRC does not recognize VBR files) and multiply it by filesize to approximate the song length. This explains why the difference is so large for VBR files.

I'm not quite sure which one of those $identifiers is doing the approximation, but I'd bet it would be the $sound().length, since it seems to only read the file, and not actually load it.

Assuming I'm right, this would not be a bug, but a limitation by design-- and there really is no better design for an approximation that uses a bitrate to calculate size (You really can't sum up all the bitrates in a VBR file). Again, assuming I'm right, Khaled's only option to fix this would have to be to use a more accurate length measurement formula.

And remember, this is just my theory of your scenario, I could be way off, so don't bitchslap me about this post grin


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
#125078 14/07/05 06:44 AM
Joined: Mar 2005
Posts: 46
P
Pariah Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2005
Posts: 46
that certainly helps to explain why $insong.length returns such a high number. what correction could be made to adjust for this? maybe a .pos property for $sound?

#125079 14/07/05 07:17 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Unfortunately that wouldn't be very possible, seeing as $sound() only seems to take information about the file via the mp3 header/id3 tag. $insong does have a .pos property though... if that's what you're looking for.

I _did_ notice a .vbr property for $sound() while looking through the help.. You could use that to test if the file is VBR, and if so, ignore $sound()'s length approximation..


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
#125080 14/07/05 08:34 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
If you're talking about what you can do until $sound() is changed or whatever, read this.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#125081 14/07/05 04:48 PM
Joined: Mar 2005
Posts: 46
P
Pariah Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2005
Posts: 46
Well in this particular case, I think that $sound() is returning the correct info. The whole problem came to my attention after trying to fix a trackbar on a mp3 player. And as far as I can tell it's $insong.pos that is giving me all my problems. I could use $sound().vbr to check and see if the mp3 is VBR or not, but when I apply the params to the trackbar the only thing I can use to get the current position in a song is $insong.pos. Which doesn't correspond with the actual length, that's the reason I said something about a .pos propety for $sound() .... just should have thought it out a little better before posting. laugh


Link Copied to Clipboard