haven't been around for awile, but got a dummy question
is it possible to get information about where an audio track is in its playing time or whatnot,
I was going to try a basic basic audio sync to somthing on screen, (a song intro)
basic audio sync question
no, not in this way. But if you use a audiosoftware like goldwave you can easily get exact timings in a music track like 3.25 seconds.
Then you could make a cutscene or something else and time your screen events just with these times
wait (3.25)
Then you could make a cutscene or something else and time your screen events just with these times
wait (3.25)
Last edited by Zimond on 03 Dec 2009, 15:07, edited 1 time in total.
*edit: Zimond's solution looks much more simple
Vice versa, you can define a position where the track will begin with playmusic(name;position). But there is no command to retrieve the playing time directly. You can make yourself a timer easily though, working with a function. As you might know, a function is executed 50 times per second. Somewhere you start your song, and under the line playmusic(), you enter the line function(song-timer;*).
Create a script which will be used as the function and name it "song-timer". The script goes as follows:
Now you can retrieve the track's position by using the variable "song-seconds". Either you can show it in a textline with textout(1;[song-seconds];...) or you can schedule the synchronized intro events by including them in a if_num(song-seconds;...).
In case you want to display the time with minutes and hours as well, you can add some lines in the function:
Vice versa, you can define a position where the track will begin with playmusic(name;position). But there is no command to retrieve the playing time directly. You can make yourself a timer easily though, working with a function. As you might know, a function is executed 50 times per second. Somewhere you start your song, and under the line playmusic(), you enter the line function(song-timer;*).
Create a script which will be used as the function and name it "song-timer". The script goes as follows:
Code: Select all
setnum(song-second-counter;+1)
if_num(song-second-counter;50)
{
setnum(song-seconds;+1)
setnum(song-second-counter;0)
}
In case you want to display the time with minutes and hours as well, you can add some lines in the function:
Code: Select all
if_num(song-seconds;60)
{
setnum(song-minutes;+1)
setnum(song-seconds;0)
}
if_num(song-minutes;60)
{
setnum(song-hours;+1)
setnum(song-minutes;0)
}
Ahm... the solution of Zimond does not work every single time. Sometimes because of loading of characters or other things the waiting-time can be longer than 3,25, even if you wrote wait(3,25).
I had this problem too and I just splitted the audiofile into two overlapping parts, so that I had a buffer-time of about 0,1-0,3s. Then I just played the second part in the right moment.
If someone has a fast computer then every works fine. If someone has a slow computer the buffer-time of 0,3s is in most cases enough to compensate this.
I had this problem too and I just splitted the audiofile into two overlapping parts, so that I had a buffer-time of about 0,1-0,3s. Then I just played the second part in the right moment.
If someone has a fast computer then every works fine. If someone has a slow computer the buffer-time of 0,3s is in most cases enough to compensate this.