Re: very simple phase-locked loop pitch detection in C

Kragen Javier Sitaker <[email protected]>
Newsgroups gmane.culture.people.kragen.discuss
Message-ID <[email protected]>
Based on the previous post, here's a one-liner phase-locked loop that tries to
sing along with you, an octave higher:

    /* A PLL in one line of C. arecord | ./tinypll | aplay */
    main(a,b){for(;;)putchar(b+=16+(a+=(b&256?1:-1)*getchar()-a/512)/1024);}

I think it would have been very surprising in 1940 or 1950 that someone could
describe a design for a phase-locked loop, in one line of text, so completely
that a general-purpose computer could realize the PLL and use it to generate a
waveform that tracked the frequency of another waveform.  It's probably still
surprising today to a lot of people.  In effect, it's a complete design for a
machine with somewhere between 15 and 40 moving parts, depending on how you
count, and the computer manufactures the machine automatically from the design.

However, it took me most of two days to write that one line of text, and I
still don't fully understand it.

Kragen
-- 
To unsubscribe: http://lists.canonical.org/mailman/listinfo/kragen-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.