iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🔊

Testing Room Acoustic Correction on Raspberry Pi - Supplement: Using Dedicated DSP Boards

に公開

Part 1: https://zenn.dev/kymok/articles/909df17dd68175
Part 2: https://zenn.dev/kymok/articles/627e72a0869d52

Deprecation Notice

I regret writing this article immediately after receiving the product, as its operation is significantly unstable. Until the cause is identified, I cannot recommend a new purchase. (2021-03-08)

Regarding the final filter coefficient settings: with the settings in this article, the sample rate configuration may not match. If applied as is, the filter's center frequency may behave as if it has nearly doubled. In this case, please multiply the filter's center frequency by 0.46 (= 44.1/96). (2021-03-08)

Specific Dangers

Unfortunately, as of the time of writing, the quality of documentation for HiFiBerry products is not very high, and the risk of incorrect settings being mixed in cannot be ignored. Incorrect settings may suddenly play noise at the full reproduction capacity of your speakers[1]. This may result in the following harms:

  • Damage to equipment such as speakers.
  • Irreparable hearing damage.

The author assumes no responsibility for any damage caused. Since it is too late once your hearing is damaged, it is recommended to take the following measures:

  • For safety, always lower the speaker volume during setup using the following methods. A guideline is to keep it at a level where music is barely audible.
    • For powered speakers without built-in volume control, insert an attenuator into the input.
    • For powered speakers with built-in volume control, use that.
    • If using a separate amplifier and speakers, lower the amplifier's volume.

Differences from Previous Articles

  • The installation procedure, enabled build options, etc., are different.
  • In the previous article, the impulse response for correction was calculated using REW, but this time we will use the filters built into the DSP.

1. Introduction

For Raspberry Pi, third-party DSP boards specifically for Raspberry Pi that can be used for room correction are available. This time, I will write about the procedure for setting up one of them, the HiFiBerry DAC2 Pro and the DSP Add-on Board, for room correction. The main points to note are as follows:

  • You need to find configuration files from the HiFiBerry repository without relying on documentation.
  • Depending on Shairport Sync settings, it may be incompatible with the DSP toolkit.
  • There is a high possibility of damaging speakers or hearing if operated incorrectly[2].

A freshly set up Raspberry Pi. It's cute, isn't it?

2. DSP Setup

2.1 Hardware Preparation

Since I'm using a metal case this time, I plugged in an inexpensive WLAN adapter.

  • DAC: HiFiBerry DAC2 Pro
  • DSP: HiFiBerry DSP Add-on Board
  • Raspberry Pi 4 2GB
  • WLAN Adapter: I-O DATA WN-G300UA

No additional drivers are required for the WLAN adapter, so it is no problem to disable the onboard wireless LAN function right from the start of the setup.

2.2 Configuring /boot/config.txt

Here, we will disable the onboard wireless LAN and audio, load the DAC driver, and enable SPI. Restart the system after finishing the edits[3].

 # Find and change to off
 dtparam=audio=off
 
 # Add to the end
 dtoverlay=disable-wifi
 dtoverlay=hifiberry-dacplus
 dtparam=spi=on

2.3 Installing hifiberry-dsp

HiFiBerry officially provides an installation script. The official procedure is here.

bash <(curl https://raw.githubusercontent.com/hifiberry/hifiberry-dsp/master/install-dsptoolkit)

This script roughly performs the following:

  • Installs dsptoolkit, a command to communicate with the DSP.
  • Installs sigmatcp, a service required for dsptoolkit.
  • Enables SPI.

At the end of the installation, a message saying mv: failed to preserve ownership for '/boot/config.txt': Operation not permitted will appear, but you can ignore it. Once completed, verify the installation by typing:

dsptoolkit

2.4 Installing the DSP Profile

Download and install the DSP profile (XML file)[4]. Installation takes a few seconds. Note that this file is not mentioned in the official documentation, so it may be deleted or changed without notice. The device name is roughly the same, and it works, so I assume it's likely correct[5].

curl https://raw.githubusercontent.com/hifiberry/hifiberry-os/master/buildroot/package/dspprofiles/dsp-addon-96-13.xml -o dsp-addon-96-13.xml
dsptoolkit install-profile dsp-addon-96-13.xml

2.5 Playing Test Audio

The noise played by speakertest is difficult to distinguish from a malfunction, so it is recommended to use meaningful sounds such as instruments or voices for testing (e.g., Test Sound Clips). Once you have prepared the audio, play the test audio with the following command.

aplay test.wav

3. Installing Shairport Sync

If you follow the instructions from the previous article, Shairport Sync will not work directly after a reboot[6]. Following the standard method will eliminate the need for tedious configuration. First, refer to the documentation and proceed up to sudo make install.

Set the following in /etc/shairport-sync.conf. Using software or DSP volume for adjustment can result in a distinct, annoying bass echo at low volumes, so we will configure it to use hardware volume. For HiFiBerry DAC2 Pro, the settings are as follows:

general =
{
    name = "hoge"
};
alsa = {
    mixer_control_name = "Digital";
};
How to find the value for mixer_control_name

The filters set in the DSP produce a characteristic echo when the audio is turned down using software volume. This is easily noticeable with solo instrument recordings. To find the hardware volume, apply the IIR filters described later and operate each fader in alsamixer one by one. The fader that lowers the volume without an audible echo belongs to the hardware volume.

4. Correction Settings

This is almost the same as the previous article, but the part where correction results are exported is different. This time, we will export the settings for individual filters as a text file.

Contents of the exported text file

Filter Settings file

Room EQ V5.20
Dated: Mar 3, 2021 01:23:45 AM

Notes:

Equaliser: Generic
All Avg
Filter 1: ON PK Fc 76.30 Hz Gain -9.90 dB Q 4.787
Filter 2: ON PK Fc 115.5 Hz Gain 9.00 dB Q 3.265
Filter 3: ON PK Fc 147.5 Hz Gain -14.00 dB Q 2.675
Filter 4: ON PK Fc 270.0 Hz Gain 4.60 dB Q 7.473
[...]

5. Loading the Correction

Load the resulting text file. While it is possible to apply corrections while music is playing, please take precautions such as suppressing the speaker volume with an attenuator. Also, be very careful not to enter incorrect commands.

dsptoolkit apply-rew-filters filter_settings.txt

To cancel the correction:

dsptoolkit clear-iir-filters

Once you are satisfied with the settings, write the configuration to the DSP as follows.

dsptoolkit store

Since we are offloading the filter processing entirely to the DSP this time, we will skip checking the CPU usage. Thank you for your hard work.

脚注
  1. For example, DTM speakers can play sounds exceeding 100dB SPL ↩︎

  2. The author failed several times before writing this tutorial but avoided damage because the volume was turned down ↩︎

  3. Alternatively, you can edit it immediately after writing the OS to the SD card by remounting it to see the boot volume ↩︎

  4. It seems possible to create original profiles using Analog Devices' SigmaDSP ↩︎

  5. In the process of searching for this, I almost broke my speakers by installing profiles one after another 🥺 ↩︎

  6. By modifying the service file and adding after=sigmatcp.service to the appropriate location in shairport-sync.service, you can set Shairport Sync to start after sigmatcp.service ↩︎

Discussion