Hi,
I did a first prototype of my planned live looper with touchOSC control and I ran into some questions I have not been able to solve on my own yet.
There are several occasions I would like to sent feedback from Sonic Pi
to touchosc
but I did not manage to do that. I am under the impression that it is possible to set the state of a toggle button (including the visual feedback of a highlighted button) from Sonic Pi. E. g. I have a button with the path /rec/track1_arm
:
live_loop :track1 do
use_real_time
c = sync "/osc/rec/track1_arm"
set :track, c[0]
end
The button either returns 1.0
or 0.0
. I tried to set the value of this button in Sonic Pi with:
osc_send "192.168.2.150", 9000,"/rec/track1_arm",0
(Of course touchOSC is set to receive on Port 9000 and my cellphone has the IP 192.168.2.150.)
This did not work. What am I doing wrong?
Also: Am I actually right, that touchOSC will respond and change the interface according to the values set? It would also be nice to have a feedback about the actual recording time via the LEDs touchosc provides as an interface object.
I case you are interested, here is the prototype so far:
- the looper is split up in two files:
lib-live-looper-touchosc.rb
(residing on my harddrive) and -
live_looper_touchosc.sps
, the control script which can be conveniently loaded via a shortcut - the prototype just records (and plays back) one track
- the general idea is to arm a track (where track/loop length is set in the control script), which can be done by the green toogle buttons
- once armed you can tell Sonic Pi to actually record with the Go-button (wich just evaluates the lib-file)
- the recording will start with the next loop cycle
- once you recorded it’ll start play back in the next loop cycle
- via touchosc you can also set the playback amp and you can toggle if the track is played at all (this also requires to press the Go-button as the code has to be evaluated)
As I said, just a prototype. Probably things will change and hopefully get better.
lib (stored as a file):
# Basic live looper library with touchOSC control
# filename: lib-live-looper-touchosc.rb
use_bpm get(:my_bpm)
t1 = buffer[:track1, get(:track1_len)]
defonce :track_one_vol do
set :track1_vol, 1
end
live_loop :metro do
sample :elec_blip, amp: get(:metro_vol), rate: 0.895
sleep 4
end
live_loop :track1 do
use_real_time
c = sync "/osc/rec/track1_arm"
set :track, c[0]
end
live_loop :track1_vol do
use_real_time
c = sync "/osc/rec/track1_vol"
set :track1_vol, c[0]
end
# Record track 1
if get(:track) == 1.0
in_thread sync: :metro do
with_fx :record, buffer: t1 do
live_audio :audio_in, stereo: true
end
end
end
live_loop :track1_play do
use_real_time
c = sync "/osc/rec/track1_play"
set :track1_play, c[0]
end
# Replay Track(s)
live_loop :play_track1, sync: :metro do
stop if get(:track1_play) == 0.0
sample t1, amp: get(:track1_vol)
sleep get(:track1_len)
end
controler
(to be loaded and executed in a buffer):
# FIXME: most of that not yet used...
set :metro_vol, 0.5
set :my_bpm, 120
set :playback_master, 10
set :rec_level, 2
set :track1_len, 8
set :track2_len, 16
set :track3_len, 8
set :track4_len, 8
live_loop :setup do
use_real_time
p = sync "/osc/rec/go"
puts "---------- #{p} --------------"
if p[0] > 0 then
# adjust this to where the file lib-live-looper-touchosc.rb
# is on your harddrive; I did set up a function for that in init.rb
run_file live_looper_touchosc
if get(:track) == 0 then
puts "-----------------------------------------"
puts ""
puts ""
puts " No Track armed. "
puts " "
puts " "
puts "-----------------------------------------"
else
puts "-----------------------------------------"
puts ""
puts ""
puts " Prepare for recording on TRACK No. #{get(:track)} ..."
puts " "
puts " "
puts "-----------------------------------------"
end
end
end
touchosc-layout sonicpi-live-looper.touchosc
(how you can transfer to touchosc and use it as a custom layout has @robin.newman thankfully explained in a video (about 4’40) ):
<?xml version="1.0" encoding="UTF-8"?>
<layout version="16" mode="3" w="320" h="540" orientation="horizontal">
<tabpage name="dHJhY2sxX3ZvbA==" scalef="0.0" scalet="1.0" li_t="" li_c="gray" li_s="14" li_o="false" li_b="false" la_t="" la_c="gray" la_s="14" la_o="false" la_b="false" >
<control name="dHJhY2sxX2FybQ==" x="20" y="25" w="40" h="40" color="orange" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazFfYXJt" type="toggle" local_off="false" ></control>
<control name="dHJhY2syX2FybQ==" x="100" y="25" w="40" h="40" color="orange" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazJfYXJt" type="toggle" local_off="false" ></control>
<control name="dHJhY2szX2FybQ==" x="180" y="25" w="40" h="40" color="orange" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazNfYXJt" type="toggle" local_off="false" ></control>
<control name="dHJhY2s0X2FybQ==" x="260" y="25" w="40" h="40" color="orange" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazRfYXJt" type="toggle" local_off="false" ></control>
<control name="bGFiZWwy" x="26" y="34" w="28" h="25" color="yellow" type="labelh" text="MQ==" size="20" background="false" outline="false" ></control><control name="bGFiZWwz" x="106" y="33" w="28" h="25" color="yellow" type="labelh" text="Mg==" size="20" background="false" outline="false" ></control>
<control name="bGFiZWw0" x="186" y="34" w="28" h="25" color="yellow" type="labelh" text="Mw==" size="20" background="false" outline="false" ></control><control name="bGFiZWw1" x="266" y="34" w="28" h="25" color="yellow" type="labelh" text="NA==" size="20" background="false" outline="false" ></control>
<control name="Z28=" x="20" y="383" w="280" h="45" color="yellow" scalef="0.0" scalet="1.0" osc_cs="L3JlYy9nbw==" type="push" local_off="false" sp="true" sr="true" ></control>
<control name="bGFiZWw2" x="110" y="395" w="80" h="25" color="yellow" type="labelh" text="R08=" size="26" background="false" outline="false" ></control>
<control name="dHJhY2sxX3ZvbA==" x="20" y="96" w="40" h="220" color="green" scalef="0.0" scalet="3.0" osc_cs="L3JlYy90cmFjazFfdm9s" type="faderv" response="absolute" inverted="true" centered="false" ></control>
<control name="dHJhY2syX3ZvbA==" x="100" y="96" w="40" h="220" color="green" scalef="0.0" scalet="3.0" osc_cs="L3JlYy90cmFjazJfdm9s" type="faderv" response="absolute" inverted="true" centered="false" ></control>
<control name="dHJhY2szX3ZvbA==" x="180" y="96" w="40" h="220" color="green" scalef="0.0" scalet="3.0" osc_cs="L3JlYy90cmFjazNfdm9s" type="faderv" response="absolute" inverted="true" centered="false" ></control>
<control name="dHJhY2s0X3ZvbA==" x="260" y="96" w="40" h="220" color="green" scalef="0.0" scalet="3.0" osc_cs="L3JlYy90cmFjazRfdm9s" type="faderv" response="absolute" inverted="true" centered="false" ></control>
<control name="dHJhY2sxX3BsYXk=" x="20" y="329" w="40" h="40" color="green" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazFfcGxheQ==" type="toggle" local_off="false" ></control>
<control name="bGFiZWw3" x="26" y="338" w="28" h="25" color="yellow" type="labelh" text="MQ==" size="20" background="false" outline="false" ></control>
<control name="dHJhY2syX3BsYXk=" x="100" y="329" w="40" h="40" color="green" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazJfcGxheQ==" type="toggle" local_off="false" ></control>
<control name="dHJhY2szX3BsYXk=" x="180" y="329" w="40" h="40" color="green" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazNfcGxheQ==" type="toggle" local_off="false" ></control>
<control name="dHJhY2s0X3BsYXk=" x="260" y="329" w="40" h="40" color="green" scalef="0.0" scalet="1.0" osc_cs="L3JlYy90cmFjazRfcGxheQ==" type="toggle" local_off="false" ></control>
<control name="bGFiZWw4" x="106" y="338" w="28" h="25" color="yellow" type="labelh" text="Mg==" size="20" background="false" outline="false" ></control>
<control name="bGFiZWw5" x="186" y="337" w="28" h="25" color="yellow" type="labelh" text="Mw==" size="20" background="false" outline="false" ></control>
<control name="bGFiZWwxMA==" x="266" y="338" w="28" h="25" color="yellow" type="labelh" text="NA==" size="20" background="false" outline="false" ></control>
<control name="bGFiZWwxMQ==" x="13" y="1" w="112" h="25" color="yellow" type="labelh" text="QXJtIGZvciBSZWNvcmRpbmc=" size="10" background="false" outline="false" ></control>
<control name="bGFiZWwxMg==" x="-10" y="71" w="112" h="25" color="green" type="labelh" text="UGxheWJhY2s=" size="10" background="false" outline="false" ></control>
</tabpage>
</layout>