Created
May 4, 2013 05:09
-
-
Save kkxlkkxllb/5516283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class window.Melody extends AudioletGroup | |
| constructor: (audiolet, frequency) -> | |
| AudioletGroup.apply(@, [audiolet, 2, 1]) | |
| @sine = new Sine(@audiolet, frequency) | |
| @modulator = new Saw(@audiolet, 2 * frequency) | |
| @modulatorMulAdd = new MulAdd(@audiolet, frequency / 2,frequency) | |
| @triangle = new Triangle(@audiolet, frequency) | |
| @gain = new Gain(@audiolet) | |
| ar = -> | |
| @audiolet.scheduler.addRelative(0,@remove.bind(@)) | |
| @envelope = new PercussiveEnvelope @audiolet,1,0.2,0.5,ar.bind(@) | |
| @modulator.connect(@modulatorMulAdd) | |
| @modulatorMulAdd.connect(@sine) | |
| @envelope.connect(@gain, 0, 1) | |
| @sine.connect(@gain) | |
| @gain.connect(@outputs[0]) | |
| @init: -> | |
| audiolet = new Audiolet() | |
| cs = (hz) -> | |
| synth = new Melody(audiolet, hz) | |
| synth.connect(audiolet.output) | |
| audiolet.scheduler.addAbsolute 0,(-> cs(270)).bind(@) | |
| audiolet.scheduler.addAbsolute 1,(-> cs(470)).bind(@) | |
| audiolet.scheduler.addAbsolute 2,(-> cs(370)).bind(@) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment