DIGITAL GUITAR AUTO-TUNER PROJECT

G

Guillaume

Jan 1, 1970
0
Just so you know, using an FFT for this purpose is going to lead
to huge disappointment. It's not the way to go.

- The frequency resolution will be too poor, because obviously you
can only use a very limited number of points in this application.

- You will face having to decide what peak to choose when analysing
the resulting FFT. This is not so obvious as you will notice there
are nasty transients.
 
P

Precious Pup

Jan 1, 1970
0
AND HERE COMES "RICH THE NEWSGROUP WACKO" CALLING ME AN ASSHOLE AND
ASKING FOR MY PAYCHECK... TRY TO THINK ABOUT IT, YOU CALL A GUY AN
ASSHOLE AND THEN ASK FOR HIS PAYCHECK... WHO'S THE REAL ASSHOLE?...


Dumbass,

He's only an asshole in his own wet dreams. He isn't smart enough to be
a real asshole.

Ignore him. He's almost as stupid as Sloman.


Have a great day,
Pup
 
B

Bob Monsen

Jan 1, 1970
0
Walter said:
[...] im aiming for
about +/-2 hz accuracy. with the fastest possible response time...


Not adequate for musical purposes, I think. Basically what you're saying is
that the best you can do would result in a 2Hz beat between a tuned string
and the correct pitch; that's still annoyingly out of tune. Simply tuning
by ear you can get 3 to 4 times better than that (i.e., one beat every 2
seconds). It might be "close enough for bluegrass," and certainly still
quite an interesting electronics project, but it's not a very good tuner.

I am reading "Musical Acoustics" by Donald Hall, and he has a graph on
page 108 that charts Hz against "JND" (which stands for "Just Noticable
Difference".) Within the frequency range of open strings on a guitar, 1
Hz appears to be 'noticable' for between 60 and 90 dB. For quieter
sounds, it goes up to 3 or 4 Hz. This is for pure sine waves.

Thus, sadly, 2 Hz probably isn't going to be good enough. The maximum
error should probably be 1/2 Hz, as Walter says.
 
G

Glenn Gundlach

Jan 1, 1970
0
Pet subject of mine as I used to have a pipe organ I built. I could
tell when the tuning was not good but I was not good enough to tune it
by ear. 2 Hz would be horrible, 1/2 Hz poor. The target was to get to
..02 Hz and tune with a strobe display. An array of 16 LEDs is used from
a 16 bit latch which 'freezes' the phase of a clock running 512 times
the desired pitch. The '0' crossing is the clock pulse to the latch
driving the 4-16 decoder. When you're on pitch, the LED pattern doesn't
move, just like a turntable strobe. Generating the scale is tough since
the ratio note-note is 12th root of 2. In '94 I used a 16 bit counter
chain which is OK even when used in the range of 32000 to 64000 but
would likely be better with digital synthesis. The tuner was MIDI in
and out with its own keyboard so I could plug it between the console
and pipework. 'Playing' the tuner turned on the correct pipe to match
the note selection for the strobe. Worked pretty slick.
GG
 
D

dhaevhid

Jan 1, 1970
0
Here are some resources:
CircuitCellar... there is a guitar tuner article that uses a
microcontroller. The article describes the entire thing, and gives you a
schematic and a listing of the assembler code.

LCD, it's a snap, given the reams of free code available to drive those
little 16 character one line displays. HD44780 LCDs are cheap. You can
drive them with 11 datalines in 8 bit mode, and 7 in 4 bit mode, and 6
if you just hardwire the write pin high.

Here is a reference: http://ouwehand.net/~peter/lcd/lcd.shtml

They are kind of painful to program, so use a microcontroller with an
on-chip debugger.

I've had some trouble using that CircuitCellar design, however. He
assumes that the first couple of waves are the fundamental, but this
doesn't seem to be true, at least for my guitar. I think a DSP design,
using some simple digital filters, would make more sense. DSPs are
getting pretty cheap. You could tune all the strings simultaneously... ;)

this is the exact reason why im still "hunting" the elusive precise
algorithm on how to do this project the correct way. almost every
project done( atleast those i see on the web) do not consider the
harmonics that would surely cause trouble... i saw some samples though
that used an FFT, IIR and all those stuff but i am yet to learn how to
do all of those in assembly language. i did a project using those
functions in matlab but its an included function in the library. so
its quite a degree more difficult this time to do all the FFT, FIR,
and IIR "hand written" on assembly.

but then again i must check in advance if these functions can be
handled efficiently by the microcontroller in the first place...

anyway, thanks for all the suggestions, links, ideas and everything...
these are all big help....



-carlo david

PS. i had to change my account in google cause my hotmail account was
flooded...
 
M

Mark

Jan 1, 1970
0
Is this really true?

I know if you excite a string (or any mechanical resonance) to vibrate
on an overtone, that the overtone is not exactly a harmonic of the
fundamental mode, just like a quartz crystal.

But in this case the string is vibrating on the fundamental frequency
and I would think that nay harmonics generated harmonics would be
exact. If what you say is true, then you should be able to hear a beat
note with only ONE string. The beat note would be between the true
harmonics of the fundamental and the overtones. I don't think it works
that way. Anybody know for sure?

Mark
 
R

Ralph Barone

Jan 1, 1970
0
im finished with the signal conditioning part of the hardware. i used
an op amp to have a 2volts squarewave that will be the input signal of
the microcontroller. i will be using the eFH5830 mcu buy EMC.(elan
microelectronics) the mcu is 8-bit RISC type, 3.582Mhz. im aiming for
about +/-2 hz accuracy. with the fastest possible response time...

You do know that +2 Hz on the low E string (84'ish Hz) gets you halfway
to F.
 
W

Walter Harley

Jan 1, 1970
0
Mark said:
Is this really true?

I know if you excite a string (or any mechanical resonance) to vibrate
on an overtone, that the overtone is not exactly a harmonic of the
fundamental mode, just like a quartz crystal.

But in this case the string is vibrating on the fundamental frequency
and I would think that nay harmonics generated harmonics would be
exact. If what you say is true, then you should be able to hear a beat
note with only ONE string. The beat note would be between the true
harmonics of the fundamental and the overtones. I don't think it works
that way. Anybody know for sure?

Listen to a guitar string! Or better, a bass string, because they're
thicker. New strings aren't so bad, but as they get older they get worse;
that "out of tune with itself-ness" is one of the things that causes one to
need new strings. The grooves that frets chew into strings also make the
string sound out of tune with itself.

A guitar/bass string is not quite a perfect resonant system, because of its
finite thickness, particularly at the witness points. The "length" of the
string is effectively not the same at all frequencies.

I wouldn't swear I'm right about the underlying theory; but the end result
is that a string definitely does audibly beat against itself.

There are also other problems - e.g., plucking a string hard tends to pull
it sharp at first. The producer Jack Endino mentioned some of these issues
in an interesting article a couple years back (maybe in TapeOp?) about the
challenge of properly tuning a guitar; basically, his feeling is you have to
tune for a particular song and playing style.
 
D

dhaevhid

Jan 1, 1970
0
Mark said:
Is this really true?

I know if you excite a string (or any mechanical resonance) to vibrate
on an overtone, that the overtone is not exactly a harmonic of the
fundamental mode, just like a quartz crystal.

But in this case the string is vibrating on the fundamental frequency
and I would think that nay harmonics generated harmonics would be
exact. If what you say is true, then you should be able to hear a beat
note with only ONE string. The beat note would be between the true
harmonics of the fundamental and the overtones. I don't think it works
that way. Anybody know for sure?

Mark

well, from all of the documents ive read so far, the guitar string
vibrates at its fundamental frequency and also have harmonics that are
multiples of 1/12th root of 2 that's (2^(1/12))... this is the first
time that someone told me that the othet components of the guitar
signal signal is not actually harmonics...

hmmm... another idea to take note...

carlo david dizon
 
V

Ville Voipio

Jan 1, 1970
0
Pet subject of mine as I used to have a pipe organ I built. I could
...
the desired pitch. The '0' crossing is the clock pulse to the latch
driving the 4-16 decoder. When you're on pitch, the LED pattern doesn't
move,

Yup. But pipe organ is easy (depending on the pipe type), as its
output is quite close to sine wave. Reed pipes are more difficult,
but probably not as bad as the sound from string instruments.
just like a turntable strobe. Generating the scale is tough since
the ratio note-note is 12th root of 2.

Nononononnononoooooo! If you tune it to the "even-tempered" scale,
the result is very bad-tempered. All the fifths are bad, all the
thirds are bad.

And here we come to the point where a custom-made tuning tool would
be useful. It is quite easy to go and buy a simple one which just
shows the pitch on a scale. However, I'd like to have one which
can be taught different temperaments.

There are some such instruments available, but they tend to be
rather bulky, eat up a lot of batteries, and cost a lot. On the
other hand, it should not be difficult to use different tempera-
ments once a reliable frequency meter has been made.

---

There are a few challenges which have to be addressed. Here is my
list:

- accuracy down to 1 cent (1/100 of a half note, around 0.6 permille
of the frequency, i.e. 0.24 Hz @ 415 Hz)

- fast response (preferably in the 100s of milliseconds), because
slow response makes it difficult to tune plucked instruments
(rapidly changing pitch)

- freely adjustable a', at least from 390 Hz to 465 Hz

- custom temperations

- good response over four octaves (lowest string of a violone is
at around 35 Hz, the highest string of a violin at 625 Hz)

I know this is not a trivial problem. Using FFT might be a solution.
On the other hand, a sliding sampling window or some other trickery
should be used, and there might be some better algorithms. In
any case the first problem is to have a coarse idea of the basic
tone and get rid of the harmonics. After that some time-domain
algorithms might be good enough.

The good thing is that the relative accuracy requirement (1 cent)
can be relaxed a lot in the low frequencies.

If someone comes up with a robust, fast, and relatively simple
algorithm, that would be nice. Even nicer if the algorithm is
simple enough to be realized with a few hundred kIPS, but OTOH
MIPS are not so expensive after all.

- Ville (viola da gamba player)
 
J

John Woodgate

Jan 1, 1970
0
I read in sci.electronics.design that dhaevhid
well, from all of the documents ive read so far, the guitar string
vibrates at its fundamental frequency and also have harmonics that are
multiples of 1/12th root of 2 that's (2^(1/12))...

Thos are the frequencies of the well-tempered scale, not harmonics.
Harmonics are 2 times frequency, 3 times, 4 times etc.
this is the first time that someone told me that the othet components
of the guitar signal signal is not actually harmonics...

I think this is a subject that you don't need to go into very much. It
seems to me that a wholly digital tuner is rather difficult, and I would
look at a hybrid design - using digital to get a series of stable
frequencies (as in 'top octave generator' for organs), and then analogue
methods for comparing the string frequency with the reference. A
Lissajou display is a very good way of adjusting one frequency to be
very near indeed to another.
 
R

Ronald H. Nicholson Jr.

Jan 1, 1970
0
Just so you know, using an FFT for this purpose is going to lead
to huge disappointment. It's not the way to go.

Only if you use an FFT naively.
- The frequency resolution will be too poor, because obviously you
can only use a very limited number of points in this application.

Incorrect. For single pitch detection, one can use as many points as
the signal-to-noise ratio will allow.

Given a sufficient signal-to-noise ratio, one can always interpolate more
points between FFT frequency bins (using a windowed-Sync, not a linear
interpolation of course), and/or zero-pad the samples for a longer
FFT with as many points as you want. There are also other methods,
depending on the amount of memory and CPU cycles available.
- You will face having to decide what peak to choose when analysing
the resulting FFT.

One does have to determine which local maxima are nearest (or near
multiples of) the pitch of interest, but there are several methods to
help with this (autocorrelation, cepstral, template pattern matching or
even back-propogation neural net techniques).
This is not so obvious as you will notice there
are nasty transients.

Not sure what you mean here. You do need to make sure your FFT output
looks like it might represent a musical note of interest, and not just
background noise between notes.


IMHO. YMMV.
 
D

Daniel Haude

Jan 1, 1970
0
["Followup-To:" header set to sci.electronics.design.]
On Mon, 25 Apr 2005 07:42:38 +0100,
in Msg. said:
I think this is a subject that you don't need to go into very much. It
seems to me that a wholly digital tuner is rather difficult, and I would
look at a hybrid design - using digital to get a series of stable
frequencies (as in 'top octave generator' for organs), and then analogue
methods for comparing the string frequency with the reference. A
Lissajou display is a very good way of adjusting one frequency to be
very near indeed to another.

Many years ago the magazine "Elektor" featured a very simple and clever
design: An oscillator/counter (probably a 4017) stepped through a row of
LEDs, but a LED would only turn on when the input signal had a zero
crossing at the same time. Given an appropriate oscillator frequency, the
right tuning of the string would be indicated by a standing light, whereas
a deviation in frequency would cause the light to "wander" to one side or
another.

Cheap, simple, and stage-proof. When I read the article I regretted that
my hearing was perfect.

--Daniel
 
D

dhaevhid

Jan 1, 1970
0
Ralph Barone said:
You do know that +2 Hz on the low E string (84'ish Hz) gets you halfway
to F.



i guess i have to correct myself for few mistakes;

1. for the accuracy, that will be +/-2cents maximum. +/-1cent
must be nice.. not +/-2hz.
2. for the harmonics, im wrong about the 12th root of two, that
is the even tempered scale. the other components found in the guitar
signal are supposed to be the harmonics factor of 2, 4, 6, 8 belongs
to the higher octaves.

here comes another newbie question:

does anyone have an exact idea how to safely "count" the
fundamental freq with all of these harmonics on the considerations?
 
A

Aleksandar Kovacevic

Jan 1, 1970
0
does anyone have an exact idea how to safely "count" the
fundamental freq with all of these harmonics on the considerations?

High order lowpass?
 
H

Hans-Bernhard Broeker

Jan 1, 1970
0
In comp.arch.embedded Guillaume said:
Just so you know, using an FFT for this purpose is going to lead
to huge disappointment. It's not the way to go.
- The frequency resolution will be too poor, because obviously you
can only use a very limited number of points in this application.

If indeed the FFT's resolution is poor, that can have two reasons:

1) the FFT was done badly, or on insufficient input

2) the uncertainty principle on waves applies

If a correctly done FT fails to deliver the necessary frequency
resolution on the given data, then no other technique is going to
work. The fundamental problem is not the FT, it's the data: the
frequencies found in a given data sample are *undefined* beyond a
certain accuracy.
 
R

Robert Scott

Jan 1, 1970
0
Is this really true?

I know if you excite a string (or any mechanical resonance) to vibrate
on an overtone, that the overtone is not exactly a harmonic of the
fundamental mode, just like a quartz crystal.

But in this case the string is vibrating on the fundamental frequency
and I would think that nay harmonics generated harmonics would be
exact. If what you say is true, then you should be able to hear a beat
note with only ONE string. The beat note would be between the true
harmonics of the fundamental and the overtones. I don't think it works
that way. Anybody know for sure?

This phenomenon has been well-studied for pianos where precise tuning
is much more important. It is called "inharmonicity", and it is due
to the stiffness of the strings. The overtones are theoretically pure
harmonics only for an infinitely thin string with zero stiffness,
where the restoring force is totally due to the tension in the string.
When part of the restoring is force is due to stiffness in addition to
tension, then higher overtones will be higher in pitch than pure
multiples because higher overtones involve more bending than lower
overtones. A typical overtone series might be:

1.000 (fundamental)
2.003 (second partial)
3.008 (third partial)
4.015 (fourth partial)
5.024 (fifth partial)
6.035 (sixth partial)
...etc.

The effect may be less on guitars than on pianos because the length to
thickness ratio is not as bad on a guitar. But it is still enough of
an effect to be considered in the design of a tuner.


-Robert Scott
Ypsilanti, Michigan
 
J

John Woodgate

Jan 1, 1970
0
I read in sci.electronics.design that dhaevhid
i guess i have to correct myself for few mistakes;

1. for the accuracy, that will be +/-2cents maximum. +/-1cent must
be nice.. not +/-2hz.
2. for the harmonics, im wrong about the 12th root of two, that is
the even tempered scale. the other components found in the guitar
signal are supposed to be the harmonics factor of 2, 4, 6, 8 belongs to
the higher octaves.

2,3,4,5,6,7... Not only even-order.
here comes another newbie question:

does anyone have an exact idea how to safely "count" the
fundamental freq with all of these harmonics on the considerations?

If your input signals do not cover as much as an octave, you band-pass
filter them before you FFT them. That gets rid of the harmonics.
 
K

Keith Williams

Jan 1, 1970
0
hi! im a total newbie on the field of assembly programming and the
microcontrollers stuff and im trying to build a digital guitar tuner
more like the ones which automatically detects the string being tuned
and has an LCD "analog needle-display"... any kind of help would be
greatly appreciated.. sample codes, ideas, references, anything would
be great..

I've read (most of) the answers here and they've gone for the first
things I'd try, so it's out-of-the-box time [*]. What about an optical
interrupter (or reflection) at the center (maxima) of the string
feeding a microcontroller's timer?


[*] ...or was that off-the wall time ;-)
 
C

Charles Krug

Jan 1, 1970
0
dhaevhid said:
[...] im aiming for
about +/-2 hz accuracy. with the fastest possible response time...

Not adequate for musical purposes, I think. Basically what you're saying is
that the best you can do would result in a 2Hz beat between a tuned string
and the correct pitch; that's still annoyingly out of tune. Simply tuning
by ear you can get 3 to 4 times better than that (i.e., one beat every 2
seconds). It might be "close enough for bluegrass," and certainly still
quite an interesting electronics project, but it's not a very good tuner.

Keep in mind that many guitar players tune their open strings to the
harmonics rather than to the frets.

This doubles (or quadruples, in the case of the B-string) the apparant
beat frequency.
 
Top