# 06 — Volume envelope

Implemented from `prompt.txt` by extending only the source files of `../05-filters/`.

## Choices

- Preserved white, pink and brown noise, source level, bypass/high-pass/low-pass/band-pass, frequency, Q, Original/Filtered comparison, filter response, resonance attenuation, and the inherited local noise generation.
- Added a separate envelope gain after the source-level gain. Changing Source level does not reset attack or release.
- Start swell fades in over Attack (initially 1.5 s); the sound then holds until Release. Release fades out over its own setting (initially 3 s). Both controls have a 0.05 s minimum and use smooth cosine-shaped automation.
- Start during release brings the same source back in from its current envelope level. Starts are disabled while preparing, attacking or holding, and repeated Release is disabled. There is never more than one connected noise source.
- Stop all cancels pending starts, colour switches and release cleanup, gives a 25 ms fade, schedules the source stop on the audio clock, and disconnects it. Stopping while first preparing invalidates the pending start.
- Colour changes preserve the envelope and briefly fade the source bus before replacing its single source. The source-level setting is retained.
- The shape preview labels attack, indefinite hold and release separately; its three widths are schematic, not a time axis. A live marker and envelope percentage show playback progress. Time edits apply to the next fade; the running fade continues with the duration chosen when triggered.
- Native buttons, labelled range inputs, fieldsets, status announcements and keyboard focus styles are retained or added. The layout stacks on smaller screens.

## Checks

- `node --check app.js` passed.
- Static HTML/JS check passed: all 32 ID references resolve, and both referenced local CSS/JS files exist.
- No external libraries or network services were added.
- Browser interaction, rendered layout and audio output are left for the parent agent to verify at `http://127.0.0.1:4191/apps/06-envelope/`; this implementation agent did not launch a browser or server.

## Limits

- The graph is a labelled shape preview, not an oscilloscope or a measured output waveform. Source/filter settings, device volume and speakers still affect audible loudness.
- Attack/release changes do not retime a fade already in progress.
- Source cleanup after a normal release uses an audio-clock-aware timer. If a background tab delays that timer, the envelope has already reached exact zero; only one silent looping source can remain pending cleanup. Stop all also schedules source termination directly on the audio clock.
- The inherited six-second local noise buffers are looped. The filters, loudness normalization and compressor remain the existing implementation.

## First complete attempt

`attempts/001/` preserves the first complete app (HTML, CSS, JS, exact prompt and these notes). Later fixes, if needed after browser verification, should change only the working files and leave that snapshot untouched.
