# Engine

> The engine: the audio logic behind audio/ui's interfaces, with no UI framework in it: devices as parameters, musical time and the look-ahead scheduler, levels and curves, MIDI input, scales and the clip player.

The engine holds what makes and times the sound: a device as named parameters and the tools an agent drives it with, musical time and the look-ahead scheduler a transport runs on, levels and the curves a panel draws, the page's MIDI input, named scales, and the clip player that plays an arrangement in an `AudioWorklet`. It runs on the main thread, in a worker or in a worklet, under any framework or none.

Each module is an item of the registry, copied into `lib/engine/<module>/` and owned like any other file: `npx shadcn@latest add @audio-ui/engine-time`, then `import { syncedSeconds } from "@/lib/engine/time"`. A component that needs a module installs it with itself, so a project holds only the modules it uses. It builds on [audio.js](https://audio.js.org) where an atom does the job.

## Modules

| Module | What it holds |
| --- | --- |
| [`device`](/docs/engine/device) | A device as a description: `defineDevice`, its state, `apply` with what each change did, the tools an agent drives it with, and its engine: the contracts an engine implements, the pieces engines are made of, and the checks that measure one. |
| [`dsp`](/docs/engine/dsp) | The audio.js processors the devices are built on: dynamics models and gain curves, filter circuits, reverbs and shelves, under one dependency. |
| [`kernels`](/docs/engine/kernels) | The audio.js code each device runs in an `AudioWorklet`, in a string, since a worklet cannot import. |
| [`time`](/docs/engine/time) | Musical time: tempos and signatures, bars and beats, grid divisions, tempo-synced note values, warp markers, the metronome, and the look-ahead scheduler a transport clock runs on. |
| [`analysis`](/docs/engine/analysis) | Reading a signal: levels in dB, a log-axis spectrum and its peaks, the curves of a filter, an equalizer and a compressor, waveform peaks, transients and auto-warp, and loudness, of a file and live. |
| [`pitch`](/docs/engine/pitch) | Named scales: the pitch classes each keeps, the nearest pitch in one, and a scale as a piano roll reads it. |
| [`midi`](/docs/engine/midi) | MIDI input as a source of notes, a raw message read, pitch bend in semitones. |
| [`files`](/docs/engine/files) | Files: audio decoded into samples, sound written to WAV, FLAC or MP3, notes from and to MIDI files, scores from and to MusicXML. |
| [`playback`](/docs/engine/playback) | What plays when: clips placed in frames, the transport on the audio clock, the clip player's processor, streamed recordings, and the mixer's pan law, solo and delay compensation. |
| [`worklet`](/docs/engine/worklet) | An `AudioWorklet` processor loaded into a context from its source, once per context. |

## Next

**In React**

- [Guides](/docs/guides): how an engine drives the components, output, the clock, synthesis, input and analysis.
- [Installation](/docs/installation): the hooks, libraries and devices built on the engine, which you install and own.

**In Vue, Svelte and Web**

- [Primitives](/docs/components/base/knob): the controls an engine of your own drives, through their values and events.

