Skip to content

Instantly share code, notes, and snippets.

@sqrtofsaturn
Created March 18, 2016 03:48
Show Gist options
  • Save sqrtofsaturn/c0ec3b5fe8b359842e75 to your computer and use it in GitHub Desktop.
Save sqrtofsaturn/c0ec3b5fe8b359842e75 to your computer and use it in GitHub Desktop.
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