見出し画像

I created my own sound field correction program for speakers.

First, please see the following graph.

Frequency response of our speakers

This is a bumpy graph.

This is the frequency response of my speaker (Yamaha MSP3) as measured with a microphone. As you can see, the characteristics are far from flat. The bumps are the result of the combination of the frequency response of the speaker itself, and the fact that certain frequencies are emphasized or cancelled out by echoes from the walls of the room.
In general, the flatter the frequency response, the better the reproduction of the original sound. In other words, the flatter the frequency response, the more "true" the music can be heard.
For this reason, there is a concept called "sound field correction," in which the bumpy frequency response is corrected by an equalizer or other means to flatten it.

Recently there has been a lot of talk in the music production community about a sound field correction device called the "ARC STUDIO" from IK Multimedia. It is said to improve the sound quality of speakers very much.
However, even though it is an inexpensive hardware sound field correction device, it costs about 50,000 yen, so it is not something that can be bought easily. Therefore, I searched for a free sound field correction program.

Free sound field correction program

One well-known software is "Room EQ Wizard (REW)," which can perform everything from measurement to creating equalizer settings for correction. The graph at the beginning of this page is a graphical representation of the results of measurements made with REW. The result of such a correction is then used to correct the sound field.

So what will the resulting sound be like after such correction?

To be honest, I did not find the sound quality to be "improved" to be flattering. I felt that the sound had become cloudy, and, in a sense, "boring" (although I did feel that the sound localization had improved).
I tried mixing the original sound and the corrected sound with an appropriate dry/wet ratio, but I began to wonder if this sound field correction was really correct.

Let's try to express sound field correction in equation

To begin with, what is the "goal" of sound field correction?
It is the playback environment of a studio. The idea is that if you can reproduce the playback environment of a studio with your home speakers, you will be able to hear the music in its "true" sound. So what is a studio playback environment? Generally speaking, it is a flat frequency response (or a frequency response with an appropriate slope or curve).

So why a flat frequency response?
Ideally, music played by ear should sound flat over the entire frequency range "as heard by the human ear. In other words, to be more precise, the frequency response of the sound source itself and the frequency response of the playback environment in the studio should be added together to obtain a flat frequency response "as heard by the human ear.

Let's put this into an easy-to-understand equation.
From the above, the following equation should hold

$${Hsource(freq)+Hstudio(freq) =Hflat(freq) }$$

Eq.(1)

Here, $${Hsorce}$$ is the frequency response of the sound source, $${Hstudio}$$ is the frequency response of the playback environment in the studio, and $${Hflat}$$ is the flat response "heard by the human ear.

Now consider reproducing this in your home speaker environment. Namely,

$${Hstudio(freq)=Hspkr(freq)+Hroom(freq)+Hsfc(freq)}$$

Eq.(2)

Here, $${Hspkr}$$ is the frequency response of the speakers in the home, $${Hroom}$$ is the frequency response of the room in the home, and $${Hsfc}$$ is the sound field correction sought.

Substituting this equation into the first equation, we get,

$${Hsource(freq)+Hspkr(freq)+Hroom(freq)+Hsfc(freq)=Hflat(freq)}$$

Eq.(3)

Here, we assume that general sound sources are designed to have "flat characteristics when listened to by the human ear". However, it is not perfect, so let's assume that we correct for this by adding an appropriate slope here,

$${Hflat(freq)=Hsource(freq)+Hslope(freq)}$$

Eq.(4)

Thus, it comes down to this

$${Hsfc(freq)=-Hspkr(freq)-Hroom(freq)+Hslope(freq)}$$

Eq.(5)

Here, "appropriate slope" is considered to mean the so-called target curve.

$${Hslope(freq) = Htarget(freq)}$$

Eq.(6)

Therefore,

$${Hsfc(freq)=-Hspkr(freq)-Hroom(freq)+Htarget(freq)}$$

Eq.(7)

The frequency response of the speaker is offset to bring it closer to the target curve. This is the general approach to sound field correction.

However, the sound field correction obtained in this way did not give good results, as mentioned earlier, the sound was cloudy or retracted.

What is wrong?

When we look for the suspicious part in the equation so far, Eq.(4) catches our attention. It says "appropriate slope," but how is this determined? Obviously, it is appropriate.
So, let's consider this more rigorously.

Equal loudness contour

There is such a thing as an equal loudness contour. The following is a quote from Wikipedia.

An equal-loudness contour is a measure of sound pressure level, over the frequency spectrum, for which a listener perceives a constant loudness when presented with pure steady tones.

Wikipedia "Equal-loudness contour"

The graph is as follows.

equal loudness contour (from Wikipedia)

This is a numerical representation of human auditory characteristics. A line along this line is perceived by the human ear to be "flat sound.

Therefore, we can say that "flat characteristics heard by the human ear" are, strictly speaking, characteristics that offset this equal loudness curve.

$${Hflat(freq)=-Heqloudness(freq)}$$

Eq.(8)

Substituting this into Eq.(3) and solving,

$${Hsfc(freq)=-(Heqloudness(freq)+Hsource(freq)+Hspkr(freq)+Hroom(freq))}$$

Eq.(9)

This may be the formula for a "more exact" sound field correction.

In reality, however, the playback environment in a studio is artificially adjusted to some target curve. Therefore, the element in Eq.(7) cannot be ignored and should be considered to some extent.

Therefore, the final sound field correction to be sought is the following formula.

$${Hsfc(freq)=α×(Htarget(freq)-Hspkr(freq)-Hroom(freq))+(1-α)×-(Heqloudness(freq)+Hsource(freq)+Hspkr(freq)+Hroom(freq))}$$

Eq.(10)

where α is the mix ratio of the two sound field corrections.

Creating a sound field correction program

So, now that I have obtained the exact form of sound field correction that I should aim for, I have created a program to calculate it. Below is the GitHub location where it is available.

The program takes the frequency response data of the speaker as input and calculates the equalizer settings for sound field correction according to Eq.(10).
This is applied by software called Equalizer APO in Windows, for example, to the sound coming out of the speakers.

How to use

Below is a brief summary of how to use the program.

First, you need to obtain the program. Open a prompt in an appropriate folder and type the following command to download a set of files (if you have not installed Git before that, please do so)

git clone https://github.com/quick-waipa/mkEqSFC.git

Next, it is necessary to create frequency response data for the speaker.
For this, you can use the free software REW mentioned earlier. Use a microphone to make measurements.
However, if the exported data is in its original form, it cannot be read by the above program, so it must be processed. Please prepare comma-delimited text data using Excel or other software. Refer to the README for the data format.

A sample of input data is shown below.

20.00, -23.69
21.86, -23.08
21.86, -23.08
22.35, -22.85
22.35, -22.85
22.72, -22.85
22.72, -22.85
...omission...
19669.59, -31.04
19779.11, -31.35
19779.11, -31.35
19889.25, -31.54
20000.00, -31.69
20000.00, -31.69

Next, run the following command in the src file to start mkEqSFC (if you have not installed Python and the required libraries, refer to the README for installation).

python mkEqSFC.py

The following window will then open, in which you can enter your input data. Please refer to the README for details on this as well.

input window of mkEqSFC

When "Run Calculate" is executed, the following will be output as output data.

  • Two equalizer setting files

  • RMS calculation results (rms.txt)

The two equalizer setting files are the equalizer settings for the two types of sound field correction described above. This is applied in some way.
Here we assume that we will use the Equalizer APO mentioned above.
With Equalizer APO, it is possible to split a given audio input into two, apply an equalizer to each, and then mix them together again. So, we can realize Eq.(10) in this way.

When mixing, it is necessary to first adjust the volume of the audio that has been divided into two parts, and the RMS calculation result (diff) of the output result should be used for this.

The gain formula for alpha is shown below.

$${Gain_A=6log_2(α)}$$

Eq.(11)

$${Gain_B=6log_2(1-α)}$$

Eq.(12)

Setting alpha to 1 produces a cloudy, boring sound, while setting it to 0 produces a clear, clean sound. Find the right balance.

For reference, a sample equalizer APO setting file is shown below.

Copy: L2=L R2=R
Channel: R2
Preamp: 1.59 dB # RMS_diffより
Include: "path of eq_A(R)"
Channel: L2
Preamp: 2.01 dB # RMS_diffより
Include: "path of eq_A(L)"
Channel: L2 R2
Preamp: -8.99246725597274 dB # =6log_2(α)
Channel: R
Preamp: 1.29 dB # RMS_diffより
Include: "path of eq_B(R)"
Channel: L
Preamp: 2 dB # RMS_diffより
Include: "path of eq_B(L)"
Channel: L R
Preamp: -3.780503809425822 dB # =6log_2(1-α)
Copy: L=L+L2 R=R+R2

Result

So what are the results?

The results are good. There was no sense of sound fogging or deterioration in sound quality as before; rather, the sound became clearer and the sound quality seemed to have clearly improved.
Whether it is correct or not, the results gave us a good impression of Eq.(10).

If you are dissatisfied with the sound quality of your speakers and cannot afford an expensive sound field correction system, you may want to try this program.

Summary

  • The much talked about ARC STUDIO was expensive, so I used a free sound field correction program

  • but it was too subtle.

  • I tried to find a more exact formula for sound field correction.

  • I created my own program to create equalization settings for sound field correction based on the formula I found.

  • As a result, the sound quality of the speakers was greatly improved.

この記事が気に入ったらサポートをしてみませんか?