Metlivi Blog

How to Keep a Sample at Constant Volume for a Set Time After Releasing a Key

To keep a sample playing steadily for a fixed interval after you release a key, delay its MIDI note-off message while keeping the sampler’s amplitude envelope at its sustain level. Let the envelope release only when that delay expires. Increasing an ordinary Release control produces a fade rather than a steady plateau. Some instruments provide a dedicated hold-after-release function, but “Hold” does not mean the same thing everywhere. FabFilter One: Envelope generator.

This guide is for a keyboard player or producer who wants, for example, two seconds of steady sample playback after lifting a finger. It explains how to identify the right control and provides a complete Logic Pro Scripter implementation when the sampler lacks that function.

October 29, 20267 min readBy Metlivi Editorial Team
Section 1

What exactly should happen after you release the key?

Define the timing before adjusting controls. The intended behavior is: play the sample while the key is down, maintain the established level for a chosen interval after key release, and then stop or begin a short fade. The interval must start at key release, regardless of how long you originally held the note.

For an illustrative two-second setting, releasing a key at 0.35 seconds should start the ending at 2.35 seconds. Releasing it at 3 seconds should start the ending at 5 seconds. These are timing examples, not measured performance results. A setting that always ends playback two seconds after the initial key press serves a different task.

Also distinguish constant envelope gain from constant audible loudness. A flat amplitude envelope leaves the sample’s own dynamics intact. If the recording fades, contains silence, or reaches its end, holding the envelope open cannot supply a continuous steady sound. Start with a sustained recording or a suitable repeating section.

Section 2

Why do Release and Hold often give the wrong result?

In Logic Pro Sampler, Sustain specifies the level maintained while a key remains held. Release specifies the transition from that level to zero. Its AHDSR Hold stage comes after Attack and before Decay; it is not a timer that starts when you lift your finger. ENV 1 controls amplitude. These definitions explain why extending Release or the initial Hold stage does not directly create the desired plateau. Apple: Use Sampler envelopes.

A genuine hold-after-release function behaves differently. FabFilter One documents Hold as additional time during which its envelope treats a released key as still held; Release follows afterward. That is the behavior to look for in a manual. FabFilter One illustrates the control semantics here; it is not the sample-playback implementation used below. FabFilter One: Envelope generator.

Ableton’s Drum Sampler documentation illustrates why labels need checking. It defines Hold relative to the attack peak in Trigger mode, while also describing continued playback after note release. Gate mode instead fades after release, and Hold is disabled there. Those descriptions warrant a timing test before treating Trigger mode’s Hold value as an interval measured from key release. Ableton Live 12: Drum Sampler.

Section 3

Which approach should you choose?

Available behavior Practical choice
The manual explicitly specifies a hold interval beginning at key release Use that function with a steady sustain level.
Hold begins after Attack, or playback has a fixed duration from triggering Delay note-off for an interval measured from key release.
You are editing an existing MIDI performance Extend each note’s end by the required interval, then use a short release.
The source recording fades or ends too early Prepare a sustained source or loop before adjusting note timing.

The decision aid follows from separating two controls: the sampler shapes amplitude, while MIDI note timing determines when its release is requested. Delaying only note-off preserves the original note-on timing. Delaying both messages would simply move the whole note later.

Section 4

How do you prepare the sample and envelope in Logic Pro?

Create a software instrument track with Sampler and load your sample. Apple documents dragging audio into Sampler’s Navigation Bar to create mapped zones. In the Zone pane, you can adjust playback boundaries, loop points, and loop crossfades. Choose a reasonably stable section for sustained playback and listen through several repetitions. Apple: Create sampler instruments with Sampler.

For an initial test, use one sustained sample at its original pitch. If it is not looped, make sure it lasts longer than the entire test: the time the key remains down, the extra hold interval, and the ending. A short recording cannot support an arbitrarily long key hold.

In Modulators, select ENV 1 and choose AHDSR. Set Delay and Hold to zero, Attack to a short value, Sustain to maximum, and Release to a short ending. At maximum Sustain, Decay has no effect on the level. These settings are a diagnostic starting point; retain a longer attack later if the sound requires it. Apple: Use Sampler envelopes.

Section 5

How can Scripter delay note-off by two seconds?

Insert Scripter in the track’s MIDI FX section before the sampler. Open its Script Editor, replace the existing script with the complete program below, and click Run Script. Apple documents this editing and execution workflow. Apple: Use the Scripter Script Editor.

The program requires Logic Pro’s Scripter environment, which supplies the MIDI event classes and scheduling methods. It needs no imports or audio-file paths. Its sample input is a normal keyboard note-on followed by note-off; a zero-velocity note-on is handled as an alternative note-off representation. Apple documents those event types and sendAfterMilliseconds(). Apple: Use the JavaScript Event object.

// Complete Logic Pro Scripter program.
// Additional hold after physical key release, in milliseconds.
var HOLD_MS = 2000;

function HandleMIDI(event) {
    if (event instanceof NoteOff) {
        event.sendAfterMilliseconds(HOLD_MS);
    } else if (event instanceof NoteOn && event.velocity === 0) {
        var off = new NoteOff(event);
        off.sendAfterMilliseconds(HOLD_MS);
    } else {
        event.send();
    }
}

Change HOLD_MS to another nonnegative duration, such as 750 for three-quarters of a second. The script sends note-ons immediately and schedules note-offs later. Other incoming messages pass through. There is no immediate copy of the original note-off, because that would tell the sampler to release too early.

The event-routing branches were checked with a small JavaScript mock: note-ons and controller events passed immediately, while both note-off representations were scheduled 2,000 milliseconds later. This verifies the routing logic; it does not measure Logic Pro’s audio timing or audition the sampler.

Section 6

How do you verify the interval starts at key release?

Use the following test with sustain-pedal input inactive and audio effects bypassed. Test one note at a time, allowing each sound to finish before repeating the same pitch.

  1. Set HOLD_MS to 2000 and run the script.
  2. Tap one key briefly. Listen for a steady continuation before the ending.
  3. Hold the same key for approximately three seconds, then release it.
  4. Check that the continuation after release is still approximately two seconds.
  5. Change HOLD_MS to 500, run the script again, and repeat both gestures.

For closer inspection, record the sampler’s output and compare its ending against the original MIDI note end. With the illustrative three-second key hold and two-second extension, release should begin around five seconds after note-on. If you add a short envelope release, final silence comes later than the plateau’s endpoint.

For example, a two-second plateau followed by an illustrative 10-millisecond release has a nominal 2.01-second ending sequence after key release. Decide whether your requested duration means “time until fading begins” or “time until silence,” and adjust accordingly.

Section 7

What should you check if the sample fades, stops early, or retriggers incorrectly?

If the sound fades during the interval, temporarily test a stable source without additional amplitude modulation or effects. Compare playback while the key is down with playback after release. If both fade similarly, investigate the recording or loop rather than extending the MIDI delay.

If playback ends early, inspect the sample endpoint and loop settings. If it continues longer than expected, reduce the sampler’s release and test without effect tails. Change one factor at a time so that you can distinguish the scheduled note ending from the audio produced afterward.

Repeated notes require a separate check. This simple script does not cancel scheduled note-offs or assign a unique identity to each voice. Replaying the same pitch on the same channel before its delayed note-off arrives can therefore produce an unwanted cutoff, depending on the instrument’s voice handling. For this implementation, let a pitch finish before replaying it; rapid repeated-note performance needs a processor designed to manage those overlaps.

Once the short-tap and long-hold tests produce the same interval after release, save the Scripter setting with the instrument patch. Keep the source sustained, the envelope level steady, and the ending brief enough for your intended sound. Those three choices make the delayed note-off produce a useful, repeatable hold.

Section 8

Sources

Related reading

Keep exploring this topic