New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bpm-detective

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bpm-detective

Detects the BPM of a song or audio sample

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

bpm-detective

Detects the BPM of a song or audio sample

This module uses the Web Audio API to try and detect the BPM of a given sound. You can find more on the implementation and how it works by reading the blog post Beat Detection Using JavaScript and the Web Audio API which happens to be where I got most of the code.

Install

$ npm install --save bpm-detective

Usage

The module exports one function. The function takes an AudioBuffer as it's only argument. It returns a promise that resolves to the detected BPM. If the sample was too short or if, for any other reason, the detection failed, the promise will be rejected.

import detect from 'bpm-detective';

let context = new AudioContext();

// Fetch some audio file
fetch('some/audio/file.wav')
  // Get response as ArrayBuffer
  .then(response => response.arrayBuffer())
  .then(buffer => {
    // Decode audio into an AudioBuffer
    return new Promise((resolve, reject) => {
      context.decodeAudioData(buffer, resolve, reject);
    });
  })
  // Run detection
  .then(detect)
  // Log error
  .catch(::console.error)
  // Log result
  .then(bpm => console.log(`Detected BPM: ${ bpm }`)):

Disclaimer

The detection presumes you are working with dance(-ish) kind of music and as so looks only in the 90-180 BPM spectrum.

License

MIT

Keywords

FAQs

Package last updated on 19 May 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