Hi all, I’m looking for some help with trying to connect an arduino headtracker to rotate the soundfield using ‘Foatransform’ in ATK (atk-sc3).
In this example (created from the tutorials), the MouseX.kr Ugen to directly pass a variable into the transform.
SynthDef(\kernelEncodeDecode, {arg buffer;
var out, src, trans, encode;
src = PlayBuf.ar(sndbuf.numChannels, buffer, BufRateScale.kr(buffer));
encode = FoaEncode.ar(src, encoder);
trans = FoaTransform.ar(encode, 'rotate', MouseX.kr(-pi, pi));
out = FoaDecode.ar(trans, decoder);
Out.ar(0, out);
}).add;
s.sync(cond);
// play the synth
synth = Synth(\kernelEncodeDecode, [\buffer, sndbuf]);
My question is if there is there a way of replacing MouseX.kr, with an expression which will pass values from a USB headtracker, the outputs of which are directly recognised by SC3 as HID elements.
I have searched the forum and found some other examples on Github (i.e. notam’s TeensyHeadTracker, nvsonic-head-tracker, etc.) which appear to either convert to MIDI or use an OSC bridge, but ideally I’d like to bypass any conversion or middleware, as intend to run on a RPi in headless mode, just running Supercollider.
I’ve checked the headtracker’s output (it’s an EdTracker DIY - Arduino Nano / MPU-9250) and it is giving out continuous data on all three axis and can use it to modify the synth the connect to a simple SinOsc synth to change pitch and amplitude (as per tutorial example):
Ndef( \sinewave, { |freq=500, amp=0.1| SinOsc.ar( freq, 0, amp * 0.2 ) } );
// Ndef( \sinewave ).play;
~freqRange = [500, 5000, \exponential].asSpec; // create a frequency range
HIDdef.usage( \freq, { |value| Ndef( \sinewave ).set( \freq, ~freqRange.map( value ) ).poll; }, \X );
HIDdef.usage( \amp, { |value| Ndef( \sinewave ).set( \amp, value ); }, \Z );
Can the same function be used/rewritten to take the place of MouseX in the first example?
Sorry if I’ve not explained that too well but if anyone has any success in using a headtracker this way (or any HID - gamepad, Wii remote), I’d be very interested to find out how - or if I am trying to do the impossible?
Many thanks!
Mike