Monthly Archives: August 2013

An introduction into the theory of room acoustics at home

The reasoning behind investing in the acoustics of a space is very much the same as the reasoning behind investing in audio equipment; one simply can not achieve good sound without investing in both the equipment and the acoustics. The hi-fi enthusiast should have enough knowledge to understand that the money spent on expensive equipment is wasted unless the acoustics of a room are in order.

A random acoustic panel placed on a aesthetically pleasing spot on the wall is seldom placed in such a way that it makes any audible difference. It might help in some cases, but in most cases the improvement can be attributed to the placebo effect (i.e. it's all in that persons head).

There are optimal places for placing acoustic elements for each and every room, and they differ from one case to another.

The sound field in a room

Everything you'll see that is written on room acoustics is essentially based on the sound field in a room. To truly understand how the acoustics in a listening space can be improved, one should first learn some basics relating to how sound behaves.

The video above shows a speaker placed in a room (well, a 2D simplification of a room, but the principle holds), in the upper left corner. As time passes in slow motion, the sound propagates through the room. This virtual room is 1 meter by 4 meters (1 meter = 3.3 feet). So the room is for tiny people. But that doesn't matter now.

The colors show what you can hear as sound. Sound equals small changes in pressure, caused by the speaker. The pressure variations propagate across the room. As you can see, the reflections quickly make the sound field appear chaotic. As strange as it seems, if one were to listen to the sounds in the room, one would still make out what sounds the speaker makes, in what visually appears to be total chaos. But in a room like the one in the video, one definitely won't be able to hear the difference a quality speaker will make in the sound.

If you didn't quite understand what happened in the video, don't fret about it. The main point is this: sound equals variations in pressure. But it also equals something else.

Particle velocity, or the movement of air

Note that the video shown earlier presented the variation of pressure, which is what our ears detect. Sound can also be thought as consisting of moving air. Pressure differences can not exist without the air moving around a bit. In the case of sound, one can not exist without the other.

The video below shows the same case as above, but in this case from the point of view of the moving air. The brighter the color, the faster the air moves.

Additional: How is the movement of the air and sound pressure related?

Sound is variation in pressure. The first image below represents a pressure wave (sound) travelling in a room. It gets reflected from the walls, thus echoing back and forth in the room.

A moving pressure wave also causes the air to move (you can even feel the air moving with massive subwoofers). This is represented in two different ways in the images below:

  • The image to the left: The lines represent how very thin sheets of some extremely light material would move with the airflow caused by the pressure wave.
  • The image to the right: The green line shows the velocity of these lines. This is the same thing as the velocity of the air flow (mean particle velocity).

2uqx8 2uy3b

The theory behind the images

  • The first image comes can be thought of as coming from the ideal gas relation pV = nRT. The pressure changes between the lines, which means that the volume between the lines has to change.
  • The second image relates velocity to pressure through Euler's equation \partial u/\partial t=-\int 1/\rho\cdot\partial p/\partial x\,dt
  • If you've seen the velocity of the movement of the air (usually called particle velocity) depicted as being out of phase with the pressure by 90 degrees, you should note that this is only the case when standing waves, or room modes, have formed.

Relating the sound field to frequency

The video below shows what happens when the speaker plays a sound at 85.75 Hz in our tiny 1 meter by 4 meters room. The sound gets reflected back and forth from the walls to the left and to the right, and a room mode (resonance) is formed after only a few reflections. To achieve proper acoustics, these should be attenuated properly! In practice, the room mode would be heard as sounds being overly accentuated at 85.75 Hz. If the concept of an equalizer is familiar to you, this would almost be the same as using that equalizer to make a sharp peak at 85.75 Hz.  Room modes are characterized by having noticeable variations in loudness depending on where in the room you're listening to them.

An important thing can be seen when viewing the speed of the motion of the air in this same situation. The air doesn't move at all close to the walls it is reflected from (the left and right wall)! Note that many acoustic absorbers should be placed at positions where the air is moving! This is why acoustic absorber panels, for example, work better with some air behind them.

Additional: Relating the distance of maximum air movement to frequency

It can be seen that the distance where the air movement speed has it's maximum is 1 meter from the reflecting walls in the case above. Note that this only holds true when the frequency of the sound is 85.75 Hz. There exists a relationship between the distance of the highest speed of air movement and the distance from a rigid wall, which can be described by the following formula.

d_{v,max}(f)=\frac{343}{4\cdot f}

Note that this formula only holds true for reflections perpendicular to the wall. When the incident angle differs from ∠90, this distance will be smaller. For example, in the case above, the distance is very close to 0 for the top and bottom walls, as the visible sound dominantly reflects from the left and right walls.

The importance of the early reflections

The easiest way to understand where early reflections arrive from is to draw  lines corresponding to different paths the sound takes before arriving at the listener. Consider the case below, where a speaker has been placed at the very corner of the room (which often isn't the optimal place to put a speaker, but never mind that for now).

Direct sound

Direct sound

Reflected sound

Reflected sound

In the first image, sound arrives directly from the speaker. In the second image, a reflection can be seen arriving at the listener. The path of the reflection can also be regarded through the reflected line in the image.

Let's assume a case where there will be only one reflection (in the above case, some very early reflections will actually be caused by the walls close to the source), so that the meaning of a single early reflection can be emphasized. Let's also assume that the reflection arrives at the listener at roughly the same volume as the direct sound.

What does this sound like? Here are some examples of direct sound played together with a single reflection. I added some diffuse reverberation to the samples, which actually is a little unrealistic, but makes the samples sound better.

The first example consists of a clapping sound. The reflections can be heard clearly, until the difference between the time the direct sound and the reflected sound is small enough.

[audio www.kaistale.com/blog/130824roomacoustics/refl_clap.mp3]

The second example consists of some noise (warning: this will sound louder than the clap). In this case, the reflection is very hard to distinguish.

[audio www.kaistale.com/blog/130824roomacoustics/refl_noise.mp3] Additional information on the delays in the sound examples

The delays used in the examples heard above are as following:

  1. 200 ms, or the time it takes for sound to travel 69 m
  2. 100 ms, or the time it takes for sound to travel 34 m
  3. 50 ms, or the time it takes for sound to travel 17 m
  4. 25 ms, or the time it takes for sound to travel 8.6 m
  5. 12.5 ms, or the time it takes for sound to travel 4.3 m
  6. 6.25 ms, or the time it takes for sound to travel 2.1 m
  7. 3.13 ms, or the time it takes for sound to travel 1.1 m
  8. 1.56 ms, or the time it takes for sound to travel 0.54 m
  9. 0.78 ms, or the time it takes for sound to travel 0.27 m

The most important thing you should notice here is that as the delay gets smaller (or the sound is less transient-like), the delays won't be audible as such. Instead, they color the sound. This is clearly audible in both examples above as a "rising pitch".

The frequency response of a room with a single reflection

People often compare the performance of speakers through their frequency responses. Early reflections have a very large impact on the magnitude of the frequency response of the system! If you pay hundreds, or even thousands, of dollars extra for a speaker with a frequency response which is a little bit smoother than the one for a cheaper speaker, you can easily loose most of the benefit due to poor acoustics.

Here, as an example, is the frequency response of a system where the speaker has a completely flat frequency response, but where we get a single early reflection 3 ms later than the direct sound (the reflected sound path is 1 meter longer). To make the example a bit more realistic, the attenuation of the sound by distance has been taken into account. We'll assume that the speaker is directed directly towards the listener, and that the wall giving the reflection is behind the listener. We'll assume that no other reflections arrive to the listener, which is quite the simplification, but illustrates the point nicely anyway.

First, here is the response of the case where the sound has been reflected of a painted concrete wall:

Frequency response when the sound is reflected from a painted concrete wall

Frequency response when the sound is reflected from a painted concrete wall behind the listener

As can be seen, the frequency response has differences of 15 dB! No wonder that the sound sounds colored. Alright, what would happen if we would cover the back wall with some A-grade absorption panels, with some airspace behind them to boost the performance at low frequencies?

Frequency response when the sound is reflected from a wall covered with a high-performance acoustic panel with some airspace behind it

Frequency response when the sound is reflected from a wall covered with a high-performance acoustic panel with some airspace behind it, placed behind the listener

The difference is huge, for an investment which costs a fraction of what decent speakers cost! It should be noted, here, that a frequency response as flat as the one above would require anechoic conditions in the room otherwise; the purpose of the example is to accentuate the importance of the back wall. Usually, a small amount of reverberation is preferable. Reverberation often results in a noise-like pattern in the response, it's the wide dips and distinct peaks that we need to watch out for.

I think amplifiers that correct the response of the room are worth mentioning here. Yes, these do wonders on low frequencies. It should be noted that they do not work on higher frequencies, as the response is very sensitive to the listener position at higher frequencies. Some advertisements might claim otherwise, but they are misleading, and, to put it bluntly, wrong. The only way to fix higher frequencies properly is through room acoustics.

The role of the late reflections

I would say that late reflections can generally be thought of as affecting two things in listening rooms or home theaters, on the top of my head:

  • The clarity of the sound, including the intelligibility of speech
  • Different spatial attributes of the sound

The clarity of the sound is self-explanatory. But spatial attributes might not be. Some late reflections might be heard as annoying echos in large rooms, but I won't go into details about that here. Also, room modes are actually a combination of early and late reflections.

Let me show how some of the more subtle spatial attributes of the sound is affected through a simple example. Listen to this piece of music, played in a room with lots of reverberation caused by multiple late reflections (listen to these examples with your headphones!):

[audio www.kaistale.com/blog/130824roomacoustics/lateref_wet.mp3]

 

You probably heard that the nature of the reverberation changed in the middle of the song? Now make sure you're wearing headphones and listen to the same exact song, but without the extra reverberation caused by the room:

[audio www.kaistale.com/blog/130824roomacoustics/lateref_dry.mp3]

 

The difference is huge, isn't it? Without the reverberation of the room, one can clearly hear the difference between the two cases. When the shape of the space is audible in a listening room, it will mask the shape of the space in the original recording.

Roundup

Alright, this was only an introduction, but we still managed to cover many of the most important things! Where, then, should one place acoustical elements to achieve proper acoustics in a listening room?

Let's go through the things presented in this post:

Early reflections can be thought of as being reflected in the same manner as light is reflected from mirrors. Draw the path of each reflection. Then place proper acoustical materials (absorbers, diffusers) at the critical spots depicted by the path. Not all surfaces are equally important (the back wall, as described in the case above, usually being one of the more important ones). If you want to be on the safe side, you should treat all the surfaces you can. At home the ceiling might be difficult to cover, but the floor can be covered using a thick floor mat.

Late reflections can usually be thought of as consisting of reflections coming from random directions. Thus, late reflections can be remedied by placing as much acoustical absorbents as possible around the room (furniture, professional acoustical panels, mats). In cases where two hard walls face each other, try to treat at least one of the walls acoustically. Plenty of absorbers will cause the room to sound dry and damped when music isn't played, but this is very often what should be preferred when listening to recorded music (or when watching movies). If you don't want the room to sound too dry, you can try replacing some of the absorbers with diffusers.

Room modes cause problems at low frequencies in regular listening rooms. Low frequencies will often require bass traps if you want an even frequency response. Regular acoustical panels won't absorb low frequencies, so taking care of room modes with acoustical panels (or other porous absorbents) is very difficult (although there are ways to do this). Resonant bass traps can be placed in the corners of the room. Corrective equalization through your amplifier can better the sound at low frequencies (but not at mid-high frequencies!), assuming you apply the correction at the same spot as you are listening in.

Absorbent materials work through friction. Friction only works when the air is moving. As could be seen in the videos earlier, air doesn't move much close to the walls. Absorption panels should generally be placed at a distance from rigid surfaces (walls, ceilings). Acoustic panels can be attached on frames which leave some air behind the panel. There are more advanced ways to get absorbent materials to attenuate low frequencies (such as room modes) at corners and room boundaries, for example by placing them inside deep cavities in the wall. Specific positions in the room will be more effective at attenuating specific room modes, but I won't go into details concerning this.

Resonant panels (often used in bass traps) work by converting pressure to mechanical movement of the panel. These should be placed where the pressure reaches its maximum. In rectangular rooms, all room modes have maximum pressure at the corners of the room, which is why resonant bass traps should placed in the corners of the room.

I'm working on a tool for optimizing the acoustics of listening spaces at Kaistale. The complex necessities behind the workings of the program will be properly hidden, to allow for the user to concentrate on key issues. 

Finite element analysis of 2D acoustics

This is a purely mathematical post covering some of the theoretical basis behind the matrices used in finite element analysis for acoustics in fluids. In coming posts, I'll cover some of the more practical uses for the method.

A lot of the content presented here is based on the book "Computational Acoustics of Noise Propagation in Fluids - Finite and Boundary Element Methods". I'll do the examination in 2D, to make things as simple as possible.

The Helmholtz equation

The linearized Euler equation is the most basic theoretical basis I will consider, even though even this equation can be derived using continuum mechanics. The linearized Euler equation is as following:

\Delta\tilde{p}(\pmb{x},t)=\frac{1}{c^2}\frac{\partial^2 \tilde{p}(\pmb{x},t)}{\partial t^2}

where \Delta is the Laplacian and \tilde{p} refers to the local perturbation of the pressure (i.e. small disturbance around the equilibrium that causes sound). \pmb{x} is a position vector. The pressure is dependent on both position and time. If the problem is assumed to be time harmonic, i.e. the time variation is sinusoidal, \tilde{p}(\pmb{x},t) can be replaced by p(\pmb{x})e^{-i\omega t}. Placing this into the Euler equation gives the Helmholtz-equation:

\Delta p(\pmb{x}) + k^2p(\pmb{x})=0

where k, the wave number, equals \omega/c_0. Note that the speed of sound can in some cases vary inside the medium. In these cases, where diffraction is to be considered, an additional factor n(x) = c_0/c(x) (the index of refraction) should be used to multiply the term on the right.

The boundary conditions

The boundary conditions can be divided into the following types of conditions:

The Robin boundary condition allows for the specification of both hard and soft boundaries, and it can be defined on the boundary of the problem as following:

v_f(\pmb{x})-v_s(\pmb{x})=Y(\pmb{x})p(\pmb{x})

where Y represents the boundary admittance. v_s denotes the normal velocity of the boundary and v_f denotes the normal fluid velocity of the acoustic domain. What exactly does this state? It states that the difference between the speed of the fluid and the speed of the structure equals the impedance times the pressure at the boundary. v_f can be calculated from the normal derivative of the sound pressure as following:

v_f(\pmb{x}) = \frac{1}{i\omega\rho_0}\frac{\partial p(\pmb{x})}{\partial n(\pmb{x})}

The weak formulation

The weak formulation is calculated in precisely the same way as was the case with the Euler-Bernoulli beam equation, in a previous blog post.  In this case, the weak formulation is calculated from the following equation (the (\pmb{x})-parts are omitted for clarity), where w represents the weighting function:

\int_\Omega w[\Delta p+k^2 p]d\Omega=0

After integrating by parts (the first term, the one with the Laplace operator):

\int_\Gamma w\nabla p \pmb{n}d\Gamma-\int_\Omega[\nabla p \nabla w-k^2wp]d\Omega=0

The first term can now be rewritten:

\int_\Gamma w \frac{\partial p}{\partial n}d\Gamma-\int_\Omega[\nabla p \nabla w-k^2wp]d\Omega=0

After inserting the earlier equation for v_f:

\int_\Gamma wi\omega\rho_0v_f d\Gamma-\int_\Omega[\nabla p \nabla w-k^2wp]d\Omega=0

Finally, let's insert the Robin boundary condition defined earlier (replacing v_f with Yp + v_s):

\int_\Gamma wi\omega\rho_0[Yp + v_s] d\Gamma-\int_\Omega[\nabla p \nabla w-k^2wp]d\Omega=0

Substituting \omega = kc, we get:

ikc\rho_0\int_\Gamma wYp d\Gamma+ikc\rho_0\int_\Gamma wv_s d\Gamma-\int_\Omega[\nabla w \nabla p-k^2wp]d\Omega=0

The shape functions

I'll choose Lagrange quadratic shape functions for this endeavor. Using local coordinates, they look as following:

Lagrange quadratic shape functions

Lagrange quadratic shape functions

N_1 N_2 N_3
\frac{(\xi - 0)(\xi-1)}{(-1-0)(-1-1)} \frac{(\xi+1)(\xi-1)}{(0+1)(0 - 1)} \frac{(\xi+1)(\xi-0)}{(1+1)(1 - 0)}

As these functions are one-dimensional, we need to multiply them by each other in order to get two-dimensional shape functions. To get a 2D shape function with the value 1 at some specific node (i,j), we need to do the following multiplication:

\phi_i(\xi,\eta)=N_i(\xi)\cdot N_j(\eta)

with \xi and \eta denoting local coordinates inside the element. A resulting two-dimensional shape function for the node at coordinates (0,0), for example, looks as following:

Two-dimensional Lagrange shape function

Two-dimensional Lagrange shape function

We do the same multiplication for all the nodes 1 ... 9. Thus we have 9 shape functions describing the evenly spaced values in a 2D square. The node numbering doesn't really matter, as long as it's something that is agreed upon.

Note that we can now get the continuous values of the pressure inside the 2D square using the shape functions as following:

\sum_{i=1}^N\phi_i(\pmb{x})p_i=\pmb{\phi^T}(\pmb{x})\pmb{p}

Integrating the shape functions

Later on, it will become apparent that we need to integrate the 2D quadratic shape functions. There will be two cases of integration:

  • Multiples of shape functions across the fluid domain
  • Multiples of shape functions on the boundary of the problem

The derivatives and integrals are, as always, performed in global coordinates. As the shape functions are defined in local coordinates, we need a way of transforming a derivation/integration performed in one coordinate system to the other. It turns out that this can be done using the jacobian matrix. It's basically the same thing as the chain rule, but in matrix form. The jacobian matrix \pmb{J} in our case is defined as following:

\begin{Bmatrix}\frac{\partial N_a}{\partial \xi}\\\frac{\partial N_a}{\partial \eta}\end{Bmatrix}=\begin{bmatrix}\frac{\partial x}{\partial \xi} & \frac{\partial y}{\partial \xi}\\\frac{\partial x}{\partial \eta} & \frac{\partial y}{\partial \eta}\end{bmatrix}\begin{Bmatrix}\frac{\partial N_a}{\partial x}\\\frac{\partial N_a}{\partial y}\end{Bmatrix}=\pmb{J}\begin{Bmatrix}\frac{\partial N_a}{\partial x}\\\frac{\partial N_a}{\partial y}\end{Bmatrix}

To convert the derivative the other way around, we invert the jacobian matrix, like this:

\begin{Bmatrix}\frac{\partial N_a}{\partial x}\\\frac{\partial N_a}{\partial y}\end{Bmatrix}=\pmb{J}^{-1}\begin{Bmatrix}\frac{\partial N_a}{\partial \xi}\\\frac{\partial N_a}{\partial \eta}\end{Bmatrix}

For integration, the following holds true:

dx\,dy=\begin{vmatrix}\pmb{J}\end{vmatrix}d\xi\,d\eta

In this case, I won't write up all the possible integrals. Suffice to say, all the necessary integrals and derivatives can be calculated using these equations.

Discretization

The continuous problem can now be discretized using the shape functions. I'll use the following notation for the different discretizations, adopted from the book I mentioned in the beginning of the post:

p(\pmb{x})=\pmb{\phi^T}(\pmb{x})\pmb{p}

v_s(\pmb{x})=\pmb{\overline{\phi}^T}(\pmb{x})\pmb{v}

Y(\pmb{x})=\pmb{\tilde{\phi}^T}(\pmb{x})\pmb{Y}

Inserting the shape functions into the weak formulation (again, omitting the (\pmb{x})-parts), we now get:

ikc\rho_0\int_\Gamma w\pmb{\tilde{\phi}^T}\pmb{Y}\pmb{\phi^T}\pmb{p} d\Gamma+ikc\rho_0\int_\Gamma w\pmb{\overline{\phi}^T}\pmb{v} d\Gamma-\int_\Omega[\nabla w \nabla \pmb{\phi^T}\pmb{p}-k^2w\pmb{\phi^T}\pmb{p}]d\Omega=0

The weighting functions are once again arbitrary. We'll use the Galerkin discretization, which here means that the weighting functions w are also replaced with 2D Lagrange quadratic shape functions, \phi_i. Thus we get N equations (I tried to explain this more thoroughly in this post, which covers a more simple case of finite element analysis). The equations A = 1 ... N can be written as following:

ikc\rho_0\int_\Gamma \phi_A[\sum_{k=1}^N\tilde{\phi}_kY_k][\sum_{m=1}^N\phi_mp_m]d\Gamma+ikc\rho_0\int_\Gamma \phi_A[\sum_{j=1}^N\overline{\phi}_jv_j]d\Gamma-\int_\Omega[\nabla\phi_A[\sum_{j=1}^N\nabla\phi_jp_j]-k^2\phi_A[\sum_{j=1}^N\phi_jp_j]]d\Omega=0

Okay, it's starting to get confusing. But now we can finally start to simplify things. Let's write the equation in the following matrix form:

(\pmb{K}-ik\pmb{C}-k^2\pmb{M})\pmb{p}=ikc\rho_0\pmb{\Theta}\pmb{v_s}

with the following matrices. For the purposes of this post, the impedance will be assumed to be constant on the boundary, which makes the damping matrix simpler to calculate. We'll also assume that Lagrange quadratic shape functions are used consistently.

\pmb{K} = \int_\Omega\nabla\pmb{\phi}\nabla\pmb{\phi}^Td\Omega

\pmb{C} = \rho_0cY\int_\Gamma\pmb{\phi}\pmb{\phi}^Td\Gamma

\pmb{M} =\int_\Omega\pmb{\phi}\pmb{\phi}^Td\Omega

\pmb{\Theta} =\int_\Gamma\pmb{\phi}\pmb{\phi}^Td\Gamma

Conclusion

This post by no means went through everything one should know to be able to do finite element analysis of acoustics in 2D. Still, it covered the theoretical basis behind what I will cover in the following posts.