Commit Graph
2 Commits
Author SHA1 Message Date
grovebit 7f9b629964 Draw each take in the Edit window while it records
Pro Tools draws a take's waveform as it records; ours showed nothing
until Stop. Each record-enabled track now shows its take growing as a
red clip with its waveform, drawn from the take's live summary through
the same column grid and channel bands as clips (Peak view, as Pro Tools
always shows while recording).

- The take writer keeps, per take channel, the (min, max) of every 128
  frames it writes (at most 2^22 blocks, three hours at 48 kHz; the file
  records on regardless). Recorder::live_take hands the Edit window what
  a track's take holds so far, while the writer runs. The blocks sit
  behind a mutex the writer thread and the UI lock briefly; the input
  callback is untouched.
- io::live_span places the take as Stop will: from the record start,
  only the pass under way when loop recording, and within the punch
  range.

Tests: the take writer's summary (record.rs), live_span with loop and
punch (io.rs) and draw_live (tests/waveform.rs).
2026-10-12 23:43:58 +01:00
grovebit a47ce1cee5 Waveforms like Pro Tools': exact per-pixel peaks and working view options
Waveforms looked blocky and jagged next to Pro Tools': each column was a
point wide (two pixels on Retina screens), and the overview only knew
32-sample blocks, so zooming in showed stair steps and, at the sample
level, wide flat bars instead of the signal. Several View > Waveforms
options did nothing or drew something else.

- Peaks keeps one tree of blocks (min, max and sum of squares). Its
  queries read the partial blocks at a range's edges from the samples,
  so every answer is exact and still O(log n). `Peaks::spans` gives each
  column the (min, max) of the line through the samples over its span;
  neighbouring spans share their boundary, so the waveform stays
  connected at any zoom.
- The Edit window draws a column per physical pixel, each over a
  1-point window anchored to absolute sample positions (no shimmer while
  scrolling), with anti-aliased ends, in one triangle strip where runs
  of equal columns such as silence share vertices. At the sample level
  (a sample per pixel or less) the waveform is a 1-point line through
  the samples, without Rectified, Power or Outlines, as in Pro Tools.
- Outlines draws an edge around a lighter fill, as Pro Tools does; it
  used to replace the fill with a line of dots along the tops.
- Power shows the RMS, which is how Pro Tools calculates it
  (`Peaks::rms_spans`). Ours squashed the peak heights with a square
  root, which drew loud material bigger than Peak view. Power draws
  +/-RMS around the centre, or 0..RMS above the base line when
  Rectified.
- Dark theme clips have a dark body tinted with the clip colour and a
  light waveform in that colour, as in Pro Tools, instead of black
  waveforms on a mid-tone body; a selected clip inverts to a bright body
  with a dark waveform, as before. MIDI notes on unselected clips take
  the waveform colour, with velocity as opacity. The Light theme is
  unchanged.
- Blocks view draws clips as empty blocks with their names, and in
  Playlists view the alternate playlists' lanes draw their clips like
  the main lane, waveforms included, instead of empty boxes.
- Overlapped Crossfades draws the outgoing clip's waveform, translucent,
  over the crossfade, so both clips' audio shows inside it. The outgoing
  clip is found by binary search in the clip's own playlist. A crossfade
  also shows both fade curves: the outgoing clip's fade-out used to be
  hidden under the incoming clip.

Tests: the peaks unit tests check every range, span and RMS against the
samples; tests/waveform.rs checks the sample-level line, a one-sample
spike zoomed out, Blocks and playlist lanes, and Overlapped Crossfades.
2026-10-12 21:18:25 +01:00