Technical discussions related to Audio Signal Processing (digital effects, acoustics, noise reduction, musical signal processing, etc).
Hi everybody I am using a dspic to detect the fundamental frequency of a music signal. I= just want to know if it is easy to have a resolution less than +-0.5 Hz. Thank you. markanos =20 =20
>Hi everybody I am using a dspic to detect the fundamental frequency of a music signal. >I= just want to know if it is easy to have a resolution less than +-0.5 Hz. > >Thank you. > >markanos Hi, It depends on the signal. A common method is to use autocorrelation. The autocorrelation can be computed with different "lag" time. In other words by looking at a shorter or longer piece of your signal. Looking at a larger extend in time leads to higher frequency resolution. But if there are variations in the observed part of the signal, your result might be useless. So if you have a stable periodic signal (musical ?) you can get more accurate than +-0.5Hz. If you have quasiperiodic signals and maybe vibrato or pitch jitter, naturally it is more problematic. gr. Anton
Hi Anton, I want the detection to be in real time. I am afraid that autocorrelation method needs a lot of samples and a lot of computation time. No?
>Hi Anton, > >I want the detection to be in real time. I am afraid that autocorrelation = method needs a lot of samples and a lot of computation time. No? Hi, It is absolutely possible in realtime, even on an older computer. I never implemented one myself. But supercollider has an autocorrelation b= ased pitch detector, which works quite well, and since it is opensource you can look at the implementation. Another tip is to look at the fiddle~ object by miller puckette. I think he also wrote a paper about the impleme= ntation. This is not a simple autocorrelation based detector AFAIK, and it also work= s in realtime.=20 A very simplistic approach is to build a detector based on zero crossings,= =20 but that works only in a very limited amount of special cases. So the ques= tion is: For what do you intend to use it? gr.=20 Anton =20 =20
I am using the Microchip DSP (dspic) to make an automatic piano tuner. So the signal comes from a piano string. For the zero crossing method, i thought about it. It demands filtering the signal to eleminate harmonics and to avoid intermediate zero crossings. May be, one can electronically do filtering, than generate a square wave using comparator. The microprocessor will have only to detect the period of the square. (using capture module for example). What do you say? > >> Hi Anton, >> >> I want the detection to be in real time. I am afraid that autocorrelation = >method needs a lot of samples and a lot of computation time. No? > >Hi, > >It is absolutely possible in realtime, even on an older computer. >I never implemented one myself. But supercollider has an autocorrelation b= >ased >pitch detector, which works quite well, and since it is opensource you can >look at the implementation. Another tip is to look at the fiddle~ >object by miller puckette. I think he also wrote a paper about the impleme= >ntation. >This is not a simple autocorrelation based detector AFAIK, and it also work= >s >in realtime.=20 >A very simplistic approach is to build a detector based on zero crossings,= >=20 >but that works only in a very limited amount of special cases. So the ques= >tion >is: For what do you intend to use it? > >gr.=20 >Anton > >=20 > >=20
>I am using the Microchip DSP (dspic) to make an automatic piano tuner. So = the signal comes from a piano string.=20 I really have no clue about how to build an automatic piano tuner. Does that mean that you have a quite good approximation which frequency you have to expect (because you know which string you are tuning)? If so, it should be an advantage. > >For the zero crossing method, i thought about it. It demands filtering >the signal to eleminate harmonics and to avoid intermediate zero >crossings. May be, one can electronically do filtering, than generate >a square wave using comparator. The microprocessor will have only to >detect the period of the square. (using capture module for example). > >What do you say? Your idea sounds sane to me (maybe that doesnt mean much ;). But I have never met any really working acurate zero crossing based pitch detector. I guess that the biggest problem with piano strings is that you can have beatings and multiple nearby frequencies in one tone. The harmonics of a piano are also a bit off. They are not exact multiples. So filtering all harmonics away with a steep filter just a bit over the expected frequency, might be a good idea. Before you implement anything for the dspic, I guess that you try stuff with matlab/octave or with testprograms in c. Try some different methods and find out. (I am interested to hear how it goes) Also you might be interested in some papers (I think you can find them with google. I don't know any urls) stefan uppgard - Implementation and analysis of pitch tracking algorithms david gerhard - Pitch Extraction and Fundamental Frequency: History and Cur= rent Techniques P J Kootsookos - A review of frequency estimation and tracking problems gr. Anton =20 =20
--- In a...@yahoogroups.com, ibrahim_marc@... wrote: > > I am using the Microchip DSP (dspic) to make an automatic piano tuner. So the signal comes from a piano string. > > For the zero crossing method, i thought about it. It demands filtering the signal to eleminate harmonics and to avoid intermediate zero crossings. May be, one can electronically do filtering, than generate a square wave using comparator. The microprocessor will have only to detect the period of the square. (using capture module for example). > > What do you say? > If you look at the frequency spectrum of the string's signal, you'll find not only harmonics. Especially in the beginning, there are transient components of several frequencies, which are fading away over time. They are responsible for the special "piano sound". They will disturbe zero crossing analysis. You'll have to wait until the signal has settled to the almost harmonic mixture. Even then, you'll have some distortions (spurious non-harmonic zero crossings). You might want to remove these "wrong" zero crossings by some statistical or probabilistic means. If you try to improve your detection step by step, you'll probably find yourself quite near the autocorrelation method, which is a mathematical approach of what comes out of using the "fitting" zeros and throwing away the "non-fitting". So I guess that auto-correlation will help you to find a superior solution to the zero-crossing detection. Take these issues into account: 1) (Especially older) pianos are usually tuned below the normal 440Hz-a, to avoid the risk of a frame crash. (Or even for sake of a better sound). So you cannot rely on pre-known frequencies. 2) A skilled piano tuner will end up with a brilliant piano sound, but a frequency meter will show certain "mis-tuned" strings. Ears are not hearing the same way as a frequency meter. 3) If you want to detect a tone of known frequency, you might use a mixture of auto-correlation and cross-correlation between the measured tone and a generated/calculated reference tone. 4) Generating square-waves before comparison might help to remove most distortions. If you meditate this a while, you'll find out that this will result in a sort of PLL. Just my 2cts... Bernhard
On Wednesday 31 May 2006 17:44, Jaime Andres Aranguren Cardona wrote: > Hi, > > Maybe this simple mwethod helps: take the FFT of the > input signal, then find the bin with the maximium > value, which will correspond to the frequency of the > measured signal. Of course, with this method, the > accuracy depends completely on the length of the FFT. > > Bernhard, what do you say? > > JaaC Hi JaaC, that's the academic solution, which might or might not work here. I'm not so familiar with the acoustic situation of a piano. I could imagine, especially at the lower tones, that the overtones could have more engery than the fundamental. This would disturbe the analysis. Then there are the resonances of the case (wood and steel), which will make things even worse. Then, as you indicated, it depends on the required resolution, if it can be practically exploited. If I have no guess, which frequency out of an allowed range (for a piano tuner 20Hz...10000Hz should suffice) is correct, the width of the bins must either be so narrow that the tones can be distinguished. Let's say 1Hz. Then you need at least 24kS/s to achieve the high end of the band. Which results in 12000Hz/1Hz = 12000 bins. This is very long FFT. Then the samples require a duration of a couple of seconds for a valuable result. Even then, this result would be splendid for a high frequency tone. It would not suffice for a very precise tuning. An approach might combine a raw FFT to find a first guess for the tone. This might work with less bins, and with a smaller duration (0.1sec?) Then, you could take the result (find the bin with highest energy). Use this result either to do another FFT with adapted resolution/sample rate, or apply any other means (Goertzel?) to go on with. Again, since it's the physical limitations, which we suffer from, it will be the same as making a PLL lock on an unknown signal: you need a broad capture region, and a very narrow lock region. And you have to take care of everything between...which is always the difficult part. Might be worth to reflect the chance of having some preknowledge: selecting the desired tone/frequency might make things easier. And maybe even more comfortable for the user. I used to work with a guitar tuner, which had three selectable modes: - auto tuning - preset tuning - off I started to use it in auto tuning mode. Which means, that it tries to find out the tone which is played, and with two LEDs it signalled below/above. Since the guitar has only 6 (or 4,10,12,...) strings, and because it was annoying to watch the LCD display because it would switch the tone and it happened, that I tuned to a wrong one, I dropped this method. Then I started to use the preset tuning: I had to enter the tone manually, let's say E. Then it would stay on this note, and I could evaluate only the LEDs. Which worked quite well for me. However, after some while, I dropped this method, too. Since then, I mostly use the third mode (off). It's quicker, more precise and works even with empty batteries. If you play an instrument in combination with others (orchestra or band), it doesn't help to know the exact frequency of a tone. It's more important that it's the right tone with respect to the other tones and/or instruments. A tuning fork (or the telephone's dial tone) with a 440Hz reference should suffice - but that's philosophic polemy and doesn't help implementation. Bernhard
Hi, Maybe this simple mwethod helps: take the FFT of the input signal, then find the bin with the maximium value, which will correspond to the frequency of the measured signal. Of course, with this method, the accuracy depends completely on the length of the FFT. Bernhard, what do you say? JaaC --- bholzmayer <H...@Foerstergroup.de> wrote: > --- In a...@yahoogroups.com, ibrahim_marc@... > wrote: > > > > I am using the Microchip DSP (dspic) to make an > automatic piano > tuner. So the signal comes from a piano string. > > > > For the zero crossing method, i thought about it. > It demands > filtering the signal to eleminate harmonics and to > avoid > intermediate zero crossings. May be, one can > electronically do > filtering, than generate a square wave using > comparator. The > microprocessor will have only to detect the period > of the square. > (using capture module for example). > > > > What do you say? > > > > If you look at the frequency spectrum of the > string's signal, you'll > find not only harmonics. Especially in the > beginning, there are > transient components of several frequencies, which > are fading away > over time. They are responsible for the special > "piano sound". > They will disturbe zero crossing analysis. > You'll have to wait until the signal has settled to > the almost > harmonic mixture. Even then, you'll have some > distortions (spurious > non-harmonic zero crossings). > You might want to remove these "wrong" zero > crossings by some > statistical or probabilistic means. > > If you try to improve your detection step by step, > you'll probably > find yourself quite near the autocorrelation method, > which is a > mathematical approach of what comes out of using the > "fitting" zeros > and throwing away the "non-fitting". > So I guess that auto-correlation will help you to > find a superior > solution to the zero-crossing detection. > > Take these issues into account: > 1) (Especially older) pianos are usually tuned below > the normal > 440Hz-a, to avoid the risk of a frame crash. (Or > even for sake of a > better sound). So you cannot rely on pre-known > frequencies. > 2) A skilled piano tuner will end up with a > brilliant piano sound, > but a frequency meter will show certain "mis-tuned" > strings. > Ears are not hearing the same way as a frequency > meter. > 3) If you want to detect a tone of known frequency, > you might use a > mixture of auto-correlation and cross-correlation > between the > measured tone and a generated/calculated reference > tone. > 4) Generating square-waves before comparison might > help to remove > most distortions. If you meditate this a while, > you'll find out that > this will result in a sort of PLL. > > Just my 2cts... > Bernhard > Jaime Andrés Aranguren Cardona j...@ieee.org j...@computer.org __________________________________________________
Hi, What you said Bernhard is in fact exact, concerning the fft and the low fre= quencies. The human tuners do not in general tune the low pitches individua= lly. They tune them according the the higer octave etc... For my automatic tuner i am working on, the spped is important. The user mu= st hit the note once, and the tuner must do its job. So, the pitch detectio= n must be accurately finished in 3 or 4 seconds. After investigating piano signals on matlab, i think that correlation metho= ds will be the most suitable. May be a small fft will be useful for detect= ing approximately the frequency at the begining.=20 I have done some experiences concerning fft. I had the following ideas conn= clusions. 1- Zero padding : ----------------- Since we want to detect the fundumental frequency, we do not need to have g= reat resolution(in term of seperating two different frequencies). All we ne= ed is a high precision for the value of the fundamental frequency. Here, i = remarked that zero padding is of great interest. In fact, with only 32 samp= les, or even 16, then zero padding till having Fs/N =3D precision wanted, w= e can measure the frequency. I know that, the fft calculation time will the= same since real samples are replaced with zero, but may it will be useful = for decreazing the sampling duration 2- fft variant=20 ----------------- I will explain my idea with an example. We take 16 samples of the signal, w= e make the fft X(k). let k0 be the greater frequency (X(k0) is a maximum). = We know at this level that the fundamental frequency is within k0-1 and k0+= 1. What i noticed is that we can directly refine this interval: in fact, if= X(k0+1) > X(k0-1), then fundamental frequency will be between k0 and the k= 0+1, if not, it is in [k0-1, k]. We will call the bound k1 (k1=3Dk0+ or k0-= 1). Now, we compute the DFT coefficient for only the intermediate frequency k2= =3D(k0+k1)/2 (that means as DFT of 32 points, where the last 16 samples are= zeros). we obtain a value X(k2)> X(k1). (this is due to the fact that ther= s is no other frequencies in this range). now the frequency is in [k0, k2]= . we can reiterate this procedure n times until the wanted precision. The result is the same as if we calculated the fft of 16*2^n points. The on= ly difference is that we calculate only the just neede coefficients. May be= this is Goertzel idea? Is it quicker than doing the correspondent fft? What do you think about it? I noticed that experimentally. I have no proofs= . Thank you for all your ideas. m. =20 =20
For whatever it's worth, I can add a note to this thread. Some years ago I had a piano to sell. The buyer came with an instrument he'd designed that measured what he called "the stretch" of a piano's inherent design. For reasons I didn't fully follow (has to do with the way the string is terminated at the end where it us cantilevered a sharp angle), the upper harmonics do not stay as precise multiples of the fundamental. Rather, they walk out of tune as their order increases. I don't know whether they always go flat or sharp or even if all the strings walk one way, the other way, or both. Anyway, he said that the degree of stretch has a lot to do with how a piano sounds. And his device permitted him to measure the stretch as an aid to piano selection. This was all done in about 1975, obviously without DSP chips. I doubt that this will have much to do with your tuning detector, but I find it an interesting understanding of piano subtleties. Chris Moore i...@hotmail.com wrote: > Hi, > > What you said Bernhard is in fact exact, concerning the fft and the > low frequencies. The human tuners do not in general tune the low > pitches individually. They tune them according the the higer octave etc... > > For my automatic tuner i am working on, the spped is important. The > user must hit the note once, and the tuner must do its job. So, the > pitch detection must be accurately finished in 3 or 4 seconds. > > After investigating piano signals on matlab, i think that correlation > methods will be the most suitable. May be a small fft will be useful > for detecting approximately the frequency at the begining. > > I have done some experiences concerning fft. I had the following ideas > connclusions. > > 1- Zero padding : > ----------------- > Since we want to detect the fundumental frequency, we do not need to > have great resolution(in term of seperating two different > frequencies). All we need is a high precision for the value of the > fundamental frequency. Here, i remarked that zero padding is of great > interest. In fact, with only 32 samples, or even 16, then zero padding > till having Fs/N = precision wanted, we can measure the frequency. I > know that, the fft calculation time will the same since real samples > are replaced with zero, but may it will be useful for decreazing the > sampling duration > > 2- fft variant > ----------------- > I will explain my idea with an example. We take 16 samples of the > signal, we make the fft X(k). let k0 be the greater frequency (X(k0) > is a maximum). We know at this level that the fundamental frequency is > within k0-1 and k0+1. What i noticed is that we can directly refine > this interval: in fact, if X(k0+1) > X(k0-1), then fundamental > frequency will be between k0 and the k0+1, if not, it is in [k0-1, k]. > We will call the bound k1 (k1=k0+ or k0-1). > Now, we compute the DFT coefficient for only the intermediate > frequency k2=(k0+k1)/2 (that means as DFT of 32 points, where the > last 16 samples are zeros). we obtain a value X(k2)> X(k1). (this is > due to the fact that thers is no other frequencies in this range). > now the frequency is in [k0, k2]. we can reiterate this procedure n > times until the wanted precision. > > The result is the same as if we calculated the fft of 16*2^n points. > The only difference is that we calculate only the just neede > coefficients. May be this is Goertzel idea? Is it quicker than doing > the correspondent fft? > > What do you think about it? I noticed that experimentally. I have no > proofs. > > Thank you for all your ideas. > > m. ----------------------------------------------------------------------- Seven Woods Audio, Inc. Christopher Moore Concepts, Products, Circuits for Audio Analog/Digital m...@SevenWoodsAudio.com http://www.SevenWoodsAudio.com
On Friday 02 June 2006 08:35, i...@hotmail.com wrote: > The human tuners do not in general tune the low pitches individually. The= y > tune them according the the higer octave etc... If you manually tune a piano, you always consider the "overall sound".=20 I mean, that the whole piano is a sort of complex resonator. When a string is excited, a concert of different tones can be heard. Especially in the beginning, it's a mixture of tones which are not easily=20 separated and discriminated. I guess it has to do with length changes due to the excitation (at first),= =20 then because of the weight of the accelerated string. Therefore you will not find an exact frequency as a fundamental. That's what a good human tuner hears and (s)he "feels" when it's perfect. > > For my automatic tuner i am working on, the spped is important. The user > must hit the note once, and the tuner must do its job. So, the pitch > detection must be accurately finished in 3 or 4 seconds. See above. Because of the initial effects, it will last a while until the t= one=20 has settled. I would expect that a measured fundamental frequency would=20 change over time (probably starting too high, then dropping too low, then=20 exponentially creeping to the final value) I'm not even sure if there is one single final value, it might be more of a= =20 vibrato, if a very fast meter would detect it fast enough. I'm not too familiar with piano (indeed, I manually tuned one once). My favorite instrument is the guitar. And just out of my feeling, I would=20 guess that it lasts around 2 seconds, until the E string has settled after = it=20 has been excited. If I take into account that the lowest piano tones are much lower,=20 I'd propose that your electronic tuner should not rely on the frequency whi= ch=20 has been measured in the first one or two seconds! Maybe it would be an interesting approach to calculate the fundamental=20 frequency as fast as possible, store this value, recalculate, store the new= =20 result again, find a trend curve (probably an exponential curve) and guess= =20 the final result.=20 That final result might be the targeted frequency.=20 =20 > > After investigating piano signals on matlab, i think that correlation > methods will be the most suitable. =C2 May be a small fft will be useful = for > detecting approximately the frequency at the begining. I guess that this is an adequate approach. Bernhard =20 =20
On Friday 02 June 2006 08:35, i...@hotmail.com wrote: > 2- fft variant > ----------------- > I will explain my idea with an example. We take 16 samples of the signal, > we make the fft X(k). let k0 be the greater frequency (X(k0) is a maximum= ). > We know at this level that the fundamental frequency is within k0-1 and > k0+1. What i noticed is that we can directly refine this interval: in fac= t, > if X(k0+1) > X(k0-1), then fundamental frequency will be between k0 and t= he > k0+1, if not, it is in [k0-1, k]. We will call the bound k1 (k1=3Dk0+ or > k0-1). Now, we compute the DFT coefficient for only the intermediate > frequency =C2 k2=3D(k0+k1)/2 (that means as DFT of 32 points, where the l= ast 16 > samples are zeros). we obtain a value X(k2)> X(k1).=20 > (this is due to the fact that thers is no other frequencies in this range= ). =C2=20 What, if other frequencies were present (maybe at lower levels) ? Are you sure that this assumption does hold in practise? > now the frequency is in [k0, k2]. we can reiterate this procedure n times > until the wanted precision.=20 > > The result is the same as if we calculated the fft of 16*2^n points. The > only difference is that we calculate only the just neede coefficients. Ma= y > be this is Goertzel idea?=20 Yes, you can look at the Goertzel algorithm as a "one-bin-FFT". Or, regard it as a filter with a resonant element (feedforward path). It requires a pre-known value for the resonant frequency. For a thorough description of Goertzel's and other algorithms, see chapter 13.17 "Single tone detection" in Rick Lyons book: "Understanding digital signal processing" ISBN 0-13-108989-7 > Is it quicker than doing the correspondent fft?=20 Depends, if it provides the result which you need.=20 I guess that your approach would be quicker if parts are omitted. And I'm s= ure=20 that you can omit parts of the calculation (though I didn't validate the=20 correctness of your thoughts). Zero padding works so nicely, because inserting zeros avoids lots of=20 calculation. If you can benefit of additional algorithmic optimization, depends mainly o= n=20 the algorithm and on the processor it is processed on. Some processors detect zeros and can avoid addition/multiplication. So it=20 depends, if a generic algorithm or the manual optimization is preferable. I'd start with the generic, and try optimization only if everything else wo= rks=20 and only the timeframe is missed. Optimizing in the beginning usually indicates a bad concept. Bernhard =20 =20
howdy, I've been dreaming of a PIC based device of my own that would require frequecy detection. The method that seems the most plausible to me is (as someone mentioned earlier), converting the signal to a square wave and then timing the duration of one period. With an 8 Mhz clock, this could be very accurate. My device would be measuring notes on a guitar, and i don't think the harmoics there will cause spurious zero crossings (atleast i dont see it as a problem on the oscilloscope). I was wondering, have you been finding false zero crossings in your analysis of piano wave forms? It seems a filter could fix that for large chucks of the piano at a time (because you just want to stop probably the 2nd harmoic from causing zero crossings, its ok if it still shows up in the signal), maybe even several octaves could be set up with one filter. especially if you used a simple comparator circuit that ignored hysterisis, so only the significant zero crossings of the fundemental were really measured. though, it seems you've considered this option and are opting for a FFT method. I think for my project this is much to computationally expensive, but I'd be interested to know why the FFT method wins out for you. --thanks bob
On Friday 02 June 2006 21:10, Christopher Moore wrote: > For whatever it's worth, I can add a note to this thread. > > Some years ago I had a piano to sell. The buyer came with an instrument > he'd designed that measured what he called "the stretch" of a piano's > inherent design. For reasons I didn't fully follow (has to do with the > way the string is terminated at the end where it us cantilevered a sharp > angle), the upper harmonics do not stay as precise multiples of the > fundamental.=20 Yep. > Rather, they walk out of tune as their order increases.=20 That's correct. You can observe this if you have a badly crafted guitar. If you play an accord, then shift your left hand right to play the same=20 accord, but at a higher note, you'll notice deviations which may hurt your= =20 ear - or at least make you feel awkward if you're not a musician. A well-crafted guitar however, will behave differently. No matter where the accord is played, it will always sound perfect. Although you won't see the difference or would be able to measure it=20 mechanically, you can easily hear it. Now give me such a bad guitar: with an electronical tuner, I can tune it perfectly, but we'll end up with = a=20 guitar with a very bad sound. manually tuned, I can "trim" it a little to sound better (though I cannot=20 remove the bad design!).=20=20 > I don't know whether they always go flat or sharp or even if all the > strings walk one way, the other way, or both. Anyway, he said that the > degree of stretch has a lot to do with how a piano sounds.=20 I agree.=20 > And his device permitted him to measure the stretch as an aid to piano > selection. This was all done in about 1975, obviously without DSP chips. As a student, once I worked in a piano house (we had to carry the sold pian= os=20 to those people who bought them - I wonder if most piano players live=20 upstairs). I played on a lot of different pianos standing side by side. I could have told you blindly the price region of every piano! And this could be achieved without any instrument at all, just by experienc= e. > > I doubt that this will have much to do with your tuning detector,=20 I guess it has - at least concerning the basic design - this means that=20 judging the correctness of the tone by harmonics maybe misleading. > but I find it an interesting understanding of piano subtleties. > > Chris Moore It's interesting if you watch the signal of a piano on an oscilloscope this= =20 way: generate a sine wave with an oscillator and tune it to the tone of a=20 certain string. Connect the generator to input X and the micro with the=20 recorded string to input Y. Looking at the resulting Lissajou figure, you should see either a straight = 45=C2=B0=20 line or a perfect circle or anything between. I tried this in school (quite a couple of years ago) and I was deeply=20 disappointed because it didn't work. The result was not at all what I had=20 expected, but a quite wild show... Bernhard=20 =20 =20
On Friday 02 June 2006 08:35, i...@hotmail.com wrote: > 1- Zero padding : > ----------------- > Since we want to detect the fundumental frequency, we do not need to have > great resolution(in term of seperating two different frequencies). All we > need is a high precision for the value of the fundamental frequency. Here, > i remarked that zero padding is of great interest. In fact, with only 32 > samples, or even 16, then zero padding till having Fs/N = precision wanted, > we can measure the frequency. I know that, the fft calculation time will > the same since real samples are replaced with zero, but may it will be > useful for decreazing the sampling duration I'm interested in this experiment. Can you describe such an example with concrete numbers: 1) which resolution do you think is necessary that the human ear doesn't feel a mistune? 2) did you check your results with real tones (mixtures including overtones and other artifacts) or does this result come from a generated artificial (and ideal) tone? Though I agree, that zero padding is a wonderful means, which will do a good job here, I suspect that you are trying to fool physics... I guess that a difference of tenth of the distance between adjacent tones is audible (because of the beat with other concurrent tones). Supposing tone A"(27.5Hz), this is a difference of 0.15Hz. Since you need a better resolution, and have to deal with different issues, this should take you at least a couple of seconds for the detection. I would guess that you need 5...8 sec. However, tradeoffs are possibly allowed: Most people don't hear these low frequencies - and we're certainly used to mistuned low tones on pianos ;-) Bernhard
>>which resolution do you think is necessary that the human ear doesn\'t >>feel a mistune? First, I will call it precision rather than resolution. I\'ll tell you the reasons later. The music experts can detect 5 cents difference. The cent is a ratio and not a fixed value. frequency*2^(1/1200) If we take the A49 (440Hz), a positif shift of 5 cents gives: 440 * (2^(1/1200))^5 = 440*2^(1/240) = 441.27 Hz For A1 this gives 27.579 which means a difference of 0.07 Hz >>2) did you check your results with real tones (mixtures including >>overtones and other artifacts) or does this result come from a generated artificial (and ideal) tone? I recorded many real piano samples and manipulated them in matlab. I give you an example: I recorded one hit of the A49 note of a Lauberger Gloss Piano (I like useless details ;) The sampling rate is fs=22050. I made a fft of a portion of N=22050 samples (chosen not from the beginning of the signal). I obtained a frequency of 434 Hz. (precision = fs/N = 1 Hz) After that I downsampled the signal at the rate of 1/10. The new fs is now 2205 Hz I took only 64 samples and performed a fft over 2048 samples (64 real samples + zeros) I obtained a frequency of 435 Hz. But I think that I will not opt for fft in my application. I have already implemented an autocorrelation function in the dsPIC. I am testing it now. I will share with you some thoughts about about autocorrelation after I finish my tests. The zero crossings is still an option especillay for the middle notes. Thank you for all your ideas. -----Original Message----- From: a...@yahoogroups.com [mailto:a...@yahoogroups.com] On Behalf Of Bernhard Holzmayer Sent: Tuesday, June 06, 2006 9:41 AM To: a...@yahoogroups.com Subject: Re: [audiodsp] Re: Re: Accurate frequency detection On Friday 02 June 2006 08:35, i...@hotmail.com wrote: > 1- Zero padding : > ----------------- > Since we want to detect the fundumental frequency, we do not need to > have great resolution(in term of seperating two different > frequencies). All we need is a high precision for the value of the > fundamental frequency. Here, i remarked that zero padding is of great > interest. In fact, with only 32 samples, or even 16, then zero padding > till having Fs/N = precision wanted, we can measure the frequency. I > know that, the fft calculation time will the same since real samples > are replaced with zero, but may it will be useful for decreazing the > sampling duration I\'m interested in this experiment. Can you describe such an example with concrete numbers: 1) which resolution do you think is necessary that the human ear doesn\'t feel a mistune? 2) did you check your results with real tones (mixtures including overtones and other artifacts) or does this result come from a generated artificial (and ideal) tone? Though I agree, that zero padding is a wonderful means, which will do a good job here, I suspect that you are trying to fool physics... I guess that a difference of tenth of the distance between adjacent tones is audible (because of the beat with other concurrent tones). Supposing tone A\"(27.5Hz), this is a difference of 0.15Hz. Since you need a better resolution, and have to deal with different issues, this should take you at least a couple of seconds for the detection. I would guess that you need 5...8 sec. However, tradeoffs are possibly allowed: Most people don\'t hear these low frequencies - and we\'re certainly used to mistuned low tones on pianos ;-) Bernhard
howdy marc and all, This is a thread that was going a while ago, but i've finally started doing some C simulations. The problem is a real time detection of a fundemental frequency knowing that harmonics and noise will be present, but not other fundementals. The simulation i've been running is simple. I recorded a few single notes on a guitar into .wav format. My program then runs through and counts the ammount of time between zero crossings and makes note of the peak amplitudes for each half period. Theorietically, a pic could do this also, and this implementation would require very little memory and very little processing power (a simple compare and increment, a few conditional branches, etc.) I did some calculations and at 44Khz sampling, i'd have 250 instrcutions between samples, and 20 to 300 samples between zero crossings (when i might actually have to do something). The periods i get between zero crossings are very chaotic due to harmonics and noise, but i found that averaging 10 cycles i easily get within 1.5samples of the true fundemental. Towards the end of the note (especially for high frequencies) noise starts to interfere and my periods are not trustworthy. Right now, I'm about to start running fourier analysis on the .wavs to see what level of harmonics and noise starts to interfere. Also, I'm about to modify my C program to average sucessive peak amplitudes, or do a simple sum of amplitudes within a half period to give me some parameters that might give me a clue about wether my signal to noise ratio is acceptable. So, whats going on with marc ibrahim and others who had projects going on? I'm curious about whats working. later, bob