English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System > Coders. Scripting

 
 
Thread Tools
Old 24 June 2016, 23:35   #1
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 666
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)
example: 270 seconds should be 4:30, not 4.5.

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?
KONEY is offline  
Old 25 June 2016, 02:14   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
Code:
seconds = (total_ms + 500) % 1000
mm = seconds % 60
ss = seconds // 60
time = mm":"right(ss,2,'0')
% is division without decimals
// is modulo
thomas is offline  
Old 25 June 2016, 13:15   #3
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 666
Thanks! this works nicely! I just removed the addition of 500ms to the total because it made no sense to me.
KONEY is offline  
Old 25 June 2016, 15:31   #4
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
Quote:
Originally Posted by KONEY View Post
I just removed the addition of 500ms to the total because it made no sense to me.
It's rounding, same result as trunc(total_ms / 1000 + 0.5)

If the song is 29.9 seconds long (29900 ms), you might want to display 0:30 rather than 0:29.
thomas is offline  
Old 25 June 2016, 19:14   #5
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
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
If this isn`t a good idea, please let me know.
daxb is offline  
Old 25 June 2016, 19:48   #6
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 666
Quote:
Originally Posted by thomas View Post
It's rounding,
If the song is 29.9 seconds long (29900 ms), you might want to display 0:30 rather than 0:29.
you're right, I'll put it back!
KONEY is offline  
Old 25 June 2016, 19:57   #7
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 666
Quote:
Originally Posted by daxb View Post
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.
Sure. Well actually I realized that an average value must be accepted, or you need to play the song fully. I assumed no premature end commands are used as they're not needed in OctaMED, since it allows custom block length. Also full stops "FFE" in the middle of the songs are not detected. I also assumed that TPL changing commands would be at the top of the block, otherwise a full scan of each line of each track would be necessary.

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: [ Show youtube player ]

if you want I can upload the script
KONEY is offline  
Old 25 June 2016, 22:27   #8
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
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.
daxb is offline  
Old 26 June 2016, 09:06   #9
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 666
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
KONEY is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
AREXX Help Zetr0 support.Other 2 26 January 2011 23:09
arexx help jimbobrocks92 Coders. General 4 19 January 2011 12:50
Arexx redblade request.Apps 2 30 August 2006 11:51
Arexx Seti Coders. General 2 05 August 2003 18:59

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:04.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07840 seconds with 13 queries