This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Game Development and the fly likes sound/notes recognition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "sound/notes recognition" Watch "sound/notes recognition" New topic
Author

sound/notes recognition

Martin Miljkovic
Greenhorn

Joined: May 04, 2011
Posts: 3
Hi, I would like to create a small program that can:

1. take the sound played (input from microphone)
2. analize the sound,
3. recognise which one is it (for example C)
4. write the name of that sound (C) in a text file.

Thank you in advance for your ideas and suggestions.
Luigi Plinge
Ranch Hand

Joined: Jan 06, 2011
Posts: 441

It doesn't sound like something you could do in a "small" program, because analysing a waveform is a complicated problem. However, I'm sure someone has tackled this problem before. Your best bet is to use Google to try to find a library that someone has already written.
Martin Miljkovic
Greenhorn

Joined: May 04, 2011
Posts: 3
well I've heard that there may be some public libraries but I am unable to find them. Also, should this toppic be on forums for input output? Looks like nobody can see it here ...
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Martin Miljkovic wrote:Looks like nobody can see it here ...


I could help with this from both the signal processing side and the Java side BUT BUT BUT from your original post I deduced that you had far too much to learn about signal processing and you need to spend some significant time studying the topic (in particular spectral estimation) before asking questions. Once you have done the research you will be in a position to ask specific questions rather than the broad brush questions such as your original post.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Martin Miljkovic
Greenhorn

Joined: May 04, 2011
Posts: 3
Hey tnx for explaining it so clearly, I thought it may be an easy task to do because so many things already exist. So, since it requires me to study for a month in order to create something that "simple" I may as well do something better with my time.

Topic closed, thank you all
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Do I detect a note of sarcasm? There may be existing Java software for detecting the dominant frequency of sound and using Google is the most likely way to find it. I have created something that could be adapted to this task but for you to modify it to your purpose would still require you to understand the theory. Don't you find leaning something new exhilarating ?

Luigi Plinge
Ranch Hand

Joined: Jan 06, 2011
Posts: 441

This might be what you're after (found in a few minutes of googling): http://sirk.sytes.net/software/libs/kjdss/index.htm
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
Steps involved:

1) you have to be able to load a sound into a file where the analysis can be performed

To do that, check out the Java Tutorials on Sound. Of particular importance will be Capturing Audio, but you will definitely want to look at some of the overview material on how sound is encoded.

2) You will need to convert the captured data to something that can be analysed. Most likely, I'm thinking something like normalized floats. The section on "Using Files and Format Converters" should be useful. There is a lot of good example code in this section, though nothing that in particular converts a (for example) 16-bit stereo little-endian 44100 fps byte array to a normalized float array. But maybe a crude pitch analysis could be done with an array of shorts (easiest to make from 16-bit encoding).

3) Once you have the float array, I assume it is a matter of iterating through it and looking for relative peaks in the data and counting the number of frames between the peaks, and multiplying that against the frame rate and converting to pitch.

Voila!

Most folks get discouraged at step 1. The Java Sound package is kind of complex as well as being very powerful. But there are many forums where people will help if you get hung up on one point or another.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Phil Freihofner wrote:Steps involved:

<snip/>

3) Once you have the float array, I assume it is a matter of iterating through it and looking for relative peaks in the data and counting the number of frames between the peaks, and multiplying that against the frame rate and converting to pitch.


I think this is a rather simplistic view of how the task might be tackled. If the OP spent even a short time researching the signal analysis aspects of the topic he would have come across terms such as 'Spectral Density Estimation' and 'Fast Fourier Transform (FFT)' which would have led him to a very practical solution.
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
Cool! I'm looking forward to learning more about this myself. I'm very happy if one can find "practical solutions". I know I do have an optimistic tendency to try and break things down into solveable steps that are sometimes more involved than expected.

I'm guessing most functions along these lines (frequency analysis) are kind of like audio filtering, where you submit an array range around the current frame for analysis. In which case, I'm hoping my steps 1 & 2 still prove helpful.

Signal Processing is a huge field, so pointing someone in that general direction is kind of like saying you have to go out into the Pacific to find Hawaii, yes?
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Phil Freihofner wrote:
Signal Processing is a huge field, so pointing someone in that general direction is kind of like saying you have to go out into the Pacific to find Hawaii, yes?


Yes, Signal Processing is a huge field but Fourier Methods for frequency analysis are 101 standard.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sound/notes recognition
 
Similar Threads
What American Accent Do You Have?
WA #1.....word association
Its a kind of misconduct
Head First JSF?
Sound in Servlet