Skip to content

feat: add sampler sustain playback#29

Merged
britle20 merged 5 commits into
developfrom
feat/23-sampler-advanced-sustain
Jun 12, 2026
Merged

feat: add sampler sustain playback#29
britle20 merged 5 commits into
developfrom
feat/23-sampler-advanced-sustain

Conversation

@britle20

@britle20 britle20 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #23

Adds a reusable sampler sustain path for sample-based pitched instruments. Iowa Piano now uses serializable sample-zone sustain metadata and the browser audio engine validates that metadata at runtime before enabling native Web Audio forward looping.

Changes

  • Added SampleZone.sustain, SampleZone.envelope, and sampleEndSeconds metadata shape for sample-based pitched instruments.
  • Added Iowa Piano forward-loop sustain metadata and basic envelope metadata through the shared sample-zone model.
  • Added src/audio/sampler-sustain.ts with pure helpers for playback plan resolution, loop validation, envelope clamping, and transport release timing.
  • Updated BrowserAudioEngine to schedule sampled notes through the shared sampler plan instead of flat Iowa-specific loop fields.
  • Added release cleanup for active/future note voices on pause/stop.
  • Added focused unit tests for sampler metadata, loop fallback decisions, envelope clamping, and release timing.
  • Updated audio engine, data model, testing docs, feature status, and Active Issue Order.

Testing

  • npm run typecheck --if-present
  • npm run lint --if-present
  • npm run test --if-present
  • npm run build --if-present

Additional checks:

  • git diff --check
  • Dev server smoke check: Vite served http://127.0.0.1:5174/ with HTTP 200 because port 5173 was occupied.

Screenshots

No UI changes.

Notes / Limitations

  • Manual listening checks were not performed in this environment.
  • crossfade-loop metadata is recognized as serializable metadata but intentionally falls back to one-shot behavior until a future task implements and tests overlapping crossfade sources.
  • Iowa Piano loop metadata is a pragmatic first pass. The engine rejects invalid loop metadata rather than clamping unsafe values into a loop, so any weak samples may still fall back to one-shot playback.
  • No user sample import UI, loop point editor, automatic loop detection, arrangement playback, or new runtime dependencies were added.

Follow-up

  • Manually test short and long Iowa Piano notes in the browser and tune loop metadata if individual samples sound weak.
  • Consider a future loop-point editor or better sample material before crossfade looping.

@britle20 britle20 merged commit 891c135 into develop Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant