Package Exports
- webaudio-tools
- webaudio-tools/db
- webaudio-tools/silence-detector
Readme
webaudio-tools
useful tools for webaudio
🔧 Install · 🧩 Example · 📜 API docs · 🔥 Releases · 💪🏼 Contribute · 🖐️ Help
Install
$ npm i webaudio-toolsAPI
Table of Contents
dbToFloat
Convert dBFS value db to float.
Parameters
dbnumber Value in dBFS
Returns any the value in float
floatToDb
Convert float value float to dBFS.
Parameters
floatnumber Value in float
Returns any the value in dBFS
PeakingDetectorNode
Extends GainNode
PeakingDetectorNode.
const peakingDetectorNode = new PeakingDetectorNode(ctx)
peakingDetectorNode.decibelsThreshold = -1
peakingDetectorNode.onpeaking = () => console.log('peaking')
someAudioNode.connect(peakingDetectorNode)
// ... sometime later peaking is detected and fired once ...
// => console: "peaking"
//
// ... then when issue is resolved by user
// we make it possible to emit "peaking" event again
peakingDetectorNode.reset()Parameters
ctxBaseAudioContext
isPeaking
Indicator whether node is peaking
decibelsThreshold
Decibels threshold in dBFS to emit peaking when above
onpeaking
Event callback that fires when peaking is detected
Returns void
SilenceDetectorNode
Extends GainNode
SilenceDetectorNode.
const silenceDetectorNode = new SilenceDetectorNode(ctx)
silenceDetectorNode.silenceThresholdSeconds = 0.5
silenceDetectorNode.onplaying = () => console.log('playing')
silenceDetectorNode.onsilent = () => console.log('silent')
oscillatorNode.connect(silenceDetectorNode)
oscillatorNode.start() // => console: "playing"
...
oscillatorNode.stop()
// ... after 0.5 seconds ...
// => console: "silent"Parameters
ctxBaseAudioContext
isSilent
Indicates whether there is silence or not
silenceThresholdSeconds
How much silent time in seconds in order to detect silence (default: 0.5)
onsilent
Event callback that fires when node becomes silent
Returns void
onplaying
Event callback that fires when node receives audio
Returns void
Contribute
All contributions are welcome!
License
MIT © 2022 stagas