Sorry for the double answer, but this also occurs to me: To improve accuracy, measure both halves of the cycle and add them. To improve further, upsample the whole mess, say by a factor of 16. Doint both of those would improve the theoretical resolution by a factor of 32. (Of course, you still have the guitar's own variation from cycle to cycle to worry about :)
M On Sun, Apr 27, 2014 at 03:56:18AM -0700, Miller Puckette wrote: > That is an excellent, witty way to measure pulse withs using > only tilde obects - my hat's off to you. > > The methond only has limited accuracy since its measurement is in > samples. For instance, a 1/2 cycle of a 440-hz. tone at 44.1 kHz is > only 50 samples, so there's only 2% accuracy. That's about 1/3 of a > half tone (30-ish cents) which would sound horribly out of tune. > > There's an alternative sine-to-sawtooth recipe described here: > > http://msp.ucsd.edu/Publications/icmc10.pdf > > This is the basis of my guitar processing patch, smeck, but should be more > broadly useful. But it has its own limitations: the sawtooth you get out > is wiggly if the input sn't a pure sinusoid. > > There's also the possibility of simply pitch tracking with sigmund~. Use > a maximum frequency around 6000 and a maximum of 6 partals (default 50!) > for best results. > > cheers > M > > On Sun, Apr 27, 2014 at 11:27:33AM +0200, Simon Iten wrote: > > dear list, > > > > i have a strange problem with my “sinetosawtooth” patch. > > > > it is basically a version of the pitch to voltage conversion used in the > > old gr300 guitar synths from roland. > > > > i cut out all the clutter to make it easier to look at and understand. (cut > > out the adaptive filtering at the input since i use a sine wave for this > > example and not a guitar string) > > > > here is how it works (or should): > > > > -an input signal gets amplified by a large factor and clipped. this squares > > the input. > > > > -the square wave is converted to pulses. > > > > -the pulses from the rising of the square wave are used to set and reset an > > accumulating filter (rpole~) > > > > this results in a sawtooth wave that varies in amplitude depending on the > > frequency of the input. > > > > -a sample and hold samples the peak of the sawtooth and holds it until the > > next peak occurs. this, after a conversion gives us the input frequency. > > yeah! > > > > in the example patch i used the falling edges of the square wave to > > trigger the sample and hold. this samples the sawtooth amplitude after half > > the rising. (this is also why i have 22050 in fexpr~ and not 44100) i > > could not figure out how to sample the peak of the sawtooth, so suggestions > > here are very welcome. > > > > now to the problem: > > > > the extracted frequency does not exactly correspond to the input frequency. > > it is pretty close at low frequencies but gets worse at higher frequencies. > > the factor is not constant. at even higher frequencies (around 5000 hertz) > > the reported frequency gets totally out of control. > > > > i first thought this is because the samphold~ object is inaccurate. but i > > then saw that the sawtooth wave from the rpole~ object has no constant > > amplitude even with the input frequency not changing. so it seems that > > either rpole~ or change~ is not accurate. > > > > or the problem is that i sample in the middle of the rising and not at the > > top ( as described earlier) > > > > attached the sinetosawtooth patch. set your sound card to 44100 or change > > the 22050 in fexpr~ to half the sampling frequency. > > > > i would really appreciate if somebody could have a look at this, > > > > thanks, simon > > > > > > _______________________________________________ > > Pd-list@iem.at mailing list > > UNSUBSCRIBE and account-management -> > > http://lists.puredata.info/listinfo/pd-list > > > _______________________________________________ > Pd-list@iem.at mailing list > UNSUBSCRIBE and account-management -> > http://lists.puredata.info/listinfo/pd-list _______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list