I have spent today revamping a previous Theremin project and improving it. I now use two ultrasonic sensors and the note control is a bit better.
Article with full code links
I have spent today revamping a previous Theremin project and improving it. I now use two ultrasonic sensors and the note control is a bit better.
Article with full code links
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
I can’t get it to work ,
sonic pi seems to be receiving the osc msgs from my phone
when i changed the amp value i can hear it but it’s not affected by my phone accelerometer
I’ve also changed the sync values to the osc adresses .
any suggetions would be appreciated i’m new to all of this , thanks
That is so freaking cool!
Never even thought about interfacing things with sonic pi like this.
Is osc easy to set up? Have not looked into it.
Hey Kayal, a few more details would be helpful - It would be useful to know which version of Sonic Pi you are using.
If you’re using Sonic Pi more recent than v3.2.0, It’s possible that it is due to a breaking change that was made in v3.2.0 that changed the way the osc and midi event addresses were stored. (OSC cues now include the IP address and port number of incoming messages, and the example written above does not have this). See Tutorial Chapter 12.1 for an example of correctly reading incoming OSC events - there is an asterisk that is used as a wildcard to match any host.
If it’s not that, then it would also be useful to see your code so that we can troubleshoot it for you
Most of the time, yes
There are some simple examples in the tutorial in Chapter twelve as I mention just above, of receiving OSC with Sonic Pi from an external script such as in Python or Clojure, and chapter 12.2 shows how to send OSC out from Sonic Pi. Setting up a listener in an external script is often quite simple if your chosen programming language has a dedicated OSC library (which many do).
thanks a lot it was the change in the osc adresses ,
added an asterisk and now it’s working .
I’ve updated the code on my gist site associated with the original article to reflect the latest versions.