DSPRelated.com
Forums

Electronic Guitar Tuners

Started by rickman August 13, 2012
tiistai, 14. elokuuta 2012 1.52.30 UTC+3 rickman kirjoitti:
> I am being asked to design a gadget that has some special features, but > > also includes a guitar tuner. I have looked at the web a bit, but not > > found any good references that show exactly how a tuner works. One > > paper I found talked about a rather complex "constant Q transform". I > > just don't think the $10 tuner I have uses anything that complex. I'm > > thinking they are doing a PLL sync to the input or something more like > > that. > > > > One reference I found talks about using a peak detect to measure period > > rather than frequency like an FFT. I would think the FFT has too little > > resolution unless it is very long. > > > > Anyone know how the commercial low end gadgets really work? Maybe I'll > > take mine apart, but my bet is they are using chip on board with the die > > under a dab of black goo. > > > > Rick
Some sort of bandpass filtering for each string's center frequency might also turn out to be useful. - Calvin
On 8/20/2012 7:20 AM, kalvin.news@gmail.com wrote:
> tiistai, 14. elokuuta 2012 1.52.30 UTC+3 rickman kirjoitti: >> I am being asked to design a gadget that has some special features, but >> >> also includes a guitar tuner. I have looked at the web a bit, but not >> >> found any good references that show exactly how a tuner works. One >> >> paper I found talked about a rather complex "constant Q transform". I >> >> just don't think the $10 tuner I have uses anything that complex. I'm >> >> thinking they are doing a PLL sync to the input or something more like >> >> that. >> >> >> >> One reference I found talks about using a peak detect to measure period >> >> rather than frequency like an FFT. I would think the FFT has too little >> >> resolution unless it is very long. >> >> >> >> Anyone know how the commercial low end gadgets really work? Maybe I'll >> >> take mine apart, but my bet is they are using chip on board with the die >> >> under a dab of black goo. >> >> >> >> Rick > > Some sort of bandpass filtering for each string's center frequency might also turn out to be useful. > > - Calvin
Thanks Calvin, Yes, I thought of that, but to make it as general as possible it would need to accommodate alternate tunings. I would like to make this a chromatic tuner capable of tuning to any note on the scale. Rick
On 8/18/2012 11:40 PM, robert bristow-johnson wrote:
> On 8/18/12 10:50 PM, rickman wrote: >> No, I think that has comparable computation to a DFT and the >> advantage of the DFT is that it can be done over a subset of the full >> frequency range rather than always having to calculate the full range >> like an FFT. > > you can compute the autocorrelation with a subset of lags. you don't > need to do it for every possible integer lag, but only the lags of > interest.
Yes, that is what I meant, the auto-corr and the DFT are the same in that regard, but the FFT - not so much.
>> I'm also intrigued by some of the "stroboscopic" methods, but I haven't >> looked at how to implement them yet. >> >> My current thinking is that no matter what method I go with, it needs to >> be very high "performance", meaning highly accurate and reasonably fast. >> I believe the market is not large for this particular device. So better >> to go Cadillac and charge a price premium than to try to find a spot in >> a crowded, high volume market. > > then i'm pretty sure that autocorrelation or AMDF or ASDF is what you'll > want to do.
I'll have to lookup the AMDF and ASDF.
>> So that means, will an auto-corr approach do a good job of resolving a >> fraction of a cent for a tuner in less than say the two or three seconds >> a note will sustain? I would have to consider just how accurate the >> auto-corr might be. > > pretty accurate, but *any* pitch detector *can* possibly have octave > errors (it's what can happen if you have inaudible sub-harmonics). then > you need to program the thing to have a little bit of common sense to > avoid some of the dumber octave errors. i think that looking for energy > at the frequency of the fundamental is a dumb octave error because there > could be more energy at the 2nd harmonic or the 3rd harmonic and your > alg might think that either of those is the fundamental frequency.
Yes, but the harmonics will fall at certain ratios which won't match if you pick a harmonic in place of the fundamental. Also, won't the energy of the harmonics add into the lag for the fundamental?
> does your DSP or whatever processor have conditional branch > instructions? you don't need to compute the whole autocorrelation (all > of the lags) for each and every sample. in fact, you might just compute > *one* lag per sample and have a couple of special states where you set > up the autocorrelation and where you process or scan the results of the > autocorrelation to come up with a period length. and you can do some > interpolation-like stuff to get the period to a precision of a fraction > of a sample period. i.e. look for the peak where it falls between two > integer lags. it's not hard.
I get the interpolation thing, that's fairly obvious, but I don't understand the comment about the one lag per sample and special states. The problem with interpolation is that it can only interpolate to some extent. Essentially this is a method of measuring the period of signals. The sample rate has to be fast enough to provide a decent resolution. There are also the same issues found in the FFT of energy splattering across bins. I suppose a window function can help with that.
> that's all you get for free.
Thanks, Rick
On 8/20/2012 4:08 AM, sigmonde wrote:
>> I am being asked to design a gadget that has some special features, but >> also includes a guitar tuner. I have looked at the web a bit, but not >> found any good references that show exactly how a tuner works. One >> paper I found talked about a rather complex "constant Q transform". I >> just don't think the $10 tuner I have uses anything that complex. I'm >> thinking they are doing a PLL sync to the input or something more like >> that. >> >> One reference I found talks about using a peak detect to measure period >> rather than frequency like an FFT. I would think the FFT has too little >> resolution unless it is very long. >> >> Anyone know how the commercial low end gadgets really work? Maybe I'll >> take mine apart, but my bet is they are using chip on board with the die >> under a dab of black goo. >> >> Rick > Hi Rick - although not a conventional technique you could use a short fft > and then apply an interferometric measurement to improve the resolution , > this is a technique which is used a lot in somar and rader with phased > arrays. With phase arrays special,frequencies relate to beam direction. So > to keep,the arrays short engineers useinterferometric techniques. I > simulated a guitar tuner using this technique a while back and it showed > promise. > Colin
I'm not sure I understand what is implied by "interferometric techniques". I know what interferometry is, but how would I use that to determine pitch of an instrument? Are you suggesting that an array of mics be used with the instrument at a known relative location and the opposite of direction finding or beam forming be used? This app does not use a mic, it plugs into an electric guitar, so I think interferometry is out. Rick
tiistai, 21. elokuuta 2012 16.27.20 UTC+3 rickman kirjoitti:
> On 8/20/2012 7:20 AM, kalvin.news@gmail.com wrote: >=20 > > tiistai, 14. elokuuta 2012 1.52.30 UTC+3 rickman kirjoitti: >=20 > >> I am being asked to design a gadget that has some special features, bu=
t
>=20 > >> >=20 > >> also includes a guitar tuner. I have looked at the web a bit, but not >=20 > >> >=20 > >> found any good references that show exactly how a tuner works. One >=20 > >> >=20 > >> paper I found talked about a rather complex "constant Q transform". I >=20 > >> >=20 > >> just don't think the $10 tuner I have uses anything that complex. I'm >=20 > >> >=20 > >> thinking they are doing a PLL sync to the input or something more like >=20 > >> >=20 > >> that. >=20 > >> >=20 > >> >=20 > >> >=20 > >> One reference I found talks about using a peak detect to measure perio=
d
>=20 > >> >=20 > >> rather than frequency like an FFT. I would think the FFT has too litt=
le
>=20 > >> >=20 > >> resolution unless it is very long. >=20 > >> >=20 > >> >=20 > >> >=20 > >> Anyone know how the commercial low end gadgets really work? Maybe I'l=
l
>=20 > >> >=20 > >> take mine apart, but my bet is they are using chip on board with the d=
ie
>=20 > >> >=20 > >> under a dab of black goo. >=20 > >> >=20 > >> >=20 > >> >=20 > >> Rick >=20 > > >=20 > > Some sort of bandpass filtering for each string's center frequency migh=
t also turn out to be useful.
>=20 > > >=20 > > - Calvin >=20 >=20 >=20 > Thanks Calvin, >=20 >=20 >=20 > Yes, I thought of that, but to make it as general as possible it would=20 > need to accommodate alternate tunings. I would like to make this a=20 > chromatic tuner capable of tuning to any note on the scale. >=20 >=20 >=20 > Rick
The notes are at discrete frequencies anyway, so getting a coarse frequency= from the highest FFT peak and then setting an appropriate (pre-computed, l= ookup-table) band-pass filter coeffs to the specific note. You would be abl= e to attenuate noise and harmonics, and get a more sine-like signal which m= ay be easier to analyse. Just an idea. - Calvin
On 8/21/12 9:31 AM, rickman wrote:
> On 8/18/2012 11:40 PM, robert bristow-johnson wrote: >> On 8/18/12 10:50 PM, rickman wrote: >>> >>> My current thinking is that no matter what method I go with, it needs to >>> be very high "performance", meaning highly accurate and reasonably fast. >>> I believe the market is not large for this particular device. So better >>> to go Cadillac and charge a price premium than to try to find a spot in >>> a crowded, high volume market. >> >> then i'm pretty sure that autocorrelation or AMDF or ASDF is what you'll >> want to do. > > I'll have to lookup the AMDF and ASDF. >
Average Magnitude/Squared Difference Function
> >>> So that means, will an auto-corr approach do a good job of resolving a >>> fraction of a cent for a tuner in less than say the two or three seconds >>> a note will sustain? I would have to consider just how accurate the >>> auto-corr might be. >> >> pretty accurate, but *any* pitch detector *can* possibly have octave >> errors (it's what can happen if you have inaudible sub-harmonics). then >> you need to program the thing to have a little bit of common sense to >> avoid some of the dumber octave errors. i think that looking for energy >> at the frequency of the fundamental is a dumb octave error because there >> could be more energy at the 2nd harmonic or the 3rd harmonic and your >> alg might think that either of those is the fundamental frequency. > > Yes, but the harmonics will fall at certain ratios which won't match if > you pick a harmonic in place of the fundamental. Also, won't the energy > of the harmonics add into the lag for the fundamental?
then you'll be sweeping some kinda comb on the data.
>> does your DSP or whatever processor have conditional branch >> instructions? you don't need to compute the whole autocorrelation (all >> of the lags) for each and every sample. in fact, you might just compute >> *one* lag per sample and have a couple of special states where you set >> up the autocorrelation and where you process or scan the results of the >> autocorrelation to come up with a period length. and you can do some >> interpolation-like stuff to get the period to a precision of a fraction >> of a sample period. i.e. look for the peak where it falls between two >> integer lags. it's not hard. > > I get the interpolation thing, that's fairly obvious, but I don't > understand the comment about the one lag per sample and special states.
it's a programming issue. some samples you will compute *one* point of the autocorrelation. and when you have filled up the table, you need to examine what you computed, that is a special mode of your program and you won't have time to compute a new point of autocorrelation and you won't need to. it's a manner to distribute the work over many different sampling periods to reduce the worst-case timing cost.
> The problem with interpolation is that it can only interpolate to some > extent. Essentially this is a method of measuring the period of signals.
yup and that period may very well not be an integer number of samples.
> The sample rate has to be fast enough to provide a decent resolution. > There are also the same issues found in the FFT of energy splattering > across bins. I suppose a window function can help with that. >
-- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
rickman <gnuarm@gmail.com> wrote:

(snip, someone wrote)k
>> Hi Rick - although not a conventional technique you could use a short fft >> and then apply an interferometric measurement to improve the resolution , >> this is a technique which is used a lot in somar and rader with phased >> arrays. With phase arrays special,frequencies relate to beam direction. >> So to keep,the arrays short engineers useinterferometric techniques. I >> simulated a guitar tuner using this technique a while back and it showed >> promise.
> I'm not sure I understand what is implied by "interferometric > techniques".
Good question. It first reminded me of the suggestion of using an LED flashing at a desired frequency, then I read the description. The general idea of interferometry is to add a delayed copy of a signal, then look for a maxima or minima. Sometimes varying the delay until the appropriate extrema is found.
> I know what interferometry is, but how would I use that to > determine pitch of an instrument? Are you suggesting that an array of > mics be used with the instrument at a known relative location and the > opposite of direction finding or beam forming be used?
I am not so sure. Maybe subtract (or add) an appropriately shifted value, then see what it looks like? -- glen
On 8/21/2012 5:11 PM, glen herrmannsfeldt wrote:
> rickman<gnuarm@gmail.com> wrote: > > (snip, someone wrote)k >>> Hi Rick - although not a conventional technique you could use a short fft >>> and then apply an interferometric measurement to improve the resolution , >>> this is a technique which is used a lot in somar and rader with phased >>> arrays. With phase arrays special,frequencies relate to beam direction. >>> So to keep,the arrays short engineers useinterferometric techniques. I >>> simulated a guitar tuner using this technique a while back and it showed >>> promise. > >> I'm not sure I understand what is implied by "interferometric >> techniques". > > Good question. It first reminded me of the suggestion of using an LED > flashing at a desired frequency, then I read the description. > > The general idea of interferometry is to add a delayed > copy of a signal, then look for a maxima or minima. > Sometimes varying the delay until the appropriate extrema is found. > >> I know what interferometry is, but how would I use that to >> determine pitch of an instrument? Are you suggesting that an array of >> mics be used with the instrument at a known relative location and the >> opposite of direction finding or beam forming be used? > > I am not so sure. Maybe subtract (or add) an appropriately > shifted value, then see what it looks like? > > -- glen
Sure, that is what others mean by the auto-correlation. Rick
On 8/21/2012 10:41 AM, kalvin.news@gmail.com wrote:
> tiistai, 21. elokuuta 2012 16.27.20 UTC+3 rickman kirjoitti: >> >> Yes, I thought of that, but to make it as general as possible it would >> need to accommodate alternate tunings. I would like to make this a >> chromatic tuner capable of tuning to any note on the scale. >> >> >> >> Rick > > The notes are at discrete frequencies anyway, so getting a coarse frequency from the highest FFT peak and then setting an appropriate (pre-computed, lookup-table) band-pass filter coeffs to the specific note. You would be able to attenuate noise and harmonics, and get a more sine-like signal which may be easier to analyse. Just an idea. > > - Calvin
Yes, but knowing which of the peaks is the fundamental is not so easy. The fundamental is not always the highest. It would be better to find multiple peaks and find the common divisor. Rick
On 8/21/2012 1:41 PM, robert bristow-johnson wrote:
> On 8/21/12 9:31 AM, rickman wrote: >> On 8/18/2012 11:40 PM, robert bristow-johnson wrote: >>> >>> then i'm pretty sure that autocorrelation or AMDF or ASDF is what you'll >>> want to do. >> >> I'll have to lookup the AMDF and ASDF. >> > > Average Magnitude/Squared Difference Function
Yes, I found the name easily enough. I need to read up on how to calculate it and why it is different from the auto-corr.
>>> pretty accurate, but *any* pitch detector *can* possibly have octave >>> errors (it's what can happen if you have inaudible sub-harmonics). then >>> you need to program the thing to have a little bit of common sense to >>> avoid some of the dumber octave errors. i think that looking for energy >>> at the frequency of the fundamental is a dumb octave error because there >>> could be more energy at the 2nd harmonic or the 3rd harmonic and your >>> alg might think that either of those is the fundamental frequency. >> >> Yes, but the harmonics will fall at certain ratios which won't match if >> you pick a harmonic in place of the fundamental. Also, won't the energy >> of the harmonics add into the lag for the fundamental? > > then you'll be sweeping some kinda comb on the data.
Not sure what you mean by this. I am suggesting that with an auto-correllation the harmonics of the frequency that corresponds to the lag will also be added into the sum. Any frequency with an integer multiple of its period being approximately equal to the lag should accumulate. So when the lag is tuned to the fundamental of a note, all harmonics should add into the result giving this the largest peak, no?
>>> does your DSP or whatever processor have conditional branch >>> instructions? you don't need to compute the whole autocorrelation (all >>> of the lags) for each and every sample. in fact, you might just compute >>> *one* lag per sample and have a couple of special states where you set >>> up the autocorrelation and where you process or scan the results of the >>> autocorrelation to come up with a period length. and you can do some >>> interpolation-like stuff to get the period to a precision of a fraction >>> of a sample period. i.e. look for the peak where it falls between two >>> integer lags. it's not hard. >> >> I get the interpolation thing, that's fairly obvious, but I don't >> understand the comment about the one lag per sample and special states. > > it's a programming issue. some samples you will compute *one* point of > the autocorrelation. and when you have filled up the table, you need to > examine what you computed, that is a special mode of your program and > you won't have time to compute a new point of autocorrelation and you > won't need to. it's a manner to distribute the work over many different > sampling periods to reduce the worst-case timing cost.
Sorry, I'm not following this. For each input sample, I need to accumulate a product for each of the lags being computed. I don't think I will have a timing issue, if by timing you mean enough processor speed. The device I am considering has 144 CPUs with >200 MIPS each.
>> The problem with interpolation is that it can only interpolate to some >> extent. Essentially this is a method of measuring the period of signals. > > yup and that period may very well not be an integer number of samples.
Yes, but interpolation can only improve the resolution by some factor, what, 5x? 10x? Noise and processing resolution will limit this at some point. It seems the frequency resolution of the human ear is not as good as I thought. One source says it is 1 Hz below 500 Hz and about 0.6% above 1000 Hz. They don't mention the range 500 to 1000 Hz, but I assume it is within this range. That should be entirely workable without interpolation if the sample rate is high enough and I am pretty sure I can do that. Rick