Search Unity

Simple limiter

Discussion in 'Audio & Video' started by twobob, Mar 9, 2015.

  1. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hi,

    Please can we have a simple limiter.

    It is incredibly easy to drive the current effects suite into distortion accidentally.

    A trivial limiter implementation could save me replacing some very expensive cones.

    Much obliged.

    Suppose I could write one :(

    :D
     
  2. Fera_KM

    Fera_KM

    Joined:
    Nov 7, 2013
    Posts:
    307
    I second this!


    But I guess, we can sort of use a compressor, setting attack and release to minimum, seeing as it doesn't have a ratio... though, doubtful about "brickwall'ing it".
     
  3. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    The lack of ratio on the compressor was ultimately what led me to this.

    I did write an incredibly trivial synth gen for the new audio API when it came out (the pluggable code thingy that I utterly fail to recall any further details of) in essence all we are asking for is /possibly/ already covered in the actual output line implementation. I have no idea since its code is in UT land. However given the propensity to kick the living death out of my studio cones (and my poor old ears) with the slightest of mis-swipes... I am guessing "No" or "Not Really".

    But more or less a brick-wall limiter - in whatever form - attached to the output would make me feel better.
    As I am intimating here it would /probably/ be one of the most simple to implement plugins.

    Perhaps I might be bothered to do it in the absence of other volunteers. No promises.
     
  4. Fera_KM

    Fera_KM

    Joined:
    Nov 7, 2013
    Posts:
    307
    I'd be very interested if you did manage to write one, even at purchasing it, not being much of a coder myself.
     
  5. JeffForKing

    JeffForKing

    Joined:
    Apr 8, 2014
    Posts:
    25
    Would you be willing to share your synth code? I'm trying to see as many examples as possible of new unity audio code as I'm learning and trying to wrap my head around it. I browsed through your messages real quick but didn't see anything
     
  6. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Aight. I'll have a butchers about - it really was something dead trivial like "Sine Osc" at "Rate" and "Amplitude".

    Really fancy. I'll dig it up but in essence it was just a unity example reworked.

    Will dig, hell I might even make a limiter i I manage to dredge up the memories - it was super trivial to do
     
  7. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Not to take the credit from others... I pretty much just butchered
    http://www.develop-online.net/tools-and-tech/procedural-audio-with-unity/0117433
    to my needs.

    That contains enough info for both the sin osc and the limiter projects.

    Enjoy

    and here is just for funz (and to say thanks for that great info) a full implementation of a wind example (that they sell I think for certain platforms - not unity as far as I know) that is linked to the onscreen info, which is cool enough to share. :) and would be the kind of thing I would like to implement. data -> sound

     
    JeffForKing likes this.
  8. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    I am going to end up writing this at this point aren't I... sigh

    Ah well I am going to visit my mate who is also a long-served sound engineer (like poor old me) give us something to talk about :)
     
    JeffForKing likes this.
  9. retraffic

    retraffic

    Joined:
    Jul 2, 2014
    Posts:
    13
    are you maybe willing to give a few more informations on what you managed to do so far? from the website you linked I couldn't extract any information that would help me implement some sort of brickwall limiter for the new audio mixer.
     
  10. Luc0ghk

    Luc0ghk

    Joined:
    Jan 4, 2016
    Posts:
    2
    Last edited: Jan 8, 2016
  11. kaufmanmoon

    kaufmanmoon

    Joined:
    Jan 27, 2015
    Posts:
    3
    A simple brickwall limiter would be a god send wouldn't it?
     
  12. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Tried requesting it on feedback site? It's just nobody actually really requests audio features, so Unity doesn't think so much about it.
     
  13. kaufmanmoon

    kaufmanmoon

    Joined:
    Jan 27, 2015
    Posts:
    3
    Will do. I'm amazed they've not thought of this. Surely there must be digital clipping going on all over unity games?
     
  14. wheatgrinder

    wheatgrinder

    Joined:
    Mar 20, 2015
    Posts:
    21
    A compressor on the MASTER mixer track will get real close to a limiter. Instant attack and infinite(never) release.

    Another consideration you might consider is rolling your own?

    I was frustrated with the lack of a input gate. I wanted the signal from my mic to be muted unity it hit a specific input level. (typical input gate right?)

    It was pretty simple few lines of code. The idea is that once the input level of the mic reaches the playbackThreshold,
    I ramp the volume of the mixer track that the mic OUTPUT is assigned to UP to the desired OutputLvl. the ramp variable lets me set how FAST the transition from -80db to OutputLvl takes place.

    void FixedUpdate()
    {
    loudness = GetAveragedVolume() * sensitivity;
    masterMixer.GetFloat("micOutLvl", out curLvl);
    if (loudness > playbackThreshold)
    {


    float newLvl = Mathf.Lerp(curLvl, OutputLvl,Time.deltaTime * ramp);

    masterMixer.SetFloat("micOutLvl", newLvl);

    }
    else
    {


    float newLvl = Mathf.Lerp(curLvl, -80.0f, Time.deltaTime );

    masterMixer.SetFloat("micOutLvl", newLvl);


    }


    }

    float GetAveragedVolume()
    {
    float[] data = new float[256];
    float a = 0;
    GetComponent<AudioSource>().GetOutputData(data, 0);
    //Debug.Log(data.ToString())
    foreach (float s in data)
    {
    //Debug.Log(s.ToString());
    a += Mathf.Abs(s);
    }
    return a / 256;
    }
     
  15. Transit161

    Transit161

    Joined:
    Dec 15, 2015
    Posts:
    2
    Hey everyone,

    I'm getting ready to submit a mastering limiter plug-in to the Unity asset store. It's been optimized for the cleanest sound for the minimum latency with the idea that that would be a useful thing for video games. However, I'm more of an audio guy than a game dev. Would anyone have any interest in checking it out and giving me some feedback before it goes live? If so, email me at newfangledaudio@gmail.com

    Thanks,
    Dan
     
    Last edited: Mar 21, 2016
  16. doublegumbo

    doublegumbo

    Joined:
    Oct 24, 2013
    Posts:
    53
    thankyou @Transit161 for making this plugin. exactly what I need. will be buying shortly.

    :D
     
  17. Fera_KM

    Fera_KM

    Joined:
    Nov 7, 2013
    Posts:
    307
  18. doublegumbo

    doublegumbo

    Joined:
    Oct 24, 2013
    Posts:
    53
    The Newfangled audio plugin got deprecated. What happened @Trainsit161??
     
  19. Paalo

    Paalo

    Joined:
    Jan 20, 2016
    Posts:
    8
    Hi all!
    I ran into the same problem with Unity not having a Brickwall Limiter-effect on hand. So I made a workaround using the "Duck Volume"-effect (because of its ability to set the "Ratio"- and "Knee"-values) and different busses. The bus-setup goes like this:
    • MASTER OUT
      (Duck Volume at end of FX-chain, receives input from MasterPrivate, and thus works as a "Limiter". Apply all other master FX, eg. Compression, EQ, etc., BEFORE the Duck Volume-effect)
      • MASTER PRIVATE
        (Gathers all the Game's audio through itself and sends it into the Duck Volume on MasterOut, feeding your newly made "Limiter" with input to react upon)
        • MUSIC
        • SFX
        • REVERB SEND
        • [YOUR OTHER COOL BUSSES HERE]
    Image of the MasterOut-bus Setup:
    BrickWallLimiter - MasterOut.PNG

    Image of the MasterPrivate-bus Setup:
    BrickWallLimiter - MasterPrivate.PNG
    • Duck Volume Settings:
      • Threshold: [whatever you want, but usually around -1dB to -0,3dB)
      • Ratio: 1000% (ie. Brickwall)
      • Attack Time: 0 ms (or something very low)
      • Release Time: [whatever you want, depends on how transparent/obvious you want to make the limiting-effect]
      • Make-up Gain: 0 dB
      • Knee: 0 dB (Brickwall, but experiment since this value is just dependent on how low your Threshold is)
      • Sidechain Mix: 100% (Make it react to ALL the sent input from Master Private)

    Image of the Duck Volume Settings:
    BrickWallLimiter - DuckVolumeSettings.PNG

    And there you go, now you have yeself a Bootleg Brickwall Limiter by "hacking" Unity's Audio Mixer Modules & Effects!

    Check out my Imgur Post for nice pictures of the setup and the Duck Volume-settings.

    Hope this helps someone out!

    Pablo Sorribes Bernhard
    Programmer, Composer & Sound Designer
    pablosorribes.com
     
  20. kswna

    kswna

    Joined:
    Apr 5, 2022
    Posts:
    2



    Hello, Paalo. I tried this with every settings are same to you but there were distortion and clipping.
    Visually, It was work in Audio Mixer but.... T.T
     
  21. MrDizzle26

    MrDizzle26

    Joined:
    Feb 8, 2015
    Posts:
    36
    I wasn't getting clipping, but I was getting "squarification" of the waves when I overloaded the input into the master, which can sound like distortion, but actually indicates it's working. So thanks!