# Artificially Extended Drum Duration?

I am watching a beginner's guide to music production using Cakewalk on Youtube. An interesting fact it points out is that adjusting a drum's note duration in the piano roll view has no effect, because the drum sound has a fixed duration. This makes sense from a physical perspective, because in real life a percussion instrument is played by applying an impulse to it, while other types of instruments are played by doing things for variable lengths of time.

However, this is presumably an arbitrary distinction from the perspective of software. If the sound an impulse to a percussion instrument makes is a wave just like any other instrument sound, is it possible for the DAW to extend that wave pattern to match whatever duration the user inputs in the piano roll view? It might not sound like that percussion instrument any more, but I'm curious as to what it would sound like.

Is it possible to trick Cakewalk into thinking a percussion instrument is another type of instrument, or find some other way to make it do this?

• I believe this would be a function of an actual sampler and how the drum samples are created than that of a DAW. Jan 23, 2021 at 6:34
• @JohnBelzaguy Quite the opposite. In the traditional sampler world, there's no way to tell the sampler how long a note should be. The only thing you can say is, "cut the sound already!" Which is not the same thing. :) By the time the sampler gets the "cut it NOW" command, it has already produced incorrect or sub-optimal sound, which it wouldn't have done, had it known in advance how long the note should be. Jan 23, 2021 at 15:09
• @piiperiReinstateMonica So in your answer when you mention the 808 sound with the looped waveform in “ Making a sustained sound from a drum sample” is that not done in the sampler? Jan 23, 2021 at 20:36
• @JohnBelzaguy Yes. That's the MIDI mindset way of doing it. What else can you do? The sampler cannot, for example, place the loop point at a different location depending on how long a note is needed. Upon receiving a note-on, the sampler can only start running at a pre-determined speed, and then suddenly stop running when it's told to cut the note. This is actually not very musical. When a player or singer is told to play or sing a note, they'll do something slightly different depending on the length of the note. A short note is not the same as an abruptly cut long note. But in MIDI it is. Jan 23, 2021 at 20:43
• @piiperiReinstateMonica so where do you create a waveform like that with a loop built into it and how does the sampler recognize that? Sorry for the questions but I’m curious and find it very interesting... Jan 23, 2021 at 20:46

I don't know why I wrote all this but here goes:

# Note duration in MIDI

The way most synthesizers and samplers (and other similar instruments) work is constrained by the conceptual model behind the MIDI standard from 1982. In that model, there is (1) a controller keyboard (physical or virtual) and (2) a "synth", i.e. a sound-producing component (physical or virtual), which receives command messages from the keyboard. The keyboard can only say, "note on" and "note off". The keyboard cannot say, "play a note which should last for one second". Explicitly stating note lengths to synths is not a part of the MIDI command language, note lengths are implicitly derived from more elementary atoms: Note-Ons and Note-Offs. In MIDI, the length of a note is not known by the synth when it starts producing sound. Maybe the keyboard player never releases the key until the power runs out - the synth cannot know. This may seem like a minor detail, but a lot of things arise as a consequence from this conceptual model.

In a Digital Audio Workstation or DAW, there is an integrated sequencer, which acts as the keyboard player, sending commands to a synth. As long as the sequencer and synth are using a MIDI-like interface to communicate, not necessarily using physical MIDI connectors and cables, but using MIDI messages on a logical level, they have no choice but to operate within the conceptual model of MIDI. The DAW cannot tell the synth (external hardware synth or VST/AU/whatever instrument plugin) in advance, how long a note should last. There are other, different protocols and interfaces where this is possible, but not with plain old MIDI from 1982.

Depending on the type of desired sound and instrument behavior, not being able to explicitly say things about note duration might be irrelevant, or it can be a minor nuisance that can be worked around, or it can be a real problem. For example, imagine a speech/vocal synth that's able to sing syllables of different lengths. If commanded via MIDI note on/off messages, some kind of a hack-around has to be invented to let it sing each syllable with the appropriate speed. If the sounds of a syllable are the wrong lengths, it may change the whole meaning of the word, or at least it can sound silly. What to do? Maybe use different MIDI programs for each different length? Perhaps use a control change message to transmit the syllable speed information? Maybe use... aftertouch? Velocity? However it's done, it's basically application-specific and won't automatically work the same across MIDI devices.

To sum up the MIDI model of note durations:

• In MIDI, a short note = a chopped-off long note

If we have two identical MIDI synths with identical settings, and one of the synths is given a short note and the other a long note at the same time, they will output the exact same thing up until the short note is cut off.

For many instruments and types of sound, that sort of model is OK. But what you cannot do is the kind of audio time stretching you're used to in DAWs, in a note-length-dependent way. That cannot be done with MIDI notes.

Next I'll explain how to do it the MIDI way.

# Sustaining and non-sustaining sounds

Sounds produced by MIDI synths can be categorized to two types: sustaining and non-sustaining sounds. The difference is in how the MIDI Note-Off message is handled.

• A sustaining sound keeps producing sound - or its envelope stays in a "sustain" phase - while a note (keyboard key) is held down. When the note is released, i.e. when the synth receives a Note-Off message, the sound stops or the envelope enters a "release" phase. Piano, organ, synth pad, guitar, bass, etc. are usually done as sustaining sounds.
• A non-sustaining sound starts at Note-On (keyboard key press), but its length or envelope stays the same regardless of when or if there is ever a corresponding Note-Off event. Drum sounds are typically non-sustaining. They are just triggered, fire and forget. When a Note-Off message comes, the synth basically doesn't react at all. Or at least it doesn't affect the envelope.

Sustaining sounds employ an envelope which has a sustaining phase. Envelopes are used most importantly to control the volume (gain/amplification) of a sound, starting from the Note-On moment. The final, ending phase of the envelope is called release. The envelope for a sustaining sound doesn't enter the release phase until it's told to do so, and that happens when the synth is sent a Note-Off message, i.e. when the keyboard key is released.

The envelope for a non-sustaining sound enters the release phase on its own, without waiting for any Note-Off message to arrive.

Here is an example where a non-sustaining drum sound sample is triggered, first by a short MIDI note and then by a long one. As you can see, the same sound output is produced for both the short and long note.

The waveform looks like this in the sampler.

# Making a sustained sound from a drum sample

How can we make this a sustained sound? If we switch on a sustaining envelope for the drum sample, we get some difference in duration between the notes, but the sound produced by the long note is only very slightly longer than one produced by the short note:

The problem is, even though the envelope keeps saying "full volume!" until the Note-Off, it is only filtering/attenuating the sample, and as the drum sample's sound (waveform) fades out, so does the final output.

To create a really sustaining sound, the wave attenuated by the volume envelope has to be much longer, so the envelope has something to attenuate. For a synthesizer sound it works, because the volume envelope is getting a wave from an oscillator which produces an infinitely long sound all the time. For an acoustic piano or, say, Rhodes sample, this works, because a piano note can easily be 20 seconds long, which is practically infinitely long compared to the envelope, so the envelope has time to enter the sustain phase. But a typical drum sample is much shorter, for example 2 seconds. In order to have something for the envelope to process, we need to somehow make the drum sample significantly longer, in other words stretch it, as the OP suggests.

Because of the MIDI model of unknown note lengths, the most straight-forward way is to stretch the sample "enough", and then let the volume envelope cut the notes to the desired length. One way to stretch a sample infinitely is to loop it. Here is the 808 drum sample with a loop:

And the same waveform zoomed in to see the loop:

Now we can have the sound sustain for as long as we want:

But now it doesn't really sound like a drum. It's more like an organ, because the single-cycle loop is so steady and organ-like. To make it more like a drum again, we'd have to add more refined envelopes for the pitch and volume... but then it would be more like synthesizing a drum sound with an oscillator. Too bad we can't have sound here, so you'll just have to imagine what it sounds like, or try it out with a sampler.

However, what happens if we time-stretch the sample with Ableton Live's "tones" algorithm which tries to preserve the original tone somehow. Let's stretch it by 8x, so the 2-second sample gets close to 20 seconds.

Now it resembles a drum, but so that the length is noticeably controlled by MIDI Note-On and Note-Off messages.

However, what the OP seems to be asking is, how to get a different time-stretch factor for each and every note, so that the time stretch is precisely and automatically adjusted for each note length. Because of the limitations in the conceptual model of plain old MIDI, I don't think that's easily done with samplers. You could do it in a DAW with time-stretching facilities, manually stretching each note to the desired length. Or you could use an array of pre-stretched samples, with a different sample length for each desired note length. Or you could somehow use time stretching facilities which are meant for mangling audio loops. But in any case, you won't be able to do it with plain old MIDI notes, at least not easily and not in a way directly supported by the old standard. As far as I know.

There are some newer "post MIDI 1.0" interfaces and software systems which might directly and specifically support the concept of note length. In any such scenario, it must be assumed that the notes come from a sequencer or notation program, which knows the note lengths before playing the notes. In live realtime keyboard playing it cannot be done.

• Wallander NotePerformer. This is a synth, a sound-producing program which integrates with notation programs such as Sibelius, Finale and Dorico. Before starting to produce sound, it pre-reads the notation for a long segment of the whole piece and tries to take lengths, slurs, techniques, expressions, hairpins etc. into account, and translate all that into a musical performance resembling human players.
• Steinberg VST Expression? This is a beyond-MIDI protocol, intended for producing orchestrations in DAWs. At a quick glance it seems that there is some support for lengths of things.
• MIDI 2.0?? I don't know if this is possible with the new MIDI 2.0. Maybe, if note lengths can be transmitted to synths, then a sampler could use an appropriate time-stretch value depending on the note length.
• ... what else? I'm sure there are integrated DAW + synth combos out there, but this is what I could get off the top of my head.

When it comes to MIDI sequencing, a DAW (like cakewalk) sends MIDI messages to a MIDI synthesizer plugin. It's the job of that synthesizer plugin to decide how to respond to those MIDI messages.

Often, a synthesizer playing percussion sounds will be set up so that it doesn't respond to MIDI note-off messages (at the end of the note), so that the MIDI message saying 'stop playing this sound' doesn't actually do anything. This is one reason why the duration of the MIDI note often doesn't matter when playing drum sounds.

Of course if you are playing a synthesizer that just triggers a very short audio sample (like a closed hi-hat), that's another reason why the duration of the MIDI note may not make much difference - because however long the MIDI note is, the sample will stop playing after a certain length of time.

In any case, the way to make the length of the MIDI note (and the duration in the piano roll) actually make a difference is:

• Set up your synthesizer so that it responds to note-off messages
• if the synthesizer is just playing a sample, make the sample long enough to continue for the range of durations you want
• if the synthesizer is generating its own sounds, make sure the envelope is set up to allow the sound to continue for the range of durations you want

Disclaimer: I don't know anything about Cakewalk specifically, so I don't know if using that drum map view instead of the piano roll does anything with regard to disabling MIDI note-off messages.

• Just wanted to add that if you start meddling with the duration of the sample, pretty fast it will start sounding "wrong", i.e. our brain knows what a drum should sound like and will know it's not correct. Jan 23, 2021 at 11:51

You don't give your Cakewalk version but I assume you're using CWBB; if not, and you're using a legacy version for some reason, the following is pretty general and most or all of it should apply to earlier versions.

The Cakewalk Session Drummer (now SI-Drum Kit) uses a combination of MIDI and WAV sample files. When you load a drum program at the UI, Cakewalk opens the selected program and then loads the corresponding sample files (WAV etc).

Although I haven't tried this myself, it should therefore be possible to change an instrument sound by substituting a different WAV file containing your stretched sound, which you have created in a wave editor. I tend to use WaveLab but I believe there's a wave editor built into Cakewalk or you may use something else. Each piece of the drum kit (snare, hi-hat etc) is an "instrument", and according to Scott R. Carrigus in his SONAR books,

An instrument can be any audio sample file in the following formats: WAV, AIF or AIFF, or OGG. In addition, instruments can be represented by SFZ files, which are not audio files but definition files that define how audio files should be loaded.

(The SFZ files are multisample files, and link to a set of samples for the same instrument being hit hard or soft etc. More on SFZs below, as you may wish to make use of the feature in your experimental changing of an instrument sound.)

You can find Cakewalk's instrument sample files in the following Windows folders:

Carrigus goes on to say that you can also create your own SFZ files if you're interested in doing so. The rgcaudio link is now dead but you can find a discussion about it here, along with a link to the archived rgcaudio page: https://www.kvraudio.com/product/sfz-by-cakewalk

Still on the multisample (SFZ) aspect, that discussion mentions difficulty obtaining the sfz program, but actually it seems now to be included in CWBB; I find it to be present and I'm pretty sure I didn't add it myself. You may also open SFZs in the TX16Wx software sampler linked from the same discussion.

A final note on WAV files: it seems Cakewalk uses a proprietary format, so you probably can't edit the existing WAV files for the Cakewalk instrument samples. If you try to play them in VLC or WMP, they just make a harsh buzzing sound. So you will need to make your own recording as the starting point for custom sounds that you map to the drum instruments. I use the word "map" to refer to the file substitution, and not Cakewalk drum maps which are MIDI-only so won't help here.

As you can see, there's quite a lot to think about but if you're up for it, I hope this gets you moving along the way in your experiments to change a sampled drum sound.