This is the code snippet to use osc from processing, you can use input values from mouse and keyboard via OSC to control the sonic pi sounds. Steps:
live_loop :foo do
use_real_time
a, b, c = sync "/osc*/trigger/prophet"
# Map a (mouseX) to MIDI note range
note = (40 + (a / 640.0) * 60).to_i
# Map b (mouseY) to cutoff frequency
cutoff = (60 + (b / 480.0) * 60).to_i
synth :prophet, note: note, cutoff: cutoff, sustain: c
##| puts "Note: #{note}, Cutoff: #{cutoff}, Sustain: #{c}"
sleep 0.5
end
Note: make sure you click on “Allow Incoming OSC” in Sonic Pi, you can find it in the menu IO>Allow Incoming OSC
It should look like this:
https://github.com/user-attachments/assets/36700413-2de1-4dda-bbff-f21f114df131