PYTHONSCRIPT
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
from gpiozero import DistanceSensor
from time import sleep
from pythonosc import osc_message_builder
from pythonosc import udp_client
sensor = DistanceSensor(echo=10, trigger=9)
sensor1 = DistanceSensor(echo=8, trigger=7)
sender = udp_client.SimpleUDPClient(‘127.0.0.1’, 4559)
while True:
pitch = round(sensor.distance * 100 + 30)
sender.send_message(’/play_this_p’, [pitch])
volume=round(sensor1.distance *100+30)
sender.send_message(’/play_this_v’, [volume])
sleep(0.1)
print(sensor.distance,0,sensor1.distance,1 )
sleep(1)
SONIC PI SCRIPT
live_loop :listen do
message = sync “/play_this_p”
note = message [:args][0]
message1 = sync “/play_this_v”
vol = message1[:args][0]
play note, amp: vol
end
The script is a python script to set up pitch and volume for a theremin machine. The output Was sent to Sonic PI by udp_client.SimpleUDPCClient and the sender.send_message call in sonic pi script The Sonic Pi scrip receives it and is supposed to give pitch and volume to audio output
In sonic pi I can see the cues box shows that data has been received by Sonic PI but there is no indication that this data is being sent to the “play” function in Sonic Pi. The oscilloscope sows no response and there is no sound output either. The Sonic Pi osc receive code is below this text. Can you give me some help here. I have tried the internet and l they do I refer me to your tutorial. Which I cannot find the reason for lack of communication in. Also what is the :arg for in this case.
Thanks for your help it has been a long time since I did coding so my brain is not working very well with this new program set.