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

audio-buffer

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-buffer

AudioBuffer class for node/browser

  • 4.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50K
decreased by-72.52%
Maintainers
4
Weekly downloads
 
Created

What is audio-buffer?

The audio-buffer npm package provides a simple and efficient way to handle audio data in the form of buffers. It allows you to create, manipulate, and process audio buffers, which are essential for various audio processing tasks such as audio synthesis, effects, and analysis.

What are audio-buffer's main functionalities?

Creating an Audio Buffer

This feature allows you to create a new audio buffer with a specified number of channels and samples per channel. In this example, a stereo buffer with 44100 samples per channel is created.

const AudioBuffer = require('audio-buffer');
const buffer = new AudioBuffer(2, 44100); // 2 channels, 44100 samples per channel

Filling an Audio Buffer with Data

This feature allows you to fill an audio buffer with data. In this example, each channel of the buffer is filled with a sine wave.

const AudioBuffer = require('audio-buffer');
const buffer = new AudioBuffer(2, 44100);
for (let channel = 0; channel < buffer.numberOfChannels; channel++) {
  const data = buffer.getChannelData(channel);
  for (let i = 0; i < data.length; i++) {
    data[i] = Math.sin(2 * Math.PI * i / 44100); // Example: filling with a sine wave
  }
}

Copying Audio Buffer Data

This feature allows you to copy data from one audio buffer to another. In this example, data from buffer1 is copied to buffer2.

const AudioBuffer = require('audio-buffer');
const buffer1 = new AudioBuffer(2, 44100);
const buffer2 = new AudioBuffer(2, 44100);
buffer2.copyToChannel(buffer1.getChannelData(0), 0);
buffer2.copyToChannel(buffer1.getChannelData(1), 1);

Resampling an Audio Buffer

This feature allows you to resample an audio buffer to a different sample rate. In this example, the buffer is resampled from 44100 samples per channel to 22050 samples per channel.

const AudioBuffer = require('audio-buffer');
const resample = require('audio-buffer-resample');
const buffer = new AudioBuffer(2, 44100);
const resampledBuffer = resample(buffer, 22050); // Resample to 22050 samples per channel

Other packages similar to audio-buffer

Keywords

FAQs

Package last updated on 28 Jun 2017

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