Question by
julialc4 · Aug 15, 2018 at 03:29 AM ·
audioupdateupdate problemmixing
Lowpass Exposed Parameter not updating in AudioMixer
Hello,
I have a Low Pass Filter on a signal going through an AudioMixer. And even though the Debug.Log shows the correct Cutoff value changing and that the mixer has the correct value changing, the actual field in the AudioMixer is not updating with SetFloat.
I cannot see why not? Any help is greatly appreciated, I've spent a while moving ClearFeilds() around to no avail!
Here is the code:
public class MixerControl : MonoBehaviour {
public AudioMixer audioMixer;
private GenerateDataSignals Generator;
private float Cutoff;
private float Resonance;
private float outCutoff;
void Awake () {
audioMixer = GetComponent<AudioSource>().outputAudioMixerGroup.audioMixer;
Generator = GetComponent<GenerateDataSignals>();
}
private void Update()
{
ClearFeilds();
Cutoff = Generator.Cutoff;
Resonance = Generator.Resonance;
audioMixer.SetFloat("CutoffMix", Cutoff);
audioMixer.SetFloat("ResonanceMix", Resonance);
outCutoff = getCurrentValue("CutoffMix");
//if the value has changed reset the float
if (outCutoff != Cutoff)
{
audioMixer.SetFloat("CutoffMix", Cutoff);
audioMixer.SetFloat("ResonanceMix", Resonance);
}
Debug.Log("++++++ Mixer cutoff got: " + Cutoff);
}
#region AudioMixerFunctions
public float getCurrentValue(string feild)
{
float value;
bool result = audioMixer.GetFloat(feild, out value);
if (result)
return value;
else
return 0f;
}
public void SetMixerPitch(float pitch)
{
audioMixer.SetFloat("AudioMasterPitch", pitch);
}
public void ClearFeilds()
{
audioMixer.ClearFloat("CutoffMix");
audioMixer.ClearFloat("ResonanceMix");
}
#endregion
}
Comment
Your answer
