First time here? Check out the FAQ!
x

Control the decay of a Sample over Time

+1 vote
409 views

How could I implement a control to decay the volume of a Sample (playing back with the Loop On) so it decays over time and gradually becomes softer on every repeat it plays back until it eventually decays to silence:

   Value 1 No Decay

   Value 0.75 - 25% Decay on each Repeat

   Value 0.50 - 50% Decay on each Repeat

   Value 0.25 - 75% Decay on each Repeat

   Value 0 - 100% Decay on next Repeat

 

Thanks

e.

 

asked May 27, 2020 in Capytalk & Smalltalk by eli (Adept) (1,130 points)

1 Answer

+2 votes
 
Best answer

You could use a TriggeredSoundToGlobalController to reduce an !Amp volume EventValue, and trigger that at the same period as the duration of your sample file:

 

 

In this example !Amp is also the value in the Sample's Scale parameter. 
I found that tick tends to trigger immediately on start up so I set the !Amp fader to have an initial value of 1.25 in the VCS. 

You could change the "0.25" value to an EventValue, like !Decrement, that would let you change the amount of decrease each iteration. 

answered May 27, 2020 by alan-jackson (Virtuoso) (15,840 points)
selected May 29, 2020 by eli
Hi Alan,
much appreciated for your response.

That's a very cool idea! :)

However, I forgot an important detail on my description..

The sample is playing back the recorded buffer of a MemoryWriter
So unfortunately I can't use your approach for my case.

So far, I'm triggering Events with 'Decay Rates' to attenuate the volume of the Sample like for example:

   1 - (!Fade ramp: (!BPM bpm s * !DecayRate))

or:

   1 - (!Fade ramp: (!LoopLength / !DecayRate s))

However, I would like to have a dedicated 'live control' as I described above rather than triggering On/Off Events for the Decays.

That way I would be able to stop the decay in real-time at any point, and  freeze the current volume at any stage by just moving the control back to maximum again..

Hope that makes sense.

Thanks,

e.
Is the Sample just looping over the MemoryWriter location so loops for the full duration of the MemoryWriter? In which case how long is the MemoryWriter capture duration?

You can change
    'file.wav' fileDuration s tick....
to
    10 s tick

if your MemoryWriter length is 10s.

The TriggeredSoundToGlobalController allows live override so you can drag the amplitude fader back up at any point. You can also logically AND the tick signal with another !EventValue to turn it on and off using "/\" or by multiplying them together.

Or use the bpm: message instead which is also easy to turn on and off with an !EventValue.

eg:

    !Enable bpm: !LoopLength s
Another approach you can take is to use a triggered ramp but either sampleAndHold it so it stays constant during a single cycle of playback or quantize it using something like:

(((!Fade ramp: !LoopLength / !DecayRate s) * !DecayRate + 0.5) rounded) / !DecayRate
I have implemented a Triggered_STGC with Live Override as you suggested, but my Paca has completely freaked out and I had to reboot..  lol  :D

look, this is what I'm working at:

https://www.dropbox.com/s/qhqbij0sga0vm5i/Looper%20Example.kym?dl=0

Cheers!

e.
Thanks!

But I would like to implement a 'live volume control' integrating the decay option by just moving a knob rather than having to trigger Events if possible..

I have also tried triggering Envelopes and Function Generators for the Fades with great results.

But I would love to find a way to implement a 'live volume control' if possible..

Do I need to lift a sound and create a variable?

or should I use a conditional control based on indexNext: instead?

Thanks!
That seems to work ok.
Alan, mate, it works like a treat! :)
I had a few bugs on my sound
that's why it was not working!

All those tips you advised work splendidly well

Thanks so much!

e.
...