Gravity sensor with OscHook on Android for Theremin plus, controlling pitch and ixi_techno phase.
#Gravity sensor with OscHook on Android for Theremin plus, controlling pitch and ixi_techno phase.
#Based on Theremin plus, controlling pitch and ixi_techno phase by Robin Newman May 2018
#I control a continously playing note (length 2000)
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
with_fx :reverb,room: 0.8,mix: 0.8 do
with_fx :ixi_techno,phase: 4,phase_offset: 1,mix: 0.8 do |p|
set :p, p
use_synth :subpulse
k=play octs(0,2),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,30,100)
else
r1=scalev(b[0],30,100)
end
if c[0]<0
r2=scalev(0,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+24,3),note_slide: 0.06 ,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.06,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
end