← All news

Tonic gets its own engine

The audio brain behind Tonic is now a separate, versioned engine that other Moshly apps can borrow. Hz already builds on it, so a fix to how we hear a note reaches both apps without anyone copying code around.

Tonic tells you the key, scale, tempo and loudness of an audio file, and it does all of it in your browser: the audio never leaves your device. The engine is the part that does the listening, and it now lives on its own.

What is in it

  • A loader for the analysis library (essentia.js, compiled to WebAssembly). It is fetched once, then cached.
  • A small shim, so the analysis runs in a background worker and the screen never freezes while a file is being read.
  • A tidy, typed surface over the library, so the apps only use the parts they need.
  • A real-time pitch tracker, the one Hz uses to follow a note as it is played.

Why separate it

Tonic and Hz both need to hear pitch properly. Instead of two copies drifting apart, there is one engine with one version number (it is at 0.2.0 now). The engine knows nothing about either app: no screens, no wording, just the listening. Every change that apps should pick up bumps the version, so it is always clear what changed and when.

How Hz stays up to date

Hz keeps its own copy of the engine. When the engine changes, Hz is told straight away, and a bot proposes the update only if Hz's own tests and build still pass with it. If something breaks, it shows up as a failed bot run, not as a broken app on your phone.

What it cannot tell you yet

We would rather be straight about this: there is no accuracy figure for real music yet. The tests so far prove that the plumbing works on synthetic sounds. Until we have measured it against a set of properly labelled real tracks, we will not quote a number. In the meantime Tonic shows how sure it is of each answer, and calls a close call Ambiguous instead of guessing.

Open source

Tonic and its engine are open source under the AGPL-3.0 licence, because the analysis library they build on is too. The code is on GitHub, with the engine in its own engine/ folder.

← All news Tonic on GitHub →