                  (let [listener (reify SensorEventListener
                                   (onAccuracyChanged [this sensor value] ())
                                   (onSensorChanged [this event]
-                                    (apply #'push-vector stack (seq (list (. event values))))))]
-                   (send-every id stack interval)
+                                    (apply #'replace-mean stack (seq (list (. event values))))))]
+                   (send-every "Data" interval)
                    (.. sensorManager
                        (registerListener listener
                                          (.getDefaultSensor sensorManager sensor-type)

                                         SensorManager/SENSOR_DELAY_GAME))
                   listener))]
    [(create "rotate" Sensor/TYPE_ROTATION_VECTOR rotate-stack)
     (create "acc" Sensor/TYPE_LINEAR_ACCELERATION acc-stack)]))

(def sensorManager (atom nil))


(def acc-stack (agent []))
(def rotate-stack (agent []))

(defn send-every [id interval]
  (letfn [(task []            
            (apply osc-send @client (str "/" id) (concat @acc-stack @rotate-stack))
            (for [stack [acc-stack rotate-stack]]
              (send stack (fn [_] []))))]
    (every interval task my-pool)))



(defn replace-mean [stack vals]
  (letfn [(mean [xs]
            (if (empty? xs) vals
                (map #(/ (+ %1 %2) 2.0) vals xs)))]
    (send-off stack mean)))


(defn push-vector [stack vals]
  (let [push (fn [xs xss]
               (if (empty? xss)
                 (map vector xs)
                 (map conj xss xs)))]
