real-world game audio development with html5 craig robinson, absolute hero martin reurings, spil...

29
Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Upload: aron-chase

Post on 05-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Real-World Game Audio Development with HTML5

Craig Robinson, Absolute HeroMartin Reurings, Spil Games

Page 2: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

About us

• Craig Robinson [email protected]

– Absolute Hero– Mobile games– Multimedia software

2

• Martin Reurings [email protected]

– Spil Games– Webbased UI’s– Ajax before it had a

name

Page 3: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

3

What's out there?

Let's get a feeling for the landscape of HTML5 audio shall we?

It can't be all bad after all…

Page 4: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

HTML, audio after the silent years

• <bgsound>, remember the midi-tracks?

• Flash, good enough while it lasted

4

Page 5: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

5

Page 6: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

HTML5 Audio vs Web Audio API

• <audio />, a ray of light, tainted by fear– Fragmented codec support– Autoplay got disabled– Only 1 sound at a time

• Web Audio API, the promised land– We’ll get back to this

6

Page 7: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

7

Page 8: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

HTML5 Audio in Desktop Browsers

• Fast response• Multiple streams• Fragmented codec support• Solid codec detection

• Supported in: Chrome, Safari, IE9+, Opera• Chrome and Safari support Web Audio API, with

support for FireFox just around the corner (FF 23)!

8

Page 9: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Playing a sound on Desktop

9

Page 10: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

What about Mobile?

• There seems to be a difference of opinion• iOS5, audio-tag, but only on user-interaction, only 1

stream• iOS6+, same <audio /> support but Web Audio API• Android 4, audio-tag, only on user-interaction, only

1 stream• Windows Phone, not enough market-share yet.• BB10, audio-tag• Latency, let’s get around that

10

Page 11: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Playing low-latency audio on Mobile

11

Page 12: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Codecs

12

Source: http://html5doctor.com/html5-audio-the-state-of-play/

Page 13: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Mobile browser codec support

13

Source: http://html5doctor.com/html5-audio-the-state-of-play/

Page 14: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Codecs

• Commonly supported audio codecs– ac3/aac– mp3/mpeg-1– ogg/vorbis– m4a/h.264

• Ogg FTW?• Just in case, there’s people creating JS decoders for

unsupported Codecs!

14

Page 15: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Handling different Codecs

15

Page 16: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Right, audio-tag, it's been around

• Pros– Widely supported– Built in capabilities for streaming/buffering

• Cons– User-interaction only, or the sound takes a long time

to load, no snappy sound-effects here

• Solutions– Audio-sprites, yay!! Easy to make with NPM and (

https://github.com/tonistiigi/audiosprite)• In Chrome, server must support byte range requests• FF doesn't support seeking in .ac• Chrome doesn't support seeking in .ogg• Ok, never tested in IE, no noticeable market-share…

16

Page 17: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Using Sound-Sprites

17

Page 18: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

This too shall pass.~ancient

proverb~

18

Page 19: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Web Audio API – What is it?

• JavaScript interface to access advanced native audio capabilities

• Modular, graph-based to support complex mixing and effects

• Allows playback of sampled audio and audio synthesis

• Integration with <audio> media element• Spatialized audio and advanced filter effects• Ability to synthesize and process audio stream in JS

code• Provides sample accurate scheduling and low

latency• Can play multiple, simultaneous sounds!

19

Page 20: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Simple routing

20

Source: https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html

Page 21: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Advanced routing

21

Source: https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html

Page 22: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Testing for availability

22

Page 23: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Loading and playing a sound

23

Page 24: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Loading and playing a sound

24

Page 25: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Use with HTML5 audio tag to support streaming

25

Page 26: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Use with HTML5 audio tag to support streaming

26

Page 27: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Demo

27

Page 28: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Three things to remember

• A bit of trouble, but it’s not that bad!

• HTML5 <audio> tag --> Web Audio API

• Desktop audio != mobile audio

28

Page 29: Real-World Game Audio Development with HTML5 Craig Robinson, Absolute Hero Martin Reurings, Spil Games

Resources

• https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html

• http://www.html5audio.org/

• http://uglyhack.appspot.com/webaudiotoy/

29