Delay an audio fade?

Jun 11, 2013 at 10:37am

Delay an audio fade?

I have created a patch that takes two parameters: an audio signal and a threshold value (in dB). A screenshot of this patch is attached. Currently, it outputs audio when the signal is above the threshold level and no audio when the signal is below (a very basic gate).

What I want to do is trigger a fade of the audio 1) after a certain time has passed since the threshold was broken and 2) over a certain amount of time. For example, the audio would fall below the threshold, thus breaking the threshold, and trigger the timer that will fire the fade. If the signal goes back above the threshold, the timer would be reset.

I don’t know what objects I should use to do this. What would you recommend? Should I be using `gate~` at all?

P.S.: I posted under Max4Live because I am working in Max under Live. This isn’t really M4L specific, though.

Attachments:
  1. audio_threshold_patcher
#252425
Jun 11, 2013 at 2:13pm

you did not ask this, but are you sure that you want to use [>~ 12] on a music signal to do something to its power?^^
it should be better to measure the power of the incoming signal first before doing that, otherwise [>~] won´t do anything. oh, and i would eventually convert the db/A value to linear 0.-1.

now to your gate, this seems the right method. note that it takes floating point. you could put a slide~ before it for some fade in fade out or something like that.

#252454
Jun 12, 2013 at 6:16am

I don’t understand why it wouldn’t work. According to the documentation the left inlet can be a signal and the right an int or float to compare against. So the impression I get is that the object converts the incoming signal into a value (e.g. dB) that can be compared to the value in the right inlet. Is this not the case?

How would I go about convert the dB/A value to a 0…1. value?

#252508
Jun 12, 2013 at 9:26am

In answer to your question,
>> How would I go about convert the dB/A value to a 0…1. value?
dbtoa or dbtoa~ (or, in the other direction, atodb or atodb~).

In answer to what I understand to be your original question, here are two example patches.

This first one doesn’t incorporate any delay, but does use smoothing to create a ramp on and off instead of an instantaneous switch on and off. I find this is quite adequate as a general-purpose ducker in live performance.

<code>

– Pasted Max Patch, click to expand. –

</code>

This second one waits a certain amount of time before it begins the release ramp, and if the input signal goes back above the threshold during that time it cancels the release. (The default amplitude threshold is -40 dB.)

<code>

– Pasted Max Patch, click to expand. –

</code>

#252519
Jun 12, 2013 at 9:32am

Thank you. I will dig into these tonight when I get home.

#252520
Jun 12, 2013 at 1:36pm

the left value can be compared against the right value, of course.

but what do you exspect when comparing the music with a db/A value?

db/A values should be compared against db/A values i think.

#252535
Jun 13, 2013 at 11:10am

@Christopher Dobrian, thank you for the patches. They are very clear. I’m going to spend some time studying them to learn how they work. I do believe they answer my question.

#252654
Jun 13, 2013 at 4:56pm

Good. Glad to hear it.

#252698

You must be logged in to reply to this topic.