Wednesday, September 06, 2006

Week6 - SuperCollider - HID

Setting up the HID (Human Interface Device) seemed fairly simple. I attached a fairly simple SynthDef to get my HID to do some controlling magic. The problem is that I return a nil value when I use the HID (I want to call it a HID device, but that's like calling an ATM an ATM machine). Thus, I get no sound. Anyway, here is a post of my code:
HUMAN INTERFACE DEVICE
(
HIDDeviceService.buildDeviceList(
usagePage: nil,
usage: nil);
)
HIDDeviceService.devices;
(
//Establish Device and Element List
HIDDeviceService.devices.do(
{ //Arguments
arg dev;
//DeviceInfo
["DEVICE", dev.manufacturer, dev.product, dev.usage, dev.vendorID, dev.productID, dev.locID].postln;
//Loop & Output Elements
dev.elements.do(
{ //Arguments
arg ele;
//Elements
[ele.type, ele.usage, ele.cookie, ele.min, ele.max].postln;
});
});
)

//Queue Device & Assign an Action
HIDDeviceService.devices.at(0).queueDevice;

//SynthDef
(
SynthDef(
\ambient,

{
//Arguments
arg resFreq = 500,
crackleMul = 0.15,
dur = 6,
legato = 4;

//Variables
var ambient,
env;


//Crackle
ambient = Ringz.ar( Crackle.ar(1.1, crackleMul),
resFreq,
1.2,
0.5
);

//Envelope
env = ambient * EnvGen.kr(Env.perc(
0,
dur*legato),
doneAction:2
);
//Output
Out.ar(0, [env, env]);
}
).send(s);
)
//Create Instance of Synth
~hidSyn = Synth(\ambient);

//Action 1
(
HIDDeviceService.action_({
//Arguments
arg productID,
vendorID,
locID,
cookie,
resFreq,
val;

//Parameter manipulation
~hidSyn.set(\resFreq, {val * 5});
//Output
[productID, vendorID, locID, cookie, val].postln;
});
)

//Start the Event Loop
HIDDeviceService.runEventLoop;

//Stop the Event Loop
HIDDeviceService.stopEventLoop;

REFERENCES:
Haines, Christian. 2006. Human Interface Device. Tutorial presented at the Electronic Music Unit, University of Adelaide, 31 August.

1 Comments:

At 5:03 pm, Blogger @*} said...

regardless, your code is looking good...

 

Post a Comment

<< Home