basic audio sync question

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

basic audio sync question

Post: #74779 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
Zimond
Der Engine Papa
Posts: 3297
Joined: 06 Apr 2003, 19:34
Location: Krefeld
Contact:

Post: #74780 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
Baelavay
PaC-DK God
Posts: 1168
Joined: 04 Jun 2006, 19:24
Contact:

Post: #74782 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

setnum(song-second-counter;+1)
if_num(song-second-counter;50)
  {
  setnum(song-seconds;+1)
  setnum(song-second-counter;0)
  }


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

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)
  }

User avatar
Schiman
PaC-DK God
Posts: 1171
Joined: 20 Dec 2006, 21:48
Contact:

Post: #74786 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.


Return to “Problems and Bugs”

Who is online

Users browsing this forum: No registered users and 1 guest