c# - 在AudioSource的输入处生成音频

标签 c# audio unity3d

我想在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/

相关文章:

c# - 处理 .NET 应用程序中的泄漏(事件类型)

c# - Asp .net MVC 5路由属性与路由之间的ID

c# - 将数据行值与 if 中的字符串进行比较

javax.sound.sampled 它是如何工作的?

javascript - 我想在用户等待时播放警报中的响铃声音

C# 脚本与 C# 编程

c# - 为什么 ThirdPersonController 角色在点击按钮后站在向上移动的平台上时会口吃?

c# - MassTransit 中的 PubSub 示例

ios - 启用 Bitcode 的 Apple APP Store 上的移动应用程序大小

java - 在字节数组上模拟吉他放大器的失真