The Audio Callback for Audio Synchronization Mathieu Pavageau - - PowerPoint PPT Presentation

the audio callback
SMART_READER_LITE
LIVE PREVIEW

The Audio Callback for Audio Synchronization Mathieu Pavageau - - PowerPoint PPT Presentation

The Audio Callback for Audio Synchronization Mathieu Pavageau Senior Sound Programmer Ubisoft Paris Studio Sound Programming Experience 2003 2003 2004 2005 2011 + Sound Middleware + R&D


slide-1
SLIDE 1

The Audio Callback for Audio Synchronization

Mathieu Pavageau Senior Sound Programmer Ubisoft Paris Studio

slide-2
SLIDE 2

Sound Programming Experience

2003 2003 2004 2005 2011

+ Sound Middleware + R&D

slide-3
SLIDE 3

Outline

  • Musical Interactivity
  • Audio Engines in Games
  • Audio needs a fast update context
  • Implementing the Audio Callback
  • Examples
slide-4
SLIDE 4

Musical Interactivity

  • Musical Content reacts to Gameplay
  • Music and Gameplay designed together
slide-5
SLIDE 5

Mickey Mousing Example

Example: Rayman Origins Menu Example: Mickey-Mousing

slide-6
SLIDE 6

²

slide-7
SLIDE 7

Current Musical Interactivity

slide-8
SLIDE 8

Either Pre-Recorded Audio

  • One music track at a time
  • Or multitracks/multilayers

High Quality Audio BUT Little Musical Interactivity

slide-9
SLIDE 9

Or MIDI System

  • Musical Score can be modified in real-time
  • Uses Sound Banks

High Musical Interactivity BUT Low Audio Quality

slide-10
SLIDE 10

Synchronizing Audio with Audio

slide-11
SLIDE 11

Synchronization: Design

  • Musical Structure: data with the wave
  • Play new sounds sync with playing sounds
slide-12
SLIDE 12

Synchronization: Design

slide-13
SLIDE 13

But: V-Sync is Master Clock

  • V-Sync image update
  • Video frame is Master Clock (FPS)
  • Entire Game updated with V-Sync

All Audio Requests made in Video Frame

slide-14
SLIDE 14

Duration of Game Frame

Frame Rate Duration

60 FPS (60 Hz TV) 17 ms 50 FPS (50 Hz TV) 20 ms 30 FPS (60 Hz TV) 33 ms 25 FPS (50 Hz TV) 40 ms 17 ms is the best time precision for audio

slide-15
SLIDE 15

Without the Audio Callback: No Sync

slide-16
SLIDE 16

Time Perception Examples (1)

0 ms 5 ms 10 ms

A B C D E F G A

slide-17
SLIDE 17

Time Perception Examples (2)

15 ms 20 ms 25 ms

A B C D E F G A

slide-18
SLIDE 18

Time Perception for Audio

  • Synchronized sounds require a precision
  • f a few milliseconds
  • Musical precision does not need sample to

sample precision

slide-19
SLIDE 19

Audio Synchronization needs a fast update context:

The Audio Callback

slide-20
SLIDE 20

The Audio Callback

  • Hardware related: it already exists!
  • Same as CoreAudio, ASIO, etc
  • Sound engines use it asynchronously

Regular filling-up of audio buffers for the hardware

Audio Output Hardware

slide-21
SLIDE 21

Audio Callback on Consoles

  • Wii/WiiU: AX callback (3 ms)
  • PS3: audio update thread (5 ms)
  • XB360: XAudio2 callbacks (5 ms)
slide-22
SLIDE 22

With the Audio Callback: Audio Sync

slide-23
SLIDE 23

Audio Callback Implementation

slide-24
SLIDE 24

Implementation: Precautions

  • Callback cannot be slowed down
  • Lockless programming
  • Some operations are forbidden

(ex CreateVoice on XAudio2)

slide-25
SLIDE 25

Architecture

  • Low level audio must expose the

Audio Callback to the game/client (for interactivity with the game)

  • It’s difficult to modify existing sound

engines to use the Audio Callback

slide-26
SLIDE 26

Advantages

  • Stable audio, not affected by FPS drop
  • Behaves the same rhythmically when

ported on different platforms

slide-27
SLIDE 27

Examples in Ubisoft Games

slide-28
SLIDE 28

Synchronized Play Requests

  • Dynamic Multitracks
  • PlayOnNextBar, PlayOnNextBeat,

etc…

slide-29
SLIDE 29
  • Click to edit Master text styles
  • Second level
  • Third level
  • Fourth level
  • Fifth level

Example: Rayman Origins Menu

slide-30
SLIDE 30

Without sync

slide-31
SLIDE 31

With sync

slide-32
SLIDE 32

Example: Rayman Origins Intro

slide-33
SLIDE 33
slide-34
SLIDE 34

Summary

  • Audio synchronization can be

implemented using the Audio Callback

  • Audio synchronization enables

better audio interactivity

  • Audio interaction requires sharing code

with the game: Architecture

slide-35
SLIDE 35

What Next?

  • Next Gen machines will give even

more power to audio

  • More process can be done in the

Audio Callback (effects, software mix, entire DAW…)

  • Mickey Mousing one day in video games!
slide-36
SLIDE 36

Questions?

More info: mathieu.pavageau@ubisoft.com