diff --git a/NOTICE b/NOTICE index f8e2d26..92b33ad 100644 --- a/NOTICE +++ b/NOTICE @@ -70,3 +70,10 @@ which are provided under the following license: MeshTerm's MCOimg decoder is its own code, written from the published format reference; only these colour values come from meshcore-open. + +Notification sounds: the files in meshterm/assets/sounds/android/ come from +the Android Open Source Project (platform/frameworks/base, data/sounds), +Copyright The Android Open Source Project, licensed under the Apache License, +Version 2.0. MeshTerm changed them: each was decoded from Ogg Vorbis, mixed to +one channel, and written as 16-bit WAV (scripts/sounds.py). The README.md +beside them names each source file. diff --git a/meshterm/assets/pages/about.md b/meshterm/assets/pages/about.md index 0c87787..2f51b35 100644 --- a/meshterm/assets/pages/about.md +++ b/meshterm/assets/pages/about.md @@ -69,6 +69,9 @@ Built on **MeshCore** *https://meshcore.io/* — its firmware and companion library — with Rich, prompt_toolkit, Typer, bleak, pyserial, pycryptodome, markdown-it-py, tomli/tomli-w, and Segno, each under its own terms. +The notification sounds come from the **Android Open Source Project** +*https://source.android.com/*, under the same Apache License as MeshTerm. + Map data **© OpenStreetMap contributors**, served as vector tiles by **OpenFreeMap** *https://openfreemap.org/* on the **© OpenMapTiles** schema *https://openmaptiles.org/*, used under the **ODbL** diff --git a/meshterm/assets/sounds/android/Ariel.wav b/meshterm/assets/sounds/android/Ariel.wav new file mode 100644 index 0000000..4069ba7 Binary files /dev/null and b/meshterm/assets/sounds/android/Ariel.wav differ diff --git a/meshterm/assets/sounds/android/Carme.wav b/meshterm/assets/sounds/android/Carme.wav new file mode 100644 index 0000000..500d544 Binary files /dev/null and b/meshterm/assets/sounds/android/Carme.wav differ diff --git a/meshterm/assets/sounds/android/Ceres.wav b/meshterm/assets/sounds/android/Ceres.wav new file mode 100644 index 0000000..c033dc5 Binary files /dev/null and b/meshterm/assets/sounds/android/Ceres.wav differ diff --git a/meshterm/assets/sounds/android/Effect_Tick.wav b/meshterm/assets/sounds/android/Effect_Tick.wav new file mode 100644 index 0000000..7715de8 Binary files /dev/null and b/meshterm/assets/sounds/android/Effect_Tick.wav differ diff --git a/meshterm/assets/sounds/android/InCallNotification.wav b/meshterm/assets/sounds/android/InCallNotification.wav new file mode 100644 index 0000000..eaec910 Binary files /dev/null and b/meshterm/assets/sounds/android/InCallNotification.wav differ diff --git a/meshterm/assets/sounds/android/LowBattery.wav b/meshterm/assets/sounds/android/LowBattery.wav new file mode 100644 index 0000000..46cd600 Binary files /dev/null and b/meshterm/assets/sounds/android/LowBattery.wav differ diff --git a/meshterm/assets/sounds/android/README.md b/meshterm/assets/sounds/android/README.md new file mode 100644 index 0000000..877af7f --- /dev/null +++ b/meshterm/assets/sounds/android/README.md @@ -0,0 +1,25 @@ +# The Android sound theme + +These are the sounds of the `android` sound theme. MeshTerm plays them for its +notifications (refer to `meshterm/services/sound.py`). + +| File | Event | Source in AOSP `data/sounds` | +| --- | --- | --- | +| `Carme.wav` | Direct message | `notifications/material/ogg/Carme.ogg` | +| `Ariel.wav` | Mention of you | `notifications/material/ogg/Ariel.ogg` | +| `InCallNotification.wav` | Channel message | `effects/ogg/InCallNotification.ogg` | +| `Ceres.wav` | Room post | `notifications/material/ogg/Ceres.ogg` | +| `LowBattery.wav` | Battery low | `effects/ogg/LowBattery.ogg` | +| `Effect_Tick.wav` | Packet tick | `effects/ogg/Effect_Tick.ogg` | + +The sources are from the Android Open Source Project, `platform/frameworks/base` at +commit `1cdfff555f4a21f71ccc978290e2e212e2f8b168`. `scripts/sounds.py` makes these files +from them again. + + +Copyright The Android Open Source Project. Licensed under the Apache License, +Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0). + +Modified by MeshTerm: each file was decoded from Ogg Vorbis, mixed down to one +channel, and written as 16-bit PCM WAV at its original sample rate. + diff --git a/scripts/README.md b/scripts/README.md index 6f74314..d6c5077 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -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//`. 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/` | diff --git a/scripts/sounds.py b/scripts/sounds.py new file mode 100644 index 0000000..2a4c158 --- /dev/null +++ b/scripts/sounds.py @@ -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(" 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()