Something that comes to mind is to apply different envelopes to each sinusoid you create inside an instrument:
0dbfs = 1
instr 1
kFirstEnvelope line 0, p3, 1
kSecondEnvelope line 0.5, p3, 0.5
kThirdEnvelope line 1, p3, 0
aFirstSine oscili 1, 440
aSecondSine oscili 1, 660
aThirdSine oscili 1, 880
aMix balance aFirstSine * kFirstEnvelope + aSecondSine * kSecondEnvelope + aThirdSine * kThirdEnvelope, a(0.15)
outs aMix, aMix
endin
You could then call instr 1
from the score with a single line of code, and you would probably want to come up with more interesting envelopes than the ones above.
i 1 0 10
However, if you are doing additive synthesis, a more elegant approach would be to trigger multiple score events from a separate instrument using event_i
within a until
loop.
instr 2
seed 0
iNoteIndex = 0
iNoteCount = 30
until iNoteIndex == iNoteCount do
iRandomStart = random(0, p3)
iRandomDuration = random(1.2, 0.5 * p3)
event_i "i", 3, iRandomStart, iRandomDuration
iNoteIndex += 1
enduntil
endin
instr 3
iAttack = .2
iDecay = .2
iSustain = .4
iRelease = 0.6
aSineWave oscili 0.1, random(200, 4000)
kEnvelope adsr iAttack, iDecay, iSustain, iRelease
outs aSineWave * kEnvelope
endin
You can then call instr 2
from the score, and that will take care of calling instr 3
.
i 2 0 10
Cheers