I'm trying to make a sample counter (k-rate) that counts how many non-zero samples occured since the last zero-crossing.
What I have so far in <code.krate>
is:
if (inlet_in<=0 and xflag == 1){
outlet_o = 281474976710656/counter*(1<<21);
counter=1;
xflag=0;
}
if(inlet_in>0 and xflag == 0){
outlet_o = 281474976710656/counter*(1<<21);
counter=1;
xflag=1;
}
counter++;
ultimately, I would want it to output a frequency from the wavelength. hence the division by counter*(1<<21)
, but that's no where near the right way to do it, apparently...
How do I correctly scale the counter value so that it outputs as a value between -64 and 64 from the object, representing the frequency?
thanks