Wednesday, 23 March 2016

Big ends and little ends and socks

Today's theme is endian-ness... Mr. Bowie's AIFF tracks are S24_3BE, which is exactly how all AIFF files will be! Scary, and I didn't realise that. Before they can play on my DAC they need to be S24_3LE. My options are:

  • Convert them as files to 3LE, so that they are like that for ever, hopefully they will then play with mpd
  • Convert them on the fly using plughw; this already works with aplay but not with mpd
This is where sox comes into play, maybe... I tried converting to WAV, which in principle allows LE - I already tried to a new AIFF but SoX wasn't having that because AIFF is BE only - see here.

pi@raspberrypi:/media/pi/David Bowie/Blackstar $ sox -V3 -B 02-\'Tis\ a\ Pity\ She\ Was\ a\ Whore.aif -x 02-\'Tis\ a\ Pity\ She\ Was\ a\ Whore\ LE.wav 
http://stackoverflow.com/questions/1111539/is-the-endianness-of-format-params-guaranteed-in-riff-wav-files
sox:      SoX v14.4.1
sox INFO formats: detected file format type `aiff'
sox INFO aiff: Unity MIDI Note: 0
sox INFO aiff: Low   MIDI Note: 0
sox INFO aiff: High  MIDI Note: 0

Input File     : '02-'Tis a Pity She Was a Whore.aif'
Channels       : 2
Sample Rate    : 96000
Precision      : 24-bit
Duration       : 00:04:52.63 = 28092161 samples ~ 21947 CDDA sectors
File Size      : 169M
Bit Rate       : 4.61M
Sample Encoding: 24-bit Signed Integer PCM
Endian Type    : big
Reverse Nibbles: no
Reverse Bits   : no

sox INFO formats: `02-'Tis a Pity She Was a Whore LE.wav': overriding file-type byte-order
sox INFO wav: Requested to swap bytes so writing RIFX header

Output File    : '02-'Tis a Pity She Was a Whore LE.wav'
Channels       : 2
Sample Rate    : 96000
Precision      : 24-bit
Duration       : 00:04:52.63 = 28092161 samples ~ 21947 CDDA sectors
Sample Encoding: 24-bit Signed Integer PCM
Endian Type    : big
Reverse Nibbles: no
Reverse Bits   : no
Comment        : 'Processed by SoX'

sox INFO sox: effects chain: input        96000Hz  2 channels
sox INFO sox: effects chain: output       96000Hz  2 channels

The bit in bold looks bad - it seems to have retained the byte order and put an instruction in the header instead! This doesn't work.


The AES31 specification for BWF (Broadcast Wave Format) references this specification for RIFF: http://www.tactilemedia.com/info/MCI_Control_Info.html
From this:
RIFF has a counterpart, RIFX, that is used to define RIFF file formats that use the Motorola integer byte-ordering format rather than the Intel format. A RIFX file is the same as a RIFF file, except that the first four bytes are 'RIFX' instead of 'RIFF', and integer byte ordering is represented in Motorola format.

Looks like I'm screwed, unless the conversion to FLAC has done the trick. For that, I'd have to get mpd to see the damn FLAC file.

OK! Used the alas-configure script to create a new mpd.conf file that uses the music directly, rather than via minimserver, and started things with mpc. Loaded the Bowie Blackstar.flac file and bingo!! Plays fine on the hw:1,0 setting. Looks like that's what I have to do - convert the AIFF to FLAC. Blimey.

No comments:

Post a Comment