diff --git a/documentation/builders/components/Readme.md b/documentation/builders/components/Readme.md new file mode 100644 index 000000000..f4d109032 --- /dev/null +++ b/documentation/builders/components/Readme.md @@ -0,0 +1,3 @@ +# Phoniebox components directory + +* [Hifberry](./hifiberry.md) \ No newline at end of file diff --git a/documentation/builders/components/hifiberry.md b/documentation/builders/components/hifiberry.md new file mode 100644 index 000000000..9aa3966f3 --- /dev/null +++ b/documentation/builders/components/hifiberry.md @@ -0,0 +1,41 @@ +# HiFiBerry + +## Automatic setup + +Use this install script to enable your HiFiBerry board. + +``` +$ cd; cd ~/RPi-Jukebox-RFID/installation/components && chmod +x setup-hifiberry.sh && sudo ./setup_hifiberry.sh +``` + +## Manual steps to enable sound through HiFiBerry board + +1. Make sure your onboard sound of your Raspberry Pi is disabled. Check `/boot/config.txt`. The installation + + ``` + dtparam=audio=off + ``` + +2. Run the following command to enable HiFiBerry boards. + + ``` + echo "dtoverlay=hifiberry-dac" | sudo tee -a /boot/config.txt + ``` + +3. Enable volume control. Create or edit the following file: `sudo vi /etc/asound.conf` + + ``` + pcm.hifiberry { + type softvol + slave.pcm "plughw:0" + control.name "HifiBerry" + control.card 0 + } + + pcm.!default { + type plug + slave.pcm "hifiberry" + } + ``` + +4. Restart your device. diff --git a/installation/components/setup_hifiberry.sh b/installation/components/setup_hifiberry.sh new file mode 100644 index 000000000..305d2d23d --- /dev/null +++ b/installation/components/setup_hifiberry.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Check if the script is run as root +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# Disable onboard sound of Raspberry Pi +echo "Disabling onboard sound..." +sed -i '/dtparam=audio=on/c\dtparam=audio=off' /boot/config.txt + +# Enable HiFiBerry board +echo "Enabling HiFiBerry board..." +grep -qxF 'dtoverlay=hifiberry-dac' /boot/config.txt || echo 'dtoverlay=hifiberry-dac' >> /boot/config.txt + +# Backup asound.conf +if [ -f /etc/asound.conf ]; then + echo "Backing up existing asound.conf..." + cp /etc/asound.conf "/etc/asound.conf.backup.$(date +%Y%m%d%H%M%S)" +fi + +echo "Configuring sound settings..." +cat > /etc/asound.conf << EOF +pcm.hifiberry { + type softvol + slave.pcm "plughw:0" + control.name "HifiBerry" + control.card 0 +} + +pcm.!default { + type plug + slave.pcm "hifiberry" +} +EOF + +echo "Configuration complete. Please restart your device." diff --git a/resources/default-settings/mpd.default.conf b/resources/default-settings/mpd.default.conf index 0e8025e4f..f2b2da6ac 100755 --- a/resources/default-settings/mpd.default.conf +++ b/resources/default-settings/mpd.default.conf @@ -11,7 +11,7 @@ # be disabled and audio files will only be accepted over ipc socket (using # file:// protocol) or streaming files over an accepted protocol. # -music_directory "%%JUKEBOX_AUDIOFOLDERS_PATH%%" +music_directory "/home/pi/RPi-Jukebox-RFID/shared/audiofolders" # # This setting sets the MPD internal playlist directory. The purpose of this # directory is storage for playlists created by MPD. The server will use @@ -19,7 +19,7 @@ music_directory "%%JUKEBOX_AUDIOFOLDERS_PATH%%" # format. This setting defaults to playlist saving being disabled. # # playlists are inside the Phoniebox path: -playlist_directory "%%JUKEBOX_PLAYLISTS_PATH%%" +playlist_directory "/home/pi/RPi-Jukebox-RFID/shared/playlists" # # This setting sets the location of the MPD database. This file is used to # load the database at server start up and store the database while the @@ -27,7 +27,7 @@ playlist_directory "%%JUKEBOX_PLAYLISTS_PATH%%" # MPD to accept files over ipc socket (using file:// protocol) or streaming # files over an accepted protocol. # -db_file "~/.config/mpd/tag_cache" +db_file "~/.config/mpd/tag_cache" # # These settings are the locations for the daemon log files for the daemon. # These logs are great for troubleshooting, depending on your log_level @@ -37,20 +37,20 @@ db_file "~/.config/mpd/tag_cache" # setting defaults to logging to syslog, or to journal if mpd was started as # a systemd service. # -log_file "syslog" +log_file "syslog" # # This setting sets the location of the file which stores the process ID # for use of mpd --kill and some init scripts. This setting is disabled by # default and the pid file will not be stored. # -pid_file "~/.config/mpd/pid" +pid_file "~/.config/mpd/pid" # # This setting sets the location of the file which contains information about # most variables to get MPD back into the same general shape it was in before # it was brought down. This setting is disabled by default and the server # state will be reset on server start up. # -state_file "~/.config/mpd/state" +state_file "~/.config/mpd/state" # # The location of the sticker database. This is a database which # manages dynamic information attached to songs. @@ -67,7 +67,7 @@ sticker_file "~/.config/mpd/sticker.sql" # initialization. This setting is disabled by default and MPD is run as the # current user. # -# user "root" +# user "root" # # This setting specifies the group that MPD will run as. If not specified # primary group of user specified with "user" setting will be used (if set). @@ -83,22 +83,22 @@ sticker_file "~/.config/mpd/sticker.sql" # activation is in use. # # For network -bind_to_address "localhost" +#bind_to_address "localhost" # # And for Unix Socket -#bind_to_address "/run/mpd/socket" +bind_to_address "/run/mpd/socket" # # This setting is the TCP port that is desired for the daemon to get assigned # to. # -port "6600" +port "6600" # # This setting controls the type of information which is logged. Available # setting arguments are "default", "secure" or "verbose". The "verbose" setting # argument is recommended for troubleshooting, though can quickly stretch # available resources on limited hardware storage. # -log_level "default" +log_level "default" # # Setting "restore_paused" to "yes" puts MPD into pause mode instead # of starting playback after startup. @@ -108,12 +108,12 @@ log_level "default" # This setting enables MPD to create playlists in a format usable by other # music players. # -#save_absolute_paths_in_playlists "no" +#save_absolute_paths_in_playlists "no" # # This setting defines a list of tag types that will be extracted during the # audio file discovery process. The complete list of possible values can be # found in the user manual. -#metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc" +#metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc" # # This example just enables the "comment" tag without disabling all # the other supported tags: @@ -137,12 +137,12 @@ auto_update_depth "10" # If this setting is set to "yes", MPD will discover audio files by following # symbolic links outside of the configured music_directory. # -#follow_outside_symlinks "yes" +#follow_outside_symlinks "yes" # # If this setting is set to "yes", MPD will discover audio files by following # symbolic links inside of the configured music_directory. # -#follow_inside_symlinks "yes" +#follow_inside_symlinks "yes" # ############################################################################### @@ -152,12 +152,12 @@ auto_update_depth "10" # If this setting is set to "yes", service information will be published with # Zeroconf / Avahi. # -#zeroconf_enabled "yes" +zeroconf_enabled "no" # # The argument to this setting will be the Zeroconf / Avahi unique name for # this MPD server on the network. %h will be replaced with the hostname. # -#zeroconf_name "Music Player @ %h" +#zeroconf_name "Music Player @ %h" # ############################################################################### @@ -253,47 +253,47 @@ audio_output { # An example of an ALSA output: # # audio_output { -# type "alsa" -# name "My ALSA Device" -# device "hw:0,0" # optional -# mixer_type "hardware" # optional -# mixer_device "default" # optional -# mixer_control "%%JUKEBOX_ALSA_MIXER_CONTROL%%" # optional -# mixer_index "0" # optional +# type "alsa" +# name "My ALSA Device" +# device "hw:0,0" # optional +# mixer_type "hardware" # optional +# mixer_device "default" # optional +# mixer_control "%%JUKEBOX_ALSA_MIXER_CONTROL%%" # optional +# mixer_index "0" # optional #} # # An example of an OSS output: # #audio_output { -# type "oss" -# name "My OSS Device" -# device "/dev/dsp" # optional -# mixer_type "hardware" # optional -# mixer_device "/dev/mixer" # optional -# mixer_control "PCM" # optional +# type "oss" +# name "My OSS Device" +# device "/dev/dsp" # optional +# mixer_type "hardware" # optional +# mixer_device "/dev/mixer" # optional +# mixer_control "PCM" # optional #} # # An example of a shout output (for streaming to Icecast): # #audio_output { -# type "shout" -# encoder "vorbis" # optional -# name "My Shout Stream" -# host "localhost" -# port "8000" -# mount "/mpd.ogg" -# password "hackme" -# quality "5.0" -# bitrate "128" -# format "44100:16:1" -# protocol "icecast2" # optional -# user "source" # optional -# description "My Stream Description" # optional -# url "http://example.com" # optional -# genre "jazz" # optional -# public "no" # optional -# timeout "2" # optional -# mixer_type "software" # optional +# type "shout" +# encoder "vorbis" # optional +# name "My Shout Stream" +# host "localhost" +# port "8000" +# mount "/mpd.ogg" +# password "hackme" +# quality "5.0" +# bitrate "128" +# format "44100:16:1" +# protocol "icecast2" # optional +# user "source" # optional +# description "My Stream Description" # optional +# url "http://example.com" # optional +# genre "jazz" # optional +# public "no" # optional +# timeout "2" # optional +# mixer_type "software" # optional #} # # An example of a recorder output: @@ -311,15 +311,15 @@ audio_output { # An example of a httpd output (built-in HTTP streaming server): # #audio_output { -# type "httpd" -# name "My HTTP Stream" -# encoder "vorbis" # optional, vorbis or lame -# port "8000" -# bind_to_address "0.0.0.0" # optional, IPv4 or IPv6 -# quality "5.0" # do not define if bitrate is defined -# bitrate "128" # do not define if quality is defined -# format "44100:16:1" -# max_clients "0" # optional 0=no limit +# type "httpd" +# name "My HTTP Stream" +# encoder "vorbis" # optional, vorbis or lame +# port "8000" +# bind_to_address "0.0.0.0" # optional, IPv4 or IPv6 +# quality "5.0" # do not define if bitrate is defined +# bitrate "128" # do not define if quality is defined +# format "44100:16:1" +# max_clients "0" # optional 0=no limit #} # # An example of a pulseaudio output (streaming to a remote pulseaudio server) @@ -327,50 +327,50 @@ audio_output { # daemon started as part of your graphical desktop session! # #audio_output { -# type "pulse" -# name "My Pulse Output" -# server "remote_server" # optional -# sink "remote_server_sink" # optional +# type "pulse" +# name "My Pulse Output" +# server "remote_server" # optional +# sink "remote_server_sink" # optional #} # # An example of a winmm output (Windows multimedia API). # #audio_output { -# type "winmm" -# name "My WinMM output" -# device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional -# or -# device "0" # optional -# mixer_type "hardware" # optional +# type "winmm" +# name "My WinMM output" +# device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional +# or +# device "0" # optional +# mixer_type "hardware" # optional #} # # An example of an openal output. # #audio_output { -# type "openal" -# name "My OpenAL output" -# device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional +# type "openal" +# name "My OpenAL output" +# device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional #} # ## Example "pipe" output: # #audio_output { -# type "pipe" -# name "my pipe" -# command "aplay -f cd 2>/dev/null" +# type "pipe" +# name "my pipe" +# command "aplay -f cd 2>/dev/null" ## Or if you're want to use AudioCompress -# command "AudioCompress -m | aplay -f cd 2>/dev/null" +# command "AudioCompress -m | aplay -f cd 2>/dev/null" ## Or to send raw PCM stream through PCM: -# command "nc example.org 8765" -# format "44100:16:2" +# command "nc example.org 8765" +# format "44100:16:2" #} # ## An example of a null output (for no audio output): # #audio_output { -# type "null" -# name "My Null Output" -# mixer_type "none" # optional +# type "null" +# name "My Null Output" +# mixer_type "none" # optional #} # ############################################################################### @@ -385,17 +385,17 @@ audio_output { # See for more details about ReplayGain. # This setting is off by default. # -#replaygain "album" +#replaygain "album" # # This setting sets the pre-amp used for files that have ReplayGain tags. By # default this setting is disabled. # -#replaygain_preamp "0" +#replaygain_preamp "0" # # This setting sets the pre-amp used for files that do NOT have ReplayGain tags. # By default this setting is disabled. # -#replaygain_missing_preamp "0" +#replaygain_missing_preamp "0" # # This setting enables or disables ReplayGain limiting. # MPD calculates actual amplification based on the ReplayGain tags @@ -404,13 +404,13 @@ audio_output { # above its original level. If replaygain_limit is disabled such amplification # might occur. By default this setting is enabled. # -#replaygain_limit "yes" +#replaygain_limit "yes" # # This setting enables on-the-fly normalization volume adjustment. This will # result in the volume of all playing audio to be adjusted so the output has # equal "loudness". This setting is disabled by default. # -volume_normalization "yes" +volume_normalization "yes" # ############################################################################### @@ -419,6 +419,6 @@ volume_normalization "yes" # If file or directory names do not display correctly for your locale then you # may need to modify this setting. # -filesystem_charset "UTF-8" +filesystem_charset "UTF-8" # -############################################################################### +############################################################################### \ No newline at end of file