I suspect that the straight averaging thing is not what you want. I haven't looked at the mic data, but it's sampling an AC signal (sound wave pressure alternates between compression and rarefaction at the frequency you perceive) and is probably biased so a no-pressure signal is pretty much in the middle of the ADC range. Averaging that AC signal over a number of high-low pressure waves will just give you the middle again.
If that is the case, what you want to do is rectify the signal -- half-wave would just chop off the samples below the mid-value, full-wave would invert them around the mid-value -- before trying to average to get a "loudness". If you are trying to get the "Sound Pressure Level" -- how loud the sound is at any particular time -- it's called "Envelope Following" in the good old days of signal processing. If you know any electronics, what you want to build is a diode or diode bridge, to rectify the signal, and a capacitor to filter, or average, it to a slowly varying DC value. MS Akankshu Dhawan wrote: > Hi All > I am using two mechanisms for high sampling. > 1. Using MicStreamC and changing the prescalar value inside MicP to > ATM128_ADC_PRESCALE_32 and the gain value is set to 64. > I create a buffer of 1000 samples and every time the buffer gets full I > take the average and print it out. The problem is that the microphone > does not seem to be responding or is not showing me sufficiently precise > values. The average when I dont make a noise is around 500 ADC.. and > even if I am clapping shouting (for long durations) it still shows me > slightly */lower values /like 497 etc. So I am not sure why this is so ?* > > 2. When I created the low level interfaces on my own using the sample > SoundLocalizer example in Tinyos programming book, I am giving the > microphone ADC a free run at the same prescale setup (there is a > difference of some parameter being passed through getData as FALSE in > that example which is suppose to cater to LEFT_ADJUSTMENT ) but when I > compare the values that I am getting inside dataReady they respond well > to sounds. This would work for me but I am just curious why the > MicStream does not work. This way I would not have to recreate all the > buffer code. > > If anyone can please tell me what setting inside MicSetting or MicP have > I done wrong that it is not responding. > > Thanks a lot. > > SIncerely > Akankshu Dhawan > > -- > First they ignore you, then they laugh at you, then they fight you, then > you win. > - Mahatma Gandhi > > > ------------------------------------------------------------------------ > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
