I'm trying to make/create a 5.1 and a 7.1 surround sound file but I'm having trouble finding a way to do it. I'm using ubuntu 12.04 and I have access to octave / matlab / python. I understand how to create an audio file in octave / matlab / python but not sure how to create the proper file format for a 5.1 and 7.1 surround file.
2 Answers
I believe Vorbis is the only free sound codec that supports surround-sound. There used to be some python projects to deal with this format, but they do not seem to be maintained any more.
You can try looking through these old projects (i.e. pyvorbis).
Alternatively you can try using this matlab project, and see if a vanilla 6-channel vorbis file will work with 5.1 surround sound (a quick glance at the spec makes me think it should).

- 3,586
- 1
- 18
- 20
-
1PCM RIFF should *technically* also be able to, but I don't know if there's any programs that could actually *read* it. – Ignacio Vazquez-Abrams Jul 18 '12 at 18:21
If you are able to create 6 (for 5.1) or 8 (7.1) separate mono audio files, one for each loud speaker (front_left.wav, front_center.wav, ...), you can join them with the following command line:
ffmpeg -i front_left.wav -i front_right.wav -i front_center.wav -i lfe.wav -i back_left.wav -i back_right.wav -filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a]join=inputs=6:channel_layout=5.1:map=0.0-FL|1.0-FR|2.0-FC|3.0-LFE|4.0-BL|5.0-BR[a]" -map "[a]" output.wav
This line is from https://trac.ffmpeg.org/wiki/AudioChannelManipulation that has several other useful channel manipulations examples. LFE
(low frequency effects) is referring to the sub-woofer. ffmpeg is available for Windows, Mac and Linux (e.g. as Debian package of the same name).
If you want to create a multichannel audio file directly from Python, have a look at the pydub package (which makes use of the ffmpeg library under the hood).
To probe whether a given audio file has multichannel content you can use ffprobe
of the ffmpeg suite:
ffprobe -hide_banner output.wav
which shows e.g.:
Input #0, wav, from 'output.wav':
Metadata:
encoder : Lavf58.20.100
Duration: 00:00:01.28, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, 5.1, s16, 1536 kb/s

- 604
- 7
- 15