Log in

View Full Version : Combining three mono wavs into 2.1 PCM?


ikantspelwurdz
13th April 2013, 16:38
I have the following:

A silent MP4 video
-H264 - MPEG-4 AVC part 10 avc1
-1920x1080
-23.976 FPS
-Planar 4:2:0 YUV

Three WAV files
-PCM S16 LE araw
-Mono
-48Khz
-16 bit

The first two are identical, and the second is the base line.

I want to author a Blu-Ray with PCM 2.1 audio. Or if this is possible and supported by BD players, PCM 1.1 (I'm assuming it isn't). I don't want to re-encode any of the audio - I want the three WAV files to be discrete channels in a PCM 2.1 sound track.

How can I go about doing this? I know how to do all of the steps except actually combine the three audio files in the manner I want.

tebasuna51
13th April 2013, 17:56
The first two are identical, and the second is the base line.
...
I want the three WAV files to be discrete channels in a PCM 2.1 sound track.

How can I go about doing this?
Are you sure than the bassline contain only low frequencies?

The subwoofer speaker can't play frecuencies over 120/200 Hz.

Maybe is better mix the tracks.

Jenyok
13th April 2013, 19:10
ikantspelwurdz
.
Try this.
.

Left=WAvSource("Left.wav")
Right=WAvSource("Right.wav")
LFE=WAvSource("LFE.wav")

Audio2_1=MergeChannels(Left, Right, LFE)

.
LFE = means subwoofer.
And so on...
.

ikantspelwurdz
13th April 2013, 21:56
tebasuna51:
These were ripped from a DVD, originally in 2.1 AC3 format. I imported into Audacity, converted to three 48Khz mono tracks, and all I did to change them was cut some time from the beginning and very slightly reduce the tempo. Then I exported them as WAVs. So as long as the original AC3 file's .1 channel was only in low frequencies, I'm pretty sure my third WAV file should be the same.

Jenyok:
Is that for AviSynth? I've never used AviSynth before, though I'm willing to teach myself how if that's the right tool for this job.

ikantspelwurdz
13th April 2013, 23:57
I think I figured out how to do what I want to do.

Load Audacity
Edit->Preferences->Import/Export->Export->Use custom mix
Import three WAV files
Export as WAV (Microsoft) signed 16 bit PCM
Set output channels to FOUR
L->Channel 1
R->Channel 2
R->Channel 3
LFE->Channel 4

Doing this generates a 3F/LFE WAV file, which is basically what I want. Filesize is huge, but it's going on a Blu-Ray.

tebasuna51
14th April 2013, 09:31
tebasuna51:
These were ripped from a DVD, originally in 2.1 AC3 format.

Sorry, when you say bassline I was thinking you have audio from midi instruments (drums, etc.)

...
Import three WAV files
Export as WAV (Microsoft) signed 16 bit PCM
Set output channels to FOUR
L->Channel 1
R->Channel 2
R->Channel 3
LFE->Channel 4

If you have 3 wav for what you select 4 channels?
Is enough 3 channels L, R and LFE, 2.1 like original.

ikantspelwurdz
14th April 2013, 15:22
Sorry, when you say bassline I was thinking you have audio from midi instruments (drums, etc.)
My mistake. I should have called it LFE.

If you have 3 wav for what you select 4 channels?
Is enough 3 channels L, R and LFE, 2.1 like original.
I tried that previously. If I select 3 channels, it comes out as 3F, not 2F/LFE. My left and center speaker play stereo, my right speaker plays the LFE, and my sub does nothing.

And it gets worse. When I use Tsmuxer to make the Blu-Ray with my 3F/LFE WAV, the output TS thinks the audio is 4.0.

So now I've tried re-encoding as a SIX channel WAV.

L.wav->Channel 1
R.wav->Channel 2
R.wav->Channel 3
LFE.wav->Channel 4
Nothing->Channel 5
Nothing->Channel 6

This produces the desired result. The final TS treats the audio as 5.1 surround, but the 3F's all fire the same mono track, the 2R's are silent, and the LFE is correct.

But now I'm having syncing issues. What's strange is that if I use Avidemux to mix the 6-channel WAV with an MKV, the output MKV syncs fine. But if I use Tsmuxer to turn that very same MKV into a TS, the TS desyncs.

tebasuna51
14th April 2013, 21:44
If I select 3 channels, it comes out as 3F, not 2F/LFE.

When you select WAV output in Audacity, make a wav file with a simple header without info about the channels present.

We need a header WAVE_FORMAT_EXTENSIBLE
You can convert you 3 channels wav file with simple header to a true 2.1 wav file with:

WavFix 3chan.wav 2.1.wav -m 11

After that any smart soft (tsMuxeR included) must recognize the wav like 2F/LFE

Edit: if wav file is > 4GB
you need add the parameter -ignorelength
and to be read by tsMuxeR must be W64 instead WAV

WavFix 3chan.wav 2.1.w64 -ignorelength -o 3 -m 11


WavFix.exe (https://forum.doom9.org/showthread.php?p=1724856#post1724856) included here (https://forum.doom9.org/showthread.php?p=424067#post424067) (new version 2016-08-01)
[EDIT]Also WavSplit.exe (https://forum.doom9.org/showthread.php?p=1520399#post1520399) included

ikantspelwurdz
16th April 2013, 04:03
Thanks for that. The output says "Stereo/LFE" as expected. I will attempt to Tsmux it with the video tomorrow.

Do you know if it's possible to have a 1.1 WAV file, and if so, if that can be Blu-Ray compliant? I'm still assuming no, since nobody has said otherwise, but the question's still open.

tebasuna51
16th April 2013, 14:06
I don't know if is BluRay compliant, but the wav file 1.1 can be obtained using a MaskChannel of 12:

WavFix 2chan.wav 1.1.wav -m 12

The default channels mask (-m 0) are:

Mask Chan. MS channels Description
---- ----- ------------------------- ----------------
4 1 FC Mono 1.0
3 2 FL FR Stereo 2.0
7 3 FL FR FC Stereo + Center 3.0
51 4 FL FR BL BR Quadro 4.0 (2/2.0)
55 5 FL FR FC BL BR like Dpl II 5.0 (3/2.0)
63 6 FL FR FC LF BL BR Old Surround 5.1 (3/2.1)
319 7 FL FR FC LF BL BR BC With back center 6.1 (3/2/1.1)
1599 8 FL FR FC LF BL BR SL SR Standard surround 7.1 (3/2/2.1)

Some other common channels mask (-m Mask):

Mask Chan. MS channels Description
---- ----- ------------------------- ----------------
12 2 FC LF Center + LFE (1.1)
11 3 FL FR LF Stereo + LFE (2.1)
259 3 FL FR BC First Surround (2/1.0)
267 4 FL FR LF BC First Surround + LFE (2/1.1)
1539 4 FL FR SL SR Alternative Quadro 4.0 (2/2.0)
15 4 FL FR FC LF Stereo + Center + LFE 3.1
263 4 FL FR FC BC like Dpl I (3/1.0)
271 5 FL FR FC BC LF like Dpl I + LFE (3/1.1)
59 5 FL FR BL BR LF Quadro + LFE (2/2.1)
1543 5 FL FR FC SL SR Alternative like Dpl II 5.0 (3/2.0)
1551 6 FL FR FC LF SL SR New surround 5.1 (3/2.1)
1807 7 FL FR FC LF BC SL SR Alternative surround 6.1 (3/2/1.1)
1591 7 FL FR FC BL BR SL SR Standard surround 7.0 (3/2/2.0)
255 8 FL FR FC LF BL BR FLC FRC With front center left/right (5/2.1)

real.finder
1st August 2016, 11:11
When you select WAV output in Audacity, make a wav file with a simple header without info about the channels present.

We need a header WAVE_FORMAT_EXTENSIBLE
You can convert you 3 channels wav file with simple header to a true 2.1 wav file with:

WavFix 3chan.wav 2.1.wav -m 11

After that any smart soft (tsMuxeR included) must recognize the wav like 2F/LFE

Edit: if wav file is > 4GB
you need add the parameter -ignorelength
and to be read by tsMuxeR must be W64 instead WAV

WavFix 3chan.wav 2.1.w64 -ignorelength -o 3 -m 11


WavFix included in the attached file

I have multi channel wav with Front: L C R, Back: L R, LFE

but the real mask is Front: L C R, Side: L R, LFE

so I try to edit the .wav with


wavfix "old.wav" "new.wav" -ignorelength -m 1551


but the new.wav still Front: L C R, Back: L R, LFE :confused:

tebasuna51
1st August 2016, 19:51
I have multi channel wav with Front: L C R, Back: L R, LFE

but the real mask is Front: L C R, Side: L R, LFE
Are you sure than the real mask include Side channels?

If the wav was obtained decoding AC3/DTS 5.1 the surround channels (120º) are more near of Back (130º) channels than to the Side (100º) channels.

BTW both channelmask are valid for standard 5.1 configuration.

but the new.wav still Front: L C R, Back: L R, LFE

Yep, is a bug, when wavfix read a channelmask in wav input ignore the passed like parameter with -m.
Only work when input wav file don't have channelmask (simple header).
I must do a new version.

By the moment you can use:
eac3to "old.wav" "new.wav"
than change the Back to Side if you really need it.

real.finder
1st August 2016, 19:57
Are you sure than the real mask include Side channels?

If the wav was obtained decoding AC3/DTS 5.1 the surround channels (120º) are more near of Back (130º) channels than to the Side (100º) channels.

BTW both channelmask are valid for standard 5.1 configuration.



Yep, is a bug, when wavfix read a channelmask in wav input ignore the passed like parameter with -m.
Only work when input wav file don't have channelmask.
I must do a new version.

By the moment you can use:
eac3to "old.wav" "new.wav"
than change the Back to Side if you really need it.

yes, but the sox make it Front: L C R, Back: L R, LFE

Looking forward to the new version :thanks:

tebasuna51
1st August 2016, 21:44
yes, but the sox make it Front: L C R, Back: L R, LFE

Is correct for me, for what you need L C R, Side: L R, LFE?

real.finder
1st August 2016, 22:11
Is correct for me, for what you need L C R, Side: L R, LFE?

the original DTS like that

tebasuna51
1st August 2016, 22:42
the original DTS like that

Nope, a standard DTS 5.1 have the layout M (see the image), with channels: L C R, Ls, Rs, LFE

The exact channel correspondence can be see in 7.1 layout A:

L = FL
C = FC
R = FR
Lss = SL (Side Left)
Rss = SR (Side Right)
Lsr = BL (Back Left)
Rsr = BR (Back Right)
LFE = LF

The DTS channels Ls (Left Surround) and Rs (Right Surround) don't have a exact correspondence with WAV channels. Are between Side and Back channels, maybe near Back.
Then both channelmask must be accepted.

BTW I put a new WavFix version in precedent post.

real.finder
1st August 2016, 23:03
Nope, a standard DTS 5.1 have the layout M (see the image), with channels: L C R, Ls, Rs, LFE

The exact channel correspondence can be see in 7.1 layout A:

L = FL
C = FC
R = FR
Lss = SL (Side Left)
Rss = SR (Side Right)
Lsr = BL (Back Left)
Rsr = BR (Back Right)
LFE = LF

The DTS channels Ls (Left Surround) and Rs (Right Surround) don't have a exact correspondence with WAV channels. Are between Side and Back channels, maybe near Back.
Then both channelmask must be accepted.

BTW I put a new WavFix version in precedent post.

I just see what the mediainfo said (I know it's not always correct)

and thank you for WavFix new version

raffriff42
2nd August 2016, 21:22
I don't want to re-encode any of the audio - I want the three WAV files to be discrete channels in a PCM 2.1 sound track.

How can I go about doing this?It can be done with ffmpeg if you want; the command line below combines the channels, but re-encoding is required due to the amerge (https://ffmpeg.org/ffmpeg-all.html#amerge-1) filter. (note that PCM-to-PCM reencoding is both lossless and extremely fast)ffmpeg
-i "FL.wav" -i "FR.wav" -i "LFE.wav"
-filter_complex "[0:0][1:0][2:0] amerge=inputs=3"
-channel_layout "2.1"
-vn -c:a pcm_s16le
"out.wav"(line breaks added for clarity)

EDIT I don't know if this should be called "re-encoding" or not: the audio samples are being merged into a single stream without changing the samples themselves. The only reason for the above caveat is that ffmpeg disallows the -codec copy option when filtering, so one could argue that (trivial) re-encoding is being done.