Socket
Book a DemoInstallSign in
Socket

audio-frequency-to-index

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-frequency-to-index

convert a Hz frequency to an index for WebAudio

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
928
-12.95%
Maintainers
1
Weekly downloads
 
Created
Source

audio-frequency-to-index

stable

Convert a Hz frequency to an index for WebAudio frequency analysis. Also see audio-index-to-frequency.

The value is clamped between [ 0 .. frequencyBinCount ]. The frequencyBinCount is the same as ananlyserNode.fftSize / 2.

const freq2index = require('audio-frequency-to-index')
const sampleRate = audioContext.sampleRate // 44100
const length = analyserNode.frequencyBinCount // 1024

const index = freq2index(400, sampleRate, length)
//=> 19

Usage

NPM

index = frequencyToIndex(frequency, sampleRate, frequencyBinCount)

Converts frequency (in Hz) to an index integer using the audioContext.sampleRate and analyserNode.frequencyBinCount from the Web Audio API.

License

MIT, see LICENSE.md for details.

Keywords

web

FAQs

Package last updated on 25 Nov 2015

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