sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.74k stars 918 forks source link

No GUI/Headless install for Linux #3407

Open tloureiro opened 1 month ago

tloureiro commented 1 month ago

I want to be able to install only the server, so I can send OSC messages to it using VScode. I have SuperCollider installed/running already.

Thanks!


Edit: I ended up figuring it out for Ubuntu 24.04, and I started working on a VSCode extension Sonic Pi Studio

tloureiro commented 1 month ago

How to do install server only on Ubuntu 24.04

You should be able to start the server now. Run ruby ./sonic-pi/app/server/ruby/bin/daemon.rb - some numbers will be printed out; these are port numbers (and the token number). If no OSC command is sent, the server shuts itself down after 90 seconds due to the Zombie Kil Switch

Testing method 1 Using a hacky/modified version of @rbnpi's gem. It's a simple gem, you can download it, modify the sonic_pi4.rb file, remove/comment out the 2 break instructions in this file, and this should do the trick. Also, on sonic_pi4.rb, make sure you change the require 'sonic_piRBN.rb' to require './sonic_piRBN.rb' Now you can run ruby sonic_pi4.rb play 72 and hear the note playing.

Testing method 2 The dev branch has the recent addition of Sonic Pi REPL (See @samaaron reply below with the video on how to use it)

vomitHatSteve commented 1 month ago

So you do have an sonicpi server running and playing audio with this technique?

If no OSC command is sent, the server shuts itself down after some time

The timeout is, what? 3 seconds? How do you keep that from happening?

I've been fighting with with a headless mode since upgrading to version 4.x for a month or two. I'll try your techniques and see if I can get it working.

vomitHatSteve commented 1 month ago

Also, what Linux distro are you on? I'm on Ubuntu 24.04 LTS

tloureiro commented 1 month ago

@vomitHatSteve

The timeout is of 90 seconds, I believe, and it's because of the Zombie Kil Switch - the GUI keeps it alive by constantly hitting a daemon OSC endpoint /daemon/keep-alive.

Right now I'm working on a VScode extension that will try to manage the OSC messaging and will also do some code syntax colouring and basic code completion

Also, what Linux distro are you on? I'm on Ubuntu 24.04 LTS

Xubuntu 24.04 - pipewire installed by default

Please let me know if you get stuck anywhere :+1:

tloureiro commented 1 month ago

I'm still working on the vscode plugin, very early phases. Right now, you can start, stop, and play a test note using the vscode prompt. This is my developing branch https://github.com/tloureiro/sonic-pi-studio/tree/version-1

I'll work on sending the contents of the current file to the server next.

samaaron commented 1 month ago

Hiya,

I've just created a very simple barebones REPL to help people work on alternative front-ends:

https://github.com/sonic-pi-net/sonic-pi/commit/05e49e4d949cfe5da6fc52d34abff5053a374143

samaaron commented 1 month ago

https://github.com/user-attachments/assets/0757825b-af64-44ff-bf51-1d673ef6f8ca

tloureiro commented 1 month ago

@samaaron EXCELENT idea, thank you. I will update the instructions

@vomitHatSteve even easier way to to test if the install worked ok

vomitHatSteve commented 3 weeks ago

And immediately after everyone else posted I got sick for a week and then went on vacation. OK, so I got an opportunity to download the latest push and try the repl tool. My results were not good

Running as root (don't judge me)

I ran ./app/linux-clean.sh to clean up the previous install Next ./app/linux-build-all.sh ran without error that I noticed Then I rebooted to ensure no lingering processes Then attempted the repl:

# ./bin/sonic-pi-repl.sh
-- Sonic Pi Daemon started with PID: 1350
-- Log files are located at: /root/.sonic-pi/log
-- OSC Cues port: 0
#<Thread:0x0000715fdedb5ce0 ../app/server/ruby/bin/repl.rb:50 run> terminated with exception (report_on_exception is true):
-- Waiting for Sonic Pi to boot...
/usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:113:in `block in encode_single_message': Unknown arg type to encode: nil (RuntimeError)
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:58:in `each'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:58:in `encode_single_message'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/udp_client.rb:32:in `send'
        from ../app/server/ruby/bin/repl.rb:65:in `block (2 levels) in initialize'
        from ../app/server/ruby/bin/repl.rb:64:in `loop'
        from ../app/server/ruby/bin/repl.rb:64:in `block in initialize'
#<Thread:0x0000715fdedb3d78 ../app/server/ruby/bin/repl.rb:76 run> terminated with exception (report_on_exception is true):
/usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:113:in `block in encode_single_message': Unknown arg type to encode: nil (RuntimeError)
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:58:in `each'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:58:in `encode_single_message'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/udp_client.rb:32:in `send'
        from ../app/server/ruby/bin/repl.rb:79:in `block in initialize'

^C
Killing the Sonic Pi Daemon...
The Daemon has been vanquished!

Farewell, artistic coder.
May you live code and prosper...

                                ╘
                         ─       ╛▒╛
                          ▐╫       ▄█├
                   ─╟╛      █▄      ╪▓▀
         ╓┤┤┤┤┤┤┤┤┤  ╩▌      ██      ▀▓▌
          ▐▒   ╬▒     ╟▓╘    ─▓█      ▓▓├
          ▒╫   ▒╪      ▓█     ▓▓─     ▓▓▄
         ╒▒─  │▒       ▓█     ▓▓     ─▓▓─
         ╬▒   ▄▒ ╒    ╪▓═    ╬▓╬     ▌▓▄
         ╥╒   ╦╥     ╕█╒    ╙▓▐     ▄▓╫
                    ▐╩     ▒▒      ▀▀
                         ╒╪      ▐▄

       _____             __        ____  __
      / ___/____  ____  /_/____   / __ \/_/
      \__ \/ __ \/ __ \/ / ___/  / /_/ / /
     ___/ / /_/ / / / / / /__   / ____/ /
    /____/\____/_/ /_/_/\___/  /_/   /_/

   The Live Coding Music Synth for Everyone

            http://sonic-pi.net

/usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:113:in `block in encode_single_message': Unknown arg type to encode: nil (RuntimeError)
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:58:in `each'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/oscencode.rb:58:in `encode_single_message'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/osc/udp_client.rb:32:in `send'
        from ../app/server/ruby/bin/repl.rb:61:in `block (2 levels) in initialize'
/usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:34:in `sleep': Interrupt
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:34:in `wait'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:34:in `block in get'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:32:in `synchronize'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:32:in `get'
        from ../app/server/ruby/bin/repl.rb:87:in `initialize'
        from ../app/server/ruby/bin/repl.rb:354:in `new'
        from ../app/server/ruby/bin/repl.rb:354:in `<main>'
/usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:34:in `sleep': Interrupt
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:34:in `wait'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:34:in `block in get'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:32:in `synchronize'
        from /usr/src/sonic-pi/app/server/ruby/lib/sonicpi/promise.rb:32:in `get'
        from ../app/server/ruby/bin/repl.rb:87:in `initialize'
        from ../app/server/ruby/bin/repl.rb:354:in `new'
        from ../app/server/ruby/bin/repl.rb:354:in `<main>'

I'm running Ubuntu 24.04 on an old Toshiba. The most notable hardware configuration I have going on is that there is a Lexicon Alpha USB interface plugged in. Its drivers work fine (aplay will play wavs)

I'll dig through more logs to see if I spot what went wrong, but if anyone else sees anything obvious, I'm all ears

kootenpv commented 2 weeks ago

How to do install server only on Ubuntu 24.04

  • Clone this repo, checkout whatever branch you want, preferably a stable one
  • Run sudo apt install supercollider pipewire-jack ruby3.2 ruby3.2-dev build-essential cmake ninja-build pkg-config libssl-dev erlang-dev erlang-xmerl elixir

I am confused, because when I try to run, it complains I don't have jackd installed. pipewire-jack has a different interface I believe than jack2, which is why I think they are not compatible? what am I missing

(I am using arch linux, not ubuntu, but don't think it makes a difference in this case)

tloureiro commented 2 weeks ago

@vomitHatSteve have you tried running ./linux-build-all.sh with the flag --system-libs ?

tloureiro commented 2 weeks ago

@kootenpv Do you have supercollider installed? It might be a dependency, and apt will install it

Can you share the command and the output you ran? thanks!

kootenpv commented 2 weeks ago

@tloureiro I made a new issue to separate it (supercollider looks to be working from the logs) https://github.com/sonic-pi-net/sonic-pi/issues/3413

vomitHatSteve commented 2 weeks ago

@vomitHatSteve have you tried running ./linux-build-all.sh with the flag --system-libs ?

I'll give it a try

Huh. It has repeatedly failed to find aubio, I'll have to figure that out

vomitHatSteve commented 2 weeks ago

Huh. Yeah that install failed with

CMake Error at api/CMakeLists.txt:44 (find_package):
  Could not find a package configuration file provided by "platform_folders"
  with any of the following names:

    platform_foldersConfig.cmake
    platform_folders-config.cmake

  Add the installation prefix of "platform_folders" to CMAKE_PREFIX_PATH or
  set "platform_folders_DIR" to a directory containing one of the above
  files.  If "platform_folders" provides a separate development package or
  SDK, be sure it has been installed.
tloureiro commented 2 weeks ago

@vomitHatSteve make sure you comment this 2 lines linux-build-all.sh

# "${SCRIPT_DIR}"/linux-config.sh "$@"
# "${SCRIPT_DIR}"/linux-build-gui.sh "$@"
vomitHatSteve commented 1 week ago

@vomitHatSteve make sure you comment this 2 lines linux-build-all.sh

# "${SCRIPT_DIR}"/linux-config.sh "$@"
# "${SCRIPT_DIR}"/linux-build-gui.sh "$@"

I've done so many passes on this that I forgot that step! headdesk

Anyway, compilation completed. Then I got the same errors trying to run the repl as the first time.

tloureiro commented 1 week ago

@vomitHatSteve were you able to run the server alone

ruby ./sonic-pi/app/server/ruby/bin/daemon.rb ?

vomitHatSteve commented 1 week ago

@tloureiro, nope

# ruby ./sonic-pi/app/server/ruby/bin/daemon.rb
SuperCollider Audio Server Boot Error
could not initialize audio.
terminate called without an active exception
Error. Unable to write to log file: closed stream
#<IOError: closed stream>

And .sonic-pi/logs/daemon.log says...

[2024-08-27 12:47:02] Welcome to the Daemon Booter
[2024-08-27 12:47:02] ----------------------------
[2024-08-27 12:47:02] SuperCollider inputs enabled by GUI
[2024-08-27 12:47:02] Booting Scsynth
[2024-08-27 12:47:02] Got Audio Settings toml hash: {:sound_card_name=>"Alpha"}
[2024-08-27 12:47:02] Unified Audio Settings toml hash: {"-H"=>"Alpha"}
[2024-08-27 12:47:02] Combined Audio Settings toml hash with GUI scsynth inputs hash: {"-H"=>"Alpha"}
[2024-08-27 12:47:02] Merged Audio Settings toml hash: {"-u"=>"REDACTED", "-a"=>"1024", "-m"=>"131072", "-D"=>"0", "-R"=>"0", "-l"=>"1", "-i"=>"16", "-o"=>"16", "-b"=>"4096", "-B"=>"127.0.0.1", "-H"=>"Alpha"}
[2024-08-27 12:47:02] Using default pipewire buffsize of: 1024
[2024-08-27 12:47:02] Using default pipewire samplerate of: 48000
[2024-08-27 12:47:02] Starting scsynth with LD_LIBRARY_PATH set to "/usr/${LIB}/pipewire-0.3/jack" so it uses pipewire's jack
[2024-08-27 12:47:02] No need to start Jackd, using pipewire instead
[2024-08-27 12:47:02] Process Booter - booting scsynth
[2024-08-27 12:47:02] Waiting for the SuperCollider Server to have booted...
[2024-08-27 12:47:02] Sending /status to server
[2024-08-27 12:47:02] [scsynth] could not initialize audio.
[2024-08-27 12:47:02] [scsynth] terminate called without an active exception
[2024-08-27 12:47:03] Unable to connect to SuperCollider
[2024-08-27 12:47:03] Extracting Scsynth info
[2024-08-27 12:47:03] sending ERROR to gui
[2024-08-27 12:47:03] ----
[2024-08-27 12:47:03] Selected ports:
[2024-08-27 12:47:03] {"spider-listen-to-gui"=>31605, "gui-send-to-spider"=>31605, "gui-listen-to-spider"=>31606, "spider-send-to-gui"=>31606, "scsynth"=>31607, "scsynth-send"=>31607, "osc-cues"=>4560, "tau"=>31608, "spider"=>31609, "phx"=>31610, "daemon"=>31611, "spider-listen-to-tau"=>31612}
[2024-08-27 12:47:03] Token: 1496101040
[2024-08-27 12:47:03] ----
[2024-08-27 12:47:03] Daemon Booter is now exiting.
[2024-08-27 12:47:03] Cleaning up any running processes...
[2024-08-27 12:47:03] Process Booter - no need to kill scsynth with pid 772933 and args ["-u", "31607", "-a", "1024", "-m", "131072", "-D", "0", "-R", "0", "-l", "1", "-i", "16", "-o", "16", "-b", "4096", "-B", "127.0.0.1", "-H", "Alpha"] - already terminated, wait_thr status: #<Process::Waiter:0x00007be11eb13228 dead>, false
[2024-08-27 12:47:03] Daemon Booter - Over and Out.

debug.log is empty

scsynth.lgo contains

could not initialize audio.
terminate called without an active exception
vomitHatSteve commented 1 week ago

Now, I am able to get a supercollider instance running if I manually use the settings that SP does and start an instance of Jackd first

I have yet to get any output from it tho