Created
March 18, 2016 03:48
-
-
Save sqrtofsaturn/c0ec3b5fe8b359842e75 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
baudio = require 'baudio' | |
class SoundEmitter | |
constructor: ({@baudRate, @channelHz, @channelWidth}) -> | |
@b = baudio @getAudio | |
@lastCharTime = Date.now() | |
getAudio: (time) => | |
@getBaseAudio time | |
getBaseAudio: (time) => | |
frequency = @channelHz | |
frequency = @channelHz + @channelWidth if Math.random() | |
sound = Math.sin(time * frequency)) | |
return Math.sin(time * frequency) | |
start: => | |
@b.play() | |
stop: => | |
@b.stop() | |
emitter = new SoundEmitter baudRate: 100, channelHz: 2000, channelWidth: 100 | |
emitter.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment