there's a zero crossing unit-gen in chuck: http://chuck.cs.princeton.edu/doc/program/ugen_full.html#zerox the example is not very meaningful i am afraid. here's some code i hacked together in a few minutes. it has some flaws (don't know exactly why i have to divide by four to get the correct value), but it works somehow. to use your mic you should substitute the SawOsc with adc. SawOsc o => ZeroX z => blackhole; o => dac; 1000 => o.freq; 0 => float val; 0 => float counter; 0 => float sampcounter; 1::second/1::samp => float samplerate; <<< "samplerate: ", samplerate >>>; while(true) { if(z.last() != val) { z.last() => val; 1 +=> counter; } 1 +=> sampcounter; if(sampcounter > samplerate) { <<< "freq: ", counter/4 >>>; 0 => sampcounter; 0 => counter; } 1::samp => now; } AlgoMantra schrieb:
Thanks Joerg.
although to be honest, I wasn't looking for the theoretical solution but what kind of Chuck code objects to use for this. My Chuck learning curve seems way slower than Python/PD, I don't know why. I think it's the lack of explanatory notes in examples, or some kind of proper tutorial.
On 10/16/07, *joerg piringer* < joerg@piringer.net mailto:joerg@piringer.net> wrote:
AlgoMantra schrieb: > 1. What is the simplest way to detect the pitch > of an audio signal (from the mic) in Chuck?
zero crossing detection. count how many times the signal crosses zero. how many times a second it changes from positive to negative values or vice versa. that could be a rough estimate of the frequency. this is not very reliable but works quite well with sounds that are not too hissy. low pass filtering before counting helps a little bit.
best joerg
-- http://joerg.piringer.net http://www.transacoustic-research.com http://www.iftaf.org http://www.iftaf.org http://www.vegetableorchestra.org/ _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu mailto:chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- ------- -.- 1/f ))) --. ------- ... http://www.algomantra.com
------------------------------------------------------------------------
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://joerg.piringer.net http://www.transacoustic-research.com http://www.iftaf.org http://www.vegetableorchestra.org/