# Sonic Pi, Processing and OSC

**URL:** <https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667>\
**Category:** Support, Help & Resources\
**Created:** [August 27, 2019, 6:35pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667 "2019-08-27T18:35:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 27, 2019, 6:35pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/1 "2019-08-27T18:35:27Z")

</div>

Hello everyone! My first post here so be kind.  
I’m really enjoying this piece of software, and wanted to have a go at combining it with another favorite of mine, processing. I’ve been able to send OSC messages to sonic pi from processing, but I’m having a hard time sending messages from sonic pi to processing.

I’ve tried different variations of “localhost”, my local IP and the good old 127.0.0.1 but none of them seem to do the trick.

My installation is from the official Arch repositories.

I’m really new to the whole OSC thing, so it’s most likely me messing something up, but I was wondering if someone had some simple working code examples they would be willing to share with me.  
I’m approaching tearing out hair level.

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [August 28, 2019, 7:29am UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/2 "2019-08-28T07:29:19Z")

</div>

Here is a project I did a couple years ago which controlled processing using OSC.

> [@Frere Jaques with processing visualisation](http://in-thread.sonic-pi.net/t/frere-jaques-with-processing-visualisation/564):
>
> One of the coolest additions that Sonic Pi 3 brings is the ability to send and receive OSC messages. This is much more versatile that midi and enables sonic pi to communicate with a wide range of other devices and programs. In this example a take an old friend Frere Jaqeus, and play it as a four part round, but send informations via OSC messages to a processing sketch, which uses the information ot ocntrol the position, size and colour of four circles, each one of which responds to a separate pa…

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 28, 2019, 8:07am UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/3 "2019-08-28T08:07:29Z")

</div>

Thanks so much for the help!  
But I’m having the same issue with your code, no signals are reaching the processing sketch, so annoying!

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [August 28, 2019, 8:41am UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/4 "2019-08-28T08:41:51Z")

</div>

What platform/OS are you working on? Is your processing sketch on the same machine as Sonic Pi?  
I’ll try a few experiments here, and check out if my code is still OK .

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 28, 2019, 9:26am UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/5 "2019-08-28T09:26:43Z")

</div>

I’m on Archlinux and everything is running on the same machine. Thanks for trying!

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 28, 2019, 10:53am UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/6 "2019-08-28T10:53:32Z")

</div>

Tried on another computer running windows, your code worked fine, so there’s something weird going on with my linux laptop, I’m no networking wizard but I’m guessing the problem may be there, have to investigate further.

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 28, 2019, 8:44pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/7 "2019-08-28T20:44:27Z")

</div>

I’ve experimented using the oscdump utility from the liblo package, and nothing shows up there either. Could there be something going with the Sonic-Pi that’s in the arch repositories?

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [August 29, 2019, 11:34am UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/8 "2019-08-29T11:34:00Z")

</div>

What version of Sonic Pi is it?

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 29, 2019, 11:51am UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/9 "2019-08-29T11:51:02Z")

</div>

It’s 3.1.0-7, installed from [https://www.archlinux.org/packages/community/x86\_64/sonic-pi/](https://www.archlinux.org/packages/community/x86_64/sonic-pi/)

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [August 29, 2019, 7:20pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/10 "2019-08-29T19:20:00Z")

</div>

Try running this test code. It sends data via OSC from Sonic Pi back to itself

```ruby
use_osc "localhost",4559
live_loop :sendtest do
  d=[0.2,0.4].choose
  osc "/play",rrand_i(48,84),d
  sleep d
end

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

```

That should check if OSC messages are being sent and received.

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 29, 2019, 8:11pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/11 "2019-08-29T20:11:17Z")

</div>

Not getting any sound over here

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [August 29, 2019, 10:05pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/12 "2019-08-29T22:05:23Z")

</div>

can you see any osc cues in the cue log?  
IF not try clicking the tick beside enable OSC server in the prefs IO section.  
Turn it off then on again and rerun the program.  
IF it was Off already then that is probably the problem.

If the program doesn’t work looks like there is something wrong with your SP

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 30, 2019, 1:22pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/13 "2019-08-30T13:22:25Z")

</div>

I’ve tried turning it off and on again 🙂  
Maybe I’ll have a go at compiling the whole thing from source and see if that helps, I’m no linux wizard, but I’ll try!  
Thanks again for trying to help me out!

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [August 30, 2019, 2:21pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/14 "2019-08-30T14:21:38Z")

</div>

IF you build latest 3.2dev then beware of several changes to port allocation, and also there IS a bug there still to be sorted where you DO have to turn OSC server off then on again before OSC messages work, by clicking the box in the IO preferences.  
Also Sonic Pi receives messages on port 4560 not 4559 as in version 3.1  
Also received cues coming in to sonic pi contain additional info

if you send “/play”,60 the cue you receive in the cue log looks like `/osc:127.0.0.1:4561/play [60]`  
To sync this you can use

`n = sync "osc*/play"`

`n=sync "osc/play"` will NOT match

The `*` matches all the extra stuff which you don’t normally need.

A final change is that some other ports are dynamically allocated, including the server Listen port which receives osc commands from the gui to Sonic Pi. The actual value allocated is shown in the server-output.log Since this port is used by programs like the sonic-pi-cli command they will be broken.  
I discussed this, and the post of an updated version [here](http://in-thread.sonic-pi.net/t/sonic-pi-cli-for-sonic-pi3-2dev/2664)

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 30, 2019, 6:53pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/15 "2019-08-30T18:53:45Z")

</div>

This whole compiling business is way above my level of computer wizardry, been hacking away at error messages and finally got to the point where I’m going to issue the final make command, but it fails with some deprecated declaration.

Think I need a pause from this to keep the few bits of sanity I have left.

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [August 30, 2019, 7:19pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/16 "2019-08-30T19:19:57Z")

</div>

Hi @andars,

I am really sympathising with your last post. I sometimes also just need a break. Technology can be very frustrating and tiring - sometimes… then again joyful bliss about things that finally work …

You are writing, that you _can receive_ OSC in SP but you _can’t send_ OSC messages, right? Did you try to [compile the erlang files](http://in-thread.sonic-pi.net/t/sending-osc-not-working/1525/3)? Just a shot in the dark but the [symptoms described in this thread](http://in-thread.sonic-pi.net/t/sending-osc-not-working/1525) match your description.

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 30, 2019, 7:59pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/17 "2019-08-30T19:59:06Z")

</div>

The problem is I haven’t built the version I’m running myself, it’s installed from the arch repositories. I’m guessing the compilation of the erlang files would only have effect if I compiled it from source myself?

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [August 30, 2019, 9:00pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/18 "2019-08-30T21:00:19Z")

</div>

Well, yes, might be true. I don’t know enough about it…

But you could try just to compile the Erlang part:

- Download osmid: [https://github.com/llloret/osmid](https://github.com/llloret/osmid)
- Follow the build instructions in …/osmid-master/INSTALL.md
- Copy files `m2o` and `o2m` to [SonicPiInstallation]/app/server/native/linux/osmid] (you will have to check were these files lie in your current installation; I am not sure that this information is still right)

This might be worth a try … once you’ll have paused a bit 😉

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [August 30, 2019, 9:39pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/19 "2019-08-30T21:39:08Z")

</div>

I can sympathise with how you feel. Recently I spent several weeks trying to debug my build of 3.2dev on a Mac. Very frustrating, but I got there in the end. Turned out that the boost library I was using had been upgraded! Once I adjusted it to be the same as the one used in SuperCollider all was well again.

One word of caution about doing your own build on the latest 3.2dev source. recently there has been a revision of the layout of files in the gui/qt folder. Make sure you base your build on a recipe which is up to date. The post I did recently about [building on a Raspberry Pi4](http://in-thread.sonic-pi.net/t/building-sp3-2dev-from-source-on-a-pi4/2645) gives an indication of what is involved, although it would have to be tweaked for archlinux.

---

<div class="post-metadata">

**Author:** ![andars](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/andars/32/1056_2.png) [@andars](https://in-thread.sonic-pi.net/u/andars)\
**Post date:** [August 30, 2019, 11:39pm UTC](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667/20 "2019-08-30T23:39:29Z")

</div>

I managed to compile it! And it sends OSC!  
had to disable warnings to get past some deprecated QSignalmapper stuff, but it works!

[Next page](https://in-thread.sonic-pi.net/t/sonic-pi-processing-and-osc/2667.md?page=2)
