Creating filters and crossovers using CamillaDSP

 

Creating filters and crossovers using CamillaDSP

You’re probably familiar with our boards featuring onboard digital signal processors, such as the DAC+DSP, Beocreate, or the DSP add-on board, which can be paired with many of our sound cards. These enable easy creation of filters for sound optimization, room correction, or speaker crossovers. The HiFiBerryOS filter designer provides an intuitive interface for crafting and modifying these filters.

Why use onboard DSP?
Once settings are stored on the DSP, no additional software on the Raspberry Pi is needed to benefit from the sound processing. The DSP operates independently, ensuring seamless functionality without impacting player applications. This simplicity makes it an excellent choice for many use cases.

Alternative: Using the Raspberry Pi’s CPU for Digital Audio Processing
Modern Raspberry Pi models, such as the Pi 4 and Pi 5, offer sufficient processing power to handle complex audio processing tasks directly on the main CPU. Numerous Linux tools are available for implementing digital audio processing, varying widely in usability, features, and sound quality.

One popular tool is CamillaDSP. Below, we’ll demonstrate how to create a simple two-way crossover using CamillaDSP. Note that this is not a step-by-step guide for deployment but an introduction to help you start experimenting. Configuration syntax and features may evolve, so check the latest documentation when implementing your setup.

Hardware Setup

We’ll use the DAC8x with the ADC8x add-on board, providing ample inputs and outputs for complex projects. For simpler tasks, such as processing stereo or mono audio streams, options like the DAC+ ADC, DAC2 ADC Pro, or Studio DAC/ADC are also suitable.

Setting Up CamillaDSP

Step 1: Download CamillaDSP

Visit the CamillaDSP GitHub page and download the latest release. For Raspberry Pi 3 or later, use the linux-aarch64 version and ensure you have a 64-bit Linux OS. Extract the file to get the executable camilladsp.

Step 2: Create a Basic Configuration

Start with a simple pass-through configuration where the input is routed directly to the output. Save the following YAML content as camilladsp.yml:

devices:
  samplerate: 96000
  chunksize: 2048
  capture:
    type: Alsa
    channels: 8
    device: "hw:0,0"
    format: S32LE
  playback:
    type: Alsa
    channels: 8
    device: "hw:0,0"
    format: S32LE

Run CamillaDSP with:

camilladsp camilladsp.yml
Step 3: Add Channel Mapping

To configure a crossover, you’ll need to map input channels to multiple output channels. Add a mixers section in your configuration:

mixers:
  to8chan:
    description: "Expand the first 2 channels to 8"
    channels:
      in: 8
      out: 8
    mapping:
      - dest: 0
        sources:
          - channel: 0
      - dest: 1
        sources:
          - channel: 1
      - dest: 2
        sources:
          - channel: 0
      - dest: 3
        sources:
          - channel: 1
      - dest: 4
        sources:
          - channel: 0
      - dest: 5
        sources:
          - channel: 1
      - dest: 6
        sources:
          - channel: 0
      - dest: 7
        sources:
          - channel: 1

Define a pipeline to use this mixer:

pipeline:
  - type: Mixer
    name: to8chan

Run CamillaDSP again to confirm the configuration works.

Step 4: Add Filters

Now, let’s add a simple high-pass and low-pass filter at 1kHz:

filters:
  hp:
    type: BiquadCombo
    parameters:
      type: LinkwitzRileyHighpass
      freq: 1000
      order: 2

  lp:
    type: BiquadCombo
    parameters:
      type: LinkwitzRileyLowpass
      freq: 1000
      order: 2

Integrate these filters into the pipeline:

pipeline:
  - type: Mixer
    name: to8chan
  - type: Filter
    channels:
      - 0
    names:
      - hp
  - type: Filter
    channels:
      - 1
    names:
      - lp

Run CamillaDSP again and verify the filters are applied. You can use audio analysis tools to visualize the changes.

Next Steps

This example demonstrates basic crossover creation. For real-world applications, you’ll need more complex configurations to adjust crossover frequencies, levels, and linearize the frequency response. Refer to the CamillaDSP documentation and experiment with different settings. For advanced users, consider exploring FIR filters, but proceed carefully, as improper usage can negatively impact sound quality.

Happy experimenting!

Last updated: December 6, 2024