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