Sound Module

Matt Karl edited this page Dec 17, 2015 · 16 revisions

The Sound module is build on CreateJS's SoundJS which provides the ability to play low-latency audio using the Web Audio API (with a convenient Flash-fallback). This modules reduces the setup needed, takes care of feature detecting and provides important missing features from SoundJS (for instance, the concept of sound "contexts", or groups, to make it much easier to pause or mute all music, sound effects or voice over audio).

Features

  • Provides sound-grouping, a.k.a. sound "contexts", for muting and pausing groups of sounds
  • Easily configurable, but with defaults for WebAudio with Flash fallback
  • Voice-over player (springroll.VOPlayer) for playing a list of sounds
  • VOPlayer supports playing captions, if available (Captions Module is required)

Dependencies

  • SoundJS The core sound playback if provided by CreateJS's SoundJS. This library contains the WebAudio and Flash playback functionality. It is required.
  • PreloadJS PreloadJS is require to dynamically load sounds.
  • Core Module
  • Captions Module (optional) If utilizing VOPlayer's caption functionality.

Installing

In order to use the Sound module, make sure to include the module's JavaScript file within the springroll.json file within your project. The module needs to be included after the core. Also, SoundJS and SoundJS's FlashPlugin (if your game plans on providing a Flash fallback strongly recommended) will need to be included as well.

"libraries": [
	"components/preloadjs/lib/preloadjs.min.js",
	"components/soundjs/lib/soundjs.min.js",
	"components/soundjs/lib/flashaudioplugin.min.js",
	"components/springroll/dist/core.min.js",
	"components/springroll/dist/modules/sound.min.js"
],
"librariesDebug": [
	"components/preloadjs/lib/preloadjs.min.js",
	"components/soundjs/lib/soundjs.min.js",
	"components/soundjs/lib/flashaudioplugin.combined.js",
	"components/springroll/dist/core.js",
	"components/springroll/dist/modules/sound.js"
],
"librariesCopy": {
	"components/soundjs/lib/FlashAudioPlugin.swf": "deploy/assets/swfs/"
}

Classes

  • Sound Class The main class for globally playing, managing audio.
  • VOPlayer Class Responsible for playback of voice-over with optional captions output