# Scenes — implementation trial

## Scope and source

Extended only the supplied source files from `../16-soundscape/`: `index.html`, `style.css`, `app.js`, `engine.js`, and `catalog.js`. Read `prompt.txt` in this app as the student request. Used the existing catalog and its supplied relative audio paths. No other apps, previous attempt files, slides, project histories, external libraries, network services, servers, or browser tools were used. All changes are contained in this app directory.

The first complete implementation is preserved in `attempts/001/` with its exact prompt. This app runs as ordinary HTML/CSS/JavaScript; no build step was added.

## Decisions

- Keep the predecessor interface and all its sound controls reachable. The scene library is an additional section above the environment controls.
- A scene captures every engine setting, the selected background and enabled events for every environment, each event's individual level and minimum/maximum wait, and imported recording enable/level/timing settings. Runtime timers, active audio nodes, and the remaining wait countdown are deliberately not saved: a fresh wait begins on Start.
- Loading any scene first stops all audio, applies its settings, and leaves Start listening available. Loading never invokes the engine's Start method. The initial example is also loaded while stopped.
- Store named scenes in localStorage. Save new, explicit Update, Load, Rename, Delete, and Undo delete are available. Changes after loading show an unsaved-changes label.
- Store original imported MP3/WAV files in IndexedDB, then decode them again on reload. Retain decoded buffers only for the active page. A successful stored file is labelled “saved in this browser”; unavailable/full storage leaves a clearly labelled session-only file. Importing alone does not start audio.
- Removing a recording removes its stored file. Saved scenes keep its settings and show a missing-file notice on load. Reimporting the same original filename in the same loop/event mode allows the scene to match it again.
- Storage is local to this browser and address. Clearing site data removes scenes and audio. Browser/private-mode policies and quota can prevent persistence. These limits appear in the page.

## Listening examples

- **Sheltered forest:** After rain recording, close soft leaves, birds and a rare footstep; warm low-pass brown noise, slow random movement, a restrained A-based drone, small short room.
- **Distant city at night:** Fog recording with quiet isolated footsteps, a distant tram bell and wind; dimmer low-pass pink noise, sparse D-based notes, longer room and audible lo-fi processing. Lower recorded levels and longer gaps create distance.
- **Slow open water:** Glassy still recording; broad slow filtered-white-noise LFO, deep C-based drone, long clean space and rare distant arrivals. Its pace and envelope are markedly slower.

The musical roots are the predecessor's environment-specific roots. Presets change synthesis, event selection and timing, levels, envelopes, motion, music mode, and processing rather than merely changing titles.

## Checks performed

- `node --check` passed for `scenes.js`, `app.js`, and `engine.js`.
- `node checks/scene-state.cjs` passed: distinct example parameters; complete settings, event selection/levels/waits, and imported timing roundtrip; scene load stops a running state without creating an AudioContext; custom save/update/rename/delete/undo; scene persistence across a fresh page context; session-only import; explicit missing-file notice after reload.
- The test uses the real engine and scene manager with a minimal document/storage harness, with no browser or audio device. The unavailable-IndexedDB fallback is covered; actual IndexedDB file retention requires the parent's browser verification.
- Existing synthesis/recording engine retained except collision-resistant imported-file IDs. Native audio playback, rendered layout, and actual browser storage are for the parent to verify.

## Limitations

- Files remain browser-local; this is not a scene export or cross-device sync system.
- A browser may evict local data. Keep original imported audio.
- Current unsaved edits are not restored automatically after a reload. Explicitly saved scenes remain selectable. Reload begins with Sheltered forest, stopped.
- Browser verification was intentionally left to the parent under the trial's operational envelope.
