Sunday, November 22, 2020

 Passive headphone correction filter for Beyerdynamics DT770 Pro 80 headphones

The Beyerdynamics DT770 Pro 80 headphones sound very good. However, the lower frequencies are emphasized which sometimes results in 'rattling'.

Solderdude from 'DIY Audio Heaven' was so kind to send me the details of a passive filter to suppress the lower frequencies. This has to be placed between the headphone amplifier output and the headphones. See DIY Audio Heaven.

I built the filter in a piece of PVC electrical conduit pipe. The photos largely speak for themselves I think:
just fits

one channel

soldered to the cable

showing the process of shoving the filter into the pipe

with a closeup

sealed with hot glue, but not air tight due to a ventilation hole

heat-shrink tubing applied, looks nicer

from left to right: PSU, filter, headphone amplifier

How does it sound? Definitely more neutral, lineair. Bass is not exaggerated anymore as was the intention and voices are more pronounced than without. I will keep the filter inserted, I like it.

Monday, October 28, 2019

Joechei Headphone Amplifier

Joechei Headphone Amplifier


I rarely listen to music over the speakers. Instead for a long time I used a headphone amplifier published by the Elektor magazine of 1987: 'The Headphone Amp'. This headphone amplifier from Elektor is based around an old opamp, the OP-50, long out of production.
So boredom striked and because of the good reviews of the Cmoy headphone amp I decided it was time to make one and it had to be a desktop version.

Tweaking the original circuit to dig up the sound qualities hidden behind this 'non-inverting opamp circuit', it eventually turned out to be an extended version of the original circuit that I am very happy with. Hence the name 'Joechei', an old Dutch word to express happiness.

It does not matter what kind of music you throw at it, but to judge its sound quality and 'musicality' while tweaking I mostly used classical music and Jazz.
Still using one opamp (which was my intention and challenge) it is fairly easy to build.

For me the result is proof that very good sound does not have to be overly expensive.


The circuit is simple and the components are cheap: it consists of one dual opamp type OPA2134PA (see addendum for other opamps) and a power supply with two resistors and capacitors. These generate a positive and negative voltage for the opamp. This way the amp can be used with a single power supply (see addendum about other rail splitters).

Schematically I setup the circuit like this:
 And electronically like this:

pdf The amplification is (8.2k / 2k) + 1 = 5.1x


Because of component tolerances, not to forget off-balance hearing and a weird but interesting phenomenon described here and here it is possible one channel appears to be louder than the other. It made me think of the 'spinning dancer' effect where the brain tries to relate the direction to which the dancer turns with the visual clues it gets.

Since the stereo imaging of this headphone amplifier is better than before, I noticed the balance shifted a bit to the left, possibly because I try to relate the visual clues of what I look at with the auditory clues of the sound. Closing my eyes the balance shifted a bit back to the right.

Anyway, I wander from the subject but that is why I added a volume balance control at the back of the enclosure.


I payed special attention to block RF as much as possible at all 'paths', the input, output and power supply because I suspect the audio quality is negatively affected by this. 

RF is the reason why the 2.2 nF and 100 nF capacitors are ceramic ones.

Component placement

An etched pcb looks nice but is a fuss to make. A circuit of this size can easily be made on a piece of perf board.

To keep everything small and orderly I first made a drawing of the way the components are placed on the board:
the grey 2k resistors, 100k resistor and 100n capacitor are placed under the board

The Zobel network consisting of a resistor of 10 ohm and a capacitor of 100n in series at the output 'equalizes' the load to the opamp for higher frequencies.
I soldered it directly onto the headphone jack input.

The low pass filter to prevent RF from entering the input was also soldered directly onto the RCA input connectors.
The opamp is placed in a socket so it can be swapped later on if needed.

Start soldering the socket first, then the resistors, smaller capacitors and at last the bigger electrolytical capacitors. Watch out for the polarity regarding the bigger capacitors.
Solder the 100n capacitors as close to the opamp as possible.
If you use a metal enclosure use isolated mount sockets for the headphone jack input and RCA inputs or you will short the power supply. 
Below are some impressions with an other rail splitter or other opamps (see addendum). The boards may be different but the instructions stay the same.

After soldering has finished test the positive and negative voltage by temporarily connecting a 9 Volts battery. A voltage of plus 4.5 Volts and minus 4.5 Volts should be measured over the 4.7k resistors.
Also, the voltage between pin 4 of the socket and signal ground should be minus 4.5 Volts and the voltage between pin 8 and signal ground should be plus 4.5 Volts. Measuring this ok it should be safe to place the opamp in its socket after disconnecting the battery.

Power supply

Using two 9 Volts batteries is not handy when using the amplifier on the desktop, although they seem to last long. And old laptop provided me with an adapter of a little more than 19 Volts.
Another advantage from using a switched power supply is to avoid the stray magnetic field, resulting in hum.

Check the resistance between 'input/mains' and the 'output' of the switched power supply (when not connected), it should be too high to measure. 


Start with wiring the power cables. Only power ground is connected to the aluminium case.

After that wire the signal ground. Connect signal ground to one point close to the signal input but do not connect it to metal enclosure. Therefore be sure to use isolated inputs and output if using a metal enclosure.

Here I used white cable for signal ground and red/black cables for power:

balance control, fixed with epoxy glue

accesible from the outside with a screwdriver
After wiring the power and signal cables wire the input and output.
Try to keep the signal wires and power wires separate. In the photo above the power wires are (mostly) on the left and the signal wires are on the right.


Connect an old headphone at the first smoke test if possible and close the volume. Only then switch on the amplifier and open the volume slowly.

The amplifier is silent, no buzzing/humming or noise. I almost cannot hear it being switched on or off.


If you hear unexpected weird sounds chances are the amplifier is oscillating.

The cable of the headphones acts as a capacitor. The longer the cable, the higher the capacity.  R5 and R8, the output resistors, prevent the opamp from oscillating due to this capacitive load at the output.

But unfortunately the value of the output resistor influences the sound. How much so depends on the type/brand and impendance of the headphones used.  Preferably R5 and R8 are not used. Without R5 and R8 the lower frequencies of the amplifier sound more accurate, for lack of a better word and for lack of measuring equipment.

Luckily some opamps are less susceptible to oscillation than others. In my experience these resistors are not needed when the OPA2134, AD826 or NJM4580 are used, for example.

If you have to use output resistors, a R5/R8 of 38 ohms is suitable for headphones with an impendance of 32 ohm, for Beyerdynamic DT 770 Pro 80 headphones 10 ohm is sufficient.

Oscillation can also be caused by the high frequency range of a fast opamp. This can be stopped by placing a 100 pF film capacitor over the feedback resistor of 8.2 kohms.


My setup:
- Archlinux
- mostly classical and Jazz music in flac format
- Audacious or Deadbeef music player bitperfect setting
- HRT Music Streamer II USB DAC with USB isolator
- Joechei headphone amplifier
- passive headphone correction filter
- Beyerdynamics DT770 Pro 80 headphones

To make the admittedly unfair comparison between the 'Headphone Amp' of the Elektor of 1987 and this Joechei headphone amp, there is a clear difference. Joechei sounds more expressive, more detailed and therefore more natural.

Compared to the Musical Fidelity 'X CANS' headphone amplifier, Joechei sounds so much more detailed and less muffled that I am thinking of replacing the internals of these 'X CANS' headphone amplifier by Joechei.

The difference between good and bad recordings is clearly audible, yet it seems to extract the musicality even from bad recordings.

The soundscape is well defined, the tonal quality is well balanced. The amplifier does not sound harsh in the upper frequency range. If needed the lower frequencies are being called upon with quality and impact. Voices sound natural.
For example, listen to 'Ocean' of Gian, the dynamics of the recording and the instrument as it moves through the vast space.
Or in Marillion 'Brave' the smallest details can be heard without increasing the volume, a refinement my old headphone amplifier lacked.
Representing the sound of the piano is a challenge for amplifiers but in 'Irina in A - Schubert - Bach - Brahms' I am convinced Irina Mejoueva plays the real thing.
Another example, try Ryan Adams 'Live at Das Haus', very realistic.
Etc, etc.
The amplifier has more than enough power to drive my 80 ohm headphones. Like the designer of the Cmoy headphone amplifier, Chu Moy said: "...It can output almost 40mA into a short circuit at room temperature. Modern dynamic headphones need about 10mW to reach full volume...". That is the reason I focused on using only one opamp to drive my headphones, more is less. Tests and my own experience confirm using just one opamp is possible.

I suspect the countermeasures to limit RFI play a major role in the quality. One supporting fact is this: while building one version I forgot to add the ferrite bead at the output (there is only one needed for both left and right). After the enclosure was closed I noticed it was susceptible to hum when I touched it. When I added the ferrite bead the hum was gone. The long headphone cable must have picked up RF creating a loop when I touched the case. At least, that is my theory.
See the sources at the end of this article.

As you may have noticed I do not have a tendency to change components once I find they qualify to fulfil their purpose. This headphone amplifier stays as is.
And it is very reproducable. By now I must have made four or five of these, all show the same quality but I advise to read the addendum below to squeeze out the last bit of performance out of this amplifier. 

Overall, I am very satisfied with the result, the 'price/quality' ratio is excellent. 



The standard version of Joechei already sounds great but it can be upgraded by trying the options described below.

Other opamps?

It is possible to use a different opamp but check some properties first. 
First check the datasheet for the maximum allowed supply voltage and maximum output current. The latter should be sufficient for the headphones used. 
With the source connected measure the voltage (DC) at the output: it should not be more than 30mV per channel. You risk damaging your headphones if it is higher. 
For example, if I use an NJM4556 opamp the DC offset of both channels are 24mV.

If you do not use a FET opamp this circuit has a higher chance of oscillating so beware. In my experience for example a LM4562 will not work but an AD826 or NJM4580 will.
If it oscillates experiment with the value of R5/R8 and/or use a 100pF feedback film capacitor. It seems placing a 10uF/35V capacitor over pin 4 and 8 also can help but I did not test that.

By now my preference is, high to low on a scale from 10 to 1:
NJM4580 in class A (9) - NJM4556 in class A(9) - NJM4580(8) - AD826(8) - NJM4556(7) - TLE2082CP(7) - OPA2134(7) - prob fake OPA627(5) - MAX97220(4) 

Other possible ways to create a virtual ground?

Joechei creates a virtual (signal) ground with two resistors and two capacitors, also called a rail splitter. However it is also possible to create the virtual ground another way.

I tried the Sijosae rail splitter:

and compared it with the original resistor rail splitter and this opamp rail splitter:
Implemented like this:

an implementation with an opamp rail splitter and a NJM4580

I can hear no difference between the Sijosae rail splitter and the opamp rail splitter but both are slighty better in stereo imaging than the original passive rail splitter.

Use metal film or carbon resistors?

Carbon resistors are less stable, give more noise than metal film resistors, and the values are less accurate.
However I use metal film and carbon resistors interchangeably without adverse effect. I keep the values as close together as possible and keep both channels consistent e.g. two 8.2k metal film resistors, two 2k carbon resistors and so on, see the photo above.

Input capacitors

In theory it is beneficial to get rid of the input capacitors as they influence the sound in a negative way. I tried that but I got DC offset at the output in return. The sound improvement is not worth the risk of damaging my headphones.
Then I swapped the 470nF capacitors for 1,5uF polypropylene capacitors. Any improvement in sound is probably my imagination playing tricks but it proves that a higher value can be used without problems.

Class A

It is possible to set the opamp in class A, thereby lessening crossover distortion, resulting in a 'smoother' and more detailed sound.
Just soldering two 10 kΩ resistors directly onto the opamp is necessary: one 10 kΩ resistor between pin 1 and 4 and the other between pin 7 and 4:

These resistors set the current at the output to a more or less constant 0.95 mA when using +/- 9.5 Volts.
The result depends on the opamp, it seems especially older type opamps benefit from this hack. In my experience the NJM4580 or NJM4556 are suitable, these opamps handle the extra current with ease, up to 2.5 mA.

Biasing the opamp does not influence DC offset at the output, tested that.
This hack is highly recommended.

Build your own switched power supply?

I recently built my own switched power supply. In fact it is a hybrid and it consists of a transformer, rectifier, XL6009 step-up boost converter and an EMI filter.
A few impressions:
the transformer is almost too big to fit in the enclosure

but sideways it just fits

to convert AC to DC I used several modules on a (very) old piece of phenolic paper

The step-up boost converter with the XL6009 allowed me to increase the voltage to 30 Volt and so the railsplitter provided the opamp with +15V and -15V.
Be careful if working with high voltages, build at your own risk.
It works flawlessly so far, no noise or other artefacts whatsoever.

Optimize the sound source

A chain is as strong as its weakest link so not to forget the source see Optimize Linux audio.

So, what is the best combination of components?

I prefer the NJM4580 and NJM4556 opamp both set to class A, with the opamp or Sijosae rail splitter delivering +15 and -15 Volts. The NJM4580 and NJM4556 opamps have a nice warm (tube like?) sound that I (can) listen to for hours, pure magic. Try, you will be blown away by it, I am sure. 

Disclaimer: always beware of high sound volume, it can damage your hearing! First close your volume control and slowly increase the volume.

Monday, April 22, 2019

Optimize Linux audio

Optimize Linux audio

These actions result in a click-free audio using an USB DAC and Linux. You may not need all of them, just try them, in this order:

0. Convert your >96 kHz flac files to 44 kHz. You probably won't hear the difference.

In Linux:
sox "inputfile_96k.flac" -G -b 16 "outputfile_44k.flac" rate -v -L 44100 dither

1. Disable frequency scaling in the BIOS.

2. Improve Linux responsiveness by adding these lines to /etc/sysctl.d/99-sysctl.conf:
vm.swappiness = 1
vm.vfs_cache_pressure = 50
vm.dirty_background_ratio = 1
vm.dirty_ratio = 40

3. Add these kernel parameters : 
intel_idle.max_cstate=0 processor.max_cstate=1 usbcore.autosuspend=-1 sysrq_always_enabled=1 isolcpus nohz_full=1-4 rcu_nocbs=1-4 threadirqs intel_pstate=disable
Underlined are most relevant.

In my experience this helps the best if dropouts occuring during playing a flac file.

4. If frequency scaling is not disabled in the BIOS, install 'cpupower', enable it and modify the following line in /etc/default/cpupower: governor='performance' 

5. 'reflac' the flac files. Use compression '-2'.
This helps against dropouts when the flac file begins to play.

6. Install the package 'realtime-privileges' and add the user to the group 'realtime': usermod -a -G realtime <username>

7. disable 'Intel Virtualization Technology', 'C-state' and on-board sound in the BIOS. 

8. change the contents of /etc/pulse/daemon.conf to:
high-priority = yes
nice-level = -11
realtime-scheduling = yes
realtime-priority = 9
rlimit-rtprio = 9
rlimit-rttime = -1
daemonize = no

9. Add the user to the 'audio' group: usermod -a -G audio $USER

10. Install ananicy.

11. Modify /etc/asound.conf to:
pcm.!default {
   type plug
   slave.pcm hw

12. Modify /etc/security/limits.conf with the following lines:
@audio - rtprio 99
@audio - memlock unlimited
@audio - nice -10

13. Bypass PulseAudio when playing music with Deadbeef or Audacious.

In configuration, Sound, set the output plugin to 'ALSA output plugin'.

In configuration, Plugins, 'ALSA output plugin', de-select 'Use ALSA-resampling'.

In configuration, DSP, remove the resampler.

In 'Audio settings' select the output plugin 'ALSA'.

14. create ~/.asoundrc for near bit perfect audio via ALSA:
pcm.usb-audio {
    type hw
    card 1
    defaults.pcm.rate_converter "samplerate_best"
    defaults.ctl.card 1
    defaults.pcm.card 1
    defaults.timer.card 1
ctl.usb-audio {
    type hw
    card 1

Beware your volume control is not PulseAudio anymore but Deadbeef or Audacious. If the volume in these are set to maximum, be sure to lower the volume first!

15. Convert your flac files to wav and back. In some cases this helps.

16. Add to /etc/pulse/
load-module module-udev-detect tsched=0

USB isolator
Later I got an USB isolator to be placed between the USB DAC and the pc:

While it does not replace the actions above and the effect is almost too subtle to notice, perhaps the sound is a bit more 'spacious'. It does not hurt I guess.

Disclaimer: always beware of a high sound volume, it can damage your hearing! First close your volume control and slowly increase the volume.