Skip to content

Digital Signal Processing with Shairport Sync

Mike Brady edited this page Apr 2, 2021 · 2 revisions

Digital Signal Processing with Shairport Sync

Shairport-Sync has the ability to do digital signal processing (DSP) to correct the audio signal being sent to the sound card.

These instructions explain how to use an application called Room EQ Wizard (REW) to generate an impulse response filter file for use with Shairport-Sync. REW can be used to play a sine-sweep through your speakers, while simultaneously recording that sine sweep from a microphone. REW compares the recorded sine-sweep against the baseline and then produces a correction filter to get a flat frequency response.

These instructions are not an exhaustive explanation of how to use Room EQ Wizard - instead the goal here is to explain the bare minimum of how to generate a filter file that can be used with Shairport-Sync. There are a number of videos out there which go into much more depth on how to use REW. The quality of the correction depends on the quality of microphone and calibration done in Room EQ Wizard.

Requirements:

  • Install the Room EQ Wizard application
  • Microphone & Speakers

Note that you can use any computer to take the measurement and produce the filter file - you do not have to use the computer which will be running Shairport-Sync.

Steps

  1. Launch Room EQ Wizard (REW)
  2. Click the Preferences icon
    • Select your speaker Output Device and microphone Input Device
    • From the Levels drop down, choose Use main speaker test signal to check/set levels
    • Click Check Levels then click Next
    • You should hear static coming out of the speakers and REW's SPL meter should show levels on the output and input. If you do not hear static, correct the Output Device settings. If you do not see levels on the Input meter, check the Input Device settings. If the levels are too high (clipping) turn your volume down.
    • Click Finish to return to the main REW window
  3. Click the Measure icon
    • Click Start Measuring
    • REW will output a sine sweep and record the result
  4. Click the EQ Icon
    • Under Target Settings set the Speaker Type to Full Range
    • Under Target Settings click the Set target level (this is text, doesn't look like a button but it is)
    • Under Filter Tasks click Match response to target
      • Note If you get a warning about the match range being above/below the target, you can adjust the Target Level (dB) value manually up or down accordingly
  5. REW has now generated a filter profile that corrects the audio characteristics of your speaker and room. Now we can export this filter so that Shairport-Sync can use it in it's Digital Signal Processor.
  6. Close the EQ Window
  7. Click File, Export, Export filters impulse response as WAV
    • Choose Mono, 16 Bit, Sample Rate of 44100
    • save the file somewhere as impulse.wav
    • Move this WAV file to the computer that will be running Shairport-Sync.
  8. Edit your /etc/shairpoint-sync.conf file and add the following section:
    dsp
    {
        convolution = "yes";
        convolution_ir_file = "/path/to/impulse.wav";
    };
    
  9. Restart Shairport-Sync

When playing audio, Shairport Sync should now be applying the convolution filter to correct the sound characteristics.

Manually adjusting the filter

In step 5, there is a button at the top of the EQ window called EQ Filters. Clicking this button opens up another window that gives you the Frequencey, Gain and Q factor for each equalizer setting that was generated by REW.

REW's goal was to get a flat frequency response. You can manually adjust these values to change the filter before exporting it.

image

Checking the effect of the filter

You can toggle the filter on and off while music is playing in order to hear the effect the filter is having using the following commands:

  • To turn off the filter: dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:Convolution variant:boolean:false
  • Turn it back on: dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:Convolution variant:boolean:true
  • Change the filter file: /dbus-send --print-reply --system --dest=org.gnome.ShairportSync /org/gnome/ShairportSync org.freedesktop.DBus.Properties.Set string:org.gnome.ShairportSync string:ConvolutionImpulseResponseFile variant:string:"/path/to/impulse_2.wav"

Contributors

Thanks to Yann Pomarède for the code and to Paul Wieland for this guide.