svjs-audio
v1.1.6
Published
Simple ES6 Module around the Web Audio API. For playing audio samples in a web page.
Downloads
4
Readme
svjs-audio
Simple ES6 Module around the Web Audio API. For playing audio samples in a web page.
Documentation
Sample
constructor(src, props?)
The parameter props is optional, the only property for now is gain
.
props = {
gain: 1 // sets the gain (volume) of the sample, default is "1"
}
setGain(value)
Set the gain of the sample after creation.
play(when?, offset?, duration?)
Play the Sample. Parameters are optional.
AudioSprite
constructor(src, props)
props = {
gain: 1, // optional, sets the gain (volume) of the sprite, default is "1"
slices: { // define the slices in the sprite-file
"sliceName1": {offset: 0, duration: 0.5},
"sliceName2": {offset: 0.5, duration: 0.5}
// [...]
}
}
play(sliceName)
Play the slice named sliceName
.