5

Hello I was wondering if using the android tone generator class would it be possible to create a tone in one device and listen for this same tone in another device. If this is possible I do have a few other questions.

Taking backround noise into consideration is it possible to listen for only this specific tone?

Would this process be resource intensive?

Could I use a tone that would be inaudable to the human ear or close to it?

Lastly could I use a tone that could only be heard with a couple of feet from the sending device?

Thanks very much for yer time guys and girls :)

Edit > Thanks For adding the audio processing tag sabastian. Much better discription.

Keith
  • 420
  • 2
  • 5
  • 12

2 Answers2

4

It would be CPU intensive, yes. The way to it is quite simple: you need a permanent recorder which puts the received data into a FFT (fast fourier transform). FFT basically does one thing: splits the audio into a frequency/power-scale. With this "background noise cleaned" result you can check things like "was there a tone with 1000Hz playing for at least 2 seconds" - and act accordingly. There is a reasonable speed FFT implementation here: http://www.badlogicgames.com/wordpress/?p=449 FFT can also be used (actually, IS used) for detection of dualtone dialing (DTMF) - 2 frequencies at same time is much better than just using one (as the error rate drop significantly and you can go to shorter duration for the tone sending/detecting).

"Inaudible" won't be possible, as (a) the speaker can not produce such sounds (b) you are limited in sampling rate - so also limited in both producing and recording such high frequencies.

"couple of feet" will be naturally imposed (not very loud speaker, not very good microphone).

Oliver
  • 1,269
  • 13
  • 21
  • If working for Android 2.3, there seems to be FFT already in the system, check out http://stackoverflow.com/questions/4720512/android-2-3-visualizer-trouble-understanding-getfft – Oliver Jan 30 '11 at 13:33
  • guys thanks very much for yer responses. I now at least now that it can be done. Im still very confused in the order of operations. Might there be any chance if someone knows how its done they could write a couple of lines of psudocode showing the order of steps. Thanks for yer help – Keith Jan 30 '11 at 14:50
  • This won't be "a couple of lines pseudo code", sorry. What you want is quite a special thing (to be frank, a really complicated one) with special needs and so some "pseudo code" will be of no help to you. If you have problems ordering the "when to do what (ordering)", you eventually are not ready to write this kind of code yet. – Oliver Jan 30 '11 at 14:58
  • thanks oliver. All I really want is to know that a device is a couple feet away from another. Iv looked at using bluetooth rssi but that also didn't work out. Would there be any easier way you could suggest? – Keith Jan 30 '11 at 15:02
  • GPS? At least not the "tone method" you are describing, that actually won't work for what you want to do (the battery will be drained in less than 30 minutes, as the recording has to be running *always*). But also GPS takes quite some battery... Bluetooth can be a way to go. Accuracy eventually is not high enough for "a couple of feet" for both. – Oliver Jan 30 '11 at 15:22
  • For your problem, guess you have to wait for NFC implemented in every phone and also not in reveiver-only mode (2.3 not allows to send). Next year? ;) – Oliver Jan 30 '11 at 15:31
2

Have a look at this other question: "Android: Need to record mic input". I think you can modify that for your task, then with sound bytes you can have filtering or FFT.

Hope it helps

Community
  • 1
  • 1
Filippo Mazza
  • 4,339
  • 4
  • 22
  • 25