-debug = require("debug")("oscilloscope")
-
 class Oscilloscope
 
   constructor: (source, options = { }) ->

      throw new Error "Signal must be an AudioNode"

    if source instanceof AnalyserNode
      debug "add signal analyser"
      @analyser = source
    else
      debug "add signal source"
      @analyser = source.context.createAnalyser()
      source.connect @analyser


  # begin default signal animation
  animate: ->
    return if @drawRequest
    @drawRequest = window.requestAnimationFrame @_drawSignal

  # todo: stop signal animation
  stop: ->
    cancelAnimationFrame @drawRequest
    @drawRequest = 0
    #@drawContext.clearRect 0, 0, @canvas.width, @canvas.height
