Cabbage Logo
Back to Cabbage Site

How to add ADSR to Sampler (instrument)?

Hi ,i’m new~ :laughing: :laughing:
I have so many questions, hope someone can help???

#how to get Cabbage Pro
#how to add sampler to presets

Depends on what you’re trying to do. This example would load a stereo wave, for example a pad sound. Then the ADSR envelope has a 2 second attack, 0 second decay, sustains at full volume then has a 2 second release.

instr 1
aL,aR diskin"pad.wav", 1, 0, 1
kEnv = adsr(2, 0, 1, 2)
    outs aL*kEnv,aR*kEnv

I’m still testing

Hi @huen97, welcome to the forum :slight_smile: So you still need to use the output of your madsr, i.e, kEnv and use it to scale your audio output:

outs a1*iAmp*kEnv, ...

Btw, it’s better to post and format code. That way we can quickly copy and paste it to see how it runs. :slight_smile:

TEST.csd (1.5 KB)

Code file

Same the thing applies as I wrote earlier. You’re not using your kEnv variable.