|
-
Jan 15th, 2012, 07:20 PM
#1
Thread Starter
New Member
Executing Code to Specific Timing
No, I am not wanting to execute code at a specific time (task scheduler)
And I am not wanting to execute code at specific intervals (timer control)
Now that that's out of the way. I am wanting to be able to upload a music track, select times in the track that will trigger code events and then, in a different part of the project, play the track back and have it execute the code at the times that I per-determined when I first uploaded the track.
A perfect visual example is this: http://soundcloud.com/bassnectar/ell...ssnectar-remix You can see all the vertical blue lines on the waveform there. Those are comments users left at those specific times in the music. As the song plays back, it displays the comments at the time that the users posted them in the song.
I know about http://www.un4seen.com/ and that their library claims to be able to do exactly this, but this application is eventually going to be for release and a license from un4seen costs $1,200 so I'm only wanting to use that as a last resort.
(Note, these examples are only pseudo code, I'm looking for broad ideas so please don't pay attention to the syntax of the following examples)
So far my ideas include a timer control that checks a time on these code events to a stopwatch sort of a:
Timer_Tick
if event(n).time = stopwatch.elapsed then
run event(n)
end if
End Sub
Another idea I had is to generate what I would call a "running script" where, once done adding events, just before playback, it compares the times of all of the events and generates a sort of:
run event(n)
threading.thread.pause(750)
run event(n+1)
etc.
The issues I think would be present with both of these are:
With the timer example, in order to get the precision I want, the shortest intervals could be say 10 milliseconds or even less. First, every timer control I've ever used has never seemed to be accurate (especially not to milliseconds of precision) so I normally opt for the stopwatch route and my current knowledge does not include whether or not I can run code based on ticks of the stopwatch. Maybe I could, that's where you come in. But second, For an application to have to look for equivalency between the song table and the stopwatch every ten milliseconds, I'm worried this will significantly slow execution of the program on slower machines resulting in out of sync events, slow playback, etc.
With the script example, I believe this would be best in terms of playback speed and is, so far, the route I am considering. Generating said script would be a simple for loop, adding the script to a hashtable or something along those lines. My one issue with it is this: with this type of script, I can't easily wrap my head around the idea of jumping to certain times in a song, which is also a necessity.
SO. If anyone has any potential ideas that might be of some help, I am all ears. What I would ultimately like is to be able to upload a song and have the actual song timer execute the code when it reaches certain times on playback but I can't even begin to guess where I would start with something like that.
Any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|