# cellphone
Phonetic sonification of a cellular automaton.
# 1 Listen
# 1.1 Live
Click button to play.
Total size 3.3 MiB gzipped, 5.2 MiB unzipped. Requires WASM, SharedArrayBuffer, Web Audio, etc, i.e. a modern web browser.
Tested with:
- Firefox ESR (Debian Bookworm)
- Chromium (Debian Bookworm)
- Fennec F-Droid (Android 7 F-Droid)
- Google Chrome (Android 7)
# 1.2 Stream
14 MiB / hour. Requires streaming server to be online, an internet connection and an MP3 streaming client.
Tested with:
- mpv (Debian Bookworm)
- VLC (Android 7 F-Droid)
# 1.3 Recording
14 MiB, 1 hour. 32kbps 16kHz mono.
# 2 Source
git clone https://code.mathr.co.uk/cellphone.git
# 3 Build
# 3.1 Linux
Dependencies can be installed via package manager (e.g. Debian):
sudo apt install build-essential make libsdl2-dev, libsndfile-dev flite1-dev
Requires support for C11 threads.h
.
make
# 3.2 Windows
For cross-compilation from Debian. Dependencies (sdl2, sndfile, flite) can be installed via build-scripts or similar.
Requires support for C11 threads.h
.
Not yet supported by gcc-mingw as found in Debian Bookworm.
Not yet supported by llvm-mingw based on clang-15.
Workaround: use Web version.
make SYSTEM=x86_64-w64-mingw32
# 3.3 Web
For cross-compilation from Debian. Dependencies (flite) can be installed via build-scripts or similar.
Requires support for C11 threads.h
.
Requires emsdk
activated in your shell.
make SYSTEM=emscripten
# 4 Run
# 4.1 Linux and Windows
./bin/cellphone [seed [api]]
Seed (a number) controls the pseudo-random number generator. Same seeds generate same output.
API controls the sound generation backend. Valid values are:
-
sdl2
uses default SDL2 audio API (e.g. ALSA on Linux, WebAudio on Web, …). -
oss
uses OSS (/dev/dsp
on Linux and similar systems). -
wav
uses libsndfile to (over)writecellphone.wav
.
With the WAV backend you will want to stop the program quickly to avoid filling your hard drive. For example:
timeout 1 ./bin/cellphone `date +%s` wav
# 4.2 Web
You need to serve (possibly also gzipped versions of):
www/index.html
www/cellphone.js
www/cellphone.worker.js
www/cellphone.wasm
www/cellphone.tar.gz
Serve the source code corresponding to the compiled code to comply with the license terms.
You need to set some Cross-Origin-*-Policy
headers
in the web server configuration
to enable SharedArrayBuffer
etc in modern web browsers
(these APIs are requied for Emscripten’s multithreading).
Configuration for Nginx:
location /cellphone/ {
add_header Cross-Origin-Opener-Policy 'same-origin';
add_header Cross-Origin-Embedder-Policy 'require-corp';
}
# 5 Stream
Tested streaming from a Raspberry Pi 3, where it uses about 20MiB RAM and 3.5% CPU.
Requires ALSA loopback kernel module:
modprobe snd-aloop
echo snd-aloop >> /etc/modules
This will be hw:2
or similar at first, but
after reboot the soundcard identifier may change:
on my system it became hw:0
.
Create a system user to run the stream source. Make sure it is in the audio group.
adduser cellphone
adduser cellphone audio
Choose an unused subdevice ID (by default 8 are available)
and configure
~/.asoundrc
following cellphone/etc/asoundrc
,
as hw:x,0,y
where
x
is the snd-aloop card (0 on my Pi after reboot),
0 is the device, and
y
is the subdevice ID (0-7).
Set the same card x
and subdevice ID y
in
cellphone/etc/darkice.cfg
following cellphone/etc/darkice.cfg.sample
,
but set the device to 1 like hw:x,1,y
.
Set your own streaming server details in cellphone/etc/darkice.cfg
,
not forgetting the password. Remember to run
chmod 600 cellphone/etc/darkice.cfg
for security, so that other users can’t see the credentials.
If your cellphone/
directory is not directly under the home directory,
configure the directory in cellphone/bin/cellphone-stream
.
Run make
to build the audio generator program cellphone/bin/cellphone
.
See the build instructions above for dependencies.
To start streaming, run cellphone/bin/cellphone-stream
.
You need the darkice
audio streamer.
If you made an own user, you can stop streaming with
killall -u cellphone
This terminates all processes running as that user.
You can start streaming automatically on boot by adding to the user’s crontab:
crontab -e
@reboot /home/cellphone/cellphone/bin/cellphone-stream
# 6 Legal
cellphone
is licensed AGPL-3.0-only:
cellphone -- phonetic sonification of a cellular automaton
Copyright (C) 2023 Claude Heiland-Allen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, version 3 of the
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
All cellphone
builds depend on flite
,
which is licensed permissively (BSD-style).
See COPYING
in the root of the flite
repository:
- https://github.com/festvox/flite
- https://github.com/festvox/flite/blob/6c9f20dc915b17f5619340069889db0aa007fcdc/COPYING
All cellphone
builds depend on sdl2
,
which is licensed permissively (zlib License).
cellphone
Linux and Windows builds depend on libsndfile
,
which is licensed copyleft (GNU Lesser General Public License 2.1, LGPL-2.1).
See COPYING
in the root of the libsndfile
repository:
- https://github.com/libsndfile/libsndfile
- https://github.com/libsndfile/libsndfile/blob/e486f20fd4b1c7490cde84f22635e1c267ae882b/COPYING
cellphone
Web builds depend on emscripten
runtime,
which is licensed permissively (MIT License).
See the licensing page on the emscripten
website: