miegl / PiFmAdv

Advanced Raspberry Pi FM transmitter with RDS encoding
GNU General Public License v3.0
484 stars 82 forks source link

[Guide] Use MP3 natively without sox #97

Open MrBoombastic opened 1 year ago

MrBoombastic commented 1 year ago

Since libsndfile1-dev version 1.1.0 supports MP3 (http://libsndfile.github.io/libsndfile/#history), we can update that library to support MP3 playback via PiFmAdv. However, this version is not supported in current Raspbian (Bullseye). Fortunately, we can use Raspbian Bookworm repo.

  1. Update your RPi (optional, but recommended). sudo bash -c 'for i in update {,dist-}upgrade auto{remove,clean}; do apt-get $i -y; done'

  2. Edit /etc/apt/sources.list file using your favourite editor, for example sudo vim /etc/apt/sources.list. In my case, the file looks like this:

    deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
    # Uncomment line below then 'apt-get update' to enable 'apt-get source'
    #deb-src http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

    Replace bullseye with bookworm.

    deb http://raspbian.raspberrypi.org/raspbian/ bookworm main contrib non-free rpi
  3. Run sudo apt update. It wil say that 69420 packages can be updated - ignore that.

  4. Run sudo apt install libsndfile1-dev. It will update only this package and its dependencies.

  5. Confirm that libsndfile1-dev is now version 1.1.0 or later. Run sudo apt-cache policy libsndfile1-dev. My output:

    libsndfile1-dev:
    Installed: 1.1.0-2 
    (...)
  6. Repeat step 1, but now revert bookworm to bullseye.

Congratulations, now you can use MP3 files with PiFmAdv without using sox! 🎉