soundbank-sample
Sample player AudioNode source extended with automatable transpose, tuning and amp.
Intended for use as a source in soundbank, but it is compatible with any Web Audio API AudioNode set up.
Deprecated
Use audio-slot/sources/sample instead.
Stability
Deprecated: Expect no more changes. Avoid using this module.
Install
$ npm install soundbank-sample
API
var Sample =
Sample(audioContext)
Returns a source AudioNode.
AudioParams: amp
source.transpose (get/set)
Due to a bug in Chrome, this is not currently an AudioParam, but will be in the future. See https://code.google.com/p/chromium/issues/detail?id=311284
source.tune (get/set)
Due to a bug in Chrome, this is not currently an AudioParam, but will be in the future.
source.mode (get/set)
Set the trigger mode of the audio node: 'hold', 'oneshot', 'loop'
'oneshot' is the same as hold, except the node.start()
method returns the time the node.stop()
should be called.
source.buffer (get/set)
Specify an instance of AudioBuffer for playback.
source.startOffset (get/set)
Choose the fraction of duration (between 0
and 1
) to use as audio in point.
source.endOffset (get/set)
Choose the fraction of duration (between 0
and 1
) to use as audio out or loop point.
source.offset (get/set)
Specify the startOffset
and endOffset
as an array [start, end]
.
source.start(at)
Schedule note start. Can only be called once. For each event, you need to create a new instance.
source.stop(at)
Schedule note stop.
Example
var Sample = var audioContext = audioContextsampleCache = {} // see example.js for full details var sample = sampleurl = 'hiss.wav'samplemode = 'oneshot' samplestartOffset = 02sampletune = 35 // centssampletranspose = -3 // semitones // trigger start and end (oneshot will suggest an end time as return value)var endTime = samplestart0sample
To run the example clone the repo and npm install && npm run example
then navigate to http://localhost:9966/.