Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

AudioLowPassFilter.cutoffFrequency does not work

Discussion in 'Scripting' started by willemsenzo, Apr 1, 2013.

  1. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
    So I'm trying to change the lowpassfilter cutoff frequency this way:
    Code (csharp):
    1.  
    2.         AudioLowPassFilter filter = GetComponent<AudioLowPassFilter>();
    3.         filter.cutoffFrequency = 1000f;
    4.  
    I'm getting this error:

    Only custom filters can be played. Please add a custom filter or an audioclip to the audiosource (GameObject).

    When I try to change the cutoff frequency of the highpass filter, it seems to work fine:

    Code (csharp):
    1.  
    2.         AudioHighPassFilter filter = GetComponent<AudioHighPassFilter>();
    3.         filter.cutoffFrequency = 1000f;
    4.  
    I've searched on google and couldn't find many topics about this, I found http://forum.unity3d.com/threads/131908-Low-Pass-filter-problems but no solution. Anyone an idea how to fix this or is this hopeless?
     
  2. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
  3. EliteMossy

    EliteMossy

    Joined:
    Dec 2, 2012
    Posts:
    513
    Do you have UnityPro?
     
  4. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
    Ehm yeah because If I didn't how would I be able to make the high pass filter work?
     
  5. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
    I figured out that it actually does work, but the value of the cutoff frequency never changes in the inspector so there definitely is some weird bug.

    Problem solved, thread can be closed now.
     
  6. samim23

    samim23

    Joined:
    Sep 11, 2012
    Posts:
    60
    Same behaviour here. Thanks for the headsup. I don´t see it in the editor, nor do i hear any changes when changing this value per script, rather annoying. A fix would be nice.
     
    Last edited: Sep 13, 2013
  7. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    How did you solve the problem?

    Edit: Sorry I misread.

    It does work, but the inspector isn't updating.
     
    Last edited: Jan 14, 2014
  8. Le-Pampelmuse

    Le-Pampelmuse

    Joined:
    Jan 2, 2015
    Posts:
    26
    It does not work for Unity 5.
    It doesnt change in the inspector nor in-game.
    Only if I slide the value in the inspector at runtime.

    My code is very simple, just a bool check that alternates between setting the cutoff to 500 or 5000.
    The filter is never affected, i tried Mathf.Lerp first but then resorted to trying simpler things.

    Annoying and unnecassary.
     
  9. PabloIH

    PabloIH

    Joined:
    Sep 20, 2014
    Posts:
    12
    It doesn't work for me. Changing cutoff frequency runtime by script only works in editor but not in builds