Flaming Lips - Zaireeka synchronization

Not at all, am actually creating a little Docker box to do the job. Will get it onto GitHub later today if that’s OK?

Thanks. That’s great :slight_smile:

I’m fascinated by this. Have no understanding of it beyond quadrophonic but fascinated.
Hopefully you cleverer people than me will be able to explain the results to me as I will never have the inclination to set up what you have!

1 Like

Have become slightly sidetracked by the stereo issue. The prospect of an 8 channel circular binaural mix for headphones is tantalizingly close. Am trying to get this working to my satisfaction:

https://ffmpeg.org/ffmpeg-filters.html#sofalizer

Edit: Right now I’d settle for getting binaural mixing working at all :joy: Went off on a bit of a Yak Shave. Found myself building ffmpeg and threatening to break a working script. A few hours sleep and I’ll get back to core businesses, putting the stereo version on GitHub. That’ll have the advantage of a working version in safer hands than mine :wink:

1 Like

Hi @DaveN the first script for this is finished, just stereo mixes ATM and you’ll need bash and ffmpeg. There’s some basic protection there (it won’t mix previous mixes to prevent geometric chaos) but it’s still a little raw in spots.

Do read the rules for CD and track numbering please.

Me too. The script bit is beyond me.

Hi @TuliaNonTroppo ,

The script’s designed to create all possible mixes of Zaireeka from the original four source CDs. It’s very short on documentation ATM, apologies. What’s there is my recording of the algorithmic rules, and they’re not complete. The idea is if you’ve ripped the four CD’s in a conventional fashion, e.g.

 ~/Music/Flaming Lips/Zaireeka> ls -alh
drwxr-xr-x 17 cfw cfw  36K Mar 15 14:03 .
drwxr-xr-x  3 cfw cfw 4.0K Mar 13 23:54 ..
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 16:57 CD1
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 17:04 CD2
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 17:09 CD3
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 17:15 CD4

it will create the 11 missing mixes:

drwxr-xr-x 17 cfw cfw  36K Mar 15 14:03 .
drwxr-xr-x  3 cfw cfw 4.0K Mar 13 23:54 ..
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 16:57 CD1
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 17:04 CD2
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 17:09 CD3
drwxr-xr-x  2 cfw cfw 4.0K Mar 12 17:15 CD4
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:02 MUXEDCD12
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:02 MUXEDCD123
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:03 MUXEDCD1234
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:03 MUXEDCD124
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:02 MUXEDCD13
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:03 MUXEDCD134
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:02 MUXEDCD14
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:02 MUXEDCD23
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:03 MUXEDCD234
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:03 MUXEDCD24
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 14:03 MUXEDCD34

Each of those will contain the tracks mixed from combinations of the CDs in the name, e.g. MUXEDCD134 will contain the same tracks as the CDs:

ls -alh MUXED134CD
total 240M
drwxr-xr-x  2 cfw cfw 4.0K Mar 15 16:18 .
drwxr-xr-x 17 cfw cfw  36K Mar 15 16:18 ..
-rw-r--r--  1 cfw cfw  14M Mar 15 16:18 01 - Flaming Lips - Okay I'll Admit That I Really Don't Understand.flac
-rw-r--r--  1 cfw cfw  38M Mar 15 16:18 02 - Flaming Lips - Riding To Work In The Year 2025 (Your Invisible Now).flac
-rw-r--r--  1 cfw cfw  25M Mar 15 16:18 03 - Flaming Lips - Thirty-Five Thousand Feet Of Despair.flac
-rw-r--r--  1 cfw cfw  54M Mar 15 16:18 04 - Flaming Lips - A Machine In India.flac
-rw-r--r--  1 cfw cfw  35M Mar 15 16:18 05 - Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac
-rw-r--r--  1 cfw cfw 8.8M Mar 15 16:18 06 - Flaming Lips - How Will We Know (Futuristic Crashendos).flac
-rw-r--r--  1 cfw cfw  37M Mar 15 16:18 07 - Flaming Lips - March Of The Rotten Vegetables.flac
-rw-r--r--  1 cfw cfw  30M Mar 15 16:18 08 - Flaming Lips - The Big Ol' Bug Is The New Baby Now.flac

It’s best run in the directory above the discs, not tested with a params too hard yet.

That’s well beyond my ability to create, but I’m fairly confident that I’ll be able to use it. That said, two quick questions.

First, am I right to assume that if I save the script in the folder that contains the multiple CDs and run it from there it will work? EDIT: just read your later post where you answered this question.

Second, re track numbering, do you mean no multiple track numbers within the individual CD folders or across them? For example, in terms of the Zaireeka discs, do I need to renumber the tracks for the second CD from 9 to 16, the third from 17 to 24 (etc)?

Hi @DaveN,

You can save the script anywhere, but the same parent folder as the discs will be fine.

You’ll be relieved to know that this is within. Indeed it needs the same track numbers across discs to match for mixing.

Cheers,
Carl

I tried it without changing any of the track numbers and am getting the following error:

-bash: /Users/djn/Desktop/1/zaireeka-mux.sh: /usr/bin/env: bad interpreter: Operation not permitted

I copied the raw data from github into a new file, ran chmod u+x. I also checked that I have an up-to-date version of ffmpeg (I have v4.3.1_8) after running ‘brew install ffmpeg’. I’m running the script in the parent folder to the four disk folders (which I’ve numbered 1 through 4).

I didn’t expect sudo would make any difference, but it did generate a different error:

sudo: unable to execute /Users/djn/Desktop/1/zaireeka-mux.sh: Operation not permitted

If you have any suggestions re what I’m doing wrong, I’d be grateful.

The only other thing I could think of - do I need to run the scripts with any additional parameters? I’ve been running it as follows:

/Users/djn/Desktop/1/zaireeka-mux.sh

Hi @DaveN just about to eat, but this is on a Mac?

Yep, on a Mac (running Catalina 10.15.7). No rush - enjoy your meal :slight_smile:

Hi David,

So the script was developed on Linux. It’ll be transferable but I’ll bet the difficulty is with your local bash env and the “universal linux shebang” that I’ve used.

The good news is that line 1 is in question is all I think. You should be able to force the interpreter by issuing bash <path-to-script>. This article should help if things don’t work or if you want an explanation:

If not please issue this command (which should work, I’m not a Mac user) which bash and let me know the answer.

Good luck,
Carl

P.S. tea was delicious thanks

‘which bash’ returns /bin/bash so I tried changing line 1 to #!/bin/bash

The script appears to run, but doesn’t do anything. I added a few echo lines to see if I could see what’s happening with the execution as follows:

This outputs the following in terminal:

4
1
2

So it doesn’t look like it’s getting to the for loop in the combine section. Also, the syntax colouring gets messed up on line 40, so there may be some mac/linux incompatibility at this point. I don’t know anywhere near enough to start debugging it but if I change the first part of line 40 to [ $[(1<i) & value] I get correct syntax colouring for the rest of the file but this doesn’t change the way the script runs, i.e. it still doesn’t seem to get to the for loop at line 36.

I’ll spin up Virtual Box, install Ubuntu, and try running the script from there.

So I can’t take credit or blame for the Mac broken bit, it was lifted from an online source (see comment link) and it’s not Mac friendly.

I can at least confirm that it works on Linux, I’ve been listening to the mixed discs and the “Track no x CD xyx” intros all match the mix disc choices and they play.

Binaural mix next.

EDIT

Am already regretting my confident tone here, this has to be done via an intermediate 8-channel mix and the mapping isn’t for the faint-hearted.

For anyone with ffmpeg who just wants to mix these together the basic pattern is pretty simple. To mix two version of a track into a single one:

fmpeg -i "./CD1/05 - Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac" -i "./CD2/05 - The Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac" -filter_complex amerge=inputs=2 -ac 2 "MUXEDCD12/05 - Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac"

The equivalent for all four CDs is:

fmpeg -i "./CD1/05 - Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac" -i "./CD2/05 - The Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac" -i "./CD3/05 - Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac" -i "./CD4/05 - Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac" -filter_complex amerge=inputs=4 -ac 2 "MUXEDCD1234/05 - Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac"

The only things that change are:

  • the addition of extra inputs, e.g. -i "./CD2/05 - The Flaming Lips - The Train Runs Over The Camel But Is Derailed By The Gnat.flac"
  • changing the option that denotes the number of inputs. e.g. amerge=inputs=2 or amerge=inputs=4

This creates a single track with all left channels mixed left and all right channels mixed right.

Edit
Final mixing “tricks”, you can make multi-channel mixes and convert them to binaural files, though it’s slightly arcane. First you need to combine four tracks into an octagonal configuration:

ffmpeg -i CD1/04\ -\ Flaming\ Lips\ -\ A\ Machine\ In\ India.flac -i CD2/04\ -\ The\ Flaming\ Lips\ -\ The\ Machine\ In\ India.flac -i CD3/04\ -\ Flaming\ Lips\ -\ A\ Machine\ In\ India.flac -i CD4/04\ -\ Flaming\ Lips\ -\ The\ Machine\ In\ India.flac -filter_complex "[0:a][1:a][2:a][3:a]amerge=inputs=4,pan=octagonal|BC<c0|FC<c1|BL<c2|FR<c3|SL<c4|SR<c5|FL<c6|BR<c7[a]" -map "[a]" 8CHAN/04\ -\ Flaming\ Lips\ -\ A\ Machine\ In\ India.flac

The inputs are the same as the other quad file examples, the difference here is the filter/mapping parts that needs some explaining:

-filter_complex "[0:a][1:a][2:a][3:a]amerge=inputs=4,pan=octagonal|BC<c0|FC<c1|BL<c2|FR<c3|SL<c4|SR<c5|FL<c6|BR<c7[a]" -map "[a]"
The initial [0:a][1:a][2:a][3:a] says that we only want the audio streams from each of the inputs (arrays are indexed 0-3 rather than 1-4, and ffmpeg handles video streams as well, e.g. [0:v]. Next comes amerge=inputs=4 which invokes the amerge filter for four input files, same as before. The worst bit is the pan channel mappings, this depends on your chosen channel mapping. Here I wanted 8 tracks so chose the octagonal channel layout, which has 8 speakers arranged in octagonal layout:

           FC
     FL          FR
SL                     SR
     BL          BR
           BC

You need to do is map each of the 2 stereo channels across 4-tracks to the stereo channels and the mapping syntax is clumsy. Channels are mapped via input, each input has 2 channels, and they’re assigned a numeric value with a c prefix. The first input has L=c0, R=c1, input two has L=c2, R=c3, and so on up to c7. Mapping these channels to the octagon layout looks like this: pan=octagonal|BC<c0|FC<c1|BL<c2|FR<c3|SL<c4|SR<c5|FL<c6|BR<c7[a]" -map "[a]" The closing [a]" -map "[a]" is a little arbitary but it’s required ;).

Once you have your 8 channel file it can be mixed to binaural using the sofalizer filter so: ffmpeg -y -i 8CHAN/04\ -\ Flaming\ Lips\ -\ A\ Machine\ In\ India.flac -filter_complex "sofalizer=sofa=./ClubFritz8.sofa:type=freq:radius=1:gain=16" BIN1234/04\ -\ Flaming\ Lips\ -\ A\ Machine\ In\ India.flac. This time a single input (the 8 channel file) and a single output (the binaural mix). The only part or interest is the filter line: -filter_complex "sofalizer=sofa=./ClubFritz8.sofa:type=freq:radius=1:gain=16". This just:

  • invokes the sofalizer filter: sofalizer=
  • provides the sofalizer spatial mapping file: sofa=./ClubFritz8.sofa which is an 8-channel setup. These can be obtained here: Index of /data/database and the file I’ve used can be downloaded here;
  • set the filter processing type type=freq, which can be time or freq. time is processing audio in time domain which is slow. freq is processing audio in frequency domain which is fast. Default is freq. I would have preferred the time versions but the resulting files were full of digital clicks so frequency it is;
  • finally radius=1:gain=16 sets the radius of the binaural sphere (default shown is 1m) and adding 16dB of gain as the first mix was quiet.

There you go, I’m done here but happy to answer questions :slight_smile:

2 Likes

Reviving this old thread because Zaireeka is now on Qobuz. Anyone figure out a synch solution for doing it the artist intended way of simultaneous playback on 4 different stereos (using Roon of course ;))

Couldn’t I just use a different Roon remote for each system and press play at the same time?

If the stereos are all Roon Endpoints, you can simply group them for simultaneous playback.

Thanks Geoff, but they are not all the same. Each stereo plays a different version of the same track.