Pergunta

Specifically, if we have a stream of events representing x/y/z acceleration on device, which rxjs can give us, how could we implement this algorithm high-pass filter in a streaming fashion in order to utilize a longer sliding window of samples in shake detection ?

Shake.js approach is promising but based only on 2 consecutive samples, and 2 samples do not a signal stream make.

I feel like once shown how to use signal processing concepts I'm familiar with from audio/music work upon streaming user input data, my ability to leverage this framework will really take off, thanks in advance.

Foi útil?

Solução

This is what I was able to do by converting the implementation found on Wikipedia.

Rx.Observable.prototype.highpass = function (rc) {
  return this
    .timestamp()
    .bufferWithCount(2, 1)
    .scan(0, function (acc, x) {
      var dt = x[1].timestamp - x[0].timestamp;
      var a = rc / (rc + dt);
      return a * (acc + (x[1].value - x[0].value));
    });
};

The following example doesn't work super great. Anyway, it still serves a purpose, assuming you keep the mouse moving.

http://jsfiddle.net/xixonia/j2H3k/

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top