SlideShare une entreprise Scribd logo
1  sur  36
EFFECTIVE HTML5 GAME AUDIO
Chris Khoo (chris.khoo@wappworks.com)
TOPICS
1.   HTML5 Audio
        Definition
        The good, the bad, and the ugly
2.   HTML5 audio game layer architecture
INTRODUCTION TO HTML5
AUDIO
HTML5 AUDIO
 HTML5 audio is part of the HTML5 specifications
  managed by the World Wide Web Consortium (W3C)
 The <audio> element
     Represents a sound or audio stream
     Not designed for real-time audio mixing

   W3C is working on a Web Audio API as an alternative
    audio solution
     Advanced sound manipulation functionality
     Not purely stream related
THE GOOD
   HTML5 audio API support is standard across all
    modern browsers
       EXCEPTION: Firefox versions prior to Jan 1, 2012 do
        not support the loop flag



    It is possible to implement a game sound engine
                     using HTML5 audio
THE BAD
   Limited audio control
     Coarse control of audio playback position and volume
     No audio panning support
     No sound filters

   Non-contiguous looping
       Expect a slight pause whenever a sound sample loops
THE BAD
   Non-standard audio formats across browsers
     No one audio format works for all browsers
     A list of supported audio formats on a per browser basis
      is available on Mozilla‟s website
     To ensure the highest browser compatibility, be sure to
      support multiple audio formats (ogg, mp3, wav)
THE BAD
   Spotty HTML5 audio support on default mobile
    device web browsers
       Android
         Android 2.x: Audio does not play
         Android 3.0+: Only one audio instance allowed to produce

          sound at a time
       iOS
         Audio must be triggered through user interaction
         Apple is actively working to prevent workarounds

       Support in third party mobile web browsers is much
        better
           Firefox mobile implements HTML5 audio perfectly
THE UGLY
   No guarantee of timely activation
       Some browsers have a noticeable delay between calling
        the play() function and sound playback starting
         Safari - always true
         IE 9 - occurs when modifying an audio element‟s src
          parameter prior to play back
   Beware of audio stream stalls
       HTML5 audio streaming can sometimes stall without
        reason
           It seems to happen more frequently with WebKit browsers
     A “stalled” event is fired whenever this occurs
     Call the load() function to manually restart streaming
THE UGLY
   Server functionality can impact HTML5 audio behavior
     On WebKit browsers (Chrome and Safari), audio/video seek
      functionality is quietly disabled if the audio web server does
      not support partial requests
     Disabling seek causes
           play() call completes without error but playback does not occur
           „ended‟ event does not fire on playback complete
           „Sound file format corrupted‟ exception is thrown when trying to
            replay sounds
       Generally happens the first time an audio is referenced
           Doesn‟t happen on subsequent accesses if the audio is cached
   Other known quirks
       Firefox 3.6: short sounds don‟t play
           No longer a problem since Mozilla is phasing out this version
       Safari: Terrible audio playback performance
DEMO TIME
SHOULD WE USE HTML5 AUDIO?
Pros
 Browser audio support is steadily improving
 It works across all platforms including mobile web
       It‟s possible to work around most of the issues through careful
        sound design and good engineering but audio experience, in
        general, is compromised
   Popular HTML5 game acceleration platforms support
    audio through the <audio> element
       CocoonJs and AppMobi take this approach
Cons
 Limited audio manipulation functionality
 Inherently more complicated to implement
 Audio experience still varies from browser to browser
QUESTIONS?
BUILDING AN HTML5 GAME
AUDIO SYSTEM
SYSTEM REQUIREMENTS
   Graceful degradation
       What if there‟s no HTML5 audio support?
 Sound loading/caching
 Sound playback
       Sound looping support
 Mute/Unmute
 Volume control
     Globally
     Per active sound
   Multiple sound channels
     Per channel volume control
     Stop all active sounds in a channel
SYSTEM REQUIREMENTS
   Polyphony limits
     Limit maximum number of simultaneous sounds per
      channel
     Why?
         Performance reasons: sound playback has a performance
          impact
         Less is more: too many sounds playing simultaneously can be

          chaotic
       Option to drop the oldest sound or ignore the latest
        sound request when polyphony limit reached
GAME AUDIO STACK
GAME AUDIO SYSTEM
GAME AUDIO SYSTEM
AudioSys
 Game-specific audio interface
 Isolates game audio implementation from the rest
  of the game systems
 Helps in implementing graceful degradation
       Game must continue to function when audio
        functionality is not available
 Audio samples are loaded and managed by an
  AudioCache instance
 Music and SFX audio are played back using
  separate AudioChannel instances
GAME AUDIO SYSTEM
GAME AUDIO SYSTEM
AudioCache
 Handles audio asset loading
       selects the best audio format
   Maps sound IDs to actual audio samples
GAME AUDIO SYSTEM
GAME AUDIO SYSTEM
AudioChannel
 Handles sound playback
 Supports looping
 Provides channel playback controls
     Stop
     Volume control
     Mute
 Monitors and enforces polyphony limits
 Plays sounds from an AudioCache and returns an
  AudioChannel::Handle for managing an actively
  playing sound
 Reusable component
GAME AUDIO SYSTEM
GAME AUDIO SYSTEM
AudioChannel::Handle
 Façade class for managing an AudioChannel‟s
  active audio instance
 Provides playback functionality
     Stop
     Set volume

   Provide functionality to check playback status
GAME AUDIO SYSTEM
GAME AUDIO SYSTEM
AudioFactory
 Instantiates augmented HTML5 audio instances
 Why?
       Adds a custom loop API
           Addresses missing loop parameter support in earlier Firefox
            versions
       Replaces the existing volume control with a two tier
        volume control system
   Augmentation is applied on an audio instance
    instead of through class extension
       It is not recommended to extend an HTML5 audio class
        directly because HTML5 audio class name is not
        standard
GAME AUDIO SYSTEM
GAME AUDIO SYSTEM
DEMO TIME
AUDIO SYSTEM IMPROVEMENTS
   Decompose AudioSys into multiple classes based
    on use case
     Improves readability and maintainability
     Hyper Grav‟s audio system decomposition
         AudioMan: Game audio system
         AudioListener: In-game specific audio interface


   Modify AudioCache to manage sound pools on a
    per sound asset basis
     AudioChannel requests an audio instance from
      AudioCache and it returns an instance from the sound
      asset‟s instance pool
     Fixes sound playback delay in IE 9
AUDIO SYSTEM IMPROVEMENTS
   Support asset filtering in AudioCache
     Current implementation selects format based on the
      order of source URLs and the browser‟s audio format
      support
     Add filtering to control audio format selection on a per
      platform basis
     Why?
           On some platforms, audio format selection has to be made for
            performance reasons e.g. audio compression has a significant
            performance impact on mobile
ALTERNATIVE WEB AUDIO APIS
   W3C Web Audio API
     Official Web Audio API
     Designed to handle more complex audio applications
      (e.g. games)
     API is still in development
     Currently, only Chrome implements a version of the
      Web Audio API
   Mozilla Audio API extension
     Extends existing HTML5 audio and video elements to
      support more complex audio application
     Mozilla has officially declared the API deprecated
THE END
          Questions?
REFERENCES
   W3C Audio Working Group
    http://www.w3.org/2011/audio/
   Latest W3C HTML5 audio specification
    http://www.w3.org/TR/html5/the-audio-element.html
   Mozilla‟s audio data browser compatibility list
    https://developer.mozilla.org/en-
    US/docs/Media_formats_supported_by_the_audio_and_
    video_elements#Browser_compatibility
   Proposed W3C Web Audio API
    http://www.w3.org/TR/webaudio/
   Mozilla Audio API extension
    https://developer.mozilla.org/en-
    US/docs/Introducing_the_Audio_API_Extension

Contenu connexe

Tendances

Integrator Series: Large files
Integrator Series: Large filesIntegrator Series: Large files
Integrator Series: Large filesQuintagroup
 
Game Audio in Mobile Development
Game Audio in Mobile DevelopmentGame Audio in Mobile Development
Game Audio in Mobile Developmentgame_audio
 
Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)Kore VM
 
Media hardware
Media hardwareMedia hardware
Media hardwarecoralprout
 
How to Change Your Voice in Counter Strike Global Offensive
How to Change Your Voice in Counter Strike Global OffensiveHow to Change Your Voice in Counter Strike Global Offensive
How to Change Your Voice in Counter Strike Global Offensiveaudio4fun
 
Absolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minuteAbsolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minuteDevGAMM Conference
 
Next Gen: More Than Extra Channels?
Next Gen: More Than Extra Channels?Next Gen: More Than Extra Channels?
Next Gen: More Than Extra Channels?Slide_N
 
Accessibility features on hulu
Accessibility features on huluAccessibility features on hulu
Accessibility features on huluJohn Peterson
 
Accessibility Reaching all Learners
Accessibility Reaching all LearnersAccessibility Reaching all Learners
Accessibility Reaching all LearnersLeslie Schecht
 
IT project (Myna application)
IT project (Myna application)IT project (Myna application)
IT project (Myna application)201013446
 
Post Production Glossary
Post Production GlossaryPost Production Glossary
Post Production GlossaryJoe Nasr
 
Audio Post Production
Audio Post ProductionAudio Post Production
Audio Post ProductionJoe Nasr
 

Tendances (20)

Integrator Series: Large files
Integrator Series: Large filesIntegrator Series: Large files
Integrator Series: Large files
 
Game Audio in Mobile Development
Game Audio in Mobile DevelopmentGame Audio in Mobile Development
Game Audio in Mobile Development
 
Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)Lua and adaptive audio - Don Veca (Activision)
Lua and adaptive audio - Don Veca (Activision)
 
Free software-course
Free software-courseFree software-course
Free software-course
 
Media hardware
Media hardwareMedia hardware
Media hardware
 
How to Change Your Voice in Counter Strike Global Offensive
How to Change Your Voice in Counter Strike Global OffensiveHow to Change Your Voice in Counter Strike Global Offensive
How to Change Your Voice in Counter Strike Global Offensive
 
hoseok valve
hoseok valvehoseok valve
hoseok valve
 
Absolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minuteAbsolutist: Porting to major platforms within a minute
Absolutist: Porting to major platforms within a minute
 
Windows movie maker
Windows movie makerWindows movie maker
Windows movie maker
 
Devices
DevicesDevices
Devices
 
Xbox final
Xbox finalXbox final
Xbox final
 
8 best audio editing
8 best audio editing8 best audio editing
8 best audio editing
 
Unity TV Menus and Features
Unity TV Menus and FeaturesUnity TV Menus and Features
Unity TV Menus and Features
 
Next Gen: More Than Extra Channels?
Next Gen: More Than Extra Channels?Next Gen: More Than Extra Channels?
Next Gen: More Than Extra Channels?
 
Accessibility features on hulu
Accessibility features on huluAccessibility features on hulu
Accessibility features on hulu
 
Accessibility Reaching all Learners
Accessibility Reaching all LearnersAccessibility Reaching all Learners
Accessibility Reaching all Learners
 
IT project (Myna application)
IT project (Myna application)IT project (Myna application)
IT project (Myna application)
 
Post Production Glossary
Post Production GlossaryPost Production Glossary
Post Production Glossary
 
Utilities
UtilitiesUtilities
Utilities
 
Audio Post Production
Audio Post ProductionAudio Post Production
Audio Post Production
 

Similaire à Effective HTML5 game audio

Chapter 7 Multimedia
Chapter 7 MultimediaChapter 7 Multimedia
Chapter 7 MultimediaPatty Ramsey
 
3Q_audio_presentation.ict for begginderss
3Q_audio_presentation.ict for begginderss3Q_audio_presentation.ict for begginderss
3Q_audio_presentation.ict for begginderssron04joshdiwa
 
Audio ResourcesChoose one of them or any other of your c.docx
Audio ResourcesChoose one of them or any other of your c.docxAudio ResourcesChoose one of them or any other of your c.docx
Audio ResourcesChoose one of them or any other of your c.docxikirkton
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improvedItsLiamOven
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improvedBen Atherton
 
Podcasting in VET
Podcasting in VETPodcasting in VET
Podcasting in VETSue Waters
 
TAA eLearn Course - Presentation Week 3
TAA eLearn Course - Presentation Week 3TAA eLearn Course - Presentation Week 3
TAA eLearn Course - Presentation Week 3Yum Studio
 
Podcasting sfrome2011 by Maria Grazia Bovo (FAO)
Podcasting sfrome2011 by Maria Grazia Bovo (FAO)Podcasting sfrome2011 by Maria Grazia Bovo (FAO)
Podcasting sfrome2011 by Maria Grazia Bovo (FAO)ShareFair
 
Moving Pictures - Web 2.0 Expo NYC
Moving Pictures - Web 2.0 Expo NYCMoving Pictures - Web 2.0 Expo NYC
Moving Pictures - Web 2.0 Expo NYCCal Henderson
 
Ig2 task 1 work sheet (glossary) steph hawkins revisited
Ig2 task 1 work sheet (glossary) steph hawkins revisitedIg2 task 1 work sheet (glossary) steph hawkins revisited
Ig2 task 1 work sheet (glossary) steph hawkins revisitedstephlizahawkins123
 
Deep dive into Android’s audio latency problem
Deep dive into Android’s audio latency problemDeep dive into Android’s audio latency problem
Deep dive into Android’s audio latency problemSirawat Pitaksarit
 
HTML Multimedia.pptx
HTML Multimedia.pptxHTML Multimedia.pptx
HTML Multimedia.pptxssuser08ea44
 
Voodoo video conference preparation - presenters
Voodoo video conference preparation - presentersVoodoo video conference preparation - presenters
Voodoo video conference preparation - presentersKhouzhan Athena
 
Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2JoeBrannigan
 

Similaire à Effective HTML5 game audio (20)

Chapter 7 Multimedia
Chapter 7 MultimediaChapter 7 Multimedia
Chapter 7 Multimedia
 
3Q_audio_presentation.ict for begginderss
3Q_audio_presentation.ict for begginderss3Q_audio_presentation.ict for begginderss
3Q_audio_presentation.ict for begginderss
 
Audio ResourcesChoose one of them or any other of your c.docx
Audio ResourcesChoose one of them or any other of your c.docxAudio ResourcesChoose one of them or any other of your c.docx
Audio ResourcesChoose one of them or any other of your c.docx
 
Sound Recording Glossary
Sound Recording GlossarySound Recording Glossary
Sound Recording Glossary
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improved
 
JAVA Media Player
JAVA Media PlayerJAVA Media Player
JAVA Media Player
 
Html multimedia
Html multimediaHtml multimedia
Html multimedia
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improved
 
Podcasting in VET
Podcasting in VETPodcasting in VET
Podcasting in VET
 
TAA eLearn Course - Presentation Week 3
TAA eLearn Course - Presentation Week 3TAA eLearn Course - Presentation Week 3
TAA eLearn Course - Presentation Week 3
 
Podcasting sfrome2011 by Maria Grazia Bovo (FAO)
Podcasting sfrome2011 by Maria Grazia Bovo (FAO)Podcasting sfrome2011 by Maria Grazia Bovo (FAO)
Podcasting sfrome2011 by Maria Grazia Bovo (FAO)
 
Moving Pictures - Web 2.0 Expo NYC
Moving Pictures - Web 2.0 Expo NYCMoving Pictures - Web 2.0 Expo NYC
Moving Pictures - Web 2.0 Expo NYC
 
Multimedia formats
Multimedia formatsMultimedia formats
Multimedia formats
 
Ig2 task 1 work sheet (glossary) steph hawkins revisited
Ig2 task 1 work sheet (glossary) steph hawkins revisitedIg2 task 1 work sheet (glossary) steph hawkins revisited
Ig2 task 1 work sheet (glossary) steph hawkins revisited
 
Deep dive into Android’s audio latency problem
Deep dive into Android’s audio latency problemDeep dive into Android’s audio latency problem
Deep dive into Android’s audio latency problem
 
HTML Multimedia.pptx
HTML Multimedia.pptxHTML Multimedia.pptx
HTML Multimedia.pptx
 
Multimedia Formats
Multimedia FormatsMultimedia Formats
Multimedia Formats
 
Voodoo video conference preparation - presenters
Voodoo video conference preparation - presentersVoodoo video conference preparation - presenters
Voodoo video conference preparation - presenters
 
Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2
 
video
videovideo
video
 

Dernier

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Dernier (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Effective HTML5 game audio

  • 1. EFFECTIVE HTML5 GAME AUDIO Chris Khoo (chris.khoo@wappworks.com)
  • 2. TOPICS 1. HTML5 Audio  Definition  The good, the bad, and the ugly 2. HTML5 audio game layer architecture
  • 4. HTML5 AUDIO  HTML5 audio is part of the HTML5 specifications managed by the World Wide Web Consortium (W3C)  The <audio> element  Represents a sound or audio stream  Not designed for real-time audio mixing  W3C is working on a Web Audio API as an alternative audio solution  Advanced sound manipulation functionality  Not purely stream related
  • 5.
  • 6. THE GOOD  HTML5 audio API support is standard across all modern browsers  EXCEPTION: Firefox versions prior to Jan 1, 2012 do not support the loop flag It is possible to implement a game sound engine using HTML5 audio
  • 7. THE BAD  Limited audio control  Coarse control of audio playback position and volume  No audio panning support  No sound filters  Non-contiguous looping  Expect a slight pause whenever a sound sample loops
  • 8. THE BAD  Non-standard audio formats across browsers  No one audio format works for all browsers  A list of supported audio formats on a per browser basis is available on Mozilla‟s website  To ensure the highest browser compatibility, be sure to support multiple audio formats (ogg, mp3, wav)
  • 9. THE BAD  Spotty HTML5 audio support on default mobile device web browsers  Android  Android 2.x: Audio does not play  Android 3.0+: Only one audio instance allowed to produce sound at a time  iOS  Audio must be triggered through user interaction  Apple is actively working to prevent workarounds  Support in third party mobile web browsers is much better  Firefox mobile implements HTML5 audio perfectly
  • 10. THE UGLY  No guarantee of timely activation  Some browsers have a noticeable delay between calling the play() function and sound playback starting  Safari - always true  IE 9 - occurs when modifying an audio element‟s src parameter prior to play back  Beware of audio stream stalls  HTML5 audio streaming can sometimes stall without reason  It seems to happen more frequently with WebKit browsers  A “stalled” event is fired whenever this occurs  Call the load() function to manually restart streaming
  • 11. THE UGLY  Server functionality can impact HTML5 audio behavior  On WebKit browsers (Chrome and Safari), audio/video seek functionality is quietly disabled if the audio web server does not support partial requests  Disabling seek causes  play() call completes without error but playback does not occur  „ended‟ event does not fire on playback complete  „Sound file format corrupted‟ exception is thrown when trying to replay sounds  Generally happens the first time an audio is referenced  Doesn‟t happen on subsequent accesses if the audio is cached  Other known quirks  Firefox 3.6: short sounds don‟t play  No longer a problem since Mozilla is phasing out this version  Safari: Terrible audio playback performance
  • 13. SHOULD WE USE HTML5 AUDIO? Pros  Browser audio support is steadily improving  It works across all platforms including mobile web  It‟s possible to work around most of the issues through careful sound design and good engineering but audio experience, in general, is compromised  Popular HTML5 game acceleration platforms support audio through the <audio> element  CocoonJs and AppMobi take this approach Cons  Limited audio manipulation functionality  Inherently more complicated to implement  Audio experience still varies from browser to browser
  • 15. BUILDING AN HTML5 GAME AUDIO SYSTEM
  • 16. SYSTEM REQUIREMENTS  Graceful degradation  What if there‟s no HTML5 audio support?  Sound loading/caching  Sound playback  Sound looping support  Mute/Unmute  Volume control  Globally  Per active sound  Multiple sound channels  Per channel volume control  Stop all active sounds in a channel
  • 17. SYSTEM REQUIREMENTS  Polyphony limits  Limit maximum number of simultaneous sounds per channel  Why?  Performance reasons: sound playback has a performance impact  Less is more: too many sounds playing simultaneously can be chaotic  Option to drop the oldest sound or ignore the latest sound request when polyphony limit reached
  • 20. GAME AUDIO SYSTEM AudioSys  Game-specific audio interface  Isolates game audio implementation from the rest of the game systems  Helps in implementing graceful degradation  Game must continue to function when audio functionality is not available  Audio samples are loaded and managed by an AudioCache instance  Music and SFX audio are played back using separate AudioChannel instances
  • 22. GAME AUDIO SYSTEM AudioCache  Handles audio asset loading  selects the best audio format  Maps sound IDs to actual audio samples
  • 24. GAME AUDIO SYSTEM AudioChannel  Handles sound playback  Supports looping  Provides channel playback controls  Stop  Volume control  Mute  Monitors and enforces polyphony limits  Plays sounds from an AudioCache and returns an AudioChannel::Handle for managing an actively playing sound  Reusable component
  • 26. GAME AUDIO SYSTEM AudioChannel::Handle  Façade class for managing an AudioChannel‟s active audio instance  Provides playback functionality  Stop  Set volume  Provide functionality to check playback status
  • 28. GAME AUDIO SYSTEM AudioFactory  Instantiates augmented HTML5 audio instances  Why?  Adds a custom loop API  Addresses missing loop parameter support in earlier Firefox versions  Replaces the existing volume control with a two tier volume control system  Augmentation is applied on an audio instance instead of through class extension  It is not recommended to extend an HTML5 audio class directly because HTML5 audio class name is not standard
  • 32. AUDIO SYSTEM IMPROVEMENTS  Decompose AudioSys into multiple classes based on use case  Improves readability and maintainability  Hyper Grav‟s audio system decomposition  AudioMan: Game audio system  AudioListener: In-game specific audio interface  Modify AudioCache to manage sound pools on a per sound asset basis  AudioChannel requests an audio instance from AudioCache and it returns an instance from the sound asset‟s instance pool  Fixes sound playback delay in IE 9
  • 33. AUDIO SYSTEM IMPROVEMENTS  Support asset filtering in AudioCache  Current implementation selects format based on the order of source URLs and the browser‟s audio format support  Add filtering to control audio format selection on a per platform basis  Why?  On some platforms, audio format selection has to be made for performance reasons e.g. audio compression has a significant performance impact on mobile
  • 34. ALTERNATIVE WEB AUDIO APIS  W3C Web Audio API  Official Web Audio API  Designed to handle more complex audio applications (e.g. games)  API is still in development  Currently, only Chrome implements a version of the Web Audio API  Mozilla Audio API extension  Extends existing HTML5 audio and video elements to support more complex audio application  Mozilla has officially declared the API deprecated
  • 35. THE END Questions?
  • 36. REFERENCES  W3C Audio Working Group http://www.w3.org/2011/audio/  Latest W3C HTML5 audio specification http://www.w3.org/TR/html5/the-audio-element.html  Mozilla‟s audio data browser compatibility list https://developer.mozilla.org/en- US/docs/Media_formats_supported_by_the_audio_and_ video_elements#Browser_compatibility  Proposed W3C Web Audio API http://www.w3.org/TR/webaudio/  Mozilla Audio API extension https://developer.mozilla.org/en- US/docs/Introducing_the_Audio_API_Extension

Notes de l'éditeur

  1. Split into 2 sectionsTime for questions between the 2 sectionsAlso have demos
  2. Note emphasis on stream – has a noticeable impact when implementing an HTML5 audio system. We’ll talk about the impact in a short whileWill talk a little bit more about the Web Audio API if there’s timeW3C Working Audio Group is responsible for HTML5 Audio and Web Audio API
  3. Firefox loop bug issue:https://bugzilla.mozilla.org/show_bug.cgi?id=449157
  4. https://developer.mozilla.org/en-US/docs/Media_formats_supported_by_the_audio_and_video_elements#Browser_compatibility
  5. On timely activation,Specs does not state that playback should begin immediately on play activation
  6. On server functionality,HTML5 audio is a stream element, therefore it relies on server streaming support i.e. make partial requests
  7. Demo:Demo Firefox: perfect working exampleDemo IE 9: delayed response + fixSafari delayed response + performance issueChrome: Server no partial content bug
  8. Sound Man
  9. Why multiple sound channels?Allows elements which logically belong together to be manipulated as one (e.g. mute speech only)
  10. Why per channel volume control?Tuning:Per channel basis is great for tuning sound mixesWhy per active sound volume control?Some games need to manipulate sound volumes post sound launch e.g. ship thruster sound volumeSound performance impact?- Talk more about this when we talk about optimizations
  11. This is the proposed game audio stack
  12. Blue are public classesGreen are private classesThe audio class are enhanced HTML5 audio element instances
  13. Blue are public classesGreen are private classesThe audio class are enhanced HTML5 audio element instances
  14. Reason behind Hyper Grav audio decomposition:In-game SFX behavior is wholly different from FE SFX behaviorWanted to make sure all in-game objects were recycled when returning to the front endIn-game audio interface allowed this by maintaining all game-specific object references required for audio playbackWished I had decomposed AudioMan’s interface further
  15. Reason behind Hyper Grav audio decomposition:In-game SFX behavior is wholly different from FE SFX behaviorWanted to make sure all in-game objects were recycled when returning to the front endIn-game audio interface allowed this by maintaining all game-specific object references required for audio playbackWished I had decomposed AudioMan’s interface further