Let a looped sample play out past its loop when the note ends #331
With "Mode" and "Loop" as two fields, One-shot plus Loop ran until Stop was pressed: letting go of the key did nothing. The two fields are now one, "Play", with four entries that each say what happens while the note is held and when it is let go. - Gate and One-shot play the sound once, as before. Loop repeats it and fades out with the note. - "Loop, then release" is new: the sampler's sustain loop. Let go, it finishes the round it is in and plays what comes after "Loop end" to the end of the sound. - A buffer source stops looping and plays on by itself. The pitch worklet gets a "leave" message. The phase vocoder then lets the round finish that its newest frame has read into, so nothing read already changes under the frames still sounding. - Samples saved with "Mode" and "Loop" are turned into "Play" on load. Gate and One-shot stay, either with Loop becomes Loop, since playing until stopped is gone. - The keys of the Instrument tab stay half lit while a note let go is still heard. Esc on the keys stops everything, like Stop. - Striking a ringing key again plays a new note beside it rather than stopping the old one, so a drum can be hit quickly. This differs from what was proposed in the issue discussion. Tests: - instrument + pitch-player + sound-library + node-catalog: 477 tests, green (12 new). - e2e 34 (melektaus-atx): ALL PASSED, 45 checks (+1). Let go after a loop of 0.05 s, the note played out for 0.31 s on the audio clock, the key half lit meanwhile. - Counter-check: a release that does not leave the loop fails the 2 new player tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a4e4a6762
commit
144dee0a97
14 files changed
+285
-29
No files matched your search
@@ -139,6 +139,41 @@ describe('compiling a note', () => {
|
||||
expect(compile(f, 71).layers).toHaveLength(1);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['gate', { loop: false, gate: true }],
|
||||
['oneshot', { loop: false, gate: false }],
|
||||
['loop', { loop: true, gate: true, loopStart: 0.25, loopEnd: 1 }],
|
||||
// Looping, not ending with the note: the player leaves the loop on a release.
|
||||
['release', { loop: true, gate: false, loopStart: 0.25, loopEnd: 1 }],
|
||||
])('plays a Sample set to %s as such', (play, source) => {
|
||||
const f = makeInstrument();
|
||||
Object.assign(nodeOf(f, 'InstrumentSample').params, {
|
||||
sound: f.sound('Pad', KICK).id,
|
||||
play,
|
||||
loopStart: 0.25,
|
||||
loopEnd: 1,
|
||||
});
|
||||
expect(way(compile(f, 60).layers[0])?.source).toMatchObject(source);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ mode: 'gate' }, 'gate'],
|
||||
[{ mode: 'oneshot' }, 'oneshot'],
|
||||
[{ mode: 'gate', loop: true }, 'loop'],
|
||||
// It ran until it was stopped; that is gone, and Loop is the nearest.
|
||||
[{ mode: 'oneshot', loop: true }, 'loop'],
|
||||
])('loads a Sample saved with %o before "Play" as %s', (old, play) => {
|
||||
const f = makeInstrument();
|
||||
const sample = nodeOf(f, 'InstrumentSample');
|
||||
delete sample.params.play;
|
||||
Object.assign(sample.params, old);
|
||||
const back = roundTrip(f.project).assets.find((a) => a.id === f.instrument.id) as InstrumentAsset;
|
||||
const params = back.graph.nodes.find((n) => n.type === 'InstrumentSample')!.params;
|
||||
expect(params.play).toBe(play);
|
||||
expect(params).not.toHaveProperty('mode');
|
||||
expect(params).not.toHaveProperty('loop');
|
||||
});
|
||||
|
||||
it('plays a Sample that does not follow the note the same for every note', () => {
|
||||
const f = makeInstrument();
|
||||
Object.assign(nodeOf(f, 'InstrumentSample').params, {
|
||||
@@ -157,7 +192,7 @@ describe('compiling a note', () => {
|
||||
name36: 'Kick',
|
||||
});
|
||||
const kick = f.edit.addNode('InstrumentSample', { sound: f.sound('Kick', KICK).id, followNote: false });
|
||||
const snare = f.edit.addNode('InstrumentSample', { sound: f.sound('Snare', SNARE).id, mode: 'oneshot' });
|
||||
const snare = f.edit.addNode('InstrumentSample', { sound: f.sound('Snare', SNARE).id, play: 'oneshot' });
|
||||
const output = f.edit.addNode('InstrumentOutput');
|
||||
f.edit.connect(notes, 'n36', kick, 'trigger');
|
||||
f.edit.connect(notes, 'n38', snare, 'trigger');
|
||||
|
||||
Reference in new issue
Block a user