npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

web-audio-ui

v2.0.1

Published

Web Audio UI Components

Downloads

16

Readme

web-audio-ui

NPM

ostensibly this package is intended to render extremely simple UI elements for controlling web audio nodes, however it can be configured to generate range inputs and select dropdowns that are bound to any sort of object, perhaps to control the settings of a generative art piece, or a data visualization, or an "indie game".

if passed an audioNode*, it will automatically generate a UI element based on a default config, however you can customize that by passing a config object in order to change behavior or support handling custom web audio objects (or any object for that matter)

DEMO

* CURRENTLY SUPPORTED audioNodes !:

  • Gain
  • Oscillator
  • Delay
  • BiquadFilter
  • AudioBufferSource
  • WaveShaper (uses this distortion curve as a default)
  • StereoPanner
  • DynamicsCompressor

TODO:

  • add analyserNode (and basic oscilliscope config from https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode ?)
  • add pannerNoder/audioListener (SO MANY ATTRIBUTES ZOMG)
  • use setValueAtTime in the default configs
  • start folder for default configs for web-audio modules on npm
  • make range inputs editable by typing in a number

INSTALL

npm install web-audio-ui

SIMPLE USE

var ui = require('web-audio-ui')

var context = new (window.AudioContext || window.webkitAudioContext)()
var osc = context.createOscillator()

var el = ui(osc)
// WOW! el is an html element with inputs bound to the parameters of the audio node! 

document.body.appendChild(el)
osc.start()
// now you have a lovely tone ringing in yr ears! play with the sliders to make it lovelier!-->

ADVANCED USE

var ui = require('web-audio-ui')

// any sort of object can be bound to web-audio-ui, for example: a custom web audio module, a processing sketch, a bunch of jquery spaghetti
var node = {
  type: 'cool',
  time: 3,
}

// we can pass a configuration object to tell web-audio-ui what to do with an arbitrary object
var el = ui(node, {
  className: "wow", // CSS class name to use for the element
  label: "Wow", // label text
  attributes: [
    {
      attribute: "time", // attribute name, used for CSS classes
      type: "range", // input type, can be `range` or `select`
      label: "Time", // UI label text
      min: 0, // min value for the range
      max: 1000, // max value for the range
      step: "any", // increments that the range can be changed by, can be "any" or a number
      value: node.time, // initial value
      update: function (val) { // function to run when input is changed
        node.time = val
        console.log(node)
      }
    },
    {
      attribute: "type", // attribute name, used for CSS classes
      type: "select", // input type, can be `range` or `select`
      label: "Type", // UI label text
      opts: ["cool", "cooler", "coolest"], // options for the select
      value: node.type, // initial value
      update: function (val) { // function to run when input is changed
        node.type = val
        console.log(node)
      }
    }
  ]
})
// WOW! el is an html element with inputs bound to the parameters of the arbitary object thing! 

document.body.appendChild(el)
// now you can update whatever you want! -->

STYLE IT

the demo main.css shows off many of the classes you can target with yr styles.

DEV

# install dependencies

npm install

## to play with the nodes:
# start watchify and local server

npm run watch
python -m SimpleHTTPServer

## to run the tests
# start watchify to build the test files 

npm run test

# => open browser to localhost:8000/test.html and inspect the console
# => it would be rly great to be able to run these tests via a CLI, but...this seems easier...