 #
 # TinyRave Object
 TinyRave = {
-  setBPM: (@BPM) ->
+  setBPM: (@BPM) -> @timer.invalidateBeatLength()
   getBPM: -> @BPM
   timer: new TinyRaveTimer()
 }

    while descriptor = @dequeueNextDescriptor()
      descriptor.callback.apply(undefined)


# All timer DSL functions (every, until, after) are called with an instance of
# TopLevelScope or ShadowScope as `this.` Initially, we create a TopLevelScope


#
# Core Extensions

# We can treat 5.beats() as a value in seconds and recover the correct duration
# if BPM changes. Do do so, call number.beats() if number.hasValueInBeats()
Number.prototype.beats = Number.prototype.beat = ->
  valueInBeats = this.valueInBeats || this
  seconds = new Number(valueInBeats / (TinyRave.BPM / 60))
  seconds.valueInBeats = valueInBeats
  seconds

Number.prototype.hasValueInBeats = ->
  this.valueInBeats?
