How to fade playing a sample via midi once playback starts

Nickipedia Member Posts: 6 Newcomer
edited April 2023 in Scripting Workshop

Here's the setup guys.

Digital Performer 11. Show is setup with a chunk per song.

Interludes being played via midi from a drum pad to a module to Kontakt 7 as a Virtual instrument in Digital Performer.

Songs are started via footswitch that acts as the spacebar (start/stop) inside of DP.

He wants to be able to start a song via the footswitch, and have the interlude sample stop, and fade out when he hits the footswitch. Not an abrupt end, or having to hit the drum pad a second time to stop the sample (using MIDI Latch currently to keep the sample playing).

Is this something I can do in Script Editor (and how?), another way, or not possible.


  • Uwe303
    Uwe303 Moderator Posts: 2,913 mod
    edited March 2023


    how do you translate the FS to a spacebar press? There is a program called bomes midi translator and with that you could maybe build something that the start song press also triggers a note to stop the interlude or something like that.

  • jamesgilmour
    jamesgilmour Member Posts: 1 Newcomer

    To fade a sample via MIDI once playback starts, you can use MIDI control change messages to modify the volume of the sample over time. Here's a step-by-step guide on how to do this:

    Determine the MIDI CC number you want to use for the volume control. This could be any number between 0 and 127, but it's best to use a number that's not already being used by other controllers in your setup.

    Map the MIDI CC number to the volume parameter of your sample. This will vary depending on the software or hardware sampler you're using. Consult your sampler's documentation for instructions on how to do this.

    Set the initial volume of the sample to its maximum level.

    Create a MIDI sequence that sends a series of MIDI CC messages to gradually decrease the volume of the sample over time. The rate at which you send these messages will determine the speed of the fade. For example, if you send one message every millisecond, the fade will be very fast, whereas if you send one message every second, the fade will be much slower.

    Start playback of the MIDI sequence and the sample simultaneously. The MIDI CC messages you created in step 4 will gradually decrease the volume of the sample over time, creating a fade effect.

    Note that the specific steps to accomplish this may vary depending on the software or hardware sampler you're using, so it's important to consult your sampler's documentation for detailed instructions.

    Javascript assignment Help

  • Nickipedia
    Nickipedia Member Posts: 6 Newcomer

    Thank ya, I was completely over thinking some stuff when it came to this.

  • Gee_Flat
    Gee_Flat Member Posts: 906 Guru
    edited April 2023

    if he's just hitting the pad once to start the interlude sample, then all you need to do is increase the 'Release' time on the volume envelope (AHDSR). Instead of stopping dead it will hang and fade.

  • stephen24
    stephen24 Member Posts: 259 Advisor

    Alternatively you could try this multiscript:

    on midi_in
     set_midi (1,$MIDI_COMMAND_CC,123,0)
     end if
    end on
    {note that channel numbers for the computer are 0-15, not 1-16}

    When you play a note on channel 1, it switches off all notes on channel 2. Assumes your song is on channel 1 and the interlude on channel 2. As Geeflat suggests, you can adjust the release time of the interlude sample to taste. Paste into a KSP slot and click Apply. If it doesn't work EvilDragon will correct any errors for you if you feed him chocolate.

Back To Top