Skip to content

Instantly share code, notes, and snippets.

@carltesta
Created September 28, 2020 04:19
Show Gist options
  • Save carltesta/a341ded1484daa8f23d5bcdba5fb949e to your computer and use it in GitHub Desktop.
Save carltesta/a341ded1484daa8f23d5bcdba5fb949e to your computer and use it in GitHub Desktop.
Using the Mach 1 MNTR CTRL app with SuperCollider
//Carl Testa
//requries SuperCollider Ambisonic ToolKit: http://www.ambisonictoolkit.net/documentation/supercollider/
//requires Mach1 M1 MNTR CTRL App: https://apps.apple.com/us/app/m1-mntr-ctrl/id1486961476#?platform=iphone
//headtracker
//Using M1 MNTR CTRL App on iPhone, place the iphone on top of your headphones if you can (or use AirPods Pro)
~ht = Bus.control(s, 1);
(
OSCdef(\tracker,
{|msg|
//(msg[1].degrad).postln;
~ht.setSynchronous(msg[1].degrad);
}, "/orientation", recvPort: 9898);
)
~encoder = FoaEncoderMatrix.newOmni;
~decoder = FoaDecoderKernel.newCIPIC(3);
//Basic Synth taken from Eli Fieldsteel Ambisonic Intro https://www.youtube.com/watch?v=VvI56TnY8tA
(
SynthDef(\field, {
|out=0, angle=0|
var sig;
//sig = Decay.ar(Dust.ar(20), 0.01, WhiteNoise.ar(0.5));
sig = WhiteNoise.ar(1!8);
sig = BPF.ar(sig, {exprand(100,4000)}!8, 0.02);
sig = FoaEncode.ar(sig, ~encoder);
sig = FoaPush.ar(sig, pi/2, 0, 0);//Push the diffuse signal straight ahead
sig = FoaRotate.ar(sig, angle);//rotate the signal based on headtracker
sig = FoaDecode.ar(sig, ~decoder);
Out.ar(out, sig);
}).add;
)
x=Synth(\field, [\out, 0, \angle, ~ht.asMap]);
//when done
x.free;
OSCdef(\tracker).free;
~encoder.free;
~decoder.free;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment