sonic-pi-net / sonic-pi

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

Build and run Sonic-Pi v4.50 on Linux Mint 21.3 (Virginia) #3396

Open idommason opened 7 months ago

idommason commented 7 months ago

(Apologies in advance, wasn't sure whether to put this in issues, or community, but it does highlight fixes for some issues if you try to do a build on Linux Mint)

These fixes for building Sonic Pi v4.50 that work on a brand new, vanilla install of Linux Mint 21.3 Virginia (the xfce version)

TL;DR

If you just want to install all the requirements, do the other prep and build:

sudo apt-get install -y build-essential git libssl-dev ruby-dev erlang-dev erlang-xmerl qt6-tools-dev qt6-tools-dev-tools libqt6svg6-dev libqt6opengl6-dev supercollider-server sc3-plugins-server alsa-utils libasound2-dev cmake ninja-build libspa-0.2-jack qt6-wayland libwayland-dev libxkbcommon-dev libegl1-mesa-dev libx11-dev libxft-dev libxext-dev qt5-qmake compton wireplumber qt6-l10n-tools libspa-0.2-bluetooth libtool python3-pip pipewire-audio-client-libraries libibus-1.0-dev

answer "yes" if asked about enabling realtime priority

Edit /etc/security/limits.d/audio.conf and uncomment the final line:

@audio - nice -19

Install jinja2 with pip3:

pip3 install jinja2 Install qpwgraph from Flatpak:

sudo flatpak install flathub org.rncbc.qpwgraph

Add the Elixir repositories and get a later version of Elixir - minimum is 1.14, currently this gets 1.15

sudo add-apt-repository ppa:rabbitmq/rabbitmq-erlang sudo apt update sudo apt install elixir erlang-dev erlang-xmerl

Add yourself to the "audio" group

sudo usermod -aG audio $USER

Disable pulseaudio:

systemctl --user disable pulseaudio pulseaudio.socket

Fix qmake to use qt6 not qt5:

sudo qtchooser -install qmake6 /usr/lib/qt6/bin/qmake sudo qtchooser -install qt6 /usr/lib/qt6/bin/qmake

Reboot

Clone the sonic-pi git repo:

git clone https://github.com/sonic-pi-net/sonic-pi.git ~/Development/sonic-pi

Change into the app folder:

cd ~/Development/sonic-pi/app

Run the linux prebuild script - this will find any problems that I have missed, or have changed since I posted this

./linux-prebuild.sh If this completes, do the full build:

./linux-build-all.sh

Run sonic-pi:

~/Development/sonic-pi/bin/sonic-pi

This should run, and you should have sound!

The Explanations:

There are a few differences and difficulties you will find if you try to follow the instructions for building on Debian Bookworm

https://github.com/sonic-pi-net/sonic-pi/blob/dev/BUILD-LINUX.md

Firstly there are some packages on that page that do not exist in Linux Mint, namely

qpwgraph - you need to install from FlatPak pipewire-jack - this is in pipewire-audio-client-libraries, not an individual package

You will also need to install a later version of Elixir as Sonic-Pi v4.50 needs at least Elixir v1.14, not 1.12.

You need to fix a couple of problems to switch over to using Qt6 and fix a missing Qt6 program that is no longer there by default.

This Qt6 missing package is qt6-l10n-tools which adds lconvert. It's in the big apt-get below

And the biggest problem I found was swapping my sound input and output to Pipepwire, but more of that later.

So let us fix some of those problems in advance before we even start building Sonic Pi

Lets do the major, modified, apt get first, including that qt6-l10n-tools, python3-pip, libtool, and also wireplumber - installing this latter program at the start might fix all the issues I had getting sound out of Sonic Pi with Pipewire.

sudo apt-get install -y build-essential git libssl-dev ruby-dev erlang-dev erlang-xmerl qt6-tools-dev qt6-tools-dev-tools libqt6svg6-dev libqt6opengl6-dev supercollider-server sc3-plugins-server alsa-utils libasound2-dev cmake ninja-build libspa-0.2-jack qt6-wayland libwayland-dev libxkbcommon-dev libegl1-mesa-dev libx11-dev libxft-dev libxext-dev qt5-qmake compton wireplumber qt6-l10n-tools libspa-0.2-bluetooth libtool python3-pip pipewire-audio-client-libraries libibus-1.0-dev

One part of the above will ask if you wish to enable Realtime (RT) in your kernel, you should answer yes

This will create the file /etc/security/limits.d/audio.conf

and you need to edit that file and uncomment the final line (the nice line) so that it reads:

@audio   -  rtprio     95
@audio   -  memlock    unlimited
@audio   -  nice      -19

You also need to add yourself to the audio group

sudo usermod -aG audio $USER

It's probably best to do a pip3 install of jinja2 at this point, or the linux-prebuild will fail

pip3 install jinja2

Now let's use Elixir's own PPA repositories to get a later version of Elixir (at time of posting this is 1.15)

See https://elixir-lang.org/install.html

sudo add-apt-repository ppa:rabbitmq/rabbitmq-erlang
 sudo apt update
 sudo apt install elixir erlang-dev erlang-xmerl

You also need to make sure you are using the Qt6 qmake

This involves using qtchooser

 sudo qtchooser -install qmake6  /usr/lib/qt6/bin/qmake
 sudo qtchooser -install qt6  /usr/lib/qt6/bin/qmake

You can then use qtchooser to list versions to see what you've just done:

qtchooser --list-versions

and you should see something like this

4
5
default
qmake
qmake6
qt4-x86_64-linux-gnu
qt4
qt5-x86_64-linux-gnu
qt5
qt6
qmake6 --version
QMake version 3.1
Using Qt version 6.2.4 in /usr/lib/x86_64-linux-gnu

Lets sort out qpwgraph now. I had to install this via a flatpak, otherwise you run into dependency issues if you search for the various .deb. packages that are available for Debian Bookworm or Ubuntu

This will install it:

sudo flatpak install flathub org.rncbc.qpwgraph

I don't think qpwgraph is necessary for the actual build, but it is useful if you have sound problems with Pipewire after the successful build.

You also need to set up Pipewire as your audio, not pulseaudio. Pulseaudio is a user level service, so to disable it:

systemctl --user disable pulseaudio pulseaudio.socket

This is all the prep done, and at this point, you have to logout to make yourself a member of the audio group, but a reboot is probably best, as that will also give you all the Realtime benefits.

So that's all the prep and fixes to the issues that will crop up if you just follow the instructions for building on Debian Bookworm on the sonic Pi GitHub site on a brand new Linux Mint 21.3 install

The Build

So lets do the git clone, now, and the build

git clone https://github.com/sonic-pi-net/sonic-pi.git ~/Development/sonic-pi

cd ~/Development/sonic-pi/app

and to build, now we've fixed all the potential problems. Personally, I would run the prebuild script first, if that fails, either I've missed a step, or something has changed (since April 2024), or you've missed a step... for example I found I needed to install libtool, and python-pip3 and then use pip3 to install jinja2, and a couple of other little things

./linux-prebuild.sh

If this completes, then run the linux-build-all.sh script

./linux-build-all.sh

This could take a 10 or more minutes, it also downloads any extras it requires for the build, so you do need internet access to do the build, and if you have a slow connection it will take longer...

This should now complete the build without error

To run Sonic Pi, you can run

~/Development/sonic-pi/bin/sonic-pi

So this is where you could run into issues between Pipewire vs Puluseaudio

I found that I had to disable pulseaudio and make sure that pipewire was running, and this is where you find you need to have uncommented that "nice" rule in /etc/security/limits.d/audio.conf (and need to be a member of group "audio")

pulseaudio runs as a user session, so to disable it

systemctl --user disable pulseaudio pulseaudio.socket

Then I rebooted again

In a VirtualBox VM running LinuxMint I found I had to install the libspa-0.2-bluetooth package as it was not there by default on a "Virtual" VM, so the pipewire-media-session was not running. I've included this in the big apt-get at the start of this guide.

However I also found that installing pipewire-media-session clashes with wireplumber - installing either one removes the other.

So I stuck with wireplumber

You should have sound output now with Sonic-Pi v4.50

If you don't use qpwgraph to check that your inputs and outputs in pipewire are getting connected. wireplumber seemed to sort this out for me by default, on a Linux Mint install on hardware. I had more problems with Pipewire on a VirtualBox one...

Sorry for the length of this, and it's not an issue in itself, it's an issue with the Documentation, specifically the

BUILD-LINUX.md but I hope I have addressed all the problems in that file specifically in reference to building on Linux Mint 21.3 and hopefully sorting out sound output

samaaron commented 7 months ago

Hiya, this is really great stuff. Would you be at all interested in condensing and writing this up as both modifications to BUILD-LINUX.md where appropriate and an additional document - say doc/BUILD-LINUX-MINT.md which contains instructions specific to Mint.

idommason commented 7 months ago

Hi Sam

Yes, no problem. I'll see if I can get something done over the weekend - although I do have a gig to play, using actual hardware synths with piano style keyboards...

idommason commented 6 months ago

hiyah

I've tested a build on a brand new, clean install of Debian Bookworm, and the only missing package is curl - so the ./linux-prebuild.sh fails pretty much immediately

Bookworm has qmake6 if you do the big "apt install" in the BUILD-LINUX.md, and the OS installer account is in the audio group by default, and has qpwgraph and pipewire-jack as package names, and sound worked out of the box

The package that asks about enabling realtime priority for sound is jackd2. I think you should add that people should answer yes to that question.

I've then wiped that and installed Linux Mint, and my description is mostly valid

A clean Linux Mint install does not add the installer account to the audio group, you do need to faff around with qtchooser, install a later version of Elixir, install qpwgraph from flatpak

and then I still had to faff around with pulseaudio and pipewire to get sound.

I will do another clean install of Linux Mint to discover getting that working from scratch as that seems to be the only point of failure that is a bit obscure.

It all builds OK if you follow my post above, you just have to fiddle about a bit to get the sound output / pipewire working.

I just need to clarify that

(oh, and the stable version is now v4.51)

idommason commented 6 months ago

I've now done a brand new install of Linux Mint 21.3 and written a BUILD-LINUX-MINT.md with the changes required for Linux Mint to build v4.5.1

Can I add the md file here so you can add it to the repository?

If so, well, let's try it...

BUILD-LINUX-MINT.md

The major change was to oust pulseaudio first, and then I didn't have issues with getting Sonic Pi to make sounds after I built it (which to me was the hardest part of the whole process)

I realise this isn't the place to tell people how to get pipewire to work, but these instructions do work on a completely fresh install of Linux Mint 21.3 (XFCE version)

idommason commented 6 months ago

PS As you can probably see, I used BUILD-LINUX.md as a template

And testing found that the only thing that needed adding to BUILD-LINUX.md (for Debian Bookworm) is to add curl to the list of packages pulled in by apt...