We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Determine a note in Processing
Page Index Toggle Pages: 1
Determine a note in Processing (Read 1079 times)
Determine a note in Processing
May 30th, 2007, 12:09am
 
Still a bit new to processing after a year, but I've been playing the trumpet for 14... so I am still a bit lost and in need of help.

If I want to determine a note from a sound through my speaker, how do I do this?

I'm sure this has been solved many times over, and so feel free to point me to the correct forum thread because I cannot find it.

I would like to share this with many others, I think it could be very important to getting musicians who use max msp into processing.

To these ends I will now pepper my thread with the things i searched for to help others find the answer (eh, I know how the search engines work :S )

note from processing
note from sound
note from frequency
note from microphone
note from talking
note from instrument
note from sonia
note from ess
note from mimim
processing determine note
processing formula note
processing determine note
processing formula note
max msp processing

can't processing return me the note in my microphone!?!?!

(ok that last one was less from my intrest of helping and more from frustration Smiley )

Thanks to all who help!

Re: Determine a note in Processing
Reply #1 - May 30th, 2007, 12:20am
 
Oh one more note. I'm a programmer, so lay it on... no really! Smiley
Re: Determine a note in Processing
Reply #2 - May 30th, 2007, 3:39am
 
In other words, you want to be able to detect the pitch of an audio signal? That's not as trivial as it sounds and Processing most certainly does not have the ability built in. And I don't believe any of the audio libraries for Processing can do it, either (I know mine can't, anyway). Well, that's only half true. What you could do is run the audio signal through an FFT and then try to find the frequency band that contains the fundamental (because there'll be harmonics and noise in there, too, especially if you use a crappy microphone, etc etc).

Here's a google search for the thing you are interested in:
http://www.google.com/search?q=pitch%20detection%20algorithm

Does max/msp have pitch detection built in?
Re: Determine a note in Processing
Reply #3 - May 31st, 2007, 12:43am
 
Yeah, Max has the fiddle~ object which detects pitch.  It 'works' well, however, there are difficulties associated with pitch detection outside the realm of software.  Its a complex problem, with lots of factors.

To continue what ddf said, Instruments with lots of high harmonics (like a trumpet) will make it harder to find the fundamental than say a flute would.  With some other instruments it doesn't work AT ALL, because there is no "fundamental".  Also, if there is any trace of another note or breath noise, etc it will disturb the pitch detection (try pitch following a guitar.. ha!). Then, you have frequency bins, and how the real world note maps into the FFT frequency bins.  The note might not fall into a bin nicely, and will "hide" the fundamental.  

That said, if you set the FFT to as many bins as possible, and sustain a very clean note, you should be able to get close results, finding the fundamental, then using this chart : http://www.phys.unsw.edu.au/jw/notes.html

For reliable live performance following, if you get a working system, please share it!!
Re: Determine a note in Processing
Reply #4 - May 31st, 2007, 6:21pm
 
You could maybe just look at the waveform data and try to find "nearby" zero-crossing with the "same" slope?  Again, harmonics will complicate matters, so you may want to lowpass filter it, but with a clean enough fundamental and the right slope measure, you might be able to find something that looks like a single cycle.
Re: Determine a note in Processing
Reply #5 - Jun 4th, 2007, 11:34pm
 
You certainly don't want to determine pitch from a single cycle.
You would have to bandpass filter the raw input signal very harshly to limit the frequencies to a narrow range, and then you'd still have a lot of variability from cycle to cycle, .. plus there are hundreds of cycles per second for mid-range tones.

If you are interested in notes in a specific limited range of the keyboard, ... a better strategy would be to measure the amplitude at 20 (or whatever) specific "notes" and declare the one with the largest amplitude to be the one the input actually contains.  You could also have a threshold to detect silence in between notes.

davbol wrote on May 31st, 2007, 6:21pm:
You could maybe just look at the waveform data and try to find "nearby" zero-crossing with the "same" slope  Again, harmonics will complicate matters, so you may want to lowpass filter it, but with a clean enough fundamental and the right slope measure, you might be able to find something that looks like a single cycle.

Page Index Toggle Pages: 1