Closed jinpavg closed 1 year ago
Okay, I can refine this. In an HDRP project, the custom filter, when paired with an AudioSource with spatial blend set fully to "3D" will have the same glitches as one in a URP project.
Can you see if this happens when you build the project and run outside of the editor?
Okay! this build (which should run on Windows), does not glitch like it does in-editor! So it does seem to be an editor issue.
My Unity version is: 2021.3.21f1
@jinpavg are there more repro instructions for the glitch? I have run both "GenAudioGlitch" and "GenAudioGlitchURP" in my windows VM and the glitch isn't reliable.. sometimes, sporatically, like at most once a minute or two, I get a retrigger like stutter.. Is that what you're talking about? BTW, I noticed that the URP project wasn't set to render in the background, so I updated that.
This doesn't seem to be a RNBO issue, but rather a Unity Editor issue. I can repro this with a completely empty URP project and the following script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class SineTest : MonoBehaviour
{
public float gain = 0.5F;
private double phase = 0.0;
private double sampleRate = 0.0F;
void Start()
{
sampleRate = AudioSettings.outputSampleRate;
}
void OnAudioFilterRead(float[] data, int channels)
{
double sample = AudioSettings.dspTime * sampleRate;
int dataLen = data.Length / channels;
int n = 0;
while (n < dataLen)
{
float x = gain * Mathf.Sin((float)phase);
int i = 0;
while (i < channels)
{
data[n * channels + i] += x;
i++;
}
phase += 0.03;
n++;
}
}
}
Loading a RNBO plugin as a custom filter using the
OnAudioFilterRead()
callback reliably glitches after a few seconds in projects using the Universal Render Pipeline. In the dropbox link here, you can find two projects, identical except one is using the built-in renderer and the other is using the URP. I've also attached the RNBO patch (it's thernbo~ @title one-parter
) below.https://www.dropbox.com/s/yt712g2noj7knlw/AudioGlitch.zip?dl=0
gen-two-parter.zip