Vap0r
Vap0r

Reputation: 2616

Get microphone input and read data

I have a square reader which has audio output that I'm trying to read via the web browser. I'm using getUserMedia to get the audio stream from the microphone, and the web audio API to get the data. My problem is that all the tutorials I've found mention using the data stream to show visuals for the audio stream. In my implementation, I need to be able to differentiate card-swipe sound with the background noise.

I have a couple basic questions:

  1. What is FFT size? I know it's Fast Fourier Transform, but I don't know how or if it pertains to what I'm doing.
  2. I understand buffer size but how do I know how big my buffer should be?
  3. I've seen multiple things regarding left and right audio. I would assume the square reader would only have one channel for simplicity's sake, would this be correct?

And finally, the most important question, how do I combine it all together to make it so I read the frame that contains the square swipe data? I have this resource but I'm not getting data as 1s and 0s from the frequency or time data values of the stream analyser.

This link has more information about what needs to be done, but I can't do it until I get the data as bytes.

Upvotes: 0

Views: 1085

Answers (1)

cwilso
cwilso

Reputation: 13908

You will probably need to do this as a ScriptProcessor, not using the Analyser. The Analyser will not guarantee you won't drop data in between processing blocks. I'm not familiar with precisely how the Square reader transmits data; I presume it's frequency-shift-keying (FSK) - more at http://www.creativedistraction.com/demos/sensor-data-to-iphone-through-the-headphone-jack-using-arduino/, and interesting teardown at http://andybromberg.com/credit-cards/. An example of using ScriptProcessor at https://github.com/cwilso/volume-meter/.

Upvotes: 2

Related Questions