I found the Sonic PI music synthesiser recently, and had fun playing with it (and the language is Ruby which is quite nice). I wondered whether it would be possible to use Julia to send OSC (Open Sound Control) instructions to it.
From the Sonic Pi manual (“Receiving OSC”, it suggests that it might be quite easy:
We can send OSC to Sonic Pi from any programming language that has an OSC library. For example, if we’re sending OSC from Python we might do something like this:
from pythonosc import osc_message_builder
from pythonosc import udp_client
sender = udp_client.SimpleUDPClient('127.0.0.1', 4560)
sender.send_message('/trigger/prophet', [70, 100, 8])
Or, if we’re sending OSC from Clojure we might do something like this from the REPL:
(use 'overtone.core)
(def c (osc-client "127.0.0.1" 4560))
(osc-send c "/trigger/prophet" 70 100 8)
So I found an OSC library written in Julia - GitHub - fundamental/OpenSoundControl.jl: Open Sound Control For Julia - and then realised that I don’t know anything about UDP socket programming.
Given the simplicity of the Python and Clojure code samples, I’m guessing it should be something as straightforward as this in Julia:
using OpenSoundControl, Sockets
sock = UDPSocket()
bind(sock, ip"127.0.0.1", 4560)
msg = OscMsg("/trigger/prophet", "[hhh]", 70, 100, 8)
send(sock, ip"127.0.0.1", 4560, msg.data)
but since this doesn’t work, perhaps I’ve missed something obvious. If anyone’s had any experience with this, or wants an excuse to play with synthesizers for a while, I’d love to know how to get it working!