After extensive testing we have created a multichannel surround sound AC3 test file for testing ac3 systems running on ALSA drivers
It works on the hardware decoder, connected by a fibre optic SPDIF, semi-works on the same hardware decoder connected by a coax cable, and plays correctly (for all physical channels) on the main 5.0, no LFE, system.
The channel order on ALSA (at least for HDA) definitely is:
L, R, Ls, Rs, C, LFE
When arranging track order (say in Audacity) for encoding into AC3 (using FFMPEG) the tracks should be set up as:
Track Content ----- -------------------- 1 L, Left Front 2 C, Centre Front 3 R, Right Front 4 Ls, Left Surround 5 Rs, Right Surround 6 LFE, Low Frequency Effects
All, left and right is in reference to facing toward the front.
This is pretty much SMPTE order except there is no Centre Surround Channel at position channel 6. Curiously, FFMPEG interprets a 7 channel ogg as having the channel order as: L, R, C, LFE, Cs, Ls, Rs so their choice for 7 channels would include a Cs, albeit everything in a different position than SMPTE AC3 order.
This is the algorithm to convert a true stereo track to "fake" 5.1 surround. You can change the outputs around based on the reccomendations above.
channel 1 - Left Front : left input channel 2:- Right Front right input channel 3 - Center : left + right + (bandpass 200hz-16000hz) + (amplify 71%) channel 4 - LFE : left + right + (low pass 200hz) + (amplify 71%) channel 5 - Left Rear: inverse left + right + (amplify 50%) + 20ms delay channel 6 - Right Rear: inverse channel 5
A little script to convert a stereo track to 5.1 surround sound format. The source should have distinct left and right signals as opposed to a mono signal copied to left and right.
Note the output for this script is different to the above reccomendations so you will need to move the tracks around before converting to AC3.
save as : convert.sh
run as : sh convert.sh in.wav out.wav
Resulting output will be: L, R, C, LFE, Ls, Rs
++++ #!/bin/bash ecasound -z:mixmode,sum -f:s16_le,2,48000 \ -a:1,2,3,4,5,6 -i $1 \ -a:1 -chmute:2 \ -a:2 -chmute:1 \ -a:3 -chmix:3 -efh:200 -efl:16000 -ea:70 \ -a:4 -chmix:4 -efl:200 -ea:70 \ -a:5 -chmute:2 -ea:-100 \ -a:6 -chmute:1 \ -a:5,6 -o loop,1 \ -a:7 -i loop,1 \ -a:7 -efh:200 -efl:16000 -etd:20,0,1,100,100 -ea:50 -o loop,2 \ -a:8,9 -i loop,2 \ -a:8 -chmix:5 \ -a:9 -chmix:6 -ea:-100 \ -a:1,2,3,4,8,9 -f:s16_le,6,48000 -o $2 ++++
add_tracks Stereo L_front R_front Center Subwoofer L_inverted Right R-L L_rear R_rear add_bunch all Stereo L_front R_front Center Subwoofer L_inverted Right R-L L_rear R_rear # no recording to disk, remove volume and pan controls for all; rec_defeat; remove_fader_effect vol; remove_fader_effect pan # create a bus for summing (inverted L) + R add_sub_bus R-L # we'll do our own routing for these tracks Stereo move_to_bus null R-L move_to_bus null # connect six tracks to the stereo source for L_front R_front Center Subwoofer L_inverted Right; source track Stereo # prepare sources for R-L (Note: 'afx' is an abbreviation for 'add_effect') L_inverted afx chmute 2; afx ea -100 Right afx chmute 1 # feed these two tracks to R-L for L_inverted Right; move_to_bus R-L # sum R-L source channels to mono R-L afx chmix 1 # Center: sum R+L to mono, bandpass, output at channel 3 Center afx chmix 3; afx efh 200; afx efl 16000; afx ea 70 # Subwoofer: sum R+L to mono, bandpass, output at channel 4 Subwoofer afx chmix 4; afx efl 200 ; afx ea 70 # L_rear and R_rear get input from R-L for L_rear R_rear; source track R-L # Output L_rear, R_rear at channels 5,6 L_rear afx chmove 1 5 R_rear afx ea -100;afx chmove 1 6