Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:raspberrypi [2015/04/19 09:17] – [Disabling unneeded services] autostaticwiki:raspberrypi [2020/03/15 17:50] (current) – [On-board audio] autostatic
Line 18: Line 18:
 >//"The latest kernel has a cpufreq kernel driver with the "ondemand" governor enabled by default. It has no effect if you have no overclock settings. But when you do, the arm frequency will vary with processor load."//((http://elinux.org/RPiconfig#Overclocking)) >//"The latest kernel has a cpufreq kernel driver with the "ondemand" governor enabled by default. It has no effect if you have no overclock settings. But when you do, the arm frequency will vary with processor load."//((http://elinux.org/RPiconfig#Overclocking))
  
-So when overclocking your RPi for audio usage you should set the governor to ''performance'' as a scaling CPU can cause audible glitches. This can be done with the following command:+So when overclocking your RPi for audio usage you should set the governor to ''performance'' as a scaling CPU can cause audible glitches. This can be done with the following command on the RPi1:
   echo -n performance \   echo -n performance \
   | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor   | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 +  
 +RPi2:
 +  for cpu in /sys/devices/system/cpu/cpu[0-9]*; do echo -n performance \
 +  | sudo tee $cpu/cpufreq/scaling_governor; done
  
 Another option is to disable CPU frequency scaling by disabling it in the kernel. You can do this when modifying the kernel config (with for example ''make menuconfig'') by unticking CPU Power Management - CPU Frequency scaling - CPU Frequency scaling. Another option is to disable CPU frequency scaling by disabling it in the kernel. You can do this when modifying the kernel config (with for example ''make menuconfig'') by unticking CPU Power Management - CPU Frequency scaling - CPU Frequency scaling.
Line 26: Line 30:
 ===== Disabling unneeded services ===== ===== Disabling unneeded services =====
  
-By default the RPi runs quite some services that are not really needed or even get in the way when setting up a real-time, low-latency environment. One way to disable such services from running and chewing up precious CPU cycles is to write a little script, an example can be found here: https://github.com/AutoStatic/scripts/raw/rpi/rpi/jackstart+By default the RPi runs quite some services that are not really needed or even get in the way when setting up a real-time, low-latency environment. One way to disable such services from running and chewing up precious CPU cycles is to write a little script, an example can be found here: https://github.com/autostatic/scripts/blob/rpi/jackstart
  
 Breaking down the script: Breaking down the script:
Line 64: Line 68:
 ## Uncomment if you'd like to disable the network adapter completely\\ ## Uncomment if you'd like to disable the network adapter completely\\
 #echo -n "1-1.1:1.0" | sudo tee /sys/bus/usb/drivers/smsc95xx/unbind\\ #echo -n "1-1.1:1.0" | sudo tee /sys/bus/usb/drivers/smsc95xx/unbind\\
 +## In case the above line doesn't work try the following\\
 +#echo -n "1-1.1" | sudo tee /sys/bus/usb/drivers/usb/unbind\\
 \\ \\
 ## Set the CPU scaling governor to performance\\ ## Set the CPU scaling governor to performance\\
Line 72: Line 78:
 \\ \\
 exit exit
-'' 
- 
-Update: 
- 
-On my model B Pi the unbind does not work, this appears to be the correct line: 
- 
-'' 
-echo -n “1-1.1” | sudo tee /sys/bus/usb/drivers/usb/unbind 
 '' ''
  
Line 99: Line 97:
 ===== On-board audio ===== ===== On-board audio =====
  
-The on-board chipset of the RPi has quite some limitations unfortunately. It only does playback and because of it'design it is not really suited for real-time, low-latency audio processing. It does work with JACK now that it has MMAP support but don't expect it to run without glitches at lower latencies.+The on-board chipset of the RPi has quite some limitations unfortunately. It only does playback and because of its PWM (Pulse Wide Modulation) based design it is not really suited for real-time, low-latency audio processing. It does work with JACK now that it has MMAP support but don't expect it to run without glitches at lower latencies.
  
 Other drawbacks of the analog audio output: Other drawbacks of the analog audio output:
Line 109: Line 107:
 http://www.raspberrypi.org/phpBB3/viewtopic.php?p=297563 http://www.raspberrypi.org/phpBB3/viewtopic.php?p=297563
  
 +===== GPIO (On-board) audio =====
 +
 +Various sound card hats and addons are available for high quality audio. These sound cards use the GPIO I2S (and I2C) pins on the GPIO header. Some sound cards have inputs as well as outputs. Sound cards range from 2 channels (in/out) to 8 channels out and 6 channels in.
 +
 +A short list of GPIO sound cards can be found on eLinux :\\
 +http://elinux.org/index.php?title=RPi_Expansion_Boards#Sound
 ===== On-board MIDI ===== ===== On-board MIDI =====
  
Line 165: Line 169:
 Another option is to comment or remove the kernel module for the onboard soundcard (snd-bcm2835) from ''/etc/modules''. Keep in mind this will disable the onboard sound altogether. This might save you some precious CPU cycles too but don't expect too much of it. Another option is to comment or remove the kernel module for the onboard soundcard (snd-bcm2835) from ''/etc/modules''. Keep in mind this will disable the onboard sound altogether. This might save you some precious CPU cycles too but don't expect too much of it.
  
-===== Audio software repository ===== 
  
-There's a [[http://rpi.autostatic.com/|repository]] available with packages of Jack1, Jack2 (both patched for use on ARM) and a small collection of software that is either not available or not up to date in the standard Raspbian repositories. 
- 
-==== Adding the repository ==== 
- 
-  wget -O - http://rpi.autostatic.com/autostatic.gpg.key| sudo apt-key add - 
-  sudo wget -O /etc/apt/sources.list.d/autostatic-audio-raspbian.list http://rpi.autostatic.com/autostatic-audio-raspbian.list 
-  sudo apt-get update 
  
 ===== Using JACK ===== ===== Using JACK =====
Line 184: Line 180:
 ==== Patching JACK ==== ==== Patching JACK ====
  
-You will need a patched JACK for the RPi otherwise you will encounter the infamous "Bus error" when starting JACK.  This is because JACK uses packed structs and the RPi doesn't like those: http://comments.gmane.org/gmane.comp.audio.jackit/26713.+You will need a patched JACK1 for the RPi otherwise you will encounter the infamous "Bus error" when starting JACK.  This is because JACK uses packed structs and the RPi doesn't like those: http://comments.gmane.org/gmane.comp.audio.jackit/26713.
  
-Patches can be found here: https://github.com/AutoStatic/jack-armel +There's a patched JACK2 package in the default Raspbian repositories so JACK2 will work out of the box.
-The patches apply cleanly to Jack1 0.121.3 git commit 75e3e20b and Jack2 1.9.8 git commit 007cdc37 but since the patches are relatively simple they can be easily adapted for other JACK versions.+
  
-When using Jack2 you might want to disable dbus dependent code in JACK components if you want to run Jack2 on a headless RPi (so without X)You can do this by building without the ''--dbus'' option.+Patches for both JACK1 and JACK2 can be found here: https://github.com/AutoStatic/jack-armel 
 +The patches apply cleanly to Jack1 0.121.3 git commit 75e3e20b and Jack2 1.9.8 git commit 007cdc37 but since the patches are relatively simple they can be easily adapted for other JACK versions.
  
 ==== Packages ==== ==== Packages ====
Line 213: Line 209:
   echo -n performance \   echo -n performance \
   | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor   | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 +
 +When using Jack2 you might want to disable dbus dependent code in JACK components if you want to run Jack2 on a headless RPi (so without X). You can do this by building without the ''--dbus'' option. The JACK2 packages in the AutoStatic repositories have dbus disabled. Another option is to export the following environment variable before starting JACK2:
 +  export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
 +
 +And then add the following lines to ''/etc/dbus-1/system.conf'' before the closing ''</busconfig>'' tag:
 +    <policy user="pi">
 +          <allow own="org.freedesktop.ReserveDevice1.Audio0"/>
 +          <allow own="org.freedesktop.ReserveDevice1.Audio1"/>
 +    </policy>
 +    
 +WARNING: In Raspbian Stretch I had to do the following instead of modifying ''system.conf'':
 +
 +Create a new file ''/etc/dbus-1/system-local.conf'' with the following contents:
 +
 +    <?xml version="1.0"?> <!--*-nxml-*-->
 +    <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 +            "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 +    
 +    <busconfig>
 +    
 +            <policy context="default">
 +                    <allow own="org.freedesktop.ReserveDevice1.Audio0"/>
 +                    <allow own="org.freedesktop.ReserveDevice1.Audio1"/>
 +            </policy>
 +    
 +    </busconfig>
 +
 +
  
 === Using an external USB audio interface === === Using an external USB audio interface ===
Line 232: Line 256:
  
 [[http://wiki.linuxaudio.org/wiki/system_configuration#build_your_own_real-time_kernel|Building a real-time kernel]] [[http://wiki.linuxaudio.org/wiki/system_configuration#build_your_own_real-time_kernel|Building a real-time kernel]]
 +
 +[[https://github.com/dddomin3/DSPi/|Instructions for kernel compilation modernized for Pi 3]]
  
 {{tag>hardware_linux usb_audio_midi raspberry_pi howtos_and_faqs}} {{tag>hardware_linux usb_audio_midi raspberry_pi howtos_and_faqs}}
wiki/raspberrypi.1429427853.txt.gz · Last modified: 2015/04/19 09:17 by autostatic