Rendering 4-channel to binaural audio

I had a period in the early 2000s when I made a few pieces in the genre of electroacoustic music (“tape music”). One of these was a 4-channel piece called Peer Peer, made for an exhibition opening at Henie-Onstad Kunstsenter in 2003. The piece was based on a montage of short snippets sampled from Edvard Grieg’s music to the play Peer Gynt by Henrik Ibsen. Someone asked about the piece the other day, so I decided to find the files.

Resurrecting an old project

Twenty years is a long time in the world of computers. Interestingly, the production tool I used, ProTools, is still around. However, I don’t have a Zip drive to access the disk with the original project files. They have an office with old equipment at UiO that I could go to, but I figured that wasn’t worth the effort right now. So I had to work with the four exported audio files that I found in my archive:

The original project was done in the surround sound studio at NOTAM in Oslo. It was set up with eight speakers, so I did the original mix for eight channels. But I only had four speakers available for the performance, so I rendered out only four tracks.

From 4 channels to binaural

The original performance was done using a custom Max patch with a quadraphonic setup. This is not convenient for others, so I wanted to create a binaural version to share. The nice thing about binaural audio is that you can get a sense of surround sound using only 2-channel audio. This only works with headphones, but it is good enough for now.

The question, then, is how to get from 4 audio files to binaural audio? I thought about using Reaper, a convenient and flexible digital audio workstation. However, given my interest in exploring the power of FFmpeg, I was curious as to whether there was a simple terminal solution.

The first step was to turn the original separate four audio files into a 5.1 surround sound file using this command:

ffmpeg -i front-left.aif -i front-right.aif -i center.aif -i lfe.aif -i back-left.aif -i back-right.aif \
-filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6[a]" -map "[a]" output2.wav

I could probably have figured out how to do the process with only my original four channels but found it easier to add two silent tracks (center and lfe) for the conversion.

Then I converted this 5.1 file to binaural using the sofalizer plugin:

ffmpeg -i output2.wav -af sofalizer=sofa=hrtf_nh2.sofa:type=freq:radius=1 output2.flac

Here is the final result:

There are many head-related transfer functions available for sofalizer. I didn’t know which one to choose, so I picked one of the first ones. The spatial representation sounds different than I remember, but it still creates a surround sound effect. If I have more time, I want to go back to the original project files and render a new binaural version. For now, this version is ok for what is needed. And it was helpful to see that FFmpeg could also be used for this type of conversion.

Published by


Alexander Refsum Jensenius is a music researcher and research musician living in Oslo, Norway.