Help with piano notes finding circuit

Thread Starter

vicky.20390

Joined May 26, 2011
1
Hi, i am thinkin of building a circuit tat takes input as analog audio signal, which is actually piano notes, analyze and display the notes being played using LCD or LED matrix. :) Kind of like what the Software 'Synthesia' does. I am hitting dead ends if i work on finding the pitch frequency. Can anyone recommend me a strategy that makes it less complex? If possible with a little schematic as well?
 

kubeek

Joined Sep 20, 2005
5,794
Schematic is simple, you just feed your signal into a DSP and use some kind of display. The real problem is finding the frequency. You could do FFT transform and then find the frequency with highest level, but I have no idea how accurate will that be. You also need to say if your input is a sound of one keyboard, or a whole song from whitch you are trying to separate the notes - i.e. if youre talking about a guitar tuner or some complex note transcriber :)
 

retched

Joined Dec 5, 2009
5,207
I would look into piano (or even guitar) tuning circuits.

That is basicially what you want to build.

A micro controller with a lookup table with the values of the notes will make things much easier.
 

rogs

Joined Aug 28, 2009
279
The interval between the frequencies of adjacent semitones on a piano is always based on the 12 th root of 2, for an 'equal temperament' (normal) tuning. Don't know if that helps wih the 'look up' table requirements?

A bigger problem is likely to be designing the analogue or DSP input circuitry, that reliably detects the fundamental of a note, from it's attendant harmonics. Especially when the range of a piano will include 2nd, and even 3rd harmonics of the lower notes, within the upper range fundamentals. Kubeeks idea for DSP is likely to have the best chance of success.

It's all possible of course, but to get reliable results, it's not going to be a simple project.

Probably much easier to look at reading in 'MIDI' values from an electronic piano, directly to a computer, and do it all in software.
 

ErnieM

Joined Apr 24, 2011
8,377
The interval between the frequencies of adjacent semitones on a piano is always based on the 12 th root of 2, for an 'equal temperament' (normal) tuning.
And isn't middle A 440 Hz?

However, AFAIK a piano isn't tuned that way (equal ratio), some notes are spaced differently just because it "sounds better that way."


Wiki is your friend.
 
Last edited:

rogs

Joined Aug 28, 2009
279
And isn't middle A 440 Hz?

Yes and no! :)

The actual orchestral pitch of middle 'A' has varied over the years. See here:
http://en.wikipedia.org/wiki/Concert_pitch


Re: the tuning of pianos away from equal temperament: - yes, you're quite right.
A top class piano tuner will adapt the tuning for each instrument to suit it's environment -often 'stretching' the upper octaves, for example, to make the shorter strings sound 'brighter'. A very sophisticated skill.

Not really needed for the project here, so apologies for hijacking the thread a bit!!:)
 

THE_RB

Joined Feb 11, 2008
5,438
That's very interesting though. :)

Are you saying they tune the high freq strings to not be in tune compared to the lower strings, or that the whole piano is tuned a little higher to make it brighter?
 

rogs

Joined Aug 28, 2009
279
Normally, with 'equal tempered' tuning, the octaves are always in tune (i.e. double or half the frequency). It's all the other intervals that are slightly out. (all the fourths are slightly 'sharp' , all the fifths are slightly 'flat' - etc.. etc..)

With a good ( and I mean good) piano tuner, and a piano worth tuning well - like a concert grand- then even the octaves may be 'stretched' or shrunk very slightly to get the 'best' out of the instrument, in any given acoustic environment.
As I say, a very sophisticated skill.
Which is why some of the world's finest pianists will often insist on using their own tuners.
Otherwise, you could just do it electronically, and tune to 'correct' equal tempered tuning.

As I say, I think I'm hijacking the thread ---sorry......:)
 

THE_RB

Joined Feb 11, 2008
5,438
Thanks Rogs, I get it now. So there's a TINY mistune that is enough to affect the timbre of the sound but not enough to be "out of tune" so to speak. :)

And yes sorry to the OP for the thread getting off topic!
 

rogs

Joined Aug 28, 2009
279
Thanks to Sgt. Wookie, the thread is back on course! :)

I don't think an analogue spectrum analyser will be selective enough for the OP's requirements though.
Even the best commercial ones are usually only 1/3rd octave, and for this task we would need 1/12 octave! I think that's going to be into DSP territory.

Take a full range piano. 88 notes. That's 88 bandpass filters, with seriously 'steep' slopes to be able to reject adjacent semitones. Providing that could be achieved, it might be possible to not worry about harmonic rejection.
But it's going to have a fairly restrictive input dynamic range, or you'll get false triggering from harmonic content.
As I mentioned in my earlier post, not a simple project.

Interestingly challenge though....:)
 

SgtWookie

Joined Jul 17, 2007
22,230
Mik3's spectrum analyzer project certainly doesn't cover all of the notes; it was meant just as an example of what one might accomplish with a microcontroller, and some sample source code to examine. You'd probably need a lot more "horsepower" to decode all 88 notes.
 

magnet18

Joined Dec 22, 2010
1,227
If you don't care so much for building the circuit yourself or pinpoint accuracy, a quick and dirty solution might be to find a cheap tuner and do a little circuit bending or hacking and patch the desired signal to that. for example, a capacitor should be all you need to replace the microphone, if it has a line in all the better. If you really wanted to get fancy you could probably replace the display with an LED matrix.
 

THE_RB

Joined Feb 11, 2008
5,438
Tuners don't respond well to multiple notes due to the beat frequencies, additive and subtractive frequencies etc.

I don't know if we have lost the OP or not, but what he/she is asking looks easy when you see it on a computer screen (like some of the PC based spectrum analysers) but decoding music in real time is VERY hard if it is more complex than just a couple of plain notes played together. If you add drums and voice etc in the mix, then well... good luck with that.

Which makes it all the more impressive that a trained human can listen to music and hear what notes are being played, what chords, key, rythms etc. The human mind's ability to process complex patterns by "feel" is phenomenal. We're still smarter than the machines... ;)
 

rogs

Joined Aug 28, 2009
279
Some excellent comments there about inharmonicity, and why this problem is so difficult for computer technology to analyse easily. The OP was looking for a simple solution. I think we may have already lost him/her! :)
 

#12

Joined Nov 30, 2010
18,224
I lost one very similar only yesterday, in "chat". "Identifying frequency of a note in a music track" by Laz Baz. I did the 12th root of 2 and "The Well Tempered Clavier" explanation and Laz Baz never returned. Odd...two of the same question in 2 days by people that don't respond to the answers.
 

Laz Baz

Joined May 29, 2011
6
I lost one very similar only yesterday, in "chat". "Identifying frequency of a note in a music track" by Laz Baz. I did the 12th root of 2 and "The Well Tempered Clavier" explanation and Laz Baz never returned. Odd...two of the same question in 2 days by people that don't respond to the answers.
Hi, Especially to #12 (Senior Member) and all other helpful members.
I earnestly apologise to you all. I do not deliberately not respond
but it takes me a while to assimilate what advice is given. Most of the time it is well beyond me to act straight away.
From my posting in "Identifying frequency of a note in a music track", I was trying this morning to "loop" the note (THE RB Senior Member #5) by reducing the time but Audacity (Free version) says not enough data to analyse. So I will try to see how else I can get a satisfactory spectrum. I also have a free TrueRTA which does 1 octave RTA and other levels up to 1/24 octave, which I may purchase but at this point I do not know how to use it .....
I have more to say but I will post this now as a mark of respect to you all and to let you know, I am not finished yet. I will be back. if this message can be duplicated (by our Moderator) in "Identifying frequency of a note in a music track", I would be grateful.
 
Top