GamePad a sketch for using GamePads as music controllers.


Note - this is a temporary version of GamePad, which has been around for 5 years or so.

To be included in / adapted for the new Ktl scheme real soon! 

written by adc and haho.


General Info


GamePad lets you use Playstation-style GamePad controllers to play with multiple 

JITLib-style proxies; see Ndef, Tdef, Pdef, ProxySpace. 

One can record loops of controller movements  that can be modified while played back, 

e.g. rescaled and inverted in value ranges, with changeable tempo and direction, etc. 


To use a gamepad with the Gamepad class, it has to have: 

2 analog joysticks, 

4-direction compass, 

4 numbered buttons, and

4 buttons on the shoulders.

The Saitek company makes pretty good models; e.g. the (now gone) Saitek Impact X6-38U 

has a fine resolution of 256 values per joystick dimension. 

Currently, the Thrustmaster Ferrari also has great resolution, plus three extra continuous 

controllers. 


Subclasses have the differing controller specs, and vendorIDs: 

Impact, ImpactNu, Ferrari, Betop, Eaxus; 

for others, you can make your own subclasses, see

"GamePad_more".openHelpFile



Overview


You can use 4 groups (wings) of 4 proxies each, and navigate between them 

with the compass on the left and the 4 button on the right side. 


W, S, E, N on the compass (the left hand direction switch), 

switch the proxies within one group (or 'rooms' in one wing), 

wich are stored as numbers 0, 1, 2, 3. 

and the 4 right hand 4 buttons (labeled 1 2 3 4)

switch between the 4 proxy groups (or 'wings' in the building). 



s.boot; // server must be booted, then:


(

GamePad.startHID; // builds the setup automatically.

p = p ?? { ProxySpace(s); }; p.push; // make a proxyspace but only if needed.

)


// Now switch your gamepad to analog mode, and test that you get numbers:


GamePad.verbose = true; // move joysticks to see e.g. [ hid, 19, 0.95686274509804 ] posted.

GamePad.verbose = false; 


// GamePad.stop; // stop HID event loop to turn gamePad off.



// Then you can put a proxy in room 0

(

// a simple proxy : modulating formant frequency, root and number of harmonics

~formsing = { arg formfrq=500, root=300, harm=20, amp=0.4, lag= 0.2;

var in = Blip.ar(root.lag(lag), harm.lag(lag), 0.1);

Formlet.ar(in, formfrq.lag(lag) * [1, 1.06], 0.005, 0.04) 

* 5 * amp.lag(lag);

};

// make sure it plays sound

~formsing.play(vol: 0.25);



// make controlspecs for its parameters:

Spec.specs.put(\formfrq, ControlSpec(100, 5000, \exp));

Spec.specs.put(\root, ControlSpec(5, 500, \exp));

Spec.specs.put(\harm, ControlSpec(1, 256, \exp));



Spec.add(\formfrq, [100, 5000, \exp]);


// make a GUI for the ProxySpace:

ProxyMixer(p);


// then put the proxy into the GamePad, at wing 0 + room 0; 

// wings are in groups of 4 proxies each. 

GamePad.putProxy(0, 

\formsing, 

(

joyRY: { arg val; ~formsing.group.set(\amp, \amp.asSpec.map(val)) }, joyLX: { arg val; ~formsing.group.set(\formfrq, \formfrq.asSpec.map(val)) }, joyLY: { arg val; ~formsing.group.set(\root, \root.asSpec.map(val)) }, joyRX: { arg val; ~formsing.group.set(\harm,\harm.asSpec.map(val)) } )

); 

)


To make this proxy controllable, click on wing 0 (right side, button "1"), 

and select room 0 (left side compass, click direction west /left).


Now you can control the 4 parameters of ~formSing with the 2 joysticks. 

Right top fire button (cookie 9) pauses the proxy (muting). 

Hold down left top fire button to record a loop of control events; 

End recording by letting go. 

then play/stop that loop with left bottom fire button. 

when playing back, right lower fire button gets you into 


METACONTROL mode: 

Now Right Joystick:

up/down sets control loop tempo, 

hatswitch flips loop direction. 

lr introduces jitter : when outside the center pos, 

the next event that gets played is chosen from 

a zone around the current loop pos.

Left Joystick: 

l-r scales the control values to a center value (left is flat), 

up-down moves that center. 

Joyst L hatswitch mirrors the control values around the center value.

switching center right button (cookie 12) toggles joyst l mapping 

between this (scale/center) and loopstart / looplength.


to disconnect GamePad, use


GamePad.stop;




Here is a documentation image for the GamePad control layout,

as used in the now historical Bejing setup: 


unixCmd("open" + Document.current.path.dirname.quote +/+ "impact.jpg");




ToDo Dev: 

* use GeneralHID for setup; 

* ! STOP HOGGING THE HIDDevcieService.action ! *

* use a HIDResponder (to be written)

* integrate into new Ktl scheme (Ktl quark)

* Tdefs, Pdefs: support pause/resume; setting params, recording ctloops.


* untangle from BufBank for live sampling ... 

* integrate RecBuf patch/sketch

* make a usable JITGui for it 

* general cleanup ...