Here is a few examples on how to use the quark:
// for this to work, we need to connect the computer and
// the phone on the same network, and point TouchOSC to the
// computer on port 55555
//
// First, create the Phone object that we need, then bind it to
// the variable ~phone
~phone = Phone.new(\iPhone, 55555);
// Check if you get any data by evaluating the .trace method
// You should get a barrage of values in your post window
~phone.trace(true);
// stop posting data
~phone.trace(false);
// now, let's make the phone trigger something.
// at first, just post the delta-value:
~deltaTriggerTest = PhoneDeltaTrig.new(
phone: ~phone,
threshold: 0.01,
speedlim: 0.5,
function: {|dt, minAmp, maxAmp|
dt.postln;
}
).play;
// adjust the threshold to make it less trigger-happy
~deltaTriggerTest.threshold = 0.05;
~deltaTriggerTest.free;
// Let's make some sound:
s.boot;
(
~deltaTrigSine = PhoneDeltaTrig.new(
phone: ~phone,
threshold: 0.05,
speedlim: 0.5,
minAmp: -50.dbamp,
maxAmp: -10.dbamp,
function:{|dt, minAmp, maxAmp|
{
// let the amount of movement energy determine the
// attack and release times: stronger impulses
// give a shorter attack and a longer release
var attack = dt.linlin(0.0, 1.0, 0.5, 0.0);
var release = dt.linlin(0.0, 1.0, 1, 3);
// Trigger a sine wave, where the frequency is
// determined by the angle of the phone's y axis
SinOsc.ar(~phone.y.linexp(0.0, 1.0, 220, 880) ! 2)
// ... and the amplitude is determined by the amount
// of movement energy
* dt.linlin(0.0, 1.0, minAmp, maxAmp)
* EnvGen.kr(Env.perc(attack, 1, release), doneAction: 2);
}.play;
}
).play;
)
~deltaTrigSine.free;
// Using the phone as a continuous controller.
(
SynthDef(\sine, {
var sig, env, lag;
lag = \lag.kr(0.1);
env = EnvGen.kr(
Env.asr(
\attack.kr(0.1),
1.0,
\release.kr(0.9)
),
\gate.kr(1),
doneAction: 2
);
sig = SinOsc.ar(\freq.kr(440, lag))
* \amp.kr(0.2, lag)
* env;
sig = Pan2.ar(sig, \pan.kr(0));
Out.ar(0, sig);
}).add;
Pdef(\phoneCC,{
Pmono(
\sine,
\dur, 0.1,
\lag, Pkey(\dur),
\freq, Pfunc{
~phone.y.linlin(0.0, 1.0, 220, 880)
},
\db, Pfunc{
~phone.x.linlin(0.0, 1.0, -70, -6)
},
)
}).play;
)
Pdef(\phoneCC).stop;