mrbombmusic / sonic-pi-drum-rnn-gui

A GUI that uses Magenta Drum RNN to create and generate drum patterns to send to Sonic Pi via OSC
MIT License
22 stars 5 forks source link

Sending OSC to Sonic Pi. #2

Open githubtefo opened 3 years ago

githubtefo commented 3 years ago

Hi!

This code looks really interesting! I'm trying to run it on sonic-pi v3.2.2 on Linux, although I'm having issues to send the OSC patterns to Sonic Pi.

I'm creating a python server

❯ python3 -m http.server 8000 Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... 127.0.0.1 - - [08/May/2021 18:47:22] "GET / HTTP/1.1" 200 - 127.0.0.1 - - [08/May/2021 18:47:22] "GET /script.js HTTP/1.1" 200 - 127.0.0.1 - - [08/May/2021 18:47:22] "GET /style.css HTTP/1.1" 200 - 127.0.0.1 - - [08/May/2021 18:47:22] "GET /musicvae.js HTTP/1.1" 200 - 127.0.0.1 - - [08/May/2021 18:47:24] code 404, message File not found 127.0.0.1 - - [08/May/2021 18:47:24] "GET /favicon.ico HTTP/1.1" 404 -

...and then running the node bridge.js and open your index.html in chromium.

But after selecting a kit and sending a beat, when I run the Sonic-Pi-receiver.rb code it seems that none OSC is getting received. (The option "Enable OSC server" is marked in sonic-pi).

What did I do Wrong? Thank you for your help!

ethancrawford commented 2 years ago

@githubtefo - maybe it's possible that in your situation, the incoming OSC port number is different to what this drum script is using to send with? that happened to me on macOS. It was necessary for me to change the 4560 on this line: https://github.com/mrbombmusic/sonic-pi-drum-rnn-gui/blob/93a5f60cab9466924eb14cc467510411d790a44a/GUI%20Code/script.js#L4

To match what Sonic Pi said the incoming OSC port was here: Screen Shot 2022-01-02 at 11 55 37 am

(Which on my mac was a different number).

githubtefo commented 2 years ago

Thank you for your feedback. I double check the ports and both are 12004 and 4560 as in script.js. I am using v3.3.1... could it be a version problem?? Thanks again!

ethancrawford commented 2 years ago

@githubtefo if you have the Sonic Pi 'Cue Log' open, and test the basic example in the tutorial for sending OSC messages:

use_osc "localhost", 4560
osc "/hello/world"

Do you see a message like this appearing in the Cue Log?

 /osc:127.0.0.1:4560/hello/world  []
githubtefo commented 2 years ago

That is a good point. I am not seeing any messages on the Cue Log after running oscsend localhost 4560 hello I am not even seeing SuperCollider having any input for midi in the QcackCtl Graph neither, if related. I will look into this, but it seems a sonic-pi issue...

ethancrawford commented 2 years ago

Do you have port 4560 blocked by a firewall by any chance? 🤷‍♂️

githubtefo commented 2 years ago

I don't think so... for instance, I can do create the http server on that port:

❯ python3 -m http.server 4560 Serving HTTP on 0.0.0.0 port 4560 (http://0.0.0.0:4560/) ... 127.0.0.1 - - [17/Feb/2022 20:32:56] "GET / HTTP/1.1" 200 -

ethancrawford commented 2 years ago

Not sure what might be going on really. Are you able to share the contents of the non-empty log files in ~/.sonic-pi/log?

ethancrawford commented 2 years ago

(after trying the Sonic Pi OSC example I refer to above - eg trying to use Sonic Pi to send OSC to itself)

githubtefo commented 2 years ago

@githubtefo if you have the Sonic Pi 'Cue Log' open, and test the basic example in the tutorial for sending OSC messages:

use_osc "localhost", 4560
osc "/hello/world"

Do you see a message like this appearing in the Cue Log?

 /osc:127.0.0.1:4560/hello/world  []

Oh I see what you mean now... I´ve got this error when I tried it:

Runtime Error: [buffer 8, line 4] - Errno::ECONNREFUSED

This is the log of server-output.log

Sonic Pi server booting... The time is 2022-02-19 18:40:54 -0500 Using primary protocol: udp Detecting port numbers... Listen port: 51235

  • OK Scsynth port: 51237
  • OK Scsynth send port: 51237
  • OK OSC cues port: 4560
  • OK Erlang port: 51238
  • OK Websocket port: 4562
  • OK Opening UDP Server to listen to GUI on port: 51235 Starting Server Runtime Booting server...

Booting Sonic Pi

Booting on Linux Jackd already running. Not starting another server... Boot - Starting the SuperCollider server... Boot - SuperCollider booted successfully. Boot - Connecting to the SuperCollider server... Boot - Sending /status to server: 127.0.0.1:51237 Boot - Receiving ack from scsynth Boot - Server connection established Started [22277] [-] scsynth -u 51237 -a 1024 -m 131072 -D 0 -R 0 -l 1 -i 16 -o 16 -b 4096 -B 127.0.0.1 [-] /tmp/sonic-pi-pids/22277 Studio - Initialised SuperCollider Audio Server v3.12.2 Studio - Resetting server Studio - Studio - clearing scsynth Studio - Studio - allocating audio bus Studio - Studio - Create Base Synth Groups Studio - Starting mixer Studio - Starting scope exec erl +C multi_time_warp -noshell -pz "/usr/lib/sonic-pi" -sonic_pi_server api_port 51238 in_port 4560 cue_port 51235 enabled false -s pi_server start Server Runtime Initialised

This is Sonic Pi v3.3.1 running on linux with ruby version 3.0.3 with api 3.0.0. Sonic Pi Server successfully booted.

Started [22301] [-] sh [-] /tmp/sonic-pi-pids/22301

While these are the server-errors.log

ERROR system:capture_1 not a valid port ERROR system:capture_2 not a valid port OSC handler exception for address: /cue-port-start Connection refused - send(2) ["/usr/lib/sonic-pi/server/lib/sonicpi/osc/udp_client.rb:33:in send'", "/usr/lib/sonic-pi/server/lib/sonicpi/osc/udp_client.rb:33:insend'", "/usr/lib/sonic-pi/server/lib/sonicpi/runtime.rb:368:in __stop_start_cue_server!'", "/usr/bin/../../usr/lib/sonic-pi/server/bin/sonic-pi-server.rb:634:inblock (2 levels) in

'", "/usr/lib/sonic-pi/server/lib/sonicpi/osc/udp_server.rb:93:in block in start_listener'", "/usr/lib/sonic-pi/server/lib/sonicpi/osc/udp_server.rb:74:inloop'", "/usr/lib/sonic-pi/server/lib/sonicpi/osc/udp_server.rb:74:in start_listener'", "/usr/lib/sonic-pi/server/lib/sonicpi/osc/udp_server.rb:37:inblock in initialize'"]

Might be related to https://github.com/sonic-pi-net/sonic-pi/issues/2951? I'm also on Arch, installed from the AUR.

Thanks!

ethancrawford commented 2 years ago

Quite possibly. Do any of the suggestions there work for you? Do you feel you'd be able to try compiling it from source yourself?