thank you @Eli, I used OSC Hook to do the @robin.newman Theremin ^^
Here another example of Theremin Gravity sensor with OSC Hook
use_debug false
define :putsPretty do |n,p|
num=(n*10**p).round/(10**p).to_f
return num
end
define :scalev do |v,l,h|
return (l+v).to_f*(h-l)/100
end
live_loop :kik do
32.times do
sample :elec_bong, amp: 1.2 if (spread 3, 8).tick
sample :elec_bong, amp: 1.2 if (one_in 64)
sample :perc_snap, amp: 0.6 if (spread 7, 11).look
sample :bd_haus, amp: 2 if (spread 6, 32).look | (one_in 32)
sample :bd_boom ,amp: 3 if (one_in 64)
sample :elec_mid_snare ,amp: 1 if (one_in 48)
sleep 0.125
end
end
with_fx :ixi_techno,phase: 4,phase_offset: 1,mix: 0.8 do |p|
set :p, p
use_synth :pulse
k=play octs(0,5),sustain: 10000,amp: 0
set :k,k
live_loop :theremin do
use_real_time
b = sync "/osc/accelerometer/gravity/y"
c = sync "/osc/accelerometer/gravity/x"
if b[0]<0
r1=scalev(0.1,30,100)
else
r1=scalev(b[0],30,100)
end
if c[0]<0
r2=scalev(0.1,0.1,1)
else
r2=scalev(c[0],0.1,1)
end
puts putsPretty(r1,2),putsPretty(r2,2)
if r1 < 60 then #adjust note pitch, and restore volume to 0.7
control get(:k),note: octs(r1+12,3),note_slide: 0.01 ,amp: 0.7,amp_slide: 0.2
else #set output vol to 0
control get(:k),amp: 0,amp_slide: 0.2
end
if r2 < 0.8 then #adjust phase modulation rate, and restore mix to 0.8
control get(:p),phase: r2*10,phase_slide: 0.01,mix: 0.9,mix_slide: 0.2
else #switch off phase modulation by setting mix to zero
control get(:p),mix: 0,mix_slide: 0.2
end
end
end