Six Android notification sounds, for the sound theme to come

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5.5 committed 2026-11-20 23:25:26 -05:00
1 parent af34c622b6
commit 7807a4cc2c
11 files changed
+121

No files matched your search

+1
View File
@@ -7,6 +7,7 @@ These are tools for the repository. None of them is in the wheel.
| `basemap-doctor.py` | Finds why a user's map has no basemap: certificates, DNS, proxy, or colour depth |
| `ladders/` | The tools with which JP chooses a visual value by eye: each draws the candidates side by side with MeshTerm's own renderer (the lightness of the node hues, the threshold of the chip seams). `README.md` there explains the method, and how Claude Code opens a ladder in a new window |
| `cardputer-zero/` | `build-deb.sh` builds the Debian package for M5Stack's app store. Run it on the Cardputer Zero or on another arm64 Debian 13 system. `store/` holds the listing for the store (`app-builder.json`, which `czdev publish` reads), its icon, and its screenshots. `screenshot.py` saves the display of a Cardputer as a 320×170 PNG over SSH, as the store wants a screenshot. `store-publish.py` sends a package to the store with M5Stack's `czdev`, with two corrections. The release workflow runs it after each release. `launcher-entry.sh` puts a source checkout in the Cardputer Zero's app launcher. `remove` takes it out. `meshterm.png` is the package's icon: the website's logo, at the launcher's 100×100 size. `meshterm-dev.png` is its negative, for the checkout's entry, so that the two entries look different. `type-text.py` types a pasted string (an API key, a Wi-Fi password) on the Cardputer's keyboard from another computer, over SSH |
| `sounds.py` | Makes the WAV files of the Android sound theme (`meshterm/assets/sounds/android/`) from the AOSP sources at a fixed commit. It needs `soundfile`, which is not a dependency of MeshTerm: run it from a separate environment |
| `screenshots.py` | Makes the screenshots of the website from the demo mesh (`--demo`): the main menu, the chat, the paths of a message, and the map, for the terminal, the Cardputer Zero, and the PicoCalc. They are the same at each run. The result goes to `docs/screenshots/<set>/`. It also draws the two wordmarks of the splash into `docs/screenshots/splash/`, which the website uses as its splash |
| `video.py` | Makes the demo video of the website from the demo mesh: a tour of less than two minutes in the terminal, with its poster and its play card. The result goes to `src/` of the `meshterm.net` checkout beside this one |
| `reels.py` | Makes the videos for Instagram from the demo mesh: one vertical video for each page, with subtitles in the picture and no sound, a cover, and a caption for the post. The tours are in `reel_tours.py`. The result goes to `output/reels/` |
+85
View File
@@ -0,0 +1,85 @@
# SPDX-License-Identifier: Apache-2.0
"""Make the WAV files of the Android sound theme from the AOSP sources.
MeshTerm plays its notification sounds through the player of the operating system:
``winsound`` on Windows, ``afplay`` on macOS, and ``pw-play``, ``paplay``, or ``aplay`` on
Linux. All of these players read WAV, but not all of them read Ogg Vorbis. The sources in
AOSP are Ogg Vorbis. Thus this script downloads each source at a fixed AOSP commit, decodes
it, mixes it to one channel, and writes a 16-bit WAV into ``meshterm/assets/sounds/android``.
The WAV files are in the repository, so a build of MeshTerm never runs this script.
The decoder is ``soundfile`` (libsndfile), which is not a dependency of MeshTerm. Install
it in a separate environment first::
python -m venv /tmp/sounds-venv
/tmp/sounds-venv/bin/pip install soundfile
/tmp/sounds-venv/bin/python scripts/sounds.py
The sources are under the Apache License 2.0 (``Android.bp`` in ``data/sounds`` declares
``Android-Apache-2.0``), the same licence as MeshTerm. ``README.md`` in the output folder
names them.
"""
from __future__ import annotations
import base64
import urllib.request
import wave
from pathlib import Path
import numpy as np
import soundfile
#: The AOSP commit of ``platform/frameworks/base`` that the files come from. A fixed commit
#: makes the output the same at each run.
COMMIT = "1cdfff555f4a21f71ccc978290e2e212e2f8b168"
#: Each source, by its path under ``data/sounds`` at :data:`COMMIT`. JP selected them by
#: ear on 2026-11-20, from an audition of 188 sounds.
SOURCES: tuple[str, ...] = (
"notifications/material/ogg/Carme.ogg",
"notifications/material/ogg/Ariel.ogg",
"notifications/material/ogg/Ceres.ogg",
"effects/ogg/InCallNotification.ogg",
"effects/ogg/LowBattery.ogg",
"effects/ogg/Effect_Tick.ogg",
)
_BASE = "https://android.googlesource.com/platform/frameworks/base/+/{commit}/data/sounds/{path}"
_OUT = Path(__file__).resolve().parent.parent / "meshterm" / "assets" / "sounds" / "android"
def download(path: str) -> bytes:
"""Download one source file from Gitiles, which serves a file as Base64 text."""
url = _BASE.format(commit=COMMIT, path=path) + "?format=TEXT"
with urllib.request.urlopen(url, timeout=30) as reply: # noqa: S310 - a fixed https URL.
return base64.b64decode(reply.read())
def write_wav(target: Path, samples: np.ndarray, rate: int) -> None:
"""Write mono samples (floats from -1 to 1) as a 16-bit PCM WAV file."""
pcm = np.clip(samples, -1.0, 1.0)
data = (pcm * 32767).round().astype("<i2").tobytes()
with wave.open(str(target), "wb") as out:
out.setnchannels(1)
out.setsampwidth(2)
out.setframerate(rate)
out.writeframes(data)
def main() -> None:
"""Download, decode, and write each source."""
_OUT.mkdir(parents=True, exist_ok=True)
tmp = _OUT / "_source.ogg"
for path in SOURCES:
tmp.write_bytes(download(path))
samples, rate = soundfile.read(str(tmp), dtype="float64", always_2d=True)
mono = samples.mean(axis=1)
target = _OUT / (Path(path).stem + ".wav")
write_wav(target, mono, rate)
print(f"{target.name}: {len(mono) / rate:.2f} s, {target.stat().st_size} bytes")
tmp.unlink()
if __name__ == "__main__":
main()