Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sound [2015/06/03 11:26]
slackermedia
sound [2021/06/03 19:48] (current)
Line 1: Line 1:
-[[{arrowp.png|border:​0;​background:​none;​width:​0;​display:​inline-block;​position:​absolute;​top:​0;​left:​0;​}jack|]] 
  
-[[{arrown.png|border:​0;​background:​none;​width:​0;​display:​inline-block;​position:​absolute;​top:​0;​margin-left:​2.5em;​}ffmpeginstall|]] 
  
  
Line 8: Line 6:
 <WRAP info> <WRAP info>
 **TL;DR** \\ **TL;DR** \\
-For full sound integration of JACK and non-JACK applications,​ you need to perform one of three configuration mods: either use an ALSA-JACK bridge, use JACK exclusively,​ or use only JACK applications ​whilst ​JACK is running. Also, there'​s a bug in Firefox.+For full sound integration of JACK and non-JACK applications,​ you need to perform one of three configuration mods: either use an [[#​alsajack|ALSA-JACK bridge]], use [[#​jackjack|JACK exclusively]], or be lazy and just [[#​jacktime|use JACK applications]] during the time you have JACK running. Also, there'​s a bug in Firefox.
 </​WRAP>​ </​WRAP>​
  
Line 21: Line 19:
 If you have these installed, then it is safe to install ''​alsa-plugins''​. It is available from [[http://​slackbuilds.org]]. If you have these installed, then it is safe to install ''​alsa-plugins''​. It is available from [[http://​slackbuilds.org]].
  
 +{{anchor:​alsajack}}
 ===== ALSA JACK Bridge ===== ===== ALSA JACK Bridge =====
 +
 +**Skill Level:**
 +//This is an intermediate solution, and the recommended Slackermedia solution.//
  
 The first method, outlined on [[http://​jackaudio.org/​faq/​routing_alsa.html]],​ is to create a dummy ALSA "​loopback"​ device that can be used from within JACK. This means that while JACK is running, a non-JACK application can still play through your system sound cards by piping its way through JACK via an ALSA tunnel, of sorts. The first method, outlined on [[http://​jackaudio.org/​faq/​routing_alsa.html]],​ is to create a dummy ALSA "​loopback"​ device that can be used from within JACK. This means that while JACK is running, a non-JACK application can still play through your system sound cards by piping its way through JACK via an ALSA tunnel, of sorts.
Line 68: Line 70:
 </​code>​ </​code>​
  
-You can set the ALSA output in non-JACK applications in that application'​s **Preferences** or **Settings** menu. For example, to configure ''​VLC''​ to pipe its output to the ALSA/JACK bridge:+Most, if not all, applications that you will normally use with or without JACK running are set to send sound to the "​default"​ device.  
 + 
 +The problem when running ​JACK is that the "​default"​ device (ALSA) is useless; the //new// default device while JACK is running should be your JACK tunnel. 
 + 
 +You could go into each application'​s **Preferences** or **Settings** menu and set the output to your bridge. For example, to configure ''​VLC''​ to pipe its output to the ALSA/JACK bridge: 
 + 
 +[{{ vlcjack.png |You probably don't //really// want to do this manually.}}] 
 + 
 +However, you would need to set it //back// to ALSA so you could hear it when JACK is not running.
  
-{{ vlcjack.png }}+Obviously, there is a better way: automatic switching.
  
  
Line 114: Line 124:
  
 <​code>​ <​code>​
---- $HOME/​.asoundrc-nodef 2015-06-03 01:​28:​04.732320885 +1200 +--- $HOME/​.asoundrc    2015-06-03 01:​28:​04.732320885 +1200 
-+++ $HOME/​.asoundrc-def 2015-06-02 18:​06:​18.974253004 +1200++++ $HOME/​.asoundrc-switch ​2015-06-02 18:​06:​18.974253004 +1200
 @@ -16,4 +16,9 @@ @@ -16,4 +16,9 @@
      hint {      hint {
Line 129: Line 139:
 </​code>​ </​code>​
  
-And finally, create the shell script wrapper that will activate or de-activate the bridge, and start and stop ''​jackd'':​+And finally, create the shell script wrapper that will activate or de-activate the bridge, and start and stop ''​jackd''​. You can copy and paste the code from here, or you can check for updates at [[https://​gitlab.com/​slackermedia/​cousteau]]
  
 <​code>​ <​code>​
 #!/bin/bash #!/bin/bash
  
-switch on +traps ctrl-c and others for this wrapper script 
-if [ "​$1"​ = "1" -o "​$1"​ = "​on"​ ]; then +trap "patch -~/.asoundrc ~/​.asoundrc-switch" 1 2 9 15
-  patch ~/.asoundrc ~/​.asoundrc-switch ​&& exec $( < ~/.jackdrc)+
  
-# switch off +function jackgo() { 
-elif [ "$1" ​= "0" -"$1" = "off" ]; then +        ​echo ​"Starting jackd.."​ 
-  patch -R ~/.asoundrc ~/​.asoundrc-switch && kill $(pgrep jackd)+        sleep 1 
 +        printf ​"." 
 +        sleep 1 
 +        exec `< ~/​.jackdrc` 
 +
 + 
 +function hijack() 
 +
 +    DEF=`grep default $HOME/​.asoundrc` 
 +    if [ -"$DEF" ]; then 
 +        patch ~/.asoundrc ~/​.asoundrc-switch 
 +        jackgo 
 +    else 
 +        jackgo 
 +    fi 
 +
 + 
 +hijack ​&
  
-help +catches ctrl-c and others for jackd 
-else +killjack=$! 
-  echo "on or off? 1 or 0?" +wait $killjack && patch -R ~/.asoundrc ~/​.asoundrc-switch || \ 
-fi+    ​echo "Unable to restore ALSA config. Check your ~/.asoundrc file." ​&& exit 1
  
 exit 0 exit 0
Line 176: Line 202:
 </​code>​ </​code>​
  
-Now you can use your script to turn ''​jackd'' ​on or off using either ''​1'' ​or ''​on'' ​and ''​0''​ or ''​off''​:+Now you can use your script to start JACK, and it your ''​~/.asoundrc'' ​file will be patched automatically for you. If jackd dies or is killed by some other process, ​or cousteau is killed by some other process (such as pressing ​''​ctrl-c'' ​in the terminal where cousteau is running), then ''​~/.asoundrc'' ​will be restored to normal.
  
-<​code>​ 
-$ cousteau on 
-$ cousteau off 
-$ cousteau 1 
-$ cousteau 0 
-</​code>​ 
  
 <WRAP alert> <WRAP alert>
Line 191: Line 211:
 </​WRAP>​ </​WRAP>​
  
 +{{anchor:​jackjack}}
 ===== Always-On JACK Daemon ===== ===== Always-On JACK Daemon =====
 +
 +
 +**Skill Level:**
 +//This is a complex solution and requires advanced skills.//
  
 The second option is to run JACK all the time, no matter what. This is a more complex setup but it has your computer being an active JACK session all the time, meaning that you can route or hijack any sound to or from any device or application at a moment'​s notice. The second option is to run JACK all the time, no matter what. This is a more complex setup but it has your computer being an active JACK session all the time, meaning that you can route or hijack any sound to or from any device or application at a moment'​s notice.
Line 428: Line 452:
 </​WRAP>​ </​WRAP>​
  
 +{{anchor:​jacktime}}
 ===== JACK Enabled Apps ===== ===== JACK Enabled Apps =====
 +
 +
 +**Skill Level:**
 +//This is the easiest solution; it requires no skill, but its limitations can be annoying.//
  
 The simplest solution, in terms of effort, is to just use JACK-enabled applications whilst you are running an active JACK session. It seems almost too simple, but in practise, depending on your workflow, it ends up being quite realistic. The simplest solution, in terms of effort, is to just use JACK-enabled applications whilst you are running an active JACK session. It seems almost too simple, but in practise, depending on your workflow, it ends up being quite realistic.
Line 444: Line 472:
  
  
-[[{arrown.png|border:​0;​background:​none;​width:​0;​display:​inline-block;​float:​right;​}ffmpeginstall|]][[{arrowp.png|border:​0;​background:​none;​width:​0;​float:​right;​}jack|]]+<WRAP centeralign>​ 
 +<wrap fa>[[jack|R]]</​wrap>​ <wrap fa>[[start|S]]</​wrap>​ <wrap fa>​[[ffmpeginstall|Q]]</​wrap>​ 
 +</​WRAP>​