[chuck-users] Joypad abuse.

Kassen signal.automatique at gmail.com
Mon May 22 07:58:01 EDT 2006


Hi list.

In testing my new joypad I quickly cooked this up. It's kinda cheap
but like many cheap things it's good fun so I thought somebody else
might have fun with it too. I'm asuming everybody has amen or simmilar
break lying around somewhere. With a little practice somewhat
convincing jungle can be made, this takes considderably less time then
it took years ago cutting&pasting in a wave editor....

It's just a quick toy, if anybody needs comments somewhere I'd be
happy to help. By the way; I'm using one of these "thrustmaster"
youpads now that are styled after teh PS2 ones. With this the
"stutter" and "reverse" buttons end up conveniently under your index
fingers. If you are using some flight-sim joystick none of thismay
make sense and you may need to edit a little.

For what it's worth,
Kas.


-------------------------
sndbuf buf => PitShift ps => dac;
"data/amnbreak.wav" => buf.read;

1 => buf.loop;
1 => ps.mix;
buf.samples()  => int A;
(A /  32) => int beat;
beat::samp => dur click;

int pos2;
int pos1;
1 => int dir;
int stut;
click / 4 => dur frtclick;

4 => int rate;

fun void joyreader()
	{

	// make HidIn and HidMsg
	HidIn hi;
	HidMsg msg;
	
	// open joystick 0, exit on fail
	if( !hi.openJoystick( 0 ) ) me.exit();


		// infinite event loop
		while( true )
		{
		    // wait on HidIn as event
		    hi => now;
		
		    // messages received
		    while( hi.recv( msg ) )
		    {
		
		        <<< msg.type, msg.which, msg.idata, msg.fdata >>>;
		        if (msg.type == 0 && msg.which == 1 ) (-msg.fdata + 1) * dir
=> buf.rate;
		        if (msg.type == 0 && msg.which == 0 ) ((16 * msg.fdata) +
16) $ int => rate;
		        if (msg.type == 0 && msg.which == 2 )  1 - msg.fdata   => ps.shift;
	        	if (msg.type == 0 && msg.which == 3 ) (A * msg.fdata *
msg.fdata) $ int => pos2;
	        	
	        	if (msg.type == 1 && msg.which == 0 ) 0 =>  pos1;
	        	if (msg.type == 1 && msg.which == 1 )  (A / 4) =>  pos1;
	        	if (msg.type == 1 && msg.which == 2 ) 2 * (A / 4) =>  pos1;
	        	if (msg.type == 1 && msg.which == 3 ) 3 * (A / 4) =>  pos1;
			if (msg.type == 1 && msg.which == 4 )
				{
				-1 => dir;
				if ( (buf.rate() * dir)  < 0) (-1 * buf.rate() ) => buf.rate;
				}
			if (msg.type == 2 && msg.which == 4 )
				{
				1 => dir;
				if ( (buf.rate() * dir)  < 0) (-1 * buf.rate() ) => buf.rate;
				}
			if (msg.type == 1 && msg.which == 6 ) 1 => stut;
			if (msg.type == 2 && msg.which == 6 ) 0 => stut;
		    }
		}
	}

spork ~ joyreader();

0 => int step;

fun void sync()
	{
	click - (now % click) => now;
	while(true)
		{
		if(!stut)
			{
			step * beat =>  pos1;
			pos1 => buf.pos;
			}
		1 +=> step;
		(step % 32) => step;
		click => now;
		}
	}

spork ~ sync();

click - (now % click) => now;
while (true)
	{
	if (stut)(pos1 + pos2) % A => buf.pos;
	if (rate==0) 1 => rate;
	 rate * frtclick => now;
	}


More information about the chuck-users mailing list