This is what you need: a routine that uses an undocumented call in Sonic Pi which enables you to extract the actual osc message used to trigger the previous sync
I have used it over several years, together with a similar one for midi messages. (The latter had to be updated when midi messages were restructured in Sonic Pi see this post
use_osc "localhost",4560
use_debug false
use_osc_logging false
define:parse_sync_address do |address| #gets info on wild cards used in sync address
v= get_event(address).to_s.split(",")[6]
if v != nil
#return a list of address elements with wild cards substituted by actual values
return v[3..-2].split("/")
else
return ["error"]
end
end
live_loop :findpushed do
v = sync "/osc*/push*" #respond to button osc and save data in v[0]
res = parse_sync_address("/osc*/push*") #use parse routing to extract actual osc message
puts res #shows the output of parse_sync address
puts "button ",res[1],"was triggered"
puts "this has index",res[1][4..-1].to_i
puts "data value sent was",v[0]
end
live_loop :test do #this loop generates osc calls from 30 virtual push buttons
n = rrand_i(1,30)
message = "/push"+n.to_s
osc message,[0,1].choose #chooses random data 0 or 1 to send from push buton
sleep 1
end
In this example I send messages from virtual push buttons named push1 to push30 with data 0 or 1 and use a single live_loop to extract the data and work out which button was activated and what data it sent.
I have used this technique very extensively especially with touchOSC interfaces.