[chuck-users] Why does the gain increase each time through the loop

Joel Matthys jwmatthys at yahoo.com
Thu Sep 13 13:24:51 EDT 2012


Hello John. It's always good to hear that there's another new laptop group.

I think your problem here comes because you're plugging another instance 
of bufKick into the dac every time you play it.

Your connection to the dac should come just once, probably at the 
beginning of the file in your global declarations. Once it's connected, 
it will stay connected (unless you un-Chuck it).

You also don't need to hook your bufKick to the blackhole; just replace 
that with the dac, and remove all of the other bufKick => dac calls and 
you should maintain a steady gain.

Joel

On 09/13/2012 12:11 PM, John Ellinger wrote:
> Hi all,
>
> After attending the SLEO conference last spring I was inspired to start a laptop group at Carleton College. I've run into a problem I don't understand. I'm using chuck version: 1.3.1.1 (chimera) mac os x : intel : 64-bit
>
> I've interfaced a 4x4 numeric touchpad to an Arduino controller that sends MIDI to Chuck. The MIDI reception works fine. I mapped keypad number 1 to a kick drum sample which works fine. The problem is every time I press keypad 1 the gain increases. This skeleton code illustrates the issue.
>
> ============================
> // gain test
> SndBuf bufKick => blackhole;
> // change to your path
> "/Users/je/Documents/ArduinoXCode/midikeypad_git/chuck_pad/data/kick.wav" => bufKick.read;
> // set the kick gain
> 0.5 => bufKick.gain;
> // get the kick duration
> bufKick.length() => dur bufKickDur;
>
> function void playKick()
> {
>      0 => bufKick.pos;
>      bufKick => dac;
>      bufKickDur => now;
> }
>
> // infinite time-loop
> while( true )
> {
>     playKick();
>     1::second => now;
> }
> ===============================
>
> I've tried things like this
> fun void playKick()
> {
>      0 => bufKick.pos;
>      bufKick => Gain g => dac;
>      g.gain() => float oldgain;
>      bufKickDur => now;
>      oldgain => g.gain;
> }
>
> and this
> fun void playKick()
> {
>      0 => bufKick.pos;
>      bufKick => dac;
>      bufKick.gain() => float oldgain;
>      bufKickDur => now;
>      oldgain => bufKick.gain;
> }
> but the gain still increases on every button press. How can I keep the gain at a constant level?
>
> It was a pleasure to meet and talk with Ge and Spencer at SLEO.
>
> John
>
> John Ellinger                           email: info at mibac.com
> MiBAC Music Software                    1019 College St.
> Music Instruction By A Computer         Northfield MN 55057
> http://www.mibac.com
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list