[chuck-users] feedback loop

Tom Lieber tom at alltom.com
Fri Sep 30 18:49:40 EDT 2011


On Fri, Sep 30, 2011 at 5:43 PM, Tomtom <tomtom at herbesfolles.org> wrote:
> I've just tried to reproduce something I've done some time ago with
> guitar pedals : a feedback loop.
>
> input -> mixer -> delay -[wet]-> various effects -> back to the mixer
>             `--> dekay -[dry]-> output
>
> by controling the amount of feedback on the mixer and the parameters of
> the effects in the loop you can create funny things.
>
> Now, for the ChucK part (not exactly the same, but quite similar) :
>
> ----
>
> class MyDelay extends Delay
> {
>        1::second => max;
> }
>
> // feedback loop
> MyDelay d => JCRev r => Gain g => d;
> d => dac;
>
> fun void note()
> {
>        SawOsc osc => Envelope e => d;
>        250 => osc.freq;
>        1 => e.value;
>        e.keyOff();
>        200::ms => e.duration => now;
> }
>
> 0.8 => g.gain;
> 0.2 => r.mix;
> 200::ms => d.delay;
>
> note();
> 10::second => now;
>
> ----
>
> with these parameters I get a positive feedback: sound is getting louder
> and louder, clipping and then silence. Using d.last(), I see the samples
> computed get outside the range [-1;+1] (thus the clipping) and then
> divert from 0 exponentially.
>
> To avoid this, I would like to truncate the sample values so they stay
> in the interval [-1;+1] :
>
> if s > 1 then s = 1, if s < -1 s = -1
>
> I tried to use Dyno as a limiter, but it seems to do something more
> clever than that.
>
> That's all folks !

The lazy hacker in me would do it manually:

  SinOsc s => Gain clipper => blackhole;
  100 => s.gain;

  fun void clippy() {
      Step steppy => dac;
      while(samp => now) {
          if(clipper.last() > 1) 1 => steppy.next;
          else if(clipper.last() < -1) -1 => steppy.next;
          else clipper.last() => steppy.next;
      }
  }

  spork ~ clippy();
  day => now;

But I felt guilty about hitting send after typing only that, so I
looked at the docs for Dyno and I'm pretty sure this does the same
thing:

  SinOsc s => Dyno d => dac;
  100 => s.gain;
  0 => d.slopeAbove;
  1 => d.slopeBelow;
  1 => d.thresh;
  0::ms => d.attackTime;
  0::ms => d.releaseTime;
  day => now;

-- 
Tom Lieber
http://AllTom.com/
http://infinite-sketchpad.com/


More information about the chuck-users mailing list