Tag Archives: python

A HiFiBerry installation with button control and LCD display

RPi HiFiBerry 2014 openPieter Kleinjahn has installed a Raspberry Pi, the HiFiBerry DAC, some buttons and a LCD display in one box.

The buttons can be used to control MPD. Distributions like Volumio and RuneAudio are based on MPD, therefore this could be interesting for many readers. Peter has provided the Python script that controls everything. You can download it here: mydisplay-20140409. Note that we provide this “as is” without any support. However, the code is clean and well-documented. Therefore it should be relatively easy to adapt it to your needs.

A simple XML model for filter networks

For the HiFiBerry DSP project we need a compact, but flexible configuration of a network of filters. Therefore I created an XML configuration that models the different parts of the filter network.

<network samplerate="48000">
<input name="input1"/>
<biquad name="bq1" input="input1" type="allpass" frequency="200" q="1" />
<biquad name="bq2" input="bq1" type="lowpass" frequency="1000" q="0.7" />
<biquad name="bq3" input="bq2" type="highpass" frequency="100" q="0.7" />
<biquad name="bq4" input="bq3" type="notch" frequency="400" q=".1" />
<biquad name="bq5" input="bq4" type="peaking_eq" frequency="700" q="4" dbgain="3" />
<output name="out1" input="bq5" />

Here you see a simple DSP configuration with one input and one output and 5 biquad filters processing the data. Today, no other filters are supported, but I will add other types soon. I plan to also support FIR filters.

Using our software you can now calculate the frequency response of this filter chain:

  Freq       Mag   Phase
    10  -40.27db  151.26°
    15  -33.54db  137.31°
    20  -28.95db  123.77°
    30  -22.92db   98.07°
    40  -19.11db   73.96°
    50  -16.52db   51.02°
    75  -13.06db   -3.32°
   100  -12.19db  -54.31°
   150  -13.86db -148.08°
   200  -16.87db -232.90°
   300  -24.77db -340.74°
   400 -298.86db -480.46°
   500  -26.91db -242.30°
   750  -16.50db -310.78°
  1000  -16.52db -346.21°
  1500  -17.48db -391.49°
  2000  -19.60db  -58.47°
  3000  -23.71db  -89.23°
  4000  -27.23db -107.29°
  5000  -30.26db -119.52°
  7500  -36.41db -137.98°
 10000  -41.23db -148.30°
 15000  -48.77db -159.52°
 20000  -54.92db -165.64°

Now let’s do a nice graph from it using Matplotlib.
Note, this is not the filter that we used before, because the response of that filter is really nasty – it was just for demonstration of the different biquad filters.

Now, we only have to merge this with our DSP upload software with this code and we already have a simple command line tool to upload and modify filters on the HiFiBerry DSP.

HiFiBerry DSP Light: Prototyping started

hifiberry-dsp-debuggingOur DSP project for the Raspberry Pi has reached the next milestone: hardware prototyping. The digital part of the circuits is working. There was still a minor bug (wrong pinout of a transistor) that was easy to correct by soldering the transistor on its back. The rest of the circuit worked well. As you can see on the picture, the analog part is not assembled yet. First I want to be able to upload the software to the chip.

Unfortunately, the simple approach to upload the program did not work. The chip simply did not acknowledge any I2S requests. Soldering some cables and connecting the I2S bus to the logic analyzer showed some unexpected behavior. While I2C read requests did not work, there was no problem with write requests. What happened? I had a look at the datasheet again and I think, I found the problem. Before every read request, the chip expects a write request with the address to read. However, both requests have to be in the same I2C transaction. The chip expects multiple start bits. Unfortunately, the Python I2C library that I wanted to use does not support multiple starts. It seems that I have to use the lower-level device driver of the operating system to upload the software to the chip.