Useless, But Fun Script-Idea.

Remember the nag-sccreen from the Renoise-demo? It would be fun if someone developed a script that would keep track of how many hours you actively spent working on a track and stored it in the song.

Just a silly idea. :)

Composing mileage?

  
function seconds_to_clock(time)  
 if time <= 0 then  
 return "00:00:00"  
 else  
 local hours = string.format("%02.f", math.floor(time / 3600))  
 local mins = string.format("%02.f", math.floor(time / 60 - (hours * 60)))  
 local seconds = string.format("%02.f", math.floor(time - hours * 3600 - mins * 60))  
 return hours .. ":" .. mins .. ":" .. seconds  
 end  
end  
  
  
local prefs = renoise.Document.create("ScriptingToolPreferences") {  
 first_start = 0,  
 session_start = 0,  
 session_end = 0  
}  
renoise.tool().preferences = prefs  
  
  
renoise.tool().app_new_document_observable:add_notifier(function()  
 local time = os.time()  
 if prefs.first_start.value <= 0 then  
 prefs.first_start.value = time  
 end  
 prefs.session_start.value = time  
 prefs.session_end.value = time  
end)  
  
  
renoise.tool().app_release_document_observable:add_notifier(function()  
 local time = os.time()  
 prefs.session_end.value = time  
 local diff_total = os.difftime(prefs.session_end.value, prefs.first_start.value)  
 local diff_session = os.difftime(prefs.session_end.value, prefs.session_start.value)  
 -- Message box  
 renoise.app():show_message(  
 "Hours spent on this song: " .. seconds_to_clock(diff_session) .. "\n" ..  
 "Hours spent since forever: " .. seconds_to_clock(diff_total)  
 )  
end)  
  

Woops, I reread the original post.

Is not supported.

vV: Yeah, something like that. :)

Conner_BW: It could be stored in one of the Song Comments-fields perhaps?

Yeah, OK, something could be hacked together using renoise.song().comments and some regular expressions.

Left as an exercise for the reader…

[xml][renoise]RENOISE-ROX[/renoise][/xml]

I’ve packaged the above code snippet into a Tool, appropriately named “Useless, but fun.”

Bonus points to the person who hacks renoise.song().comments to store the time on a per song basis.

Enjoy?

Silly or not, I think this is a pretty sweat feature.

Nice to know how many hours (years? ;) ) you have been fiddling with a song. Especially if you happen to get job where you charge them by the hour. B)

Simply just store the mileage in a script-document with the song-name as reference?
If you must add an MD5 fingerprint on the contents of the first pattern instead of the song-title. Is more reliable.

Conner_BW: Wow, cool. Thank you. :) Got a chance to try it out today. If I should add anything to the wishlist, being able to call it from the menu would be useful (and setting an option whether to show it when loading a new project or not).

Maybe I’ll check out Lua one day, but at the moment I’m so into writing 6502 assembly-stuff for a game, so that will probably have to wait.

This script makes me feel really productive! I haven’t used Renoise much in the last week but it still reports “hours spent since forever: 221:06:27”. Excellent! ;)

Is this a bug? Or is this somehow accurate?

The script saves a timestamp in the preferences.xml and does simple calculations with it. My guess is that either the timestamps are corrupted, or my timestamp to hours function is buggy.

I"m not really going to fix it, though. It was just a cheap Lua trick I posted to incentivize. I’m not up to maintaining this…

It’s a bug (I haven’t used Renoise more than a couple of hours I think) but I understand, don’t worry about it. :)

I like this idea. :)
Would be nice if someone has time to finish it.