I’m sorry for the vague title, but it was the best I could come with, which is also why I can’t google this.
I want to make a music synced game, but it would be a pain to hard-code all the timing in it. I know I could use alarms, but is there any software/file format that’d make timing setting/tuning easier?
I realise this isn’t strictly an FP question, so sorry abut that too.
Thanks in advance.
Timed events writer
I know; what I’m looking for is something like OGMO but that would allow me to set timed events and tweak them more easily.
I.e. use software to set flags -> export file with timing data -> use FP to parse file into timers
I thought of using a MIDI writer and then parsing the exported file, but it doesnt seem to be a very well handled file format by most languages.
Oh, now i understand. I don’t think there is any editor. Well we’ll have to create a simple one ;).
BTW, I have this fucntion that callsback to the function you want after the specified time. It may help.
package
{
import net.flashpunk.FP;
import net.flashpunk.Tweener;
/**
* ...
* @author Copying
*/
public class MultiTimer extends Tweener
{
public function MultiTimer()
{
_callbacks = new Vector.<Time>;
}
override public function update():void
{
var t:Time;
for each (t in _callbacks)
{
t.timer -= FP.elapsed;
if (t.timer <= 0)
{
t.callback.call();
deleteCallback(t);
}
}
}
public function addCallback(time:Number, callback:Function):Time
{
var t:Time;
t.time = time;
t.callback = callback;
var x:int = 0;
while (true)
{
if (!_callbacks[x])
{
_callbacks[x] = t;
}
else x++;
}
return t;
}
public function deleteCallback(t:Time):void
{
var x:int = _callbacks.indexOf(t);
if (x >= 0)
{
_callbacks[x] = null;
}
}
private var _callbacks:Vector.<Time>;
}
}
package
{
public class Time
{
public var callback:Function;
public var time:Number;
}
}
Hey, thanks, that’ll definitely come in handy when parsing, but it’s not quite what I was looking for, I might go with MIDI reading after all.
I’m glad it will be usefull to you.
If you tell me your exact case i can try to find a better solution (I’m thinking about create a simple editor that saves the information into an XML).
Not sure if this would be helpful, but if you’re trying to sync something with music, Audacity has something called Label Tracks that let you attach plain text labels to any point in time. They can be exported as text files that are easy to read. It might be simpler to work with than MIDI (I was thinking about using something like this to do the timing in cutscenes, but I never got around to it).