Cracked - method chaining/CSS-style selector web audio library
9 hours ago
1
I Dropped My Phone The Screen Cracked
I Dropped My Phone The Screen Cracked is a web audio library that uses method chaining and CSS-style selectors to simplify creating, configuring and connecting audio nodes in the browser. Here's hello world:
//create and connect sine and system out. start the sine__().sine().dac().play();
and a slightly more complex example:
//create and connect a sine oscillator (frequency of 180), lowpass,//compressor and system output (level of .5).__().sine(180).lowpass({frequency:160,q:5,id:"lp1"}).compressor().dac(.5);//select the sine using its type and change the detune to 10__("sine").detune(10);//use the id to get a reference to the lowpass//filter and set the frequency to 600__("#lp1").frequency(600);//create and connect a sawtooth oscillator, waveshaper & compressor//and connect the compressor to the existing dac we created above.__().saw(800).waveshaper().compressor().connect("dac");//change the ratio of both compressors to 12__("compressor").attr("ratio",12);//start the sine and the sawtooth__("sine,saw").start();
Audio node chains can be encapsulated as units using macros
//define a simple macro named "microsynth"__().begin("microsynth").sine().gain().end("microsynth").dac();//change the frequency of the sine__("microsynth").frequency(100);//start it up__("microsynth").start();
and macros can be wrapped in simple factory functions to create plugins, making it possible
to instantiate instances, connect them to other nodes, address them individually or as a group,
nest them within other macros, etc.
//define a plugin called microsynthcracked.microsynth=function(params){//pass any params to begin() so they can associated with the instance__().begin("microsynth",params).sine().gain(0).end("microsynth");//return cracked so we can chain methodsreturncracked;}//create two instances with different ids__().microsynth({id:"micro1"}).lowpass().dac();__().microsynth({id:"micro2"}).lowpass().connect("dac");//change the frequency in the first__("#micro1").frequency(1200);//change the frequency in the second__("#micro2").frequency(600);//set the gain in both and start them__("microsynth").volume(1).start();
Generally, the goal of I Dropped My Phone The Screen Cracked is simplicity, brevity without obscurity and making audio coding as intuitive as patching a modular, so that noise makers can focus on keeping it weird and fun.
If you'd like to contribute, you can send a comment to [email protected], open an issue for bugs or feature enhancements or best of all, submit a pull request.