Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naomiaro/webaudio-peaks
Small library to extract peaks from either a TypedArray of audio samples or a webaudio AudioBuffer into an Int8Array, Int16Array, or Int32Array.
https://github.com/naomiaro/webaudio-peaks
peaks waveform webaudio
Last synced: about 1 month ago
JSON representation
Small library to extract peaks from either a TypedArray of audio samples or a webaudio AudioBuffer into an Int8Array, Int16Array, or Int32Array.
- Host: GitHub
- URL: https://github.com/naomiaro/webaudio-peaks
- Owner: naomiaro
- License: mit
- Created: 2016-01-19T00:14:50.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T09:40:55.000Z (almost 2 years ago)
- Last Synced: 2024-10-16T13:22:23.469Z (about 2 months ago)
- Topics: peaks, waveform, webaudio
- Language: JavaScript
- Homepage:
- Size: 377 KB
- Stars: 56
- Watchers: 4
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-javascript-audio - webaudio-peaks - small library to get peaks from audio (Libraries: Web Audio API / Web MIDI API)
README
# webaudio-peaks
Small library to extract peaks from an array of audio samples or a webaudio AudioBuffer.
[![npm](https://img.shields.io/npm/dm/webaudio-peaks.svg)](https://www.npmjs.com/package/webaudio-peaks)
## Installation
`npm install webaudio-peaks --save`
## Basic Usage
```javascript
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`
```javascript
{
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](http://doge.mit-license.org)