Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

audio-rms

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-rms

Connect a Web Audio API AudioNode and stream out the realtime RMS audio level.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

audio-rms

Connect a Web Audio API AudioNode and stream out the realtime RMS audio level.

Install

$ npm install audio-rms

Example

Stereo level meter using html5's meter element.

<meter id='L' min='-20' class='.left' high='0' value='-20' max='6' />
<meter id='R' min='-20' class='.right' high='0' value='-20' max='6' />
var AudioRMS = require('audio-rms')

var leftMeter = document.getElementById('L')
var rightMeter = document.getElementById('R')

var audioContext = new AudioContext()
var output = audioContext.createGain()
output.gain.value = 0.4
output.connect(audioContext.destination)

var oscillator = audioContext.createOscillator()
oscillator.connect(output)
oscillator.start()

// modulate audio level
var lfo = audioContext.createOscillator()
var amp = audioContext.createGain()
lfo.frequency.value = 1
amp.gain.value = 0.4
lfo.connect(amp)
amp.connect(output.gain)
lfo.start()

var rms = AudioRMS(audioContext)
output.connect(rms.input)

rms.on('data', function(data){
  leftMeter.value = Math.max(-40, getDecibels(data[0]))
  rightMeter.value = Math.max(-40, getDecibels(data[1]))
})

function getDecibels(value) {
  if (value == null) return 0
  return Math.round(Math.round(20 * (0.43429 * Math.log(value)) * 100) / 100 * 100) / 100
}

Keywords

FAQs

Package last updated on 04 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc