我想在Unity中的AudioSource
的输入处生成音频。
我试过使用 OnAudioFilterRead()
MonoBehaviour,但这仅允许您更改AudioSource
之后的音频数据,从而绕过AudioSource
组件上的任何空间/音调/增益等。
我也有使用AudioClip
作为缓冲区,用音频数据填充然后将其加载到AudioSource
的想法,但是我认为如果不知道缓冲区大小并能够加载新剪辑就无法做到这一点。读取每个缓冲区时。由于需要每个新缓冲区,因此没有方法可以读取AudioClip
。
在通过音频源的空间/音调/增益等之前,是否有任何方法可以更改AudioSource
的音频数据?
最佳答案
我自己解决了。这是一个愚蠢的错误。正确阅读OnAudioFilterRead
文档后,我发现它指出:
The audio data is an array of floats ranging from [-1.0f;1.0f] and contains audio from the previous filter in the chain or the AudioClip on the AudioSource. If this is the first filter in the chain and a clip isn't attached to the audio source this filter will be 'played'. That way you can use the filter as the audio clip, procedurally generating audio.
我在
AudioSource
中有一个音频剪辑,它停止了OnFilterRead
,这是DSP链中的第一个过程。卸下音频夹解决了问题!
关于c# - 在AudioSource的输入处生成音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41551906/