Qirky / Troop

Real-time Live Coding collaboration app
306 stars 37 forks source link

Automatically discover Sonic Pi command port #59

Closed Sohalt closed 4 years ago

Sohalt commented 4 years ago

Sonic Pi no longer receives OSC messages on port 4557 but instead chooses a random free port for the communication between server and client. This PR automatically finds the correct port by parsing the Sonic Pi log file.

Qirky commented 4 years ago

Looks fine to me but presumably this always returns 4557 windows users right? Is there a default log directory on windows?

Sohalt commented 4 years ago

I don't have a Windows install to test, but I just checked the documentation and https://docs.python.org/3/library/os.path.html#os.path.expanduser seems to handle Windows just fine. I however found, that Sonic Pi uses a different path, when SONIC_PI_HOME is set (https://github.com/sonic-pi-net/sonic-pi/blob/main/app/gui/qt/mainwindow.cpp#L3001). I'll push a fix for that.

Sohalt commented 4 years ago

Also for some reason I get a AttributeError type object 'SonicPiInterpreter' has no attribute 'port'. But I get a working connection to Sonic Pi.

Qirky commented 4 years ago

Ah the error message is to do with the stop_sound method which is a class method. I'll approve the PR and change the class method to use the instance attributes