| View previous topic :: View next topic |
| Author |
Message |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sun Oct 03, 2010 3:11 am Post subject: Speaking of @mci... |
|
|
Umm... /embarrassed
How do I convert the milliseconds returned from the MCI to minutes and seconds?
Thanks,
~Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Sun Oct 03, 2010 5:39 am Post subject: |
|
|
There may be a simpler way, but i came up with this:
| Code: |
option decimalsep,.
%x = 118551
%s = @fdiv(%x,82400)
%z = @fdiv(%s,1000)
info %x milliseconds = @datetime("nn:ss:z",%z)
exit
|
. |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Sun Oct 03, 2010 3:12 pm Post subject: |
|
|
Correction:
%s = @fdiv(%x,86400)
Not
%s = @fdiv(%x,82400)
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sun Oct 03, 2010 3:41 pm Post subject: |
|
|
I'm not sure what I'm doing wrong, but everything I've tried gives me incorrect time. With a 2:47 mp3 file I get the minutes fine, but seconds are wrong. With a 7:58 file I get like 13 minutes and the seconds are wrong. I've tried 3 different routines so far, 1 being mine, 1 from old SADE example and now Bornsoft's idea.
Ok, I see now that Hooligan also replied and I added his correction. It works correctly on the 2:47 file but like the previous attempts goes astray on the 7:58 file, it gives the result of 13:17 instead.
Any ideas why on longer file times it goes whack?
Thanks a bunch,
~Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sun Oct 03, 2010 8:48 pm Post subject: |
|
|
Ok, this is really boggling my mind. 1000 milliseconds equals 1 second. So if I divide the total amount of milliseconds the mci is returning by 1000, I should end up with the total amount of seconds of the audio file. Then if I want total minutes I should be able to divide that by 60. But my logic doesn't seem to match up with the logic needed to gain correct numbers with the mci.  _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Mon Oct 04, 2010 9:42 am Post subject: |
|
|
Thanks Hooligan for the correction, I should do more menthal arithmetic.
@Garrett: The "z" option for @datetime works only with VDS6. if you omit this, you should get correct minutes and rounded seconds.
If that doesn't give the correct time, there seems to be something wrong with the value you get from MCI or informations within the file itself are incorrect. Try it with a WAV file instead of MP3. |
|
| Back to top |
|
 |
|