Time conversion in Arexx
I'm writing an Arexx script for OctaMED SoundStudio which will calculate (roughly) the total playing time of a song.
Now I've got a quite correct amount of seconds which I'd like to show as minutes:seconds. Problem is, just dividing by 60 is returning a value which is minute and part of minute elapsed, not seconds. Code:
TRUNC(total_ms/1000/60,1) I'm not very familiar with Arexx and I don't know if there's a way to format time, or a ready to use code or library without having to manually split the value etc. Any help? |
Code:
seconds = (total_ms + 500) % 1000 // is modulo |
Thanks! this works nicely! I just removed the addition of 500ms to the total because it made no sense to me.
|
Quote:
If the song is 29.9 seconds long (29900 ms), you might want to display 0:30 rather than 0:29. |
Do you want to show us how do you calculate the total playing time of a OctaMED SoundStudio song? It would be nice to know if scanning of all pattern data is needed.
Usually I use the following to eliminate decimal digits from a given seconds value: Code:
s = (sec // 60) % 1 |
Quote:
|
Quote:
So the script in pseudo code will: play the song cycle blocks in sequence allow a few ms to tpl commands to eventually get applied calculate lines ms accordingly to bpm and tpl add to a total finish cycle stop playing format the output show output I am quite satisfied with the resulting values, they quite match the real song playing time. I made a video also: https://www.youtube.com/watch?v=Fc_SkySeS90 if you want I can upload the script |
I guess for most mods it will work. Only on some mods with several/regular speed/tempo changes won`t taken into account. A play song in fast motion function would be nice. :)
|
yes and 90% of the mods you mentioned change TPL at every line to simulate quantize/shuffle therefore the final bpm are quite the same, so I suppose it would do a good job anyway :)
|
All times are GMT +2. The time now is 02:47. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.