Delay an audio fade?

    Jun 11 2013 | 5:37 pm
    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.

    • Jun 11 2013 | 9:13 pm
      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.
    • Jun 12 2013 | 1:16 pm
      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?
    • Jun 12 2013 | 4:26 pm
      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.
      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.)
    • Jun 12 2013 | 4:32 pm
      Thank you. I will dig into these tonight when I get home.
    • Jun 12 2013 | 8:36 pm
      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.
    • Jun 13 2013 | 6:10 pm
      @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.
    • Jun 13 2013 | 11:56 pm
      Good. Glad to hear it.