Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
#1 | Link |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
Audio up/downmix with SoX
Background: I wanted to add the possibility to up-/downmix the audio to sx264/Hybrid decoding with ffmpeg, piping the output to sox and then pipe it to ffmpeg or neroaacenc for encoding, problem is I found no documentation how to:
a. do a up/downmix with sox b. do it in general, like what channels need to be mixed how Anyone got infos on how to use SoX to do up- and downmixes and how up-/downmixes are done? Cu Selur |
|
|
|
|
|
#2 | Link |
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,374
|
This Dolby ProLogic II downmix:
fl' = 0.3254xFL + 0.2301xC + 0.2818xSL + 0.1627xSR fr' = 0.3254xFR + 0.2301xC - 0.1627xSL - 0.2818xSR Can be implemented with SoX (and normalized) like: sox 6w321.wav 2dpl.wav remix -m 1v0.3254,3v0.2301,5v0.2818,6v0.1627 2v0.3254,3v0.2301,5v-0.1627,6v-0.2818 norm Of course you can use other coeficients for dpl I or simple stereo or add LFE to mix. A correct upmix is more difficult to implement, in BeHappy there are some upmix functions using sox filter (thanks to NorthPole): http://forum.doom9.org/showthread.ph...216#post787216 |
|
|
|
|
|
#4 | Link | |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
Just tried to convert a 5.1 ac3 audio file to mp3 using:
Quote:
|
|
|
|
|
|
|
#7 | Link | |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
Is there's some explanation somewhere how to get from http://en.wikipedia.org/wiki/Dolby_P...oding_matrices to:
Quote:
Cu Selur Ps.: damn, must have changed something with the calls, since I can't get the pipe working anymore ![]() got it, the '-y' is needed ![]() Code:
ffmpeg -y -i "AC3-5.1.ac3" -ac 6 -ar 48000 -acodec pcm_s16le -f wav - | sox -s -b 16 -c 6 -r 48000 -t raw - -t wav - remix -m 1v0.3254,3v0.2301,5v0.2818,6v0.1627 2v0.3254,3v0.2301,5v-0.1627,6v-0.2818 norm | ffmpeg -v -1 -threads 4 -y -i - -ab 128000 -ac 2 -ar 48000 "test.mp3" Last edited by Selur; 12th January 2010 at 16:49. |
|
|
|
|
|
|
#8 | Link |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
Based on http://forum.doom9.org/showthread.ph...92#post1134992 and the infos posted in this thread I tried to convert the infos from the other post:
Code:
function Dmix5Dpl2(clip a) # 5 Channels FL,LR,C,SL,SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
// 0.3254*FL+0.2301*C 0.3254*FR+0.2301*C
bl = GetChannel(a, 4)
br = GetChannel(a, 5)
sl = MixAudio(bl, br, 0.2818, 0.1627)
// 0.2818*SL 0.1627*SR
sr = MixAudio(bl, br, -0.1627, -0.2818)
// -0.1627*SL -0.2818*SR
blr = MergeChannels(sl, sr)
//0.2818*SL+0.1627*SR -0.1627*SL-0.2818*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//fl' = 0.3254*FL+0.2301*C+0.2818*SL+0.1627*SR
//fr' = 0.3254*FR+0.2301*C-0.1627*SL-0.2818*SR
}
Code:
1v0.3254,3v0.2301,4v0.2818,5v0.1627 2v0.3254,3v0.2301,4v-0.1627,5v-0.2818 Code:
function Dmix6Dpl2Lfe(clip a) # 6 Channels FL,LR,C,SL,SR,SUB
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.2646, 0.1870)
// 0.2646*FL+0.1870*C 0.2646FR+0.1870*C
lfe = GetChannel(a, 4, 4)
lrc = MixAudio(lrc, lfe, 1.0, 0.1870)
// 0.2646*FL+0.1870*C+SL 0.2646*FR+0.1870*C+SL
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.2291, 0.1323)
// 0.2291*SR 0.1323*SUB
sr = MixAudio(bl, br, -0.1323, -0.2291)
// -0.1323*SR -0.2291*SUB
blr = MergeChannels(sl, sr)
// 0.2291*SR+0.1323*SUB -0.1323*SR-0.2291*SUB
return MixAudio(lrc, blr, 1.0, 1.0)
//fl' = 0.2646*FL+0.1870*C+SL+0.2291*SR+0.1323*SUB
//fr' = 0.2646*FR+0.1870*C+SL-0.1323*SR-0.2291*SUB
}
Code:
1v0.2646,3v0.1870,4,5v0.2291,6v0.1323 1v0.2646,3v0.1870,4,5v-0.1323,6v-0.2291 ![]() (Especially the part that Dmix6Dpl2Lfe->SoX contains in both channel more Infos from SL than from SR let's me suspect that I got something wrong.) Cu Selur |
|
|
|
|
|
#9 | Link | ||
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,374
|
Quote:
Quote:
1) The correct channel order is FL,LR,C,SUB,SL,SR 2) You forget the 0.1870 when mix the SL (SUB) Then must be: fl' = 0.2646*FL +0.1870*C +0.1870*SUB +0.2291*SL +0.1323*SR fr' = 0.2646*FR +0.1870*C +0.1870*SUB -0.1323*SL -0.2291*SR And 1v0.2646,3v0.1870,4v0.1870,5v0.2291,6v0.1323 2v0.2646,3v0.1870,4v0.1870,5v-0.1323,6v-0.2291 Edit: Problems when use LFE (SUB) in the mix: - Not recommended by Dolby because the mix can produce artifacts. - The dpl decoder send the LFE content to Center channel (common part in FL-FR). The receiver must filter the low frequencies to subwoofer (the Center speaker can't be defined as "large") Last edited by tebasuna51; 13th January 2010 at 02:27. Reason: LFE edit |
||
|
|
|
|
|
#10 | Link |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
Thanks for the help!
![]() Code:
function Dmix6Dpl2Lfe(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.2646, 0.1870)
// 0.2646*FL+0.1870*C 0.2646FR+0.1870*C
lfe = GetChannel(a, 4, 4)
lrc = MixAudio(lrc, lfe, 1.0, 0.1870)
// 0.2646*FL+0.1870*C+SUB*0.1870 0.2646*FR+0.1870*C+SUB*0.1870
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.2291, 0.1323)
// 0.2291*SL 0.1323*SR
sr = MixAudio(bl, br, -0.1323, -0.2291)
// -0.1323*SL -0.2291*SR
blr = MergeChannels(sl, sr)
// 0.2291*SL+0.1323*SR -0.1323*SL-0.2291*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//fl' = 0.2646*FL+0.1870*C+SUB*0.1870+0.2291*SL+0.1323*SR
//fr' = 0.2646*FR+0.1870*C+SUB*0.1870-0.1323*SL-0.2291*SR
}
Code:
1v0.2646,3v0.1870,4v0.1870,5v0.2991,6v0.1323 2v0.2646,3v0.1870,4v0.1870,5v-0.1323,6v-0.2291 Code:
Problems when use LFE (SUB) in the mix ![]() Cu Selur Last edited by Selur; 13th January 2010 at 09:20. |
|
|
|
|
|
#11 | Link |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
For those interested, here's the full list with SoX remix calls:
Code:
function Dmix3Stereo(clip a) # 3 Channels L,R,C or L,R,S
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
return MixAudio(flr, fcc, 0.5858, 0.4142)
//0.5858*FL+0.4142*C 0.5858*FR+0.4142*C
}
SoX: 1v0.5858,3v0.4142 2v0.5858,3v0.4142
function Dmix3Dpl(clip a) # 3 Channels only L,R,S
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = Amplify(sl, -1.0)
blr = MergeChannels(sl, sr)
//S S*-1.0
return MixAudio(flr, blr, 0.5858, 0.4142)
//FL*0.5858+S FR*0.4142+S*-1.0
}
SoX: 1v0.5858,3 2v0.4142,3v-1.0
function Dmix4qStereo(clip a) # 4 Channels Quadro L,R,SL,SR
{
flr = GetChannel(a, 1, 2)
blr = GetChannel(a, 3, 4)
return MixAudio(flr, blr, 0.5, 0.5)
//FL*0.5+SL*0.5 FR*0.5+SR*0.5
}
SoX: 1v0.5,3v0.5 2v0.5,3v0.5
function Dmix4qDpl(clip a) # 4 Channels Quadro L,R,SL,SR
{
flr = GetChannel(a, 1, 2)
bl = GetChannel(a, 3)
br = GetChannel(a, 4)
sl = MixAudio(bl, br, 0.2929, 0.2929)
//0.2929*SR 0.2929*SL
sr = MixAudio(bl, br, -0.2929, -0.2929)
//-0.2929*SR -0.2929*SL
blr = MergeChannels(sl, sr)
//0.2929*SR-0.2929*SR 0.2929*SL-0.2929*SL <- Kann das Sinn machen?
return MixAudio(flr, blr, 0.4142, 1.0)
//0.4142*FL+0.2929*SR-0.2929*SR 0.4142*FR+0.2929*SL-0.2929*SL
}
SoX: 1v0.4142,4v0.2929,4v-0.292 2v0.4142,3v0.2929,3v-0.292
function Dmix4qDpl2(clip a) # 4 Channels Quadro L,R,SL,SR
{
flr = GetChannel(a, 1, 2)
bl = GetChannel(a, 3)
br = GetChannel(a, 4)
sl = MixAudio(bl, br, 0.3714, 0.2144)
//0.3714*SL 0.2144*SR
sr = MixAudio(bl, br, -0.2144, -0.3714)
//-0.2144*SL -0.3714*SR
blr = MergeChannels(sl, sr)
//0.3714*SL-0.2144*SL 0.2144*SR-0.3714*SR
return MixAudio(flr, blr, 0.4142, 1.0)
//0.3712*FL+0.3714*SL-0.2144*SL FR+0.2144*SR-0.3714*SR
}
SoX: 1v0.4142,3v03714,3v-0.2144 2,3v0.2144,3v-0.3714
function Dmix4sStereo(clip a) # 4 Channels L,R,C,S
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.4142, 0.2929)
//0.4142*FL+0.2929*C 0.4142*FR+0.2929*C
blr = GetChannel(a, 4, 4)
return MixAudio(lrc, blr, 1.0, 0.2929) //<- instead of MixAudio(flr, blr, 1.0, 0.2929)
//0.4142*FL+0.2929*C+0.2929*SUB 0.4142*FR+0.2929*C+0.2929*SUB
}
SoX: 1v0.4142,3v0.2929,4v02929 2v0.4142,3v0.2929,4v02929
function Dmix4sDpl(clip a) # 4 Channels L,R,C,S
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.4142, 0.2929)
//0.4142*FL+0.2929*C 0.4142*FR+0.2929*C
sl = GetChannel(a, 4)
sr = Amplify(sl, -1.0)
blr = MergeChannels(sl, sr)
//SUB -1,0*SUB
return MixAudio(flr, blr, 1.0, 0.2929)
//0.4142*FL+0.2929*C+SUB 0.4142*FR+0.2929*C-1.0*SUB
}
SoX: 1v0.4142,3v0.2929,4 2v0.4142,3v0.2929,4v-1.0
function Dmix5Stereo(clip a) # 5 Channels L,R,C,SL,SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
//0.3694*FL+0.2612*C 0.3694*FR+0.2612*C
blr = GetChannel(a, 4, 5)
return MixAudio(lrc, blr, 1.0, 0.3694)
//0.3694*FL+0.2612*C+0.3694*SL 0.3694*FR+0.2612*C+0.3694*SR
}
SoX: 1v0.3694,3v0.2612,4v0.3694 2v0.3694,3v0.2612,5v0.3694
function Dmix5Dpl(clip a) # 5 Channels L,R,C,SL,SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3205, 0.2265)
//0.3205*FL+0.2265*C 0.3205*FR+0.2265*C
bl = GetChannel(a, 4)
br = GetChannel(a, 5)
sl = MixAudio(bl, br, 0.2265, 0.2265)
//0.2265*SL 0.2265*SR
sr = MixAudio(bl, br, -0.2265, -0.2265)
//-0.2265*SL -0.2265*SR
blr = MergeChannels(sl, sr)
//0.2265*SL-0.2265*SL 0.2265*SR-0.2265*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//0.3205*FL+0.2265*C+0.2265*SL-0.2265*SL 0.3205*FR+0.2265*C+0.2265*SR-0.2265*SR
}
SoX: 1v0.3205,3v0.2265,4v0.2265,4v-0.2265 2v0.3205,3v0.2265,5v0.2265,5v-0.2265
function Dmix5Dpl2(clip a) # 5 Channels FL,LR,C,SL,SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
// 0.3254*FL+0.2301*C 0.3254*FR+0.2301*C
bl = GetChannel(a, 4)
br = GetChannel(a, 5)
sl = MixAudio(bl, br, 0.2818, 0.1627)
// 0.2818*SL 0.1627*SR
sr = MixAudio(bl, br, -0.1627, -0.2818)
// -0.1627*SL -0.2818*SR
blr = MergeChannels(sl, sr)
//0.2818*SL+0.1627*SR -0.1627*SL-0.2818*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//fl' = 0.3254*FL+0.2301*C+0.2818*SL+0.1627*SR
//fr' = 0.3254*FR+0.2301*C-0.1627*SL-0.2818*SR
}
SoX: 1v0.3254,3v0.2301,4v0.2818,5v0.1627 2v0.3254,3v0.2301,4v-0.1627,5v-0.2818
function Dmix6Stereo(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
//0.3694*FL+0.2612*C 0.3694*FR+0.2612*C
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.3694)
//0.3694*FL+0.2612*C+0.3694*SL 0.3694*FR+0.2612*C+0.3694*SR
}
SoX: 1v0.3694+3v0.2612+4v0.3694 2v0.3694+3v0.2612+5v0.3694
function Dmix6Dpl(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3205, 0.2265)
//0.3205*FL+0.2265*C 0.3205*FR+0.2265*C
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.2265, 0.2265)
//0.2265*SL 0.2265*SR
sr = MixAudio(bl, br, -0.2265, -0.2265)
//-0.2265*SL -0.2265*SR
blr = MergeChannels(sl, sr)
//0.2265*SL-0.2265*SL 0.2265*SR-0.2265*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//0.3205*FL+0.2265*C+0.2265*SL-0.2265*SL 0.3205*FR+0.2265*C+0.2265*SR-0.2265*SR
}
SoX: 1v0.3205,3v0.2265+4v0.2265-4v-0.2265 2v0.3205,3v0.2265+5v0.2265-5v-0.2265
function Dmix6Dpl2(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
//0.3254*FL+0.2301*C 0.3254*FR+0.2301*C
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.2818, 0.1627)
//0.2818*SL 1627*SR
sr = MixAudio(bl, br, -0.1627, -0.2818)
//-0.1627*SL -0.2818*SR
blr = MergeChannels(sl, sr)
//0.2818*SL-0.1627*SL 1627*SR-0.2818*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//0.3254*FL+0.2301*C+0.2818*SL-0.1627*SL 0.3254*FR+0.2301*C+1627*SR-0.2818*SR
}
SoX: 1v0.3254,3v0.2301,5v0.2818,5v-0.1627 2v0.3254,3v0.2301,6v0.2818,6v-0.1627
function Dmix6StereoLfe(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.2929, 0.2071)
//0.2929*FL+0.2071*C 0.2929*FR+0.2071*C
lfe = GetChannel(a, 4, 4)
lrc = MixAudio(lrc, lfe, 1.0, 0.2071)
//0.2929*FL+0.2071*C+0.2071*SUB 0.2929*FR+0.2071*C+0.2071*SUB
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.2929)
//0.2929*FL+0.2071*C+0.2071*SUB+0.2929*SL 0.2929*FR+0.2071*C+0.2071*SUB+0.2929*SR
}
SoX: 1v0.2929,3v0.2071,4v0.2071,5v0.2929 2v0.2929,3v0.2071,4v0.2071,6v0.2929
function Dmix6DplLfe(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.2613, 0.1847)
//0.2613*FL+0.1847*C 0.2613*FR+0.1847*C
lfe = GetChannel(a, 4, 4)
lrc = MixAudio(lrc, lfe, 1.0, 0.1847)
//0.2613*FL+0.1847*C+0.1847*SUB 0.2613*FR+0.1847*C+0.1847*SUB
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.1847, 0.1847)
//0.1847*SL 0.1847*SR
sr = MixAudio(bl, br, -0.1847, -0.1847)
//-0.1847*SL -0.1847*SR
blr = MergeChannels(sl, sr)
//0.1847*SL-0.1847*SL 0.1847*SR-0.1847*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//0.2613*FL+0.1847*C+0.1847*SUB+0.1847*SL-0.1847*SL 0.2613*FR+0.1847*C+0.1847*SUB+0.1847*SR-0.1847*SR
}
SoX: 1v0.2613,3v0.1847,4v0.1847,5v0.1847,5v-0.1847 2v0.2613,3v0.1847,4v0.1847,6v0.1847,6v-0.1847
function Dmix6Dpl2Lfe(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.2646, 0.1870)
// 0.2646*FL+0.1870*C 0.2646FR+0.1870*C
lfe = GetChannel(a, 4, 4)
lrc = MixAudio(lrc, lfe, 1.0, 0.1870)
// 0.2646*FL+0.1870*C+SUB*0.1870 0.2646*FR+0.1870*C+SUB*0.1870
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.2291, 0.1323)
// 0.2291*SL 0.1323*SR
sr = MixAudio(bl, br, -0.1323, -0.2291)
// -0.1323*SL -0.2291*SR
blr = MergeChannels(sl, sr)
// 0.2291*SL+0.1323*SR -0.1323*SL-0.2291*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//fl' = 0.2646*FL+0.1870*C+SUB*0.1870+0.2291*SL+0.1323*SR
//fr' = 0.2646*FR+0.1870*C+SUB*0.1870-0.1323*SL-0.2291*SR
}
SoX: 1v0.2646,3v0.1870,4v0.1870,5v0.2991,6v0.1323 2v0.2646,3v0.1870,4v0.1870,5v-0.1323,6v-0.2291
|
|
|
|
|
|
#13 | Link | |
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,374
|
Quote:
Code:
function Dmix6Stereo(clip a) # 6 Channels FL, FR, C, LFE, SL, SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
//0.3694*FL+0.2612*C 0.3694*FR+0.2612*C
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.3694)
//0.3694*FL+0.2612*C+0.3694*SL 0.3694*FR+0.2612*C+0.3694*SR
}
SoX: 1v0.3694+3v0.2612+4v0.3694 2v0.3694+3v0.2612+5v0.3694
|
|
|
|
|
|
|
#14 | Link |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
I'm a bit confused about all the dpl downmixes
, e.g. Code:
function Dmix5Dpl(clip a) # 5 Channels L,R,C,SL,SR
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3205, 0.2265)
//0.3205*FL+0.2265*C 0.3205*FR+0.2265*C
bl = GetChannel(a, 4)
br = GetChannel(a, 5)
sl = MixAudio(bl, br, 0.2265, 0.2265)
//0.2265*SL 0.2265*SR
sr = MixAudio(bl, br, -0.2265, -0.2265)
//-0.2265*SL -0.2265*SR
blr = MergeChannels(sl, sr)
//0.2265*SL-0.2265*SL 0.2265*SR-0.2265*SR
return MixAudio(lrc, blr, 1.0, 1.0)
//0.3205*FL+0.2265*C+0.2265*SL-0.2265*SL 0.3205*FR+0.2265*C+0.2265*SR-0.2265*SR
}
SoX: 1v0.3205,3v0.2265,4v0.2265,4v-0.2265 2v0.3205,3v0.2265,5v0.2265,5v-0.2265
I suspect I should have used another SoX open to represent the negative values or I just don't get what the mean. ![]() Cu Selur |
|
|
|
|
|
#15 | Link | |
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,374
|
Quote:
Code:
blr = MergeChannels(sl, sr) //0.2265*SL+0.2265*SR -0.2265*SL-0.2265*SR return MixAudio(lrc, blr, 1.0, 1.0) //0.3205*FL+0.2265*C+0.2265*SL+0.2265*SR 0.3205*FR+0.2265*C-0.2265*SL-0.2265*SR } SoX: 1v0.3205,3v0.2265,4v0.2265,5v0.2265 2v0.3205,3v0.2265,4v-0.2265,5v-0.2265 |
|
|
|
|
|
|
#16 | Link | ||
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
okay, that solves my confusion
Thanks again ! ![]() all the functions are ment to be symetric: Quote:
Quote:
Last edited by Selur; 14th January 2010 at 11:52. |
||
|
|
|
|
|
#17 | Link | ||
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,374
|
Quote:
Quote:
// 0.2291*SL+0.2291*SR, -0.1323*SR-0.1323*SL and this isn't a correct mix, isn't stereo, isn't dpl, isn't dpl II Remember: MixAudio take 2 audios (with 1 or more channels each one) and return only a mixed one audio. MergeChannels take 2 (or more) channels and return a multichannel audio without mix. Last edited by tebasuna51; 14th January 2010 at 13:19. |
||
|
|
|
|
|
#18 | Link | |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
DOH, I misunderstood the MixAudio
![]() Quote:
Code:
function Dmix3Stereo(clip a) # 3 Channels L,R,C or L,R,S
{
flr = GetChannel(a, 1, 2)
//FL FR (2 channel)
fcc = GetChannel(a, 3, 3)
//C C (2 channel)
return MixAudio(flr, fcc, 0.5858, 0.4142)
//0.5858*FL+0.4142*C 0.5858*FR+0.4142*C
}
Last edited by Selur; 14th January 2010 at 13:23. |
|
|
|
|
|
|
#19 | Link |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
So is this right:
Code:
function Dmix5Dpl(clip a) # 5 Channels L,R,C,SL,SR
{
flr = GetChannel(a, 1, 2) //FL FR (2 channel)
fcc = GetChannel(a, 3, 3) //C C(2 channel)
lrc = MixAudio(flr, fcc, 0.3205, 0.2265) //0.3205*FL+0.2265*C 0.3205*FR+0.2265*C
bl = GetChannel(a, 4) //SL (1 channel)
br = GetChannel(a, 5) //SR (1 channel)
sl = MixAudio(bl, br, 0.2265, 0.2265) //0.2265*SL+0.2265*SR (1 channel)
sr = MixAudio(bl, br, -0.2265, -0.2265) //-0.2265*SL-0.2265*SR (1 channel)
blr = MergeChannels(sl, sr) //0.2265*SL+0.2265*SR -0.2265*SL-0.2265*SR (2 channel)
return MixAudio(lrc, blr, 1.0, 1.0) //0.3205*FL+0.2265*C+0.2265*SL+0.2265*SR 0.3205*FR+0.2265*C-0.2265*SL-0.2265*SR (2 channel)
}
Last edited by Selur; 14th January 2010 at 15:02. |
|
|
|
|
|
#20 | Link |
|
.
![]() Join Date: Oct 2001
Location: Germany
Posts: 7,875
|
Finally found the time and motivation to try to convert one of NorthPole's BeHappy UpMix functions to sox.
Function to be converted: Code:
<Option>
<Name>Audio with a mix of sounds (ie. Action, Adventure)</Name>
<Value>
# Profile to use with audio sources that have a wider range of sound content. 20ms delay and -3db attenuation on surround
# Note: General purpose profile
front_{2} = stereo_{2}.soxfilter("filter 20-20000")
back_{2} = stereo_{2}.soxfilter("filter 100-7000")
fl_{2} = mixaudio(front_{2}.GetLeftChannel(),front_{2}.GetRightChannel(),0.668,-0.668)
fr_{2} = mixaudio(front_{2}.GetRightChannel(),front_{2}.GetLeftChannel(),0.668,-0.668)
cc_{2} = mixaudio(mixaudio(front_{2}.GetLeftChannel(),fl_{2},1,-1),mixaudio(front_{2}.GetRightChannel(),fr_{2},1,-1),0.398,0.398)
lfe_{2} = ConvertToMono(stereo_{2}).SoxFilter("lowpass 120","vol -0.447")
sl_{2} = mixaudio(back_{2}.GetLeftChannel(),back_{2}.GetRightChannel(),0.473,-0.473)
sr_{2} = mixaudio(back_{2}.GetRightChannel(),back_{2}.GetLeftChannel(),0.473,-0.473)
sl_{2} = DelayAudio(sl_{2},0.02)
sr_{2} = DelayAudio(sr_{2},0.02)
</Value>
</Option>
<Option>
Code:
#input to wav
mplayer -ao pcm input.mp3 -ao pcm:file="dump.wav"
#resample to 48kHz and lower volume to avaid clipping
sox -S -V -c 2 dump.wav -r 48k stereoInput.wav gain -h
#front = stereo.soxfilter("filter 20-20000")
sox -S -V -c 2 stereoInput.wav front.wav sinc 20-20000
sox -S -V -c 2 front.wav -c 1 frontL.wav mixer -l
sox -S -V -c 2 front.wav -c 1 frontR.wav mixer -r
#fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.794,-0.794)
sox -S -V -c 2 front.wav front_left.wav remix -m 1v0.794,2v-0.794
#fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.794,-0.794)
sox -S -V -c 2 front.wav front_right.wav remix -m 2v0.794,1v-0.794
#rear = stereo.soxfilter("filter 100-7000")
sox -S -V -c 2 stereoInput.wav rear.wav sinc 100-7000
#sl = mixaudio(rear.GetLeftChannel(),rear.GetRightChannel(),0.562,-0.562)
#sl = DelayAudio(sl,0.02)
sox -S -V -c 2 rear.wav rear_left.wav remix -m 1v0.562,2v-0.562 delay 0.02
#sr = mixaudio(rear.GetRightChannel(),rear.GetLeftChannel(),0.562,-0.562)
#sr = DelayAudio(sr,0.02)
sox -S -V -c 2 rear.wav rear_right.wav remix -m 1v0.562,2v-0.562 delay 0.02
#cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.224,0.224)
# = mixaudio(cc_l, cc_r, 0.224,0.224)
#cc_l(1) = mixaudio(front.GetLeftChannel(),fl,1,-1)
#cc_r(1) = mixaudio(front.GetRightChannel(),fr,1,-1)
sox -S -V -M frontL.wav front_left.wav centerL.wav remix -m 1v0.224,2v-0.224
sox -S -V -M frontR.wav front_right.wav centerR.wav remix -m 1v0.224,2v-0.224
sox -S -V -m centerL.wav centerR.wav center.wav
#lfe = ConvertToMono(stereo).SoxFilter("lowpass 120","vol -0.596")
sox -S -V -v -0.596 stereoInput.wav -c 1 lfe.wav lowpass 120 remix -
#merge channels
sox -S -V -M front_left.wav front_right.wav rear_left.wav rear_right.wav center.wav lfe.wav multichannel.wav
#normalize + making sure it's 16bit
sox -S -V -G multichannel.wav -b 16 normalize.wav
#convert
neroAacEnc -if normalize.wav -br 196k -ignorelength -of "test.mp4"
)Cu Selur Last edited by Selur; 24th March 2010 at 09:44. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|