build system overhaul, lots of files changed

Alessandro Mauri 4 years ago
parent 5e89bf3f6a
commit 6cc3e03573
  1. 8
  2. 20
  3. 1
  4. 163
  5. 3
  6. 13
  7. 3
  8. 93

@ -1,17 +1,15 @@
SRCDIR = src
SITENAME = "Mauri's website"
mkdir -p ${DESTDIR}
ssg ${SRCDIR} ${DESTDIR} ${SITENAME} 'https://${URL}'
rivet -o ${DESTDIR} ${SRCDIR} ${DOMAIN}
test: all
xdg-open ${DESTDIR}/index.html
install: all
rsync -vmruLz --delete ${DESTDIR}/ www@${URL}:/www/
rsync -vmruLz --delete ${DESTDIR}/ www@${DOMAIN}:/www/
rm -rf ${DESTDIR}

@ -1,11 +1,9 @@
Author: Alessandro Mauri
<a href=""></a>
The content of this site is licensed under the
<a href="">
Creative Commons CC0 Public Domain Dedication</a>
Author: Alessandro Mauri
<a href=""></a>
The content of this site is licensed under the
<a href="">
Creative Commons CC0 Public Domain Dedication</a>

@ -1,4 +1,3 @@
<title>Mauri's website</title>
<link rel="stylesheet" href="styles.css">
<div class="header">

@ -1,13 +1,54 @@
Title: Unofficial ALSA API documentation
Author: Alessandro Mauri
# Unofficial ALSA API documentation
ALSA has to be the **worst** documented API in the whole FOSS world, so since I
had to go trough the pain of reverse-engineering other programs I thought to save
you form the same pain. So I present to you the most half-hassed description of
the ALSA API on the interweb.
Official links:
* ALSA documentation [main page](
- The [PCM interface](
Unofficial links:
* [Userspace documentaion](
## Functions
All the functions I encountered and some documentation / explanation
### Interfaces
[//]: # (TODO explain what interfaces are)
### Streams
In ALSA a stream is the collection of audio data flowing from an application to
a card (playback), or from a card to an application (capture).
ALSA uses the ring buffer to store outgoing (playback) and incoming (capture,
record) samples. There are two pointers being maintained to allow a precise
communication between application and device; pointing to current processed
sample by hardware and last processed sample by application.
The modern audio chips allow to program the transfer time periods. It means that
the stream of samples is divided to small chunks. Device acknowledges to
application when the transfer of a chunk is complete.
The type of stream (or the direction in which sound is flowing) can be either
capture or playback and is determined by `snd_pcm_stream_t` which is defined as:
typedef enum _snd_pcm_stream {
SND_PCM_STREAM_PLAYBACK = 0, // Playback stream
SND_PCM_STREAM_CAPTURE, // Capture stream
} snd_pcm_stream_t;
### Hints
Hints are names, descriptions and other information about sound cards, interfaces
@ -112,3 +153,123 @@ int main (int argc, char *argv[])
return 0;
### PCMs
PCM is an abbreviation for "Pulse Code Modulation". PCM is how digital audio is
typically represented in a computer. The audio signal is represented by samples
of its instantaneous amplitude taken at regular intervals the representation of
each sample can take several forms.
In ALSA we usually use the term PCM to refer to a **PCM device**, a PCM device
is something like an abstract soundcard. It can either be a hardware device or a
PCM plugin layer device (like dmix, softvol, etc).
#### Open modes
**Blocking mode (0)**: when opening a PCM in blocked (which is the default mode)
the behaviour is that if the resources are already in use with another
application, then it blocks the caller, until resources are free.
**Non blocking mode (SND_PCM_NONBLOCK)**: the non-blocked mode doesn't block the
caller in any way and instead returns `-EBUSY` (that is `EBUSY * -1`) error when
the resources are not available.
**Asynchronous mode (SND_PCM_ASYNC)**:
The opening modes affect all the standard I/O operations (such as writing), in
the same way the options operate with `open(2)` and `write(2)`, so instead of
making the calling process wait when the resource is not available, operations
return `-EAGAIN /* EAGAIN * -1 */`, which literally means resource temporarly
unavailable. The operation mode for successive (to opening) I/O calls can be
changed with the `snd_pcm_nonblock()` function.
In ALSA PCM devices are controlled trough handles, which are basically pointers
to a data structure `snd_pcm_t` that defines it
typedef struct _snd_pcm {
char *name;
snd_pcm_type_t type;
int stream;
int mode;
int poll_fd;
int setup;
unsigned int access; /* access mode */
unsigned int format; /* SND_PCM_FORMAT_* */
unsigned int subformat; /* subformat */
unsigned int rate; /* rate in Hz */
unsigned int channels; /* channels */
size_t fragment_size; /* fragment size */
unsigned int fragments; /* fragments */
unsigned int start_mode; /* start mode */
unsigned int ready_mode; /* ready detection mode */
unsigned int xrun_mode; /* xrun detection mode */
size_t avail_min; /* min avail frames for wakeup */
size_t xfer_min; /* xfer min size */
size_t xfer_align; /* xfer size need to be a multiple */
unsigned int time: 1; /* timestamp switch */
size_t boundary; /* pointers wrap point */
unsigned int info; /* Info for returned setup */
unsigned int msbits; /* used most significant bits */
unsigned int rate_master; /* Exact rate is rate_master / */
unsigned int rate_divisor; /* rate_divisor */
size_t fifo_size; /* chip FIFO size in frames */
size_t buffer_size;
size_t bits_per_sample;
size_t bits_per_frame;
size_t *appl_ptr;
volatile size_t *hw_ptr;
int mmap_rw;
snd_pcm_channel_info_t *mmap_channels;
snd_pcm_channel_area_t *running_areas;
snd_pcm_channel_area_t *stopped_areas;
void *stopped;
snd_pcm_ops_t *ops;
snd_pcm_fast_ops_t *fast_ops;
snd_pcm_t *op_arg;
snd_pcm_t *fast_op_arg;
void *private;
} snd_pcm_t;
That's a lot of stuff but luckly we have functions to operate on this struct.
#### `snd_pcm_open`
Open a pcm returning it's handle that is pointer to it's defining data structure,
int snd_pcm_open (snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode);
* `(const char)name`: PCM name identifier
* `(snd_pcm_stream_t)stream`: wanted stream
* `(int)mode`: mode of opening, valid modes are
- 0: blocking mode
- SND_PCM_NONBLOCK: non blocking mode
- SND_PCM_ASYNC: async notification mode
* `(snd_pcm_t)pcmp`: PCM handle, link to the PCM's defining struct. After use
the handle should be passed to `snd_pcm_close()` to close and free the resources.
RETURN: `(int)` 0 on success or negative code on error
#### `snd_pcm_close`
Close a PCM handle freeing the allocated resources
int snd_pcm_close (snd_pcm_t *pcm);
* `(snd_pcm_t *)pcm`: the PCM handle to close
RESULT: RETURN: `(int)` 0 on success or negative code on error
#### `snd_pcm_nonblock`

@ -1,3 +1,6 @@
Title: Size in loc of common software
Author: Alessandro Mauri
# Size in loc of common software
Bloat is everywhere, in 2018 I started my journey on debloating my digital
life, so far I mostly use linux as my main OS (the mostly is due to uni

@ -1,11 +1,4 @@
# Mauri's blog lol
## Articles
Title: Mauri's blog homepage
Author: Alessandro Mauri
[Size in loc of common software](commonsizes.html)
[Programs I would like to see made/remade](makesoftware.html)
[Unofficial ALSA documentation](alsadoc.html)
# Mauri's blog lol

@ -1,3 +1,6 @@
Title: Programs someone should make
Author: Alessandro Mauri
# Programs that I'd like to see made/remade
Most small utilities have already been made, and most big programs are perhaps
too big even for a small team, moreover old software has a lot of historical

@ -1,10 +1,34 @@
/* Global options */
/* GLOBAL */
* {
text-align: left;
font-family: monospace;
font-family: sans-serif;
:root {
--bg: #282828;
--bg-code: #1d2021;
--bg-alt: #32302f;
--fg: #ebdbb2;
--fg-code: #fbf1c7;
--fg-alt: #d5c4a1;
--fg-link: #d79921;
body {
width: 50%;
margin: 0 auto;
background-color: var(--bg);
color: var(--fg);
padding: 10px;
html {
/* background-color: #696969;*/
scroll-behavior: smooth;
/* Table styles */
/* TABLES */
table, th, td {
margin-left: auto;
margin-right: auto;
@ -21,64 +45,63 @@ th, td {
th {
border-bottom: 1px solid black;
border-bottom: 1px solid var(--fg);
tr:nth-child(odd) {
background-color: #dcdcdc;
background-color: var(--bg-alt);
/* Code style */
/* CODE */
pre {
background-color: #282828;
color: #ebdbb2;
padding: 2px;
font-size: 14;
background-color: var(--bg-code);
color: var(--fg-code);
padding: 4px;
font-size: 15;
font-family: monospace;
tab-size: 8;
:not(pre) > code {
background-color: #f9f4d7;
color: #504945;
/* List styles */
/* LISTS */
li {
font-size: 14;
/* Paragraphs and text */
p {
font-size: 16;
font-size: 17;
padding-left: 20px;
padding-right: 20px;
body {
width: 50%;
margin: 0 auto;
background-color: #f5fffa;
color: black;
padding: 10px;
h1, h3, h5 {
text-decoration: underline;
html {
/* background-color: #696969;*/
scroll-behavior: smooth;
h2, h4, h6 {
background-color: var(--bg-alt);
/* Headings and footer */
h1 {
text-decoration: underline;
h1, h2, h3, h4, h5, h6 {
text-align: center;
h1 { font-size: 35; }
h2 { font-size: 30; }
h3 { font-size: 25; }
h4, h5, h6 { font-size: 20; }
/* LINKS */
a {
color: var(--fg-link);
/* FOOTER */
footer {
border: 1px solid black;
border: 1px solid var(--fg);
footer p {
@ -87,7 +110,7 @@ footer p {
font-size: 12;
/* Header style */
/* HEADER */
#thumb {
position: absolute;
border-radius: 50%;
@ -125,7 +148,7 @@ footer p {
height: 80px;
text-align: left;
line-height: 80px;
font-size: 16;
border: 1px solid black;
font-size: 17;
border: 1px solid var(--fg);
overflow: hidden;