Help with code that's not working

Hello, I’m working on a project using TouchOSC on iPhone connected to SonicPI on computer.

The loop doesn’t seem to be working, just hear a single sound and then it stops.

Might someone please be able to look review this screenshot for possible errors??

Many thanks!!

It’s waiting for the next osc message

1 Like

Thank you, so the phone is connected and when we move it around we see all the inputs coming into the cues area (in orange), just no effect on the sound.

have you ticked the OSC network settings in Preferences? Can you try

puts acc[1]

to help debug? Here’s a simple OSC tester, which sends OSC from Sonic Pi back to itself:

/loopback OSC s-r test/

/SPi listen port: 4560/

use_osc "localhost", 4560 #receiver

live_loop :sendFromSPi do
  osc "/play", rrand_i(58,72), d
  sleep d

live_loop :receiveToSpi do
  n,d = sync "/osc*/play"
  play n, release: d

You should hear random pitches when you run this. If this works then the issue may be the OSC settings on your phone.


1 Like

use_osc "localhost",4560
live_loop :testSend do 
  osc "/accxyz",rrand(-1,1),rrand(-1,1),rrand(-1,1)
  sleep 0.2

live_loop :accxyz do
  acc = sync "/osc*/accxyz"
  y = acc[1]
  x = acc[0]
  z = acc[2]
  puts y.abs
  sample :ambi_soft_buzz,rate: y.abs * 10,amp: 4

This worked on my Mac. I simulated the op from the iPhone with the testSend loop.I dropped out the final sleep. as the sync delays until you get a fresh message. It may be that the rate of messages is very high from the iPhone, but I haven’t tried it. I think you have a superfluous / at the end of the sync address. Also you can use wild card * match" /osc*/accxyz"

This worked, thank you!! Big help.