Show a Sample node as a device that draws its waveform (#400)
game-maker / gate (push) Successful in 4m14s
game-maker / suite (push) Successful in 16m49s

The Sample was the last node of an instrument that still showed rows.
It now draws the sound or clip it plays, so the loop and what plays
after the note can be seen instead of read off two numbers.

- SamplePanel, SampleFace and sampleView: a compact gold plate of
  480x280 with the sound picker beside the name, a waveform screen,
  the four ways of playing it as buttons two by two, the root as a
  knob that reads as a note, a lever for following the note and the
  loop's start above its end.
- The waveform comes from the library's peaks of the played sound,
  a clip's own cut included, scaled by the sound's volume. It is
  loaded on demand as the Reverb's sound is.
- Each part has its colour: played once, looped, played after the
  note, never heard. The loop is held as playback holds it: an end
  of 0 or past the sound is the end, a start not before it loops
  all of it.
- Idle settings come from the node's own idleParams, so the device
  greys out what the rows did.
- A new instrument places its Output at x 840, past the device.
  At 460 it lay under the Sample.
- Hook __gm.sample.panel and a check in e2e 34 behind the first
  instrument check.

Tests:
- Unit sample-view: 11 tests, new. pattern and chip-presets green.
- e2e 34 (atx): ALL PASSED, 144 checks (1 new).
- Gate (atx): 293 files, 4495 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-10 22:54:17 +02:00
1 parent a6c00f7b8b
commit 6383cc0d8e
9 files changed
+1116 -8

No files matched your search

+7 -5
View File
@@ -120,7 +120,7 @@ const ROOT = noteRow('root', 'Root', MIDDLE_C);
const FOLLOW = { key: 'followNote', label: 'Follow note', kind: 'boolean' as const, default: true };
/** How a Sample plays while its note is held and once it is let go. */
export type SamplePlay = 'gate' | 'oneshot' | 'loop' | 'release';
const SAMPLE_PLAYS: { value: SamplePlay; label: string }[] = [
export const SAMPLE_PLAYS: { value: SamplePlay; label: string }[] = [
{ value: 'gate', label: 'Gate' },
{ value: 'oneshot', label: 'One-shot' },
{ value: 'loop', label: 'Loop' },
@@ -154,7 +154,7 @@ export function withSamplePlay(params: PropertyBag): PropertyBag {
const { mode: _mode, loop: _loop, ...rest } = params;
return { ...rest, [PLAY.key]: samplePlay(params) };
}
const LOOP_START: PropertyDef = {
const LOOP_START: FlatDef<'number'> = {
key: 'loopStart',
label: 'Loop start (s)',
kind: 'number',
@@ -162,7 +162,7 @@ const LOOP_START: PropertyDef = {
min: 0,
step: 0.01,
};
const LOOP_END: PropertyDef = {
const LOOP_END: FlatDef<'number'> = {
key: 'loopEnd',
label: 'Loop end (s)',
kind: 'number',
@@ -170,6 +170,8 @@ const LOOP_END: PropertyDef = {
min: 0,
step: 0.01,
};
/** Where a Sample loops, in seconds; its device (#400) types them in. */
export const SAMPLE_LOOP_ROWS = { loopStart: LOOP_START, loopEnd: LOOP_END };
export const InstrumentSample: InstrumentNodeDef = {
type: INSTRUMENT_SAMPLE,
@@ -366,7 +368,7 @@ export const INSTRUMENT_NODES: readonly InstrumentNodeDef[] = [
/**
* What a new instrument starts as: every note of an octave from C4 plays one Sample, which waits for
* its sound to be picked.
* its sound to be picked. The Output sits past the Sample's device (#400), some 580 wide.
*/
export function starterInstrumentGraph(): Graph {
const notes = newId();
@@ -376,7 +378,7 @@ export function starterInstrumentGraph(): Graph {
nodes: [
{ id: notes, type: INSTRUMENT_NOTES, x: 0, y: 0, params: {} },
{ id: sample, type: INSTRUMENT_SAMPLE, x: 220, y: 0, params: {} },
{ id: output, type: INSTRUMENT_OUTPUT, x: 460, y: 0, params: {} },
{ id: output, type: INSTRUMENT_OUTPUT, x: 840, y: 0, params: {} },
],
edges: [
{ id: newId(), from: { node: notes, port: 'any' }, to: { node: sample, port: 'trigger' } },