DDR EffectsPad.ck

From CSWiki
Jump to: navigation, search
adc => Gain g => dac;
adc => Chorus chor => dac;
adc => Echo ech => dac;
adc => NRev rev => dac;
0.0 => chor.mix => ech.mix => rev.mix;
0.0::second => ech.delay;
0.5 => g.gain;

// make HidIn and HidMsg
Hid hi;
HidMsg msg;

// which controller
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;

// open controller 0, exit on fail
if( !hi.openJoystick( device ) ) me.exit();

<<< "DDRPad '" + hi.name() + "' ready", "" >>>;

// infinite event loop
while( true )
{
    // wait on HidIn as event
    hi => now;
    // messages received
    while( hi.recv( msg ) )
    {
               //=button down
        if( msg.isButtonDown() )
        {
            <<< "joystick button", msg.which, "down" >>>;
            if (msg.which == 9) {
                     0.9 => chor.mix;
                    <<< "chorus on" >>>;
                }
                if (msg.which == 8) {
                    0.25 => rev.mix;
                    <<< "reverb on" >>>;
                }
                if (msg.which == 2) {
                    0.075::second => ech.delay;
                    0.2::second => ech.max;
                    1.5 => ech.mix;
                    <<< "echo on" >>>;
         }
     }
         //button up
        else if( msg.isButtonUp() )
        {
            <<< "joystick button", msg.which, "up" >>>;
            if (msg.which == 9) {
                0.0 => chor.mix;
                <<< "chorus off" >>>;
        }
        if (msg.which == 8) {
            0.0 => rev.mix;
            <<< "reverb off" >>>;
        }

        if (msg.which == 2) {
            0.0::second => ech.delay;
            0.0 => ech.mix;
            <<< "echo off" >>>;  
    }
            
    }
}
}