       @geom.vertices[p.target].copy p.position
       @vertexAttributes.energy.value[p.target] = p.energy
 
-  onBeat: ->
-    @counter.particles = @particlesPerBeat
-    @counter.used = no
+  onMusicEvent: (event) ->
+    if event.segment
+      if @counter.used
+        @counter.particles = @particlesPerSegment * event.segment.volume
+        @counter.used = no
 
-  onSegment: ->
-    if @counter.used
-      @counter.particles = @particlesPerSegment
+    else if event.bar
+      # console.log @velocity
+      @counter.particles = @particlesPerBeat * event.bar.volume
+      @counter.used = no
+
+    else if event.beat
+      @counter.particles = @particlesPerBeat * event.beat.volume
       @counter.used = no
 
   alive: ->

    @emitter.start()

  setupValues: ->
    @drift = THREE.Math.randFloat 0, 500

    @baseColor = new THREE.Color().setHSV(
      THREE.Math.randFloat 0, 1

    
    @emitterZone = new MirrorPointZone(new THREE.Vector3 0, 0, 0)
    @emitter.addInitializer new SPARKS.Position(@emitterZone)
    @emitter.addInitializer new SPARKS.Velocity(new SphereZone(0, 0, 0, 70))
    @emitter.addInitializer new SPARKS.Lifetime .2, 1.5

    @emitter.addAction      new SPARKS.Age
    @emitter.addAction      new SPARKS.RandomDrift @drift, @drift, @drift
    @emitter.addAction      new SPARKS.Move
    @emitter.addAction      new Resistance 60
    @emitter.addAction      new Gravity 35

    @emitter.addCallback "created", @onParticleCreated
    @emitter.addCallback "dead",    @onParticleDead
