Waveform
Draws a sound file's waveform under a tempo grid, with WaveformMarker
<Waveform ... />
Overview
records the person places and drags.
Grid lines fall on bars, beats and division steps per beat; bar numbers
sit in a ruler band at the top, and slice numbers (counted from the file's
start, as exported) at the bottom. Pressing empty space adds a marker on
the nearest step; pressing a marker selects it and dragging moves it,
snapped while it moves. division 0 places markers freely.
Topics
Properties
| Name | Type | Required | Description |
|---|---|---|---|
source |
string | optional | Path of the sound file. |
bpm |
number | optional | Tempo of the grid; 0 draws no grid. |
beatsPerBar |
number | optional | Beats in a bar (default 4). |
division |
number | optional | Snap steps per beat (default 4, sixteenths in 4/4). |
gridOffset |
number | optional | Seconds where bar 1 starts. |
selected |
string | optional | Id of the selected marker. |
playFrom |
number | optional | Start of the span being played, in seconds. |
playTo |
number | optional | End of the span being played. |
playState |
string | optional | "stopped" (default), "playing" or "paused": a playhead moves from playFrom to playTo in real time with Core Animation and stops where it is when paused. |
onAdd |
function | optional | onAdd(seconds). |
onSelect |
function | optional | onSelect(id). |
onMove |
function | optional | onMove(id, seconds) when a dragged marker is dropped. |
onKey |
function | optional | onKey(key) -> handled; the view takes keyboard focus when clicked. |
onZoom |
function | optional | onZoom(factor) for a vertical wheel or pinch; the app sets the new width and the view keeps the time under the pointer in place. |
Example
<Waveform source="loop.wav" bpm="140"><WaveformMarker id="a" time="1.5" /></Waveform>
Platform notes
- AppKit uses the AppKit implementation.
Source: lua/embedded/AppKit.lua:2245 (AppKit.Waveform)