Synchrotron 1.2
Both audio encoders and decoders often add over a thousand samples of delay at the beginning of a file. This prevents both gapless playback and proper, sample synced ABX testing.
Several different implementations for gapless meta information have evolved over time for different lossy encoders. In practice this can work out pretty well, if you have full control over encoding and playback.
If you want to compare samples of different encoders, experience has shown that one cannot be sure that delay has really been removed for all files. Some decoders add their own delay or not and remove encoder delay (by reading meta information) or not. For example, converting Quicktime encoded AAC files through the Quicktime framework does not add decoding delay and removes encoder delay. Converting the same file to WAV with VLC adds 1088 samples of overall delay instead. I also got different overall delays from LAME encoded files at 48 kb/s and 128 kb/s.
Synchrotron can remove delay introduced by all lossy codecs, without having to rely on meta data. It uses a mathematical process called cross-correlation to exactly sample synchronize two files and then cut off any leading delay from the second (or just display it).
It serves the following purposes:
- Prepare files prior to ABX testing.
- Verify your encoder's/decoder's or disk writer's accuracy concerning meta-data based delay handling.
- Generally provide ability to display two files' cross correlation.
- Provide well structured and easy to read sample code, so that other developers can implement the same mechanism into their programs (e.g. Foobar's ABX component).
This is the cross platform Java binary:
Synchrotron-1.2.zip
There is only a command line interface, yet no GUI. It is easy to integrate into scripts or other applications. I'm also not planning to write a GUI, feel free to try it yourself, if you are interested.
Usage: java -jar synchotron.jar [--cut] primary_wav secondary_wav
primary_wav: original PCM WAVE file (up to 24 bit integer supported)
secondary_wav: PCM WAVE file with similar content and possible delay
--cut: remove delay from the beginning of secondary_wav
--fullscan: scan entire file (very slow)
Sample output:
java -jar Synchrotron.jar --cut tmp1.wav tmp2.wav
PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
Skipped 24598 leading sample(s) to improve accuracy.
Delay: 1088 - Cross Correlation: 0.99712723
Delay removal successful!
Make sure that you have a current Java Runtime Environment installed, either from your distribution's package repository (Linux) or from here (Windows). Mac OS X has it pre-installed.
Put the jar file into the same directory as your WAV files or better: a directory listed in your PATH environment variable. For example: /usr/local/bin or c:\windows, ...
Testing and comments welcome!
For developers:
The code is plain OO. All cross-correlation related issues are encapsulated inside the Correlator class. Java specific code, for example anything related to audio file reading, is located in the AudioFileCorrelator class. You are probably only interested in the former.
Testing has shown, that it is totally sufficient to cross-correlate about 40000 samples instead of the whole file. AudioFormatCorrelator will forward the audio streams to a significant position, so that cross-correlation isn't just applied to leading silence/noise.
This is the source including Netbeans project files:
Synchrotron-1.2-Source.zip