SonicPi REPL support
munshkr opened this issue · 4 comments
What's the first step to getting Sonic Pi connected to flok? I'm interested in looking into how to make this happen.
Hi @carltesta , for starters, it would be nice to know if there is a way to send code to Sonic PI from another process, as in a REPL by writing to its standard input. I remember that SonicPi was written in Ruby so I think it should be possible, but I'm not sure if this is still the case (I know it has some bits of Erlang now...). I also don't have it installed right now, but I'll try to do that this weekend.
Looking up how Troop communicates with SonicPi, apparently there is an OSC protocol for evaluating code in SonicPi:
https://github.com/Qirky/Troop/blob/529c5eb14e456f683e6d23fd4adcddc8446aa115/src/interpreter.py#L614-L666
We can do the same, by creating a custom REPL class (e.g. SonicPiREPL
), similar to the RemoteSclangREPL class, that uses OSC to send messages to SonicPI.
Another thing to be aware of is that on SonicPI you usually evaluate the whole code instead of blocks or paragraphs (like in Tidal or FoxDot).
Ok, I added support for sonicpi
target in flok-repl
, it's still in the 29-sonicpi
branch.
Apparently as of Sonic Pi 3.1, the OSC Control Port number changes randomly at boot, so I had to make flok-repl
read through the SonicPi log files and look up the port number there. I'm following what sonic-pi-cli does. Still I haven't been able to control it (nothing happens when I send a block of code), maybe a Windows permission issue?
It'd be great if someone can help me test this! I have SonicPi installed only on a Windows machine (still not working), and a simple test on Linux and Mac would be nice to have.