## Introduction

Most of the action related games today usually implement some kind of algorithm for calculation of the sound reflections in either a room or tunnel
or other enclosed spaces. There are several ways to implement this modification of the sound that will occur in a room, but I am going to show you a couple
of the simplest ways using classical theory to show you how acousticians see a room.

The sound in a room is quite important to simulate, as we make many
assumptions about the space we are in by what we hear. For a realistic reproduction of the sound, we need to implement some modifications to the sound pressure,
and here the actual acoustics plays a part.

The program that follows this article calculates the
reverberation time of a rectangular room, were you
can choose the surface elements.

## Reverberation

I am going to explain
reverberation
in the following way: If you stand in a valley and scream at a mountain with a
reasonably flat surface, you would hear an echo, as the sound will travel from your mouth to the flat wall, and reflect back to your ears. The reason that you don't hear it in a room is that the reflections from the ceiling floor and walls are so close together that you just assume that the echo is part of the voice. This is also present in instruments as for instance guitar, piano, drums, and so on, as they give off sound long after the tone is initiated even if you stop the vibration in the strings.

The first to consider the reverberation time was the American physicist W. C. Sabine,
his article in 1900 outlined the result of the general equation given below (were w is the source energy, V is the Volume, and W_{abs} is the
absorption in the room):

As with all equations, it seems rather difficult at first, but this one is actually quite simple. It simply says, the energy from our source (loudspeaker,
car voice or anything that makes a sound in the enclosed room) is equal to the momentary energy equally distributed in the room, plus the energy absorbed from
our surfaces (the reduced echo from the walls, ceiling or floor). Absorption is actually the procentwise decay of sound from one reflection (similar
to Snell's reflection law for light, except
absorption describes the loss of energy in the reflected wave),
and is usually given as a factor between 0 - 1.0. The most important aspect to
contemplate in the formula, is that the sound energy according to Sabine's
equation is equal everywhere in the room.

We will skip a lot of the details in developing the equation to something we can use.
In general we assume that all the sound energy that would reach the walls, would take the form of a plan wave, and transforming the general equation
with this assumption gives the p^{2} value at any given time. The result is this equation below (were rho_{0} is the weight of air, in this case (1.21 kg/m^{3}),
and C_{0} is the speed of sound in air (343 m/s) and A = Surface area*
Absorption coefficient, and V is the Volume
of the room, and t is the time. This applies for all the formulas given in the article):

The absorption area in Sabine's formula is calculated from the equation below (were S is the surface area and alfa is the
absorption coefficient for the material):

*A = S*_{1} α_{1} + S_{2} α_{2} + ... + S_{n} α_{n} = ∑ S_{i}α_{i}

The reverberation time could be extrapolated from this equation. If we set up a source that continually supplies us with a know effect and turn it off, that is set w = 0
at t=0, we can calculate the sound pressure since the time we switch off the source like this:

We are however only, as Sabine defined the reverberation time, interested in how long the soundfield takes to decay with 60 dB, and this is actually independent
of the sound source. So the formula for reverberation time could the be set like this:

Not surprisingly, this differential equation could be solved by using the number e. As a side note in the article this number appears in many solutions,
because the number e^{x} is its own derivative and integrant, which can be shown by the simple formula below using nonbounded integral from 0 to x (I have not seen it
written like this anywhere else though):

Shortly after a number of revisions to the theory came, and Eyring-Norris (although Schuster and Waetzmann found the result independently)
is based on the notion that a sound wave would have an average distance to travel before it hits a wall. That means that a wave in the form of a ray,
would on average travel a distance between the reflections. This could easily be explained. If you place a laser light at any point wall, ceiling,
or floor, and shoot many rays in a random direction, the average length before the laser light hits a surface would be the mean distance in the room.
In room acoustics we are however more interested in the number of reflections per second, and this could be found by the formula below, were c is the
speed of sound, L_{n}is the length of x, y, and z direction in a rectangular room, and V is the total volume in the room (the two different
formulas are derived using different techniques but they yield the same result):

With this information we can easily find the number of reflections per time unit and thus a function for the decay rate of a reverberation field.
The equation is developed like the one below (one small remark is that the *alpha is the average
absorption coefficient in the formula below,
and can be formulated as a*_{alpha} = A / S*)*:

With the average absorption on the walls calculated like this:

This is actually quite similar to Sabine's equation, except that that alpha is a little bigger due to the incident angels instead of the plan wave.
This is more clear if we take the series expansion of the absorption function:

But the problem with Eyring-Norris is that the incident angle is diffuse over the entire room, this could be a problem if the
absorption coefficient
on some of the surfaces is very different on some sections. The is is way Millington-Sette made the modification that you take Eyring-Norris formula and
apply it to smaller sections. Millington-Sette gives the following expression:

There is a simple formula for the annutation coefficient that is valid between 1.5 to 10 kHz, were h is relative
humidity (valid between 20 - 70 %) i percent
and f is frequency. The approximate formula is given below:

The exact formula for the annutation in air is given in ISO 9613-2 and it can be view here.

They are coupled together with the formulas for reverberation, as air annutation is just another
absorption coefficient. The resulting in the modified equations for Sabine:

Eyring-Norris:

Millington-Sette:

The problem with these reverberation formulas is that they are not absolutely correct. You can see why when you see what kind of
assumptions that lay behind
the development of them. One of the main problems is that you could have
standing waves in a room in all the directions, and this leads to a different
perceived reverberation
time than you would have calculated by any of the three formulas above. One method to try and remedy the situation is the equation by Frizroy,
who is based on calculation the reverberation time in the different directions and average them. His proposed a formula looks like this:

An approximate formula with air absorption (if you do the math you'll see that it is not accurate but its usually not too bad either):

In recent years there has been several other formulas (which are not given here) that also tries to capture the different reverberation times
in the different directions. But unless you take scattering into account you won't get the correct reverberation time curve. You can see
the video were some of it is explained quite good by Jens Holger Rindel (one of the developers
behind the acoustic software Odeon).

He explains among other things, that the decay rate in some rooms would not be a
straight line after taking the logarithm
of the exponential decay. You can in some circumstances get an exponential decay. This is due to the
parallel walls in the x, y, and z direction.
If the reverberation time varies much the sound energy would stay longer in the direction with the lowest
absorption. If you imagine a plan wave coming towards a wall,
some of the energy would be reflected in the two other directions due to scattering. The reverberation time curve would thus be effected most by the
coupling
between the directions with low reverberation time to the direction with the high reverberation time, and this would happen over the entire reverberation time curve,
as the directions would have infinite many coupled parallel walls over time (this is
similar to the problems regarding coupled rooms).

However, the calculation of the reverberation field is limited to the accuracy of the measured
absorption coefficient, and that can vary as much as +/- 5%. So even if we had
the perfect formula for reverberation time it wouldn't matter. This is by the way true for all physical prediction models as it depends strongly on the accuracy
of the input - or GIGO (garbage in garbage out).

The implementation of all the formulas above is given in the code below:

Dim FullOctaveBand() As String
Dim OctaveBandString As String = "31,63,125,250,500,1000,2000,4000,8000,16000"
FullOctaveBand = OctaveBandString.Split(",")
If Not _lstXAbsorbers.Count = 0 And Not _lstYAbsorbers.Count = 0 _
And Not _lstZAbsorbers.Count = 0 Then
TotalSufraceArea = _TotalSurfaceArea
Humidity = CInt(txtHumidityRoom.Text)
Sabine.Name = "Sabine"
Eyring.Name = "Eyring"
Miller.Name = "Millington-Sette"
Fritzroy.Name = "Fritzroy"
Volume = _Height * _Length * _Width
For i As Integer = 0 To Sabine.Count - 1
Dim SabineTempZ, SabineTempY, SabineTempX As Double
SabineTempX = 0
SabineTempY = 0
SabineTempZ = 0
Dim EyringTempZ, EyringTempY, EyringTempX As Double
EyringTempZ = 0
EyringTempY = 0
EyringTempX = 0
Dim MillingtonSetteTempZ, MillingtonSetteTempY, MillingtonSetteTempX As Double
MillingtonSetteTempZ = 0
MillingtonSetteTempY = 0
MillingtonSetteTempX = 0
For Each p As Absorber In _lstZAbsorbers
SabineTempZ += p.Area * p.GetItem(i)
EyringTempZ += p.Area * p.GetItem(i) / _TotalSurfaceArea
MillingtonSetteTempZ += p.Area * CalculateAlfa(p.GetItem(i))
Next
For Each p As Absorber In _lstYAbsorbers
SabineTempY += p.Area * p.GetItem(i)
EyringTempY += p.Area * p.GetItem(i) / _TotalSurfaceArea
MillingtonSetteTempY += p.Area * CalculateAlfa(p.GetItem(i))
Next
For Each p As Absorber In _lstXAbsorbers
SabineTempX += p.Area * p.GetItem(i)
EyringTempX += p.Area * p.GetItem(i) / _TotalSurfaceArea
MillingtonSetteTempX += p.Area * CalculateAlfa(p.GetItem(i))
Next
Dim m As Double = 5.5 * 10 ^ (-4) * (50 / Humidity) * _
(CDbl(FullOctaveBand(i)) / 1000) ^ (1.7)
Dim AbsorbtionAreaSabine As Double = (SabineTempX + SabineTempY + SabineTempZ) + 4 * m * Volume
Dim AbsorbtionAreaEyring As Double = _TotalSurfaceArea * _
CalculateAlfa(EyringTempX + EyringTempY + EyringTempZ) + 4 * m * Volume
Dim AbsorbtionAreaMillingtonSette As Double = MillingtonSetteTempX + _
MillingtonSetteTempY + MillingtonSetteTempZ + 4 * m * Volume
Dim FritzroyTempZ, FritzroyTempY, FritzroyTempX As Double
FritzroyTempX = CDbl(lblXrea.Content) / (CalculateAlfa(EyringTempX) + _
(4 * m * Volume / 3) * (CDbl(lblXrea.Content) / _TotalSurfaceArea ^ 2))
FritzroyTempY = CDbl(lblYrea.Content) / (CalculateAlfa(EyringTempY) + _
(4 * m * Volume / 3) * (CDbl(lblYrea.Content) / _TotalSurfaceArea ^ 2))
FritzroyTempZ = CDbl(lblZarea.Content) / (CalculateAlfa(EyringTempZ) + _
(4 * m * Volume / 3) * (CDbl(lblZarea.Content) / _TotalSurfaceArea ^ 2))
Sabine.SetItem(i, ReverberationTime(AbsorbtionAreaSabine))
Eyring.SetItem(i, ReverberationTime(AbsorbtionAreaEyring))
Miller.SetItem(i, ReverberationTime(AbsorbtionAreaMillingtonSette))
Fritzroy.SetItem(i, (0.16 * Volume / (_TotalSurfaceArea ^ 2)) * _
(FritzroyTempX + FritzroyTempY + FritzroyTempZ))
Next
Dim AverageReverberationTimeSabine As Double
AverageReverberationTimeSabine = 0
For i As Integer = 0 To Sabine.Count - 1
AverageReverberationTimeSabine += Sabine.GetItem(i) / Sabine.Count
Next
Schroeder = 2000 * Math.Sqrt(AverageReverberationTimeSabine / Volume)
RoomRadius = Math.Sqrt(55.26 * Volume / (16 * Math.PI * C0 * AverageReverberationTimeSabine))
lblSchroder.Content = Math.Round(Schroeder, 0).ToString
lblRoomRadius.Content = Math.Round(RoomRadius, 2).ToString
_lstResult2.Add(Sabine)
_lstResult2.Add(Eyring)
_lstResult2.Add(Miller)
_lstResult2.Add(Fritzroy)
lstResult.ItemsSource = _lstResult2
For Each p As Absorber In _lstResult2
PlotReverbrationTime(p, False)
Next
Else
MessageBox.Show("missing absorbers")
End If

## Comments on the formulas

There are several comments to be given in relation to the result that is derived, and
especially with regards to the limitations of the theory. The assumption
was that all the points in the room had the exact same energy, which was used to formulate that it
didn't matter where in the room the absorbing surfaces were.

There is actually a simple analogy from electrical circuit theory. The room can be
modeled as a simple capacitor, and thus the absorption in a room as a simple resistor
and the leakage from slits like a window, doors etc could be modeled as a inductor. It is evident that a "normal" room would behave as a bandpass filter with
coefficient dependent on the acoustic properties of the boundaries and the geometry of the room. This means that we could model the energy in a room, based on the charge over a
capacitor:

The steady state condition could be found between the charge and discharge, as is also true in a room.
In the capacitor analogy reverberation time calculations is the same as the discharge in a capacitor. However the charge of the capacitor has also it's
equivalent in room acoustics,
and it's called early decay time (EDT). There are a couple of things missing from the analogy that is performed between the capacitor and a room. One is the direct sound,
i.a. the shortest path between the listener and the source, the other is that the steady state in acoustics is a combination of three different
phenomena, namely DirectSound,
EDT and at last the reverberation time, while the capacitor is a combination of charge and discharge only. And 3D
coupled walls is also not percent in a single capacitor. So the simulation of an impulse
response squared with the different regions marked by different color is shown in the picture below:

In Fourier analysis, the room nodes or eigenvalues, are often used to acoustics to explain how the sound pressure is distributed through the room. The problem is that the walls are the sources with this assumtion, the same assumtion that was used to derive the reverberation time in Sabines equation, and would thereby not give you the correct values of sound pressure in a room with an arbitrary placement of the source.

The do however explain the influence of the walls in a room with the averaging of several
measurement points in a room, were both the source and microphone position is varied. This is actually known information, and the Waterhouse calculated a formula based on the
assumption, as the sound pressure at the low frequencies have to be fixed due to the influence of the low frequency nodes.

Up to this point the article only explains what happens in the reverberation section of the sound in the room. The direct sound is relatively easy to implement in a game, as it is the direct or shortest distance between source and receiver. The early reflections are very important if you want to simulate a sound field in a room, as most of the
perceived spatial information is picked up here. This part is usually simulated with Image sources, or mirror sources. Normally the most
important information comes from 0 to 80 ms after the direct sound, and EDT is defined in standards as the 10 dB decay from the first reflection. (In measurement it is defined as from the top -0.1 dB to -10.1 dB, as one tries to not include the effect of the direct sound.)

So if we cant find the sound pressure exactly what
techniques could we use? Well as it turns out the only technique that could predict the sound field completely accurate is the Transmission Line Model (TLM) or the equivalent Finite Difference Time Dependent (FDTD), but the calculation time is
directly dependent on frequency, and it is therefore not a viable
technique for real time processes.

Geometrical acoustics is the analytic tool used by room acoustic consultants, and this is a hybrid solution with a combination of rays and image sources. Examples of programs used are:

Those are the only two I know of and there might be other who offer commercial programs. They predict the sound pressure quite good at
medium and high frequencies, but fail at the lower frequencies. This is becouse at low frequencies the sound don't move around as rays but more as plane waves. At the frequency were the ray transformation is valid, can be estimated using the Schroeder frequency. This says when our sound pressure is diffuse, and thus below this frequency we could expect the sound pressure to be dominated by the nodes generated by the boundaries.

However the information you'll get out of these programs is in many circumstances is a huge overkill for what is needed to roughly
estimate a decay curve, that would sound believable in most cases. (This is not to say that they are not needed,
because they are. Mostly in situations were you are going to spend millions of dollars constructing a symphony hall, huge lecture hall, theater, opera house etc., only to find out that the sound is messing up the impression leaving the audience/students in
disarray. The ray tracing/image source technique is usually also very reliable for frequencies were our hearing is most
sensitive.)

## Auralization

The name auralization derives directly from visualization, but sound is not visible but
audible, therefore the name Auralization. It does however require quite a lot of
processing to translate the calculated reverberation time into something the could be used to artificially create the sound in a room.

To create an audio of reasonable you need ot make an 1/3 octave band filter, that could be applied in the range from 31.5 Hz - 16 000 Hz (the program only calculates the full octave bands, but values can be usually be interpolated to cover 1/3 octaveband. The exception would be different kind of narrow Helmholt absorbers). This is not
straightforward and requires knowledge of DSP (Digital signal processing) and filter design. A
pseudo impulse response for rooms could be created as suggested below:

- Get a white noise signal with sufficient length (approximately 4
seconds or more should be enough in most circumstances. (I will assume that this has values from 1 to -1, and I know wav files do not have that)
- Filter the signal in all octave bands and store it.
- Multiply the filtered signal by p(t) equation (or rather the e
^{-xt} signal) -10 dB. p(t) would be found in the different reverberation time formulas. - Add the direct sound at the beginning with the value 1 (a
delay of about 60 - 80 ms between the direct sound and the reverberation field would make it sound more natural, or better even to calculate the sound between the direct sound and the reverberation field using image sources).
- Take the sound (without reflections) that you want to play in the game and convolute this with the proposed filter.

As you by now
probably have guessed, making a game sound natural is quite a task, and I know that there are instances were this
algorithm won't be advisable, as in corridors, outdoor or other areas that do not have a
reverberant field (look at the pre-conditions that was set when deriving the equations).

A bit of warning before you use the software directly. I won't
guarantee that the absorption coefficient supplied in the excel-file are correct, though they look like reasonable
assumptions to me. But then again you can add all the items in the excel file that you could think of (or find other places),
so there is no problem in that sense.

## History

First relase 31.07.2012

The program includes:

- Calculation of reverberation time (four different algorithms)
- Loading
absorption data in full octave band from an editable Excel file

## References

The books I list here offers a good explanation of what I describe, and are good further references if you want to know more.

*"Building acoustics"*, First edition (2008), Tor Erik Vigran, CRC Press
*"Auralization - Fundamentals of Acoustics, Modelling, Simulation, Algorithms and Acoustic Virtual Reality"*,
First edition (2008), Michael Vorlander, Springer.
*"Room Acoustics"*, Fifth edition (2009), Henrich Kuttruff, Spon Press.
*"Fundementals of Acoustics"*, Fourth edition, Kinsler, Frey, Coppens and Sanders, John Wiley & Sons, Inc.

There is a book that just deals with reflections and absorption of materials, and if you want to know how to deal with theoretical calculations you should
defiantly read this:

*"Acoustic Absorbers and diffuseres - Theory, design and application"*, Second edition (2009), Trevor J. Cox and Peter D'Antonio, Taylor & Francis.

A short history of different reverberation time formulas could be found here:

Some other interesting sites: