GithubHelp home page GithubHelp logo

jsynth's Introduction

jsynth

Generate audio/DSP with javascript functions in the browser. Compatible with baudio style functions. Works on webkits, including Chrome, and iOS 6 mobile safari (see note below). Maybe Firefox now, but untested.

Pass your audio context, and your DSP function to the constructor. It will return a Web Audio Script Processing Node, which can be connected to any other Web Audio Node on the graph.

Simple use, generate a tone:

var master = new webkitAudioContext();

var jsynth = require('jsynth')
  , tau = Math.PI * 2
  , frequency = 555
;

var sineGenerator = function (time, index, input){
  return Math.sin(time * tau * frequency)
}

var synth = jsynth(master, sineGenerator); // returns a web audio node

synth.connect(master.destination)

Your function will be called with the following arguments:

  • Time, in seconds (float)
  • Sample index (integer)
  • Input sample (float), MONO, this will be zero if there is no input. Use this if you are connecting other web Audio Api Nodes to this one. In the near future this will be a an array, for multiple input channels.

You function should return a float between [-1, 1]. See examples below.

usage

npm install jsynth

Mobile Safari

On mobile safari webkit (iOS), you can only initiate web audio API sounds from within a user event context, such as a click.

Example

to run the example, use opa

npm install -g watchify opa

(watchify is browserify + file a file watcher) Then:

git clone [email protected]:NHQ/jsynth.git
cd jsynth
opa -n -e example.js 

open your browser to http://localhost:11001

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.