jsantell / dancer.js

high-level audio API, designed to make sweet visualizations
jsantell.github.com/dancer.js
MIT License
2.11k stars 211 forks source link

Add microphone support, using new WebKit Audio API. #37

Open endel opened 11 years ago

endel commented 11 years ago

Modify and document out new Dancer#load interface, which must accept only plain objects right now, since there are already three ways of loading it (via audio element, src attribute, and microphone Input).

There is an example of microphone using FFT on examples/fft-microphone.

Please consider incrementing minor version, since Dancer#load interface was modified.

(Note: live audio input must be enabled.) webkit-audio-input-flags.png

romaricdrigon commented 11 years ago

Hi endel,

I've tried to use your code in a small project, here (dancer branch). I fetched all your code, build it using grunt (by the way, there're two warnings about 2 forgotten ;)

However I'm not able to make it work: the offKick event would declench a bunch of time (like every ms...), but nothing happen. I'm using Chrome 23, flags enabled (I can use Chrome demo).

May I have forgotten something?

endel commented 11 years ago

Hey @romaricdrigon, I've checked out your code and it worked just fine. You may calibrate the "threshold" of the Kick for your microphone sensitivity and ambient noise.

kick = dancer.createKick({
  threshold: 0.1,
  onKick: function (mag) {
    console.log('kick');
  },
  offKick: function () {
    console.log('off');
  }
}).on();
romaricdrigon commented 11 years ago

I think I get it: I was trying to test it using my laptop microphone & some music playing on it. But it must have some kind of anti Larsen filter, it was filtered...

So thanks for the tip!