Created
July 20, 2025 09:43
-
-
Save octiwhale/2e450bbd79418b947b0eedc1b4215a75 to your computer and use it in GitHub Desktop.
Convert stereo to EV-4 quadraphonic WAV (32-bit float)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # ev4_decode_f32.sh — Convert stereo to EV-4 quadraphonic WAV (32-bit float) | |
| # | |
| # Usage: ./ev4_decode_f32.sh input_stereo.wav [output_quad.wav] | |
| # | |
| # Description: | |
| # This script decodes a 2-channel (stereo) WAV file into a 4-channel WAV file | |
| # simulating EV-4 (also known as Electro-Voice Stereo-4) quadraphonic sound. | |
| # The output format is 32-bit floating point PCM at 48kHz sample rate. | |
| # | |
| # History: | |
| # EV-4 (Electro-Voice Stereo-4) was one of the earliest matrix quadraphonic sound formats | |
| # introduced in the early 1970s. It attempted to encode 4 discrete audio channels | |
| # (Left Front, Right Front, Left Back, Right Back) into a standard 2-channel stereo | |
| # signal for vinyl LP records. A decoder could then extract an approximation | |
| # of the original four channels from the stereo mix. | |
| # | |
| # This script implements a simple EV-4-style matrix decoder using FFmpeg’s pan audio filter. | |
| # The decoding math is based on early matrix decoding formulas documented in quadraphonic | |
| # audio literature, particularly "Four Channel Sound: A Guide" by Leonard Feldman and | |
| # Marshall Buck (1974), which described how to simulate rear channels using | |
| # phase-shifted or level-adjusted versions of the stereo channels. | |
| # | |
| # Channel Mapping in the EV-4 matrix: | |
| # - Front Left (FL) = original Left channel | |
| # - Front Right (FR) = original Right channel | |
| # - Rear Left (RL) = Left minus attenuated Right | |
| # - Rear Right (RR) = Right minus attenuated Left | |
| # | |
| # The decoding matrix in this script follows the classic pattern: | |
| # RL = L - 0.8*R | |
| # RR = R - 0.8*L | |
| # The constant 0.8 is used as a balance between separation and natural blending. | |
| infile="$1" | |
| outfile="${2:-quad_output_f32.wav}" | |
| # Check if input file was provided | |
| if [[ -z "$infile" ]]; then | |
| echo "Usage: $0 input_stereo.wav [output_quad.wav]" | |
| exit 1 | |
| fi | |
| # Run ffmpeg with pan filter to decode EV-4 | |
| ffmpeg -y -i "$infile" \ | |
| -af "pan=4c|c0=c0|c1=c1|c2=c0-0.8*c1|c3=-0.8*c0+c1" \ | |
| -ar 48000 -ac 4 \ | |
| -c:a pcm_f32le \ | |
| "$outfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment