2

I'm doing an app where I want to detect sound frequency. How to detect frequency for particular sound like dog sound? Does anybody have tutorial or some sample codes?

Paul R
  • 208,748
  • 37
  • 389
  • 560
Deepak
  • 1,278
  • 3
  • 15
  • 23
  • 3
    A dog barking doesn't have a particular *frequency* - it has a complex time-varying *spectrum*. – Paul R Dec 19 '12 at 10:36
  • your right but how to compare two sound are same – Deepak Dec 19 '12 at 10:39
  • It's a very complex subject - you typically convert the sound to the frequency domain and then perform feature extraction so that you can compare features of an incoming sound with a database of reference features. – Paul R Dec 19 '12 at 11:07
  • @Bing Consider marking as answer if your question is answered. – Bijoy Thangaraj Dec 19 '12 at 11:36

2 Answers2

2

Detecting a single frequency, or even computing a single FFT, is not a reliable method for differentiating a dog bark from other common sounds of around the same volume.

What might work is sound fingerprint analysis using MFCC's, followed by statistical pattern matching against a large enough "dog" sound database. Some pointers to the type of signal processing required might be answered here: Music Recognition and Signal Processing

This is non-trivial stuff more suited for multiple college textbook chapters than any short tutorial.

Community
  • 1
  • 1
hotpaw2
  • 70,107
  • 14
  • 90
  • 153
0

To detect the frequency, you can use a pitch detection algorithm like FFT.

Learn more here: http://en.wikipedia.org/wiki/Pitch_detection_algorithm

You can look at this project for working source code for iOS that uses FFT algorithm to detect frequencies: https://github.com/hollance/SimonSings

Bijoy Thangaraj
  • 5,434
  • 4
  • 43
  • 70
  • Here is a more stripped down example of FFT pitch tracking, with a tutorial explanation: http://blog.bjornroche.com/2012/07/frequency-detection-using-fft-aka-pitch.html – Bjorn Roche Dec 19 '12 at 14:48
  • FFT is a naive way to detect pitch: even if you find the global maximum in the frequency domain, that could still be an harmonic. – Rad'Val Dec 19 '12 at 17:42
  • @ValentinRadu You are right. FFT is just one of the ways, and not be the best. – Bijoy Thangaraj Dec 20 '12 at 04:32
  • There are ways to deal with avoiding harmonics, one of which is to use a filter (which is what I do in my tutorial). Comparing FFT and time-domain methods and simply saying one is "best" depends on many factors. – Bjorn Roche Dec 20 '12 at 16:32