本文介绍了混响算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个简单的或注释的混响算法,即使在伪码中也会有很多帮助。

I'm looking for a simple or commented reverb algorithm, even in pseudocode would help a lot.

我发现了一对夫妇,

推荐答案

这里是一个非常简单的实现延迟线,将产生一个混响效果在现有数组中(C#, buffer is short [] ):

Here is a very simple implementation of a "delay line" which will produce a reverb effect in an existing array (C#, buffer is short[]):

int delayMilliseconds = 500; // half a second
int delaySamples =
    (int)((float)delayMilliseconds * 44.1f); // assumes 44100 Hz sample rate
float decay = 0.5f;
for (int i = 0; i < buffer.length - delaySamples; i++)
{
    // WARNING: overflow potential
    buffer[i + delaySamples] += (short)((float)buffer[i] * decay);
}

基本上,取每个样本的值,乘以衰减参数并将结果添加到缓冲区 delaySamples 中的值。

Basically, you take the value of each sample, multiply it by the decay parameter and add the result to the value in the buffer delaySamples away.

这将产生真正的混响效果,因为每个声音将听到多次衰减幅度。为了得到更简单的回声效果(每个声音只重复一次),你使用基本相同的代码,只需反向运行循环。

This will produce a true "reverb" effect, as each sound will be heard multiple times with declining amplitude. To get a simpler echo effect (where each sound is repeated only once) you use basically the same code, only run the for loop in reverse.

更新:,此上下文中的reverb一词有两种常见的用法。上面的代码示例产生了卡通中常见的经典混响效果,而在音乐应用中,该术语用于表示混响,或者更通常地表示人工空间效果的产生。

Update: the word "reverb" in this context has two common usages. My code sample above produces a classic reverb effect common in cartoons, whereas in a musical application the term is used to mean reverberation, or more generally the creation of artificial spatial effects.

关于混响的文献是如此难以理解的一个大原因是,创建一个好的空间效果需要比我的样本方法更复杂的算法。然而,大多数电子空间效应是使用多个延迟线建立的,所以这个例子希望说明发生了什么的基础。为了产生一个非常好的效果,你可以(或者应该)使用FFT或者甚至是简单的模糊来混响混响的输出。

A big reason the literature on reverberation is so difficult to understand is that creating a good spatial effect requires much more complicated algorithms than my sample method here. However, most electronic spatial effects are built up using multiple delay lines, so this sample hopefully illustrates the basics of what's going on. To produce a really good effect, you can (or should) also muddy the reverb's output using FFT or even simple blurring.

Update 2:以下是多延迟线混响设计的几个提示:

Update 2: Here are a few tips for multiple-delay-line reverb design:


  • 选择不会对每个延迟线产生积极干扰的延迟值其他(在波的意义上)。例如,如果您在500ms处有一个延迟,在250ms处有一个延迟,则会有许多具有来自两条线的回波的点,产生不切实际的效果。

  • Choose delay values that won't positively interfere with each other (in the wave sense). For example, if you have one delay at 500ms and a second at 250ms, there will be many spots that have echoes from both lines, producing an unrealistic effect. It's common to multiply a base delay by different prime numbers in order to help ensure that this overlap doesn't happen.

在一个大房间里(在真实的房间里)世界),当你发出一个噪音,你会倾向于听到几个立即(几毫秒)尖锐的回声,相对不失真,其次是一个更大,更昏暗的云的回声。您可以通过使用几个向后运行的延迟线创建初始回波和几个完整的混响线加上一些模糊来创建云,以便实现这种效果。

In a large room (in the real world), when you make a noise you will tend to hear a few immediate (a few milliseconds) sharp echoes that are relatively undistorted, followed by a larger, fainter "cloud" of echoes. You can achieve this effect cheaply by using a few backwards-running delay lines to create the initial echoes and a few full reverb lines plus some blurring to create the "cloud".

绝对的最好的技巧(我几乎觉得我不想给这个,但是什么鬼)只有当你的音频是立体声的。如果你稍微改变左右声道之间的延迟线的参数(例如左声道为490ms,右声道为513ms,左为0.273衰减,右为.2631)更逼真的混响。

The absolute best trick (and I almost feel like I don't want to give this one up, but what the hell) only works if your audio is stereo. If you slightly vary the parameters of your delay lines between the left and right channels (e.g. 490ms for the left channel and 513ms for the right, or .273 decay for the left and .2631 for the right), you'll produce a much more realistic-sounding reverb.

这篇关于混响算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 22:17