Hi list,
I'm trying to simulate how adc conversion works using chuck. However,
I'm not succeeding as I'm getting too many artifacts in the output
sound. Don't know whether i'm getting this wrong from a conceptual
point of view or I'm using/setting chuck's UGens wrongly. The patch I
use is:
<<<"usage:", "sample_and_hold.ck:output_gain:sr" >>>;
adc => OnePole lpf => blackhole;
Impulse pulse => lpf => Gain g => dac;
.8 => g.gain;
if( me.args() ) Std.atof( me.arg(0) ) => g.gain;
1::second/1::samp => float chuck_sr => float new_sr;
if( me.args() > 1 ) Std.atof( me.arg(1) ) => new_sr;
chuck_sr/new_sr => float next_samp;
1. - new_sr/chuck_sr => lpf.pole;
<<>>;
<<< next_samp>>>;
while(true)
{
now => time T;
next_samp::samp +=> T;
lpf.last() => pulse.next;
while( now < T )
{
1::samp => now;
}
}
Then the user should be able to give a certain SR and experience how
the input sound would sound when sampled at SR.
I'd like to be able to set lpf cutoff frequency at SR/2 and what I
thougt of is something like:
1. - new_sr/chuck_sr => lpf.pole;
thus,
if user_sr= 44100, then pole=0 and cutoff freq=chuck_sr/2 (should be
22050 if running at 44.1).
if user_sr=22050, then pole=0.5 and cutoff freq=chuck_sr/4 (should
be 11025 if running at 44.1)
etc...
Am I doing this right? On the other hand, a Onepole filter will not
suffice to get rid off all frequencies above the cutoff. Is there a
way of having a kind of brickwall filter in chuck?
Thanks,
eduard