Socket
Socket
Sign inDemoInstall

audio-param-transform

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    audio-param-transform

Apply multiple transforms with custom functions to Web Audio API AudioParams.


Version published
Weekly downloads
5
decreased by-75%
Maintainers
1
Install size
15.4 kB
Created
Weekly downloads
 

Readme

Source

audio-param-transform

Apply multiple transforms with custom functions to Web Audio API AudioParams.

Install

$ npm install audio-param-transform

API

var extendTransform = require('audio-param-transform')

extendTransform(audioParam, audioContext)

Pass in the AudioParam you wish to add a transform() method to and the relevant AudioContext.

Returns the extended param.

param.transform(func, defaultValue)

Returns an instance of TransformAudioParam applied to the target AudioParam which works the same as the base AudioParam, except applying the specified func(a, b) to all values, ramps and curves.

If you do not specify a function, the specified value for this transform will override all previous transforms (if any).

TransformAudioParam#setValueAtTime(value, at)

TransformAudioParam#linearRampToValueAtTime(value, endTime)

TransformAudioParam#exponentialRampToValueAtTime(value, endTime)

TransformAudioParam#setValueCurveAtTime(float32ArrayCurve, at, duration)

TransformAudioParam#cancelScheduledValues(from)

TransformAudioParam#getValueAt(time)

Example

Creating a transpose param.

var extendTransform = require('audio-param-transform')

var audioContext = new AudioContext()
var oscillator = audioContext.createOscillator()
oscillator.connect(audioContext.destination)


// create a base transform in case we want to automate the two independently
var baseFrequencyParam = oscillator.frequency.transform()

// now add the transpose transform
var transposeParam = oscillator.frequency.transform(transpose)

// modulate the transpose up an octave then down again each second
var on = false
setInterval(function(){
  if (on){ // ramp up
    transposeParam.linearRampToValueAtTime(12, audioContext.currentTime + 0.3)
  } else { // and back again
    transposeParam.linearRampToValueAtTime(0, audioContext.currentTime + 0.3)
  }
  on = !on
}, 1000)

function transpose(a,b){
  return a * Math.pow(2, (b || 0) / 12)
}

Keywords

FAQs

Last updated on 21 Aug 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc