vsariola / sointu

Fork of 4klang that can target 386, amd64 and WebAssembly. Tools run on Windows, Mac & Linux
MIT License
239 stars 15 forks source link

Play Sointu Tracks from Python #108

Closed LeStahL closed 9 months ago

LeStahL commented 9 months ago

Hi! I wrote a code that is able to play Sointu tracks from Python (Mainly to evaluate if it's viable in a Game Jam). It compiles a track and is able to play it asynchronously - and provides a timestamp. I also added a pyinstaller spec file to create an executable from it. I'm not entirely sure of its use case (Sointu is a size coding synth, and this results in a ~7 megabytes executable), but the journey to making it work on both linux and windows was annoying and might be worth documenting somehow. :D

I imagine writing Python bindings for the Sointu vm would be actually useful (for tools, or live coding from Python), and the mechanism used here could achieve that as well in theory - just let me know if you want me to add these instead of the diff here.

vsariola commented 9 months ago

Uh oh :D I most certainly am willing to merge it to the repo, just to document how it's done, but I also fail to see the practical use case. I'm thinking if binding something sointu-play functionality but as a library might be more useful i.e. playing arbitrary songs, not just one.

Sointu is not exactly designed to be used as a library, but I think with some thought a simple enough interface could be offered to compile and render songs. I'd imagine leaving the playback to the user of such a library would make more sense.

vsariola commented 9 months ago

Merged, yolo. Never saw a Python build executable before, so it was at least educational to me. Thanks!