Arduino Forum

Using Arduino => Audio => Topic started by: runningdude22 on Feb 08, 2013, 09:54 pm

Title: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: runningdude22 on Feb 08, 2013, 09:54 pm
I bought the sound sensor (YwRobot 537473). I've found many examples that detect volume using the sensor, but nothing that detects tone or pitch. For grins I'd like to see if I can make a simple guitar tuner. Is it possible with this device?
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: Grumpy_Mike on Feb 08, 2013, 10:03 pm
Well a link to the sensor would help google turns up nothing.

However if it is used to measure the volume of a sound then it is likely that it is a peak detector followed by a filter. In that case it will not let the full audio waveform into the arduino in order for you to make these measurements.
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: runningdude22 on Feb 09, 2013, 02:44 am
The sensor is like this:

http://www.electricheap.net/arduino-blocks/36-arduino-sound-sensor-module.html
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: Grumpy_Mike on Feb 09, 2013, 02:12 pm
Yes just like I said, you can't get sound signals from that board only envelope information.
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: runningdude22 on Feb 09, 2013, 07:27 pm
Do you have any suggestions (link) as to what I should get if I want to make a device that can determine the frequency of a sound?
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: Grumpy_Mike on Feb 09, 2013, 07:37 pm
There are lots of them but this would work:-
http://www.dfrobot.com/index.php?route=product/product&product_id=83#.URaXLejR34g (http://www.dfrobot.com/index.php?route=product/product&product_id=83#.URaXLejR34g)
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: runningdude22 on Feb 09, 2013, 11:10 pm
Thanks! I'm still confused as to what the difference is between that and what I got.    :smiley-eek:
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: Grumpy_Mike on Feb 10, 2013, 12:18 am

Thanks! I'm still confused as to what the difference is between that and what I got.    :smiley-eek:

Look at the schematics. That is a simple amplifier, what you have is an envelope detector which is an amplifier, diode, capacitor and discharge resistor. Like this:-
http://www.allaboutcircuits.com/vol_3/chpt_3/5.html (http://www.allaboutcircuits.com/vol_3/chpt_3/5.html)
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: runningdude22 on Feb 10, 2013, 12:24 am
Ah! Thank you!  :-)
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: rickso234 on Feb 10, 2013, 01:21 am
> However if it is used to measure the volume of a sound then it is likely that it is a peak detector followed by a filter.

Wouldn't that be a filter followed by a peak detector. I suppose that depends on your definition of a filter.
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: spatula on Feb 10, 2013, 09:04 am
I'm also perplexed (schematics notwithstanding) about the differences between the two products/links from electricheap and dfrobots, they look very similar to me. I think I found the link to the manufacturer, not very informative I'm afraid but with larger pictures.

http://item.taobao.com/item.htm?spm=a1z10.3.w7504506493.3.0QqHPb&id=13338760752 (http://item.taobao.com/item.htm?spm=a1z10.3.w7504506493.3.0QqHPb&id=13338760752)

A question: shouldn't pitch detection be performed in the ADC? Assuming that the output of the external device is just an amplified signal (unfiltered), roughly corresponding to the output of the mic, in order to get the pitch one needs to sample the signal.

Then, shame on me, I don't know how many samples would be necessary to detect, say, a 440Hz frequency with good approximation, it's a very simple calculation but I don't remember the parameters to be factored in. But if, let's say, we needed just 880 samples / second, it would probably be within the reach of a program running on an Arduino.
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: Grumpy_Mike on Feb 10, 2013, 09:43 am
To determin a frequency you need to sample at at least twice the rate of the frequency. Look up Shannon.
Yes all those circuits need feeding into an analogue input.

You determin the frequency by using an FFT. The arduino can just about do this.
Title: Re: Tone, pitch, etc with Arduino Sound Sensor (537473)
Post by: rickso234 on Feb 11, 2013, 05:55 am
Also look up "Goertzel algorithm and Arduino". The DFT Goertzel may be easier than an FFT but, since the DFT captures discrete frequencies, it can determine if you're on-frequency but not as easily if you're high or low. FFT may be better then. THere are many code examples for FFT and Arduino.