feat: add bounded audio sample editor with waveform selection and source statistics

This commit is contained in:
Johannes Findeisen 2026-11-06 01:01:37 +01:00
commit 7a04c6d922
12 changed files with 364 additions and 8 deletions

15
docs/AUDIO_EDITOR.md Normal file
View file

@ -0,0 +1,15 @@
# Audio source editor workflows
Phases 69–79 use the existing bounded mono WAV reader. Stereo input is downmixed;
these are offline control-thread tools, not stereo restoration or time stretching.
The project format remains 16. No new dependencies are required.
## Phase 69 — Source inspection
Select an audio clip and use View / Sample editor or double-click it. The modal
editor loads an independent snapshot of the complete source, up to 4,194,304 frames
(about 87 seconds at 48 kHz). Drag or enter half-open native frame bounds; zoom
1..64 and View start control the visible region. Statistics show raw mono min/max,
RMS and mean/DC before clip gain, fades or mixer processing. Display clamps to
±1; sample statistics retain finite over-range values. Editing project MIDI still
opens the piano roll. This editor does not audition or stream long files.

View file

@ -1681,6 +1681,171 @@ real FLTK widgets and isolated demonstration data.
---
## Phase 69 — Sample Editor and Source Inspection
### Goal
Open selected audio in a dedicated modal waveform editor with frame-based selection, zoom/scroll and peak/RMS/DC statistics. Preload bounded mono samples outside callbacks; originals and project remain unchanged.
### Tasks and acceptance criteria
- [x] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [x] Preserve source files, atomic error handling, history and callback safety.
- [x] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Implemented: bounded C99 source snapshots, per-range min/max/RMS/DC analysis and a real modal waveform editor with frame selection, zoom/scroll and audio double-click integration. Warning-enabled full core and focused GUI range/view validation pass; no callback or source file changes.
---
## Phase 70 — Nondestructive Source Range Trimming
### Goal
Apply sample-editor selection as audible clip trims with conservative frame-to-musical-tick rounding, preserved source content and one project undo step.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 71 — Sample Selection Export and Edited Copy Adoption
### Goal
Export selected frames or save the complete edited source into a new mono float32 WAV; optionally relink the selected clip with project undo and cleanup on failed preparation. Never overwrite source/destination files.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 72 — Reversible Sample Range Reversal
### Goal
Reverse a selected source frame range in an independent sample snapshot, with bounded local undo/redo and save-copy adoption.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 73 — Sample Polarity Inversion
### Goal
Invert selected samples without altering frames outside the selection, with reversible local processing and no implicit clipping.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 74 — DC Offset Removal
### Goal
Measure and subtract the selected range mean using double precision accumulation, preserve other frames and reject invalid ranges atomically.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 75 — Offline Sample Fade Curves
### Goal
Apply linear or equal-power fade-in/out over selected source frames with exact endpoint behavior, local undo and explicit distinction from nondestructive clip fades.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 76 — Sample Range Gain and Normalization
### Goal
Process selected sample gain or peak normalization with finite bounded parameters, whole-result validation, silence rejection and reversible edits.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 77 — Silence Boundary Detection
### Goal
Find audible selected-range bounds using a user threshold and padding; select detected bounds for export or nondestructive clip trimming. Silence is an explicit no-result error.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 78 — Zero Crossing Selection Snapping
### Goal
Find nearest bounded mono zero crossings around selection boundaries with deterministic ties; adjust selection without crossing or inventing samples.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Phase 79 — Transient Detection and Transactional Audio Slicing
### Goal
Detect threshold attacks with a refractory gap, inspect their source positions, and split the original clip at representable interior source transients in one undoable transactional operation. Qualify integrated rollback, persistence, rendering and GUI behavior.
### Tasks and acceptance criteria
- [ ] Implement bounded C99 analysis/processing and accessible FLTK controls.
- [ ] Preserve source files, atomic error handling, history and callback safety.
- [ ] Pass meaningful core and GUI checks; document exact behavior and limits.
### Implementation status
Planned.
---
## Recommended Execution Order
Reorder the phases when the audit reveals a blocking dependency. Do not mark a phase complete merely because code exists: its acceptance criteria must be demonstrated by builds, tests, or documented manual verification.