#137261 - MChiz - Thu Aug 09, 2007 5:42 pm
Hi all!!
I'm doing some tests on my DS and I'm dealing with trying to detect if anyone is blowing on the mic. I have achieved it by detecting how many times the wave clips on the lower limit and higher limit, but it not works as I'd like. If I hit the mic it does the tests and gives me as if I'm blowing. I checked the minigame from New Super Mario Bros ( the one where Yoshi must arrive at the top of the level with blows ) and the game doesn't accepts anything but blowing on the mic.
I have searched on the web and it seems like Fast Fourier Transform is the solution. Apply it to the wave and see if there are signal on lows, mids and highs, but I don't know how to compute it and I suspect it would be too much expensive for the DS.
If anyone could help me I'd be very grateful.
Thanks a lot
EDIT: Sorry for my poor english =/
< MChiz >
#137263 - jetboy - Thu Aug 09, 2007 5:56 pm
Usualy just adding input from the mic over fixed amount of time and checking if it gives you high enough value should be enough.
_________________
Colors! gallery -> http://colors.collectingsmiles.com
Any questions? Try http://colors.collectingsmiles.com/faq.php first, or official forums http://forum.brombra.net
#137265 - MChiz - Thu Aug 09, 2007 6:03 pm
Thanks for your fast answer, jetboy =)
I did it as you said, checking the upper and lower limits and it works, but hitting the mic, screaming, or things like that are detected as if I'm blowing, and in New Super Mario Bros it doesn't happen ( at the Yoshi's minigame ).
Also I'd like to read the intensity of the blow ( soft or strong blow ), as an analogous value, not binary. With a soft blow the wave doesn't arrives too high ( in volume terms ).
Thanks for helping!!
< MChiz >
#137266 - jerbob92 - Thu Aug 09, 2007 6:22 pm
why not take some sound samples if somebody is blowing hard or soft or middle and compare it to the input from the mic, is this possible?
#137268 - Ant6n - Thu Aug 09, 2007 6:55 pm
if there is a certain frequency associated with 'blowing', then you could try a fourier transform. Try recording a couple of 'blow's with the computer and analyze the frequency spectrum, maybe there's a pattern?
#137326 - MChiz - Fri Aug 10, 2007 8:18 am
I don't know if recording three kinds of blows will do the job, I think not because it would be difficult that two waves are equals ( aprox ). If you have an idea of how achieve it I would be very grateful that you post it here!! =)
About Ant6n's solution, yes, there is a pattern. A blow has in the three bands ( low, mids and highs ) the same ( aprox. ) volume, so I think it would be nice to implement this one, but I don't know how to do a fast fourier transform and I have my doubts if it is ok for a DS ( maybe too expensive? ). Even I would know how to implement FFT, I'm not sure about how to apply a FFT to a wave and get the spectrum of it. Have you implemented this on DS?
Thanks to all for helping me!!
< MChiz >
#137366 - tepples - Fri Aug 10, 2007 10:16 pm
MChiz wrote: |
About Ant6n's solution, yes, there is a pattern. A blow has in the three bands ( low, mids and highs ) the same ( aprox. ) volume, so I think it would be nice to implement this one, but I don't know how to do a fast fourier transform and I have my doubts if it is ok for a DS ( maybe too expensive? ). |
If you want to analyze the distribution of lows, mediums, and highs, then perhaps an autoregressive model like that used in linear predictive coding (use Google or Wikipedia if you're not familiar) is best.
Linguists call blowing a voiceless bilabial fricative. Like other voiceless sounds, blowing lacks pitch.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#137445 - Sweater Fish Deluxe - Sat Aug 11, 2007 9:40 pm
I was looking into something similar a few months ago and made a post about it here as well and got pretty much the same answers, which seemed hopelessly vague to my weak mind.
I'd never heard of FFTs before, so I looked into them and found a program on The Code Project that used them for displaying a spectrograph. Taking a look at that source code, I thought the actual FFT math should be quite within reason on a DS (there's lots of division, but as the author of the original program suggested, bitwise shifting could optimize it a lot if needed). I never actually got as far as testing it out on the hardware, but since it's all math, it shouldn't be hard to drop that sample code into a test program and see what kind of processor time it eats.
What had me stalled was what to do next. Assuming you could get the FFT done in real time in your game, how exactly would you compare the two datasets to see if they match? Especially since they almost certainly wouldn't match perfectly. Anything I can think of seems incredibly complicated--much more so than the FFT itself. Lots of averaging and branching logic would have to involved, I think.
I'm a very very amateur programmer, though, so maybe there's a simple solution to this that I don't know about, though.
By the way, when establishing the base pattern to compare against, I would recommend recording them on the DS mic itself since it has very different properties and capabilities than whatever mic you have on your PC.
...word is bondage...
#137448 - tepples - Sat Aug 11, 2007 9:50 pm
What you are doing is digital signal processing. Have you read through Bores Introduction to DSP?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#137472 - Dood77 - Sun Aug 12, 2007 5:26 am
But, the sound you hear when someone is blowing is much different then the waveforms generated when someone blows on a microphone. I have no technological knowledge about microphones, but I assume they work similar to an ear drum; by capturing the fine vibrations of sound and transforming them into electric signals. When you blow on the mic, you're causing it to vibrate, not from sound, but from gas molecules pushing against the 'drum' as the spring of the drum resists the force of the blowing and causes it to vibrate.
...am I right about how all this works? :-/
_________________
If I use a term wrong or something then feel free to correct, I?m not much of a programmer.
Original DS Phat obtained on day of release + flashme v7
Supercard: miniSD, Kingston 1GB, Kingston 2GB
Ralink chipset PCI NIC
#137509 - Sweater Fish Deluxe - Sun Aug 12, 2007 9:06 pm
Something like that, I guess. However, in the case of blowing on a mic--or at least a cheap mic like the one in the DS--what you actually get is a lot of clipped waveforms that don't look at all like the proper waveforms of a blowing noise (such as you could obtain using a very high quality mic).
...word is bondage...
#137533 - Ant6n - Mon Aug 13, 2007 1:43 am
well, the whole fft thing sounds awfully complicated. why not just do a fourier transform on a couple of frequencies (like 10) and check whether they are the same or something like that.
#137538 - tepples - Mon Aug 13, 2007 3:10 am
Sweater Fish Deluxe wrote: |
in the case of blowing on a mic--or at least a cheap mic like the one in the DS--what you actually get is a lot of clipped waveforms that don't look at all like the proper waveforms of a blowing noise (such as you could obtain using a very high quality mic). |
So if blowing in the DS microphone does cause a near rail-to-rail signal, then just look for an energy level (sum of squares of sample values over a given time period) over a threshold.
Ant6n: Yes, there is something like a Fourier transform on a small set of frequencies. It's called the Goertzel algorithm, based on a set of narrow band-pass filters, and it's often used to detect DTMF (Touch-Tone) presses. But I don't see how Goertzel could be applied to detect blowing.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#137548 - MChiz - Mon Aug 13, 2007 9:41 am
Sweater Fish Deluxe:
Which datasets would you want to compare? My idea with FFT was to check if the wave has no pitch ( it is easy to say, of course... ). Anyway, how did you detect the blowing? Did you find a solution?
tepples:
wow, you know a lot of interesting things. I'd like to know how would you detect a blow =)
I think I will use the 'clipping method'. I doesn't give bad results at all on the DS if you turn on the mic gain amp.
Really, thanks to all for your help =)
< MChiz >
#137586 - Sweater Fish Deluxe - Mon Aug 13, 2007 7:18 pm
tepples wrote: |
Sweater Fish Deluxe wrote: | in the case of blowing on a mic--or at least a cheap mic like the one in the DS--what you actually get is a lot of clipped waveforms that don't look at all like the proper waveforms of a blowing noise (such as you could obtain using a very high quality mic). |
So if blowing in the DS microphone does cause a near rail-to-rail signal, then just look for an energy level (sum of squares of sample values over a given time period) over a threshold. |
Yeah, I think that would work. Specifically the "over a given time period" part. I think that's all MChiz needs to add to his detection routine to get it to distinguish between blowing on the mic and tapping on it.
I didn't want to suggest that, though, because I hoped someone (else) would put in the work to get some actual detection routines that could distinguish between a number of basic sounds the player might make.
If all you're interested in is blowing/not blowing, I think looking for data over a certain threshold for a prolonged period would work. (The signal may drop below that threshold briefly, of course, but not for longer than say 10 vblanks?) If the player was screaming into the mic, that might cause a misdetection, of course. But I say if the player can keep screaming for long enough to accomplish the task in the game, just give it to 'em.
And no, MChiz, I never came up with a solution. I wanted to be able to detect not just blowing, but also humming, whistling, yelping, etc. I just decided that this stuff seemed too complicated to waste my time on since it was just a little idea I had for a game that I may or may not even ever finish up.
I do still think it would be really cool if someone who already has the idea of how DSP works could release sample code or even a lib or some functions for PAlib, because the mic is an important part of the DS and it would be nice if homebrewers could get more use out of it.
...word is bondage...