Learn creative coding writing simple programs

138. Processing talks to SuperCollider via OSC

We have previously taken a brief look at OSC (in episodes 102 and 105). OSC is something that lets different programs running in the same or in different computers communicate.

By using OSC we can send messages between Processing and SuperCollider. In this episode we make an old Processing program send messages to SuperCollider, so it can now produce sound.

In the Processing side we need a library called oscP5. If you don't have it installed, go to the Sketch menu, import Library, add Library, and search and install oscP5.

In the program I write I map the vertical position of the star to numbers between 0 and 1. If I would not do that, imagine I make SuperCollider produce nice sounds for my stars, and then I go and increase the height of my Processing sketch (changing size()). Suddenly, the numbers SuperCollider would receive could be larger, and maybe it would sound bad. If I map the vertical position to numbers between 0 and 1, the numbers received by SuperCollider will stay in the same range no matter what size() I use: always 0 to 1. When receiving values via OSC is good to have predictable ranges.

I will be doing more videos without introducing new concepts so you become more comfortable with the SuperCollider topics I introduced so far.

Tags: supercollider, osc, oscdef, oscp5, sound

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:
``` void setup() { size(600, 600); } ```