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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st December 2023, 17:11   #1  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,308
SoxFilter 2

Latest:
SoxFilter 2.2 for AviSynth - 20240104
https://github.com/pinterf/SoxFilter/releases

----

SoxFilter 2.0 for AviSynth.
Based on Sox audio library 14.4.2.
Requres Avisynth+ 3.7.3

Download:
https://github.com/pinterf/SoxFilter/releases/tag/v2.0

Previous discussion:
https://forum.doom9.org/showthread.php?t=104792&page=3

Treat it as a beta, you are the real testers. Spent some weeks on the project this year, got tired of it.

Some effects has been changed, merged with others or removed from the Sox core library since the 1.1 release; do not erase your old dll's yet.

Last edited by pinterf; 3rd January 2024 at 19:52. Reason: subversion independent thread name
pinterf is offline   Reply With Quote
Old 1st December 2023, 19:00   #2  |  Link
Thundik81
Registered User
 
Join Date: Jul 2004
Posts: 22
Thanks!
Thundik81 is offline   Reply With Quote
Old 2nd December 2023, 12:51   #3  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,860
Thanks, I'll test it.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 2nd December 2023, 12:59   #4  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,127
Thanks (R.D don't online so long so I won't get complain )
kedautinh12 is offline   Reply With Quote
Old 2nd December 2023, 15:42   #5  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,860
Tested the downmix 7.1->5.1 (than can be applied in MEGUI):
Quote:
# As AudioLimiter.dll is not available, SoftClipperFromAudX() cannot be used
# 7.1 Channels L,R,C,LFE,BL,BR,SL,SR -> standard 5.1
function c71_c51(clip a)
{
front = GetChannel(a, 1, 2, 3, 4)
back = GetChannel(a, 5, 6)
side = GetChannel(a, 7, 8)
# mix = MixAudio(back, side, 0.5, 0.5)#.SoftClipperFromAudX(0.0)
mix = MixAudio(back, side, 0.5, 0.5).SoxFilter("compand 0.0,0.0 -90,-84,-8,-2,-6,-1,-0,-0.1")
return MergeChannels(front, mix)
}
With the same output than ffmpeg here
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 2nd December 2023, 22:49   #6  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,308
Thanks for trying it out.

I'm just testing the behavior of effects which change the channel count and/or the sample rate, so far so good. 2.1 will get this feature, 2.0 is giving an error message intentionally.

This works in my test for example

Code:
ColorBars().Trim(0,30*60*1) # ~1 min Stereo 48000Hz
SoxFilter("rate 2400", "remix -") # resample to 2400 Hz and convert to mono
pinterf is offline   Reply With Quote
Old 3rd December 2023, 02:03   #7  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,836
Thank you so much for this!
I look forward to try version 2.1 on the various upmix functions! (UpSoundOnSound() etc).
On Monday I'll try version 2.0 at work and I'll report back, but thank you for picking this one up, it feels like yesterday but it's been a long time since the last release as we have to go all the way back to 2006!
Back then I had just started fansubbing in Italy, I was still studying at school and my main worry at the time was going to the beach on summer and hanging around in winter.
Man, those were the days... Little did I know things were gonna get harder growing up from there...

Anyway, enough for the depressing thing, this is a very nice present under the Christmas tree!



Oh, I almost forgot: if anyone wants to try this on XP, don't, it's not compiled targeting it so it lacks the function GetLocaleInfoEx and won't work when it makes a kernel call ('cause it doesn't exist in kernel32).

Last edited by FranceBB; 3rd December 2023 at 02:07.
FranceBB is offline   Reply With Quote
Old 3rd December 2023, 11:45   #8  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 592
Thank you very much for this.

I was wondering though if this issue got fixed:

Quote:
Originally Posted by tebasuna51 View Post
I make some test and I can confirm the bug detected by Jenyok here:
http://forum.doom9.org/showthread.ph...20#post1622520

Using:
back = soxfilter(a, "filter 100-7000")

There are buggy samples, when reach 0dB invert the sign, than can produce crackling. Then I can't recommend the use of this plugin without low the volume of the source before.


I am interested in using it as a compressor like this:

Quote:
Originally Posted by flossy_cake View Post
for those cases where dialogue is quiet and explosions are very loud....

Code:
SoxFilter("compand 0.3,1.0 6:-90,-90,-70,-70,-60,-20,0,0")

# attack time: 0.3 seconds
# decay time: 1.0 seconds
# soft-knee amount for smoothing between curve points: 6db
# curve point 1: set -90db to -90db (no change)
# curve point 2: set -70db to -70db (no change)
# curve point 3: set -60db to -20db (40db gain)
# curve point 4: set 0db to 0db (no change)
Resulting curve looks something like this but with 6db of soft knee smoothing between each linear segment


The result sounds crackly but then I tried changing the final curve point to 0,-5 and it sounds better but maybe still a bit crackly, not sure.

If I seek too much the audio then gets really crackly, but then I can seek again and it resolves itself. Does it still require linear access?

flossy_cake is offline   Reply With Quote
Old 3rd December 2023, 12:02   #9  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 592
I think the -5db trick might be solving the crackling issue mentioned by tebasuna51.

And I lowered the attack/decay for less "pumping" effect, and made the curve less steep:

Code:
SoxFilter("compand 0.01,0.1 6:-90,-90,-70,-70,-50,-30,0,-5")
Seems to work fairly well, just need to avoid seeking as that can cause it to crackle. Tried Preroll(30) without effect.

So I guess my only request would be to make it more compatible with seeking, but that's probably not of interest to most users.
flossy_cake is offline   Reply With Quote
Old 3rd December 2023, 12:18   #10  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 592
Quote:
Originally Posted by tebasuna51 View Post
SoxFilter("compand 0.0,0.0 -90,-84,-8,-2,-6,-1,-0,-0.1")
May I ask how you came up with this curve? Is it some standard curve used by Dolby or something? It sounds quite good to me. But I see you didn't specify a soft knee -- does that mean it uses linear segments or does it default to something?
flossy_cake is offline   Reply With Quote
Old 3rd December 2023, 16:37   #11  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,308
Version 2.1
https://github.com/pinterf/SoxFilter/releases/tag/v2.1
Code:
- Allow effects which can alter sampling rate
- Allow effects which can change the number of channels
- Add XP build (v141_xp toolset)
pinterf is offline   Reply With Quote
Old 3rd December 2023, 16:47   #12  |  Link
richardpl
Registered User
 
Join Date: Jan 2012
Posts: 269
Is this still using same internal processing sample format that sox is using?
richardpl is offline   Reply With Quote
Old 3rd December 2023, 19:49   #13  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,836
Thank you Ferenc!
I tested version 2.1, but when I call

Quote:
UpSoundOnSound()
it says:

SoxFilter: (filter) could not find any effect.

The function I'm trying to use is:

Quote:
function UpSoundOnSound(clip a)
{
# Sound On Sound Profile
# SOS approach Profile with 20ms delay and some attenuation on surround
back = a.soxfilter("filter 100-7000")
fl = a.GetLeftChannel()
fr = a.GetRightChannel()
cc = mixaudio(a.GetRightChannel(),a.GetLeftChannel,0.5,0.5)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
to go from stereo to 5.1.

Other upmix functions end up with the same results, for instance:

Quote:
UpDialog()
results in the same error message:

SoxFilter: (filter) could not find any effect.

Quote:
function UpDialog(clip a)
{
# Audio with mostly dialog (ie. Comedy, Drama)
# Profile to use with audio sources that have mostly mono content. 20ms delay and -3db attenuation on surround
# Note: the center channel is very weak for this profile
front = a.soxfilter("filter 20-20000")
back = a.soxfilter("filter 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.794,-0.794)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.794,-0.794)
cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.224,0.224)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.596")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.562,-0.562)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.562,-0.562)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
FranceBB is offline   Reply With Quote
Old 3rd December 2023, 20:03   #14  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,308
This is the day of the diligently read f** readme files

@FranceBB
"Also, some effects were removed, and others added in the past ~15 years. The parameters of some effects had been changed as well.
E.g. reverb parameters were modified in 2008; "filter" was removed, use "sinc" instead (with a different syntax).
"

@richardpl
"SoxFilter will convert the audio to 32 bit integer format, this is how libsox works internally. It calls "ConvertAudio" which is part of AviSynth+."
pinterf is offline   Reply With Quote
Old 3rd December 2023, 20:10   #15  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,308
I admit, this error message "SoxFilter: (filter) could not find any effect." is not something I would expect. I'm going to check, as far as I remember such an unknown effect name would return a proper error message. At least it returned in April , this UpSoundOnSound and "filter" issue was my first surprise (showing that things has been changed in two decades).

Last edited by pinterf; 3rd December 2023 at 20:23. Reason: typo
pinterf is offline   Reply With Quote
Old 4th December 2023, 03:17   #16  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,836
Of course it was, it's been 15 years, silly me! xD

Ok, so, second test, first I extracted the first two channel (stereo) out of a sample mxf and trimmed it to 1 minute only:

Quote:
video=BlankClip(length=74625, width=848, height=480, pixel_type="YV12", fps=25)
audio=LWLibavAudioSource("I:\temp\NAS\EART4ALL_FTR-2D-25_F_IT-IT_IT-G_51-IT_2K_20231108_OV\Audio.mxf")
AudioDub(video, audio)

Left=GetChannel(1)
Right=GetChannel(2)

MergeChannels(Left, Right)

trim(0, 1500)



then I upmixed using the original SoxFilter 1.0 and the SoundOnSound 5.1 upmixing function:

Quote:
video=BlankClip(length=1500, width=848, height=480, pixel_type="YV12", fps=25)
audio=LWLibavAudioSource("I:\temp\stereo.wav")
AudioDub(video, audio)

back = soxfilter("filter 100-7000")
fl = GetLeftChannel()
fr = GetRightChannel()
cc = mixaudio(GetRightChannel(),GetLeftChannel,0.5,0.5)
lfe = ConvertToMono().SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)

MergeChannels(fl, fr, cc, lfe, sl, sr)


Then I upgraded to SoxFilter 2.1 and I replaced Filter with Sinc:

Quote:
video=BlankClip(length=1500, width=848, height=480, pixel_type="YV12", fps=25)
audio=LWLibavAudioSource("I:\temp\stereo.wav")
AudioDub(video, audio)

back = soxfilter("sinc 100-7000")
fl = GetLeftChannel()
fr = GetRightChannel()
cc = mixaudio(GetRightChannel(),GetLeftChannel,0.5,0.5)
lfe = ConvertToMono().SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)

MergeChannels(fl, fr, cc, lfe, sl, sr)



Then I compared the two versions:

Quote:
video=BlankClip(length=1500, width=848, height=480, pixel_type="YV12", fps=25)
old_sox=LWLibavAudioSource("I:\temp\SoxFilter_10_Upmix_51.wav")
new_sox=LWLibavAudioSource("I:\temp\SoxFilter_21_Upmix_51.wav")

old=AudioDub(video, old_sox).VideoTek().Crop(692, 420, -0, -0)
new=AudioDub(video, new_sox).VideoTek().Crop(692, 420, -0, -0)

StackHorizontal(old, new)







and of course the Surround Left and Surround Right are different between the two version as we can also see with Subtract:




I then grabbed SL and SR from both the old Sox upmix and the new Sox upmix and I compared them individually:

Quote:
AudioDub(video, old_sox)

sl=GetChannel(5)
sr=GetChannel(6)
MergeChannels(sl, sr)
Quote:
AudioDub(video, new_sox)

sl=GetChannel(5)
sr=GetChannel(6)
MergeChannels(sl, sr)
and although they seem different, when I listened to them, they both did their job, in fact in both the old one and the new one I could only hear the little sparrows tweet and then the music soundtrack without any words in it.

I then wrote something silly to prevent the upmix functions from failing when using an older version of Sox:

Quote:
function UpSoundOnSound(clip a)
{
# Sound On Sound Profile
# SOS approach Profile with 20ms delay and some attenuation on surround

try {

back = a.soxfilter("filter 100-7000")
fl = a.GetLeftChannel()
fr = a.GetRightChannel()
cc = mixaudio(a.GetRightChannel(),a.GetLeftChannel,0.5,0.5)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}

catch(back) {

back = a.soxfilter("sinc 100-7000")
fl = a.GetLeftChannel()
fr = a.GetRightChannel()
cc = mixaudio(a.GetRightChannel(),a.GetLeftChannel,0.5,0.5)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
}


The samples are here (link valid for 7 days): https://we.tl/t-Q83d2Uthtr

in the package there's:

- stereo.wav (original audio)
- SoxFilter_10_Upmix_51.wav (old sox upmix)
- SoxFilter_21_Upmix_51.wav (new sox upmix)
- SoxFilter_10_SL_SR_Only.wav (Surround Left Surround Right only of the old Sox Upmix)
- SoxFilter_21_SL_SR_Only.wav (Surround Left Surround Right only of the new Sox Upmix)


Before I go on with this, though, I'd like to ask Tebasuna as he's far more expert than me on this.

Needless to say, the same "workaround" can be applied to the other upmix functions of course.

UpAction:

Quote:
function UpAction(clip a)
{
# Audio with a mix of sounds (ie. Action, Adventure)
# 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

try {

front = a.soxfilter("filter 20-20000")
back = a.soxfilter("filter 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.668,-0.668)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.668,-0.668)
cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.398,0.398)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.447")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.473,-0.473)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.473,-0.473)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}

catch(front) {

front = a.soxfilter("sinc 20-20000")
back = a.soxfilter("sinc 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.668,-0.668)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.668,-0.668)
cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.398,0.398)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.447")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.473,-0.473)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.473,-0.473)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
}

UpDialog:

Quote:
function UpDialog(clip a)
{
# Audio with mostly dialog (ie. Comedy, Drama)
# Profile to use with audio sources that have mostly mono content. 20ms delay and -3db attenuation on surround
# Note: the center channel is very weak for this profile

try {

front = a.soxfilter("filter 20-20000")
back = a.soxfilter("filter 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.794,-0.794)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.794,-0.794)
cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.224,0.224)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.596")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.562,-0.562)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.562,-0.562)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}

catch(front) {

front = a.soxfilter("sinc 20-20000")
back = a.soxfilter("sinc 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.794,-0.794)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.794,-0.794)
cc = mixaudio(mixaudio(front.GetLeftChannel(),fl,1,-1),mixaudio(front.GetRightChannel(),fr,1,-1),0.224,0.224)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.596")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.562,-0.562)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.562,-0.562)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
}
UpFarina:

Quote:
function UpFarina(clip a)
{
# Farina Profile
# Farina/Sursound approach Profile M=L+R, S=L-R, c=0.75, L' = (1-c/4)*M+(1+c/4)*S, C' = c*M, R' = (1-c/4)*M-(1+c/4)*S
# also added with 20ms delay and some attenuation on surround

try {

front = a.soxfilter("filter 20-20000")
back = a.soxfilter("filter 100-7000")
fl = mixaudio(mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,0.500),mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,-0.500),0.8125,1.1875)
fr = mixaudio(mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,0.500),mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,-0.500),0.8125,-1.1875)
cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.375,0.375)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}

catch(front) {

front = a.soxfilter("sinc 20-20000")
back = a.soxfilter("sinc 100-7000")
fl = mixaudio(mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,0.500),mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,-0.500),0.8125,1.1875)
fr = mixaudio(mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,0.500),mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.500,-0.500),0.8125,-1.1875)
cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.375,0.375)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
}
UpGerzen:

Quote:
function UpGerzen(clip a)
{
# Gerzen Profile
# Gerzen approach Profile modified with 20ms delay and some attenuation on surround

try {

front = a.soxfilter("filter 20-20000")
back = a.soxfilter("filter 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.885,-0.115)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.885,-0.115)
cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.4511,0.4511)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}

catch(front) {

front = a.soxfilter("sinc 20-20000")
back = a.soxfilter("sinc 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),0.885,-0.115)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),0.885,-0.115)
cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.4511,0.4511)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
}
UpMultisonic:

Quote:
function UpMultisonic(clip a)
{
# Multisonic Profile
# Multisonic approach Profile modified with 20ms delay and some attenuation on surround

try {

front = a.soxfilter("filter 20-20000")
back = a.soxfilter("filter 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),1,-0.5)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),1,-0.5)
cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.5,0.5)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}

catch(front) {

front = a.soxfilter("sinc 20-20000")
back = a.soxfilter("sinc 100-7000")
fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),1,-0.5)
fr = mixaudio(front.GetRightChannel(),front.GetLeftChannel(),1,-0.5)
cc = mixaudio(front.GetRightChannel(),front.GetLeftChannel,0.5,0.5)
lfe = ConvertToMono(a).SoxFilter("lowpass 120","vol -0.5")
sl = mixaudio(back.GetLeftChannel(),back.GetRightChannel(),0.668,-0.668)
sr = mixaudio(back.GetRightChannel(),back.GetLeftChannel(),0.668,-0.668)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
}

Last edited by FranceBB; 4th December 2023 at 09:19.
FranceBB is offline   Reply With Quote
Old 4th December 2023, 12:07   #17  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,860
About these old upmix filters I make some comments longtime ago:

1) Filters like front = a.soxfilter("sinc 20-20000") does not have sense only can waste time and quality.

2) Create a LFE channel with a lowpass of front channels is don't understand what is the LFE channel, and how work all audio equipments: the bass frequencies of ALL channels (not only LFE) are sended to SubWoofer speaker. The mix of bass from front channels and LFE channel can be doubled/cancelled/distorted. The best option is always a LFE empty:
lfe = fl.Amplify(0)

3) To avoid problems, at least with SoxFilter 1.0 and multichannel, I recommend use multiple mono instances for sox filters, instead back = a.soxfilter("filter 100-7000"):
bl = fl.soxfilter("filter 100-7000")
br = fr.soxfilter("filter 100-7000")

4) Some mix with sum of coeficients greater than 1 can cause clips for instance fl = mixaudio(front.GetLeftChannel(),front.GetRightChannel(),1,-0.5)

A example of my suggested upmix:
Quote:
function UpSoundOnSound(clip a)
{
# Sound On Sound Profile
# SOS approach Profile with 20ms delay and some attenuation on surround

a=ConvertAudiotoFloat(a)
fl = a.GetLeftChannel()
fr = a.GetRightChannel()
cc = mixaudio(fl, fr,0.5,0.5)
lfe = fl.Amplify(0)
bl = fl.soxfilter("sinc 100-7000").ConvertAudiotoFloat()
br = fr.soxfilter("sinc 100-7000").ConvertAudiotoFloat()
sl = mixaudio(bl,br,0.5,-0.5)
sr = mixaudio(br,bl,0.5,-0.5)
sl = DelayAudio(sl,0.02)
sr = DelayAudio(sr,0.02)
return MergeChannels( fl, fr, cc, lfe, sl, sr)
}
5) I never recommend that upmixes, VCR's have many functions to play in 5.1 stereo inputs.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 4th December 2023 at 12:23.
tebasuna51 is offline   Reply With Quote
Old 5th December 2023, 19:11   #18  |  Link
richardpl
Registered User
 
Join Date: Jan 2012
Posts: 269
Its year 2023, using 32 fixed point processing is vintage. Switch to double-floating point.
richardpl is offline   Reply With Quote
Old 6th December 2023, 09:08   #19  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,308
Wrong doorbell, complain here
https://sourceforge.net/p/sox/mailma...ail.gmail.com/
pinterf is offline   Reply With Quote
Old 1st January 2024, 16:32   #20  |  Link
flossy_cake
Registered User
 
Join Date: Aug 2016
Posts: 592
Not sure if I'm knocking at the wrong doorbell but, as noted by tebasuna51:

Quote:
Originally Posted by tebasuna51 View Post
Normalize don't work after SoxFilter("compand...")
Demo:

Code:
# Make sine tone
ColorBars().ConvertToYV12().Trim(0, 3000)

# Apply "Dolby film standard" compression profile which looks like this: tiny.cc/dolbydrc
SoxFilter("compand 0.05,0.10 -90,-90,-70,-64,-43,-37,-31,-31,-21,-21,0,-20")

# Problem occurs here
# Normalize(0.98)  # audible distortion & visible clipping on histogram
# Normalize(0.60)  # no visible clipping on histogram but still audible distortion

# Show levels
Histogram(mode="audiolevels")
AvsPMod seems to have issues with the sine tone though - it pops/crackles a lot even with just ColorBars(). Best way of testing I think is with ffmpeg command line:

Code:
"C:\program files\ffmpeg\bin\ffmpeg.exe" -i "C:\script.avs" -c:v libx264 -tune film -b:v 8000000 -pix_fmt yuv420p -c:a aac -b:a 320k "c:\audiotest.mkv"
MPC-HC seems to be ok for testing - it can also correct the issue by seeking backwards (I'm guessing this behaviour is specific to MPC-HC or specifically the LAV DirectShow filter I'm using to open .avs scripts with).

A workaround seems to do the Normalize first, then Soxfilter, then AmplifyDB(15.0) or so to gain back the 20db headroom created by the Soxfilter (or put " 15" at the end of the Soxfilter string). But seeking backwards can still cause it to bug out and become audibly distorted - more so in MPC-HC and less so in AvsPMod.

I have tried mucking around with Preroll, Prefetch and SetCacheMode without success.


Last edited by flossy_cake; 1st January 2024 at 16:56.
flossy_cake is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:38.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.