Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Analyzing sound data  (Read 812 times)
0 Members and 1 Guest are viewing this topic.
Offline ~Spaceaholic

Senior Member


Medals: 2
Projects: 1



« Posted 2012-05-27 00:18:09 »

I am working on android devices, but I do not think this questions needs to be android specific so i am posting it here...
I would like to detect a user blowing into the microphone of my phone so I can create something similar to the candle apps that let you blow them out.
currently I have captured the audio and get the max amplitude for a given sample, if the amplitude is high enough I consider it a blow. but this works the same for any loud noise. how would I go about filtering out everything but a blowing noise on the mic? Thanks.
Offline aazimon

Senior Member


Medals: 5



« Reply #1 - Posted 2012-05-30 21:48:17 »

You may want to add a maximum amplitude, to cut out sounds that are too loud. Another thing would be to look at the sound's wave pattern. (You should be able to view that through any decent sound editor), and then try to match it with the sound coming in from the mic. You will need to have a variance, in which close enough is good enough.
This is just a theory. I hope it helps.  Smiley
Offline philfrei
« Reply #2 - Posted 2012-05-30 22:03:41 »

I think you are going to have to get into some fancy filtering algorithms. Most loud noises will have some strong pitches in them, or sharp amplitude peaks and valleys. The puff of air sound is more like white noise (and might not be distinguishable from someone speaking "shhh" or "ffff" or "sss").

Have you looked into the DFT (discrete fourier transform) or Fast Fourier algorithms? This is not a trivial problem, computationally.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline krasse
« Reply #3 - Posted 2012-05-30 22:14:25 »

My first approach would be to use a couple of bandpass filters that are reasonably spread out over the frequency.
If all of the filters get "sufficiently much" simultaneous signal energy out of them when you send in your data, you can assume that you have a wide energy spectrum (which is one of the characteristics of white noise).

If that wouldn't work, I would use a DFT like philfrei suggested. Note that you have to split up the data in smaller chunks where you smooth the edges. The bandpass filter approach is probably cheaper though but if you use many filters it may not.

You can probably use the filter part of a vocoder as well, if I am not mistaken Smiley

Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #4 - Posted 2012-05-31 10:24:27 »

As mentioned, blowing into the mic will look to an FFT like significant energy is produced at many different frequencies, varying rapidly. Note libgdx has code to do FFTs.

Offline nsigma
« Reply #5 - Posted 2012-05-31 10:30:38 »

My first approach would be to use a couple of bandpass filters that are reasonably spread out over the frequency.

If you're looking for bandpass filter code, you could try this class - http://code.google.com/p/praxis/source/browse/audio.ops.impl/src/org/jaudiolibs/audioops/impl/IIRFilterOp.java  It's ported from Gervill / OpenJDK to this interface in order to remove any other dependencies.  Type.BP12 is the bandpass.

Praxis LIVE - Open-source graphical environment for developing intermedia performance tools, projections and interactive spaces.
Praxis LIVE on Twitter
Offline ~Spaceaholic

Senior Member


Medals: 2
Projects: 1



« Reply #6 - Posted 2012-06-01 23:06:36 »

Thanks for all the responses
I would like to try and use the FFT which will require that I convert my audio file into a float[], any pointers as to how I should go about doing this?
Offline krasse
« Reply #7 - Posted 2012-06-01 23:47:34 »

http://www.jsresources.org/faq_audio.html#reconstruct_samples

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (130 views)
2013-05-17 21:29:12

alaslipknot (137 views)
2013-05-16 21:24:48

gouessej (168 views)
2013-05-16 00:53:38

gouessej (160 views)
2013-05-16 00:17:58

theagentd (172 views)
2013-05-15 15:01:13

theagentd (157 views)
2013-05-15 15:00:54

StreetDoggy (201 views)
2013-05-14 15:56:26

kutucuk (225 views)
2013-05-12 17:10:36

kutucuk (224 views)
2013-05-12 15:36:09

UnluckyDevil (228 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.095 seconds with 21 queries.