Audio synchronisation test

  • 7 Replies
  • 5167 Views
*

Offline Nifflas

  • 1532
  • 61
    • View Profile
Audio synchronisation test
« on: April 07, 2011, 11:15:47 »
Here's a little test program that uses MMF2's "set sample position" to attempt to play 32 audio tracks together. Problem is, the actions that sets the sample position are triggered in a separate thread, resulting in a possible delay between when each audio file is triggered. The sound output of this test tool will let me know exactly how much of a problem it is (already pretty bad on my computer, a delay of 10 milliseconds (which I guess is the length of the audio buffer) is randomly introduced for some new tracks, but it doesn't happen everytime I try to syncronize a layer).

If you record what the program plays and post them here (as an ogg file, it'll only take like 6Kb for a recording), I'll know a lot more about how this problem differs on each computer. Unfortunately, it already looks like the synchronisation is too bad, so that I won't add the feature though the game needs it.
« Last Edit: April 07, 2011, 11:18:13 by Nifflas »

*

Offline sergiocornaga

  • 1285
  • 131
    • View Profile
    • Sergio's Games
Re: Audio synchronisation test
« Reply #1 on: April 07, 2011, 13:33:16 »
Here's mine.

*

Offline Nifflas

  • 1532
  • 61
    • View Profile
Re: Audio synchronisation test
« Reply #2 on: April 07, 2011, 13:57:50 »
Pretty much same as mine. A randomly introduced 10 millisecond delay.

What I'm worried about is now how MMF2 handles the audio buffer; if it's statically set to 10ms or if it varies depending on some system variables. If the randomly introduced delay can be more than 10 milliseconds, it can be a disaster. Apart from my concern about the audio buffer, I also realize that a slower system where it takes longer to perform the sample position reset action (which is done in a separate thread), the delay can be double or tripple the audio buffer.

I guess this is pretty bad then :(  I always knew MMF2's audio features were designed wrong, so I saw this coming.
« Last Edit: April 07, 2011, 14:05:50 by Nifflas »

*

Offline egomassive

  • 1850
  • 250
    • View Profile
    • egomassive games
Re: Audio synchronisation test
« Reply #3 on: April 07, 2011, 15:41:08 »
How about setting channels 2 through 32 to the position of channel 1? The attachment is my edit of Nifflas' .mfa I'm still hearing some lag but it's reduced considerably. If the delay is program dependent, and not hardware, then setting channels 2 through 32 to position of channel 1 minus the delay may refine it further.

*

Offline Nifflas

  • 1532
  • 61
    • View Profile
Re: Audio synchronisation test
« Reply #4 on: April 07, 2011, 15:42:48 »
Hmmm, interesting! I'll check it out!

Actually, this is awesome! The desynchronisation is constant, which means that all channel 2 to 32 are very nicely aligned with each other. If I use the first channel as an inaudiable dummy channel, I can pretty much sync up all the other channels. I wonder what happens if I use the timer to align the samples instead of Channel 1. The beginning of some musical layers will be cut off, but I'll just have to design the music to fade in.

Edit: Using the timer doesn't work, it doesn't seem to update on a sub-frame basis. I'll basically have to use a dummy channel to align the others. Thanks, I wouldn't have thought of this!
« Last Edit: April 07, 2011, 15:51:42 by Nifflas »

*

Offline egomassive

  • 1850
  • 250
    • View Profile
    • egomassive games
Re: Audio synchronisation test
« Reply #5 on: April 07, 2011, 15:50:15 »
Glad I could help.

Edit: I was thinking the same thing about using a dummy channel as a timer. My concern with a real timer was that it would run on the main processor while the music ran on the sound processor probably resulting in de-synchronization when one or the other became burdened.
« Last Edit: April 07, 2011, 20:41:32 by egomassive »

*

Offline LPChip

  • You can only truly help other people by allowing them to fail.
  • 3510
  • 138
  • Excel at the thing you're the best at!
    • View Profile
    • LPChip Interactive
Re: Audio synchronisation test
« Reply #6 on: April 07, 2011, 17:27:00 »
Do you still need our help in testing the first audio test?

Or perhaps can you provide a newer testbuild with this new discovery?
on the left, above my avatar.

MODPlug Central Forum
"If I tried to kill you, I'd end up with a big fat hole through my laptop." - Chironex

*

Offline Nifflas

  • 1532
  • 61
    • View Profile
Re: Audio synchronisation test
« Reply #7 on: April 07, 2011, 18:07:44 »
I might provide a new one soon, but afaik egomassive's solution should not be more off than twice the audio buffer (regardless of how many layers that are used), which I'm beginning to think is fixed to 10ms in MMF2 apps. I won't attempt to sync drum tracks using this technique, but for syncing e.g. slow attack chords or pads to drums it should be close enough.
« Last Edit: April 07, 2011, 18:09:23 by Nifflas »