diff options
author | dvs1 | 2024-10-19 11:20:17 +1000 |
---|---|---|
committer | dvs1 | 2024-10-19 11:20:17 +1000 |
commit | 7b224e3f003a20ec62edb4f99344d01fb95cdc6b (patch) | |
tree | d72db4c55998a6c6b39eedc666805a58a60afff9 | |
parent | Delete excess files, now I've combined them. (diff) | |
download | JackOnAllDevices-7b224e3f003a20ec62edb4f99344d01fb95cdc6b.zip JackOnAllDevices-7b224e3f003a20ec62edb4f99344d01fb95cdc6b.tar.gz JackOnAllDevices-7b224e3f003a20ec62edb4f99344d01fb95cdc6b.tar.bz2 JackOnAllDevices-7b224e3f003a20ec62edb4f99344d01fb95cdc6b.tar.xz |
Add how_it_works.
-rw-r--r-- | how_it_works.md | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/how_it_works.md b/how_it_works.md new file mode 100644 index 0000000..606ecdf --- /dev/null +++ b/how_it_works.md | |||
@@ -0,0 +1,99 @@ | |||
1 | Reminder that this is all just rough for now. Also I squeezed it all | ||
2 | into one file to make things easy to try out, no need to put things in | ||
3 | your path or for it to know where you installed it. Later, when it | ||
4 | becomes a proper package, things will be split up and spread around | ||
5 | properly. | ||
6 | |||
7 | Note that everything is subject to change without notice, this being a | ||
8 | very raw project for now. | ||
9 | |||
10 | aataaj.lua is a polyglot script, written in such a way that several | ||
11 | different things can deal with it, including shell and Lua languages. | ||
12 | |||
13 | The very first line is your typical shell script first line, but telling | ||
14 | the system that it's Lua not shell script. Perl and Python do similar | ||
15 | things, and there is likely plenty of those scattered around your system, | ||
16 | other languages to. Lua basically ignores the first line if it starts | ||
17 | with #. The system that runs files checks the beginning of the file to | ||
18 | see how it should run. Binaries have magic numbers, scripts have this #! | ||
19 | thing. So that system only reads that first line, then passes the script | ||
20 | to that command in the first line. | ||
21 | |||
22 | The next bit of palyglotism is the Sys V LSB comment block. This is the | ||
23 | magic that turns it into an init script you can put in /etc/init.d Any | ||
24 | LSB compliant init program will look for a comment block like that near | ||
25 | the beginning of the script. This is why all the scripts in /etc/init.d | ||
26 | have such a thing near the top. In this case the script type comment | ||
27 | block is wrapped inside a Lua comment block. Lua will ignore it, Shell | ||
28 | interpreters will ignore it, but shouldn't even get this far anyway. LSB | ||
29 | compliant init programs will find what they are looking for. | ||
30 | |||
31 | This tells the system to run it in run level S for Start, and before | ||
32 | alsa-utils and espeakup. So should in theory be the first thing to mess | ||
33 | with ALSA other than the kernel. | ||
34 | |||
35 | |||
36 | The next major blob of stuff in aataaj.lua is the Help text, which is a | ||
37 | copy of README.md. Later the --help option will print README.md instead | ||
38 | of having it's own copy. | ||
39 | |||
40 | The definition of APT is something I just copied from my apt-panopticon | ||
41 | project. Should break it out into it's own separate library some day. | ||
42 | |||
43 | Then comes the argument handling. Handles the usual init script | ||
44 | arguments, plus a couple more. Some are just aliases for "start", for | ||
45 | now. | ||
46 | |||
47 | "stop" is very crude and violent, mostly just killall. | ||
48 | |||
49 | |||
50 | A short bit where you can change some options. | ||
51 | |||
52 | |||
53 | The actual audio device scanning. | ||
54 | |||
55 | Basically we scan through /proc/asound/card[0-9]* looking for audio | ||
56 | devices that the kernel has already recognised. Collect a few details | ||
57 | about what we find, stuff it in the Cards table. For playback devices we | ||
58 | feed some of those details into espeak-ng, so it'll speak them through | ||
59 | this found playback device. If this is running during init startup time, | ||
60 | then the computer should speak through all audio output devices one at a | ||
61 | time, and you should hear it through anything with speakers attached. | ||
62 | |||
63 | |||
64 | If this is "start" then it'll write details about what it found into | ||
65 | /var/lib/aataaj/ files. One is a jack-plumbing config file for the later | ||
66 | JACK stage, the other is a fragment of an ALSA / asound config file you | ||
67 | can include in the real ones. This includes some extra stuff that is | ||
68 | experiments to get ALSA and JACK to behave that are commented out. | ||
69 | |||
70 | |||
71 | If this is "JACK" then it'll start up a bunch of JACK software, and hook | ||
72 | everything up in JACK. | ||
73 | |||
74 | First it starts the JACK server, then starts up a patchbay GUI so you can | ||
75 | watch the rest of what happens. | ||
76 | |||
77 | Next up is jack-plumbing, using that config file we created before. This | ||
78 | automates the various connections we are about to make. Note this config | ||
79 | is only used for this setup phase, you can still use your own | ||
80 | jack-plumbing config. | ||
81 | |||
82 | a2jmidid is up next, which is used to automatically connect MIDI devices | ||
83 | into the JACK system. Alas the same thing doesn't happen with audio | ||
84 | devices, which is why I need this script. | ||
85 | |||
86 | Next we use alsa_in / alsa_out and their zita equivalents to create JACK | ||
87 | devices for all those ALSA devices we found. We start with anything | ||
88 | configured in the alias table, then add the ALSA loopback devices. | ||
89 | Finally we loop through what's left. Since jack-plumbing is running with | ||
90 | our generated config, it'll automatically hook everything up to | ||
91 | everything else. | ||
92 | |||
93 | Next we scan for joysticks, and use aseqjoy to convert them into MIDI | ||
94 | input devices. Just coz. B-) | ||
95 | |||
96 | Next we fire up qsynth, so you have something to play that makes noises. | ||
97 | |||
98 | Finally we wait for a bit, then kill the jack-plumbing we started. It's | ||
99 | done it's job, the user can pick their own session management. | ||