basic audio sync question

For problems with creating games or for reporting bugs of the Tool.
Post Reply
User avatar
PaC-DK Newby
Posts: 41
Joined: 11 Apr 2007, 15:50
Location: north of Toronto

basic audio sync question

Post: # 74779Post theswitch
03 Dec 2009, 14:02

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)

User avatar
Der Engine Papa
Posts: 3393
Joined: 06 Apr 2003, 19:34
Location: Krefeld

Post: # 74780Post Zimond
03 Dec 2009, 14:08

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)
Last edited by Zimond on 03 Dec 2009, 15:07, edited 1 time in total.

User avatar
PaC-DK God
Posts: 1168
Joined: 04 Jun 2006, 19:24

Post: # 74782Post Baelavay
03 Dec 2009, 14:18

*edit: Zimond's solution looks much more simple :doh:

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

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:

Code: Select all


PaC-DK God
Posts: 1176
Joined: 20 Dec 2006, 21:48

Post: # 74786Post Schiman
03 Dec 2009, 21:52

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.

Post Reply