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

webaudio-peaks

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webaudio-peaks

Small library to extract peaks from an array of audio samples or an AudioBuffer from the WebAudio API.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
695
decreased by-44.84%
Maintainers
1
Weekly downloads
 
Created
Source

webaudio-peaks

Small library to extract peaks from an array of audio samples or a webaudio AudioBuffer.

npm

Installation

npm install webaudio-peaks --save

Basic Usage

var extractPeaks = require("webaudio-peaks");

var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
//decode an ArrayBuffer into an AudioBuffer
audioCtx.decodeAudioData(audioData, function (decodedData) {
  //calculate peaks from an AudioBuffer
  var peaks = extractPeaks(decodedData, 10000, true);
});

extractPeaks(source, samplesPerPixel, isMono, cueIn, cueOut, bits)

function to extract peaks from a TypedArray, or AudioBuffer

Params

  • source TypedArray|AudioBuffer - A source of audio samples.
  • samplesPerPixel number - Number of samples used to calculate a single peak.
  • isMono boolean - Combine all channels into one array of peaks or not.
  • cueIn number - Sample to begin at. The offset is inclusive.
  • cueOut number - Sample to end at. The offset is exclusive.
  • bits (8|16|32) - Resolution of calculated peaks.

Returns: object

{
  length: `number`; //Number of calculated peaks,
  //Computed peak data, length ==  #channels or 1 if isMono == true
  //Each entry of type `Int{bits}Array`
  data: `Array`;
  bits: `(8|16|32)`; //Resolution of calculated peaks.
}

License

MIT License

Keywords

FAQs

Package last updated on 29 Jul 2021

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