Issues with OSC on RPi3

Hello,

A little while ago I started messing around with Sonic Pi for a project on my Raspberry Pi. Using the pyOSC library I managed to send OSC messages to Sonic Pi and get it to do simple things such as play a note. I’m not sure exactly what I did between my initial tests and now, but for some reason when I send the same messages that used to work they don’t seem to work anymore. If I send “play :E2” to Sonic Pi I will see in the log output:

=> Starting run 22
{run: 22, time: 0.0}
-- synth :beep, {note:40.0}
=> Completed run 22
=> All runs completed
=> Pausing SuperCollider Audio Server

However, the strange thing is it won’t play any sound and I don’t see anything on the scope. If I just run “play :E2” within Sonic Pi itself it will output the same messages in the log and it will play the note.

I’m using Sonic Pi v3.0.1 on the Raspberry Pi 3.

Here is the Python code I am using which worked at one point when I first used Sonic Pi:

import OSC

c = OSC.OSCClient()
c.connect(('127.0.0.1', 4557))
msg = OSC.OSCMessage()
msg.setAddress('/run-code')
msg.append('PYTHON')
msg.append('play :E2')
c.send(msg)

I’m pretty clueless as to what the issue is. Does anyone have any suggestions for where to start?

Thanks,
Robert

Hi there,

sorry that you’re having issues - I’m sure we can sort you out and get up up and running soon :slight_smile:

Unfortunately, from the information you’ve given, it’s not clear what the issue is. May I ask two further things:

  1. Are you seeing the OSC messages arrive in the cue logger?
  2. What is the Sonic Pi code you’re trying to run?
  1. I can see the OSC messages in the cue logger.

  2. I do not have any code in Sonic Pi itself. From my Python code I am just trying to have Sonic Pi run something like “play :E2”

How curious!

Firstly, you’re trying to use the internal code transmission API that the GUI uses to send code to the server. There’s nothing inherently wrong with this, but it is important to say that it’s undocumented and unsupported at this point, so things may or may not change without warning from version to version.

Secondly, it’s really very odd that you’re seeing a "/run-code" cue being received in the cue logger. The cue logger should only log messages sent to the public (and supported) port 4559.

Please could you let me know what you can see in the cue logger?

I’ll have to apologize, I misunderstood your question about the cue logger. I could not see the /run-code cue when I was sending these cues to port 4557.

I believe at some point I did actually upgrade Sonic Pi to the most recent version, so from what you’re saying about that being unsupported may explain why what code I had previously working wasn’t working anymore. I just started looking into using “sync” in Sonic Pi with OSC on port 4559 with the latest version of Sonic Pi instead of using the internal code transmission API and I managed to get Sonic Pi to play notes through OSC. This seems to work a lot better than what I was doing originally any way.

Thanks for your time and assistance!

1 Like

Great to have been assistance - albeit in a rubber-duck kind of way :slight_smile:

Have fun! And please do let me know if you have any further questions…