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

John Ellinger info at mibac.com
Thu Sep 13 12:11:20 EDT 2012


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



More information about the chuck-users mailing list