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

audio-automator

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-automator

A better way to change AudioParam values

  • 0.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

audio-automator

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

A better way to change AudioParam values.

This library was created to deal with some of the issues I've encountered when working with the WebAudio AudioParam (MDN) automation features. The web-audio-api provides 6 functions for automating param values, as well as letting you set the param.value directly:

  • AudioParam.cancelScheduledValues()
  • AudioParam.exponentialRampToValueAtTime()
  • AudioParam.linearRampToValueAtTime()
  • AudioParam.setTargetAtTime()
  • AudioParam.setValueAtTime()
  • AudioParam.setValueCurveAtTime()

There are however, some annoyances with the API (IMHO), so I created this library. For example, when using any of the 6 functions above, the param.value does not change while automations are occurring, so you cannot inspect where in the automation you are (you have to calculate this yourself by keeping track of timings). Also, when you cancel an automation, the "value" jumps back to the value when the automation started (which may or may not be what you intended).

I've "fixed" these issues by always setting the param.value directly, and not using the built-in web audio automation functions. This allows me to expose different types of automation easing functions, as well as allowing end users to inspect automation timings and values at any time. It also lets you schedule new automations that just "pick up from the right spot". Meaning you don't have to cancel running automations if you don't want to. Just schedule a new one, and the most recent automation added will work correctly.

You can check out a live demo here:

Getting Started

Install the module with: npm install audio-automator

Documentation

Basic Usage
import AudioAutomator from 'audio-automator';

// create a context, and a gain node (which we will automate)
const audioContext = new AudioContext();
const gain = audioContext.createGain();

// create our AudioAutomator
const auto = new AudioAutomator(audioContext);

// Automate the gain node:
// This waits for 3 seconds, then starts using a `sinInOut` easing
// function to change the value of the gain node to 0.5. It will
// take 1.2 seconds to complete the automation.
auto.sinInOut(gain.gain, 0.5, 1.2, 3);

License

Copyright (c) 2016 skratchdot
Licensed under the MIT license.

FAQs

Package last updated on 30 Jan 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