@dioramajs/audio/beat
Exports of @dioramajs/audio/beat.
import { BASS, default, Detector } from '@dioramajs/audio/beat'Functions
energy | Mean linear amplitude of the bins between `lo` and `hi` Hz, from decibels. |
findPlayer | The player: `for`, else the first audio or video of the closest container that holds one. |
loudness | Root mean square of analyser bytes around 128. |
Classes
Detector | Beats from the energy of each frame: a rise above the running average by a margin, and near the loudest recent energy (so a hi-hat between kicks is not one), no sooner than GAP after the last beat. The sensitivity lowers both bars. Returns the strength 0..1 of a beat on this frame, 0 for none. Deterministic: the same frames give the same beats. |
Constants
BASS | The kick and the bass line, Hz. |
default | An element that pulses with a page's music: it scales, shakes and glows, or sends out rings, on the beats, the bass or the loudness of an <audio> or <video>. It never starts the sound; frames only while the player plays and a pulse fades. The element stays live DOM. |
GAP | Shortest time between two beats, s: at most three pulses a second, under the flash threshold of WCAG 2.3.1 whatever the tempo; faster music pulses on every other beat. |