New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

audio-slot-param

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-slot-param

Link and transform schedule-based observables and connect to AudioParams (Web Audio API).

  • 2.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
increased by314.29%
Maintainers
1
Weekly downloads
 
Created
Source

audio-slot-param

Link and transform schedule-based observables and connect to AudioParams (Web Audio API).

Params are instances of observ-node-array/single.

NPM

Example

var Param = require('audio-slot-param')
var apply = require('audio-slot-param/apply')

var context = {
  audio: new AudioContext(), // Web Audio
  nodes: {
    lfo: require('audio-slot/modulators/lfo')
  }
}

var frequency = Param(context, 440)

var osc = audioContext.createOscillator()
var unapply = apply(context, osc.frequency, frequency)

osc.connect(context.audio.destination)
osc.start()

// set the value explicitly:
frequency.set(220)

// modulate with an LFO
frequency.set({
  node: 'lfo',
  mode: 'add',
  amp: 50,
  value: 220,
  rate: 8, // hz
  trigger: false
})

Transforms

var Transform = require('audio-slot-param/transform')

var pitch = Param(context, 0)
var octave = Param(context, 0)

var frequency = Transform(context, [ 440, // base freq
  { param: obs.octave, transform: transformOctave },
  { param: obs.noteOffset, transform: transformNote }
])

apply(context, osc.frequency, frequency)

octave.set(-1)
pitch.set(4)

osc.frequency.value //= 277.1826309768721

// or as above, we can specify a modulator instead of explicit value:
pitch.set({
  node: 'lfo',
  mode: 'add',
  amp: 1,
  value: 4,
  rate: 8, // hz
  trigger: false
})

function transformOctave(baseFrequency, value){
  return baseFrequency * Math.pow(2, value)
}

function transformNote(baseFrequency, value){
  return baseFrequency * Math.pow(2, value / 12)
}

Param Proxy

Creates a placeholder param that can be swapped for a real param later.

var Proxy = require('audio-slot-param/proxy')
var param = Proxy(context, 440)
apply(context, osc.frequency, param)

// then later on swap:
var target = LFO(context)
param.set(target)

Keywords

FAQs

Package last updated on 01 Sep 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