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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th December 2005, 16:43   #1  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Sox Audio Effect Filters v1.1 beta

This christmas holiday brought a new filter to extend sound processing support in AviSynth.

This plugin will allow you to run SOX effects within AviSynth. Most effects are supported, and multiple effects can be stacked after eachother.

You can download it here: http://forum.doom9.org/showthread.ph...154#post761154

Usage
SoxFilter(clip, string effect1 [, string effect 2, string effect 3...])

Any number of effects can be entered, and they will be executed in the order they are specified. Effect syntax is just like SOX. See Effect Overview and Filter Reference below.

A simple filter could look like this:
Code:
AviSource("movie.avi")
SoxFilter("bandpass 500 100")
convertAudioTo16Bit()
This will keep a 100Hz band around 500Hz. SoxFilter converts audio to 32 bit integers. This allows to keep the additional dynamic range of float point samples, but it requires a convertion to 16 bit audio before output, since most codecs only support 16 bit.

Multiple effects can be stacked like this:
Code:
AviSource("movie.avi")
SoxFilter("bandpass 2000 1000", "vol 2.0", "reverb 1.0 600.0 180.0 200.0 220.0 240.0")
ConvertAudioTo16Bit()
Known Issues
* Linear access is heavily recommended. SOX filters doesn't support seeking, so stream is restarted every time a samples previous to the last one is requested.
* The AviSynth version is VERY picky about spaces. If you make double spaces or a space before or after the quotes the command will not be recognized.
* If one filter doesn't support multichannel audio the entire chain is converted to mono filters, this might affect some filters like "earwax". Use multiple filter instaces instead.
* Some filters have been removed since they were incompatible with the AviSynth version. All these filters have internal Avisynth equivalents.
* compand is very unstable in the current interface, and doesn't support restarts (distorted audio). Don't use this together with other effetcs.
* The length of audio cannot be modified.

Feedback and bugs here, but please check if it is not a SOX problem, if possible.
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 3rd January 2006 at 00:06.
sh0dan is offline   Reply With Quote
Old 29th December 2005, 16:49   #2  |  Link
dimzon
BeHappy/MeGUI developer
 
dimzon's Avatar
 
Join Date: Oct 2003
Location: Moscow, Russia
Posts: 1,727
WOW! Thanx a lot!
dimzon is offline   Reply With Quote
Old 29th December 2005, 17:07   #3  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Just realised I'd left out some options in the docs of the newest version. I'll add them now.

Edit: Page and archives updated.
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 29th December 2005 at 17:34.
sh0dan is offline   Reply With Quote
Old 2nd January 2006, 01:10   #4  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,984
Host server is dead, Apache 409 error...
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Old 2nd January 2006, 16:31   #5  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,984
Ah, noise removal looks promising for simple things like system hum.
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Old 3rd January 2006, 00:02   #6  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
v 1.1:

* Solved issue with earwax refusing to play.
* Solved problem with time alternating effects.
* Solved issues with some filters producing clicks.
* Made sure compand and mcompand doesn't crash. Still quite buggy though.

Attached. Please test, and report your findings here!
Attached Files
File Type: zip SoxFilter_11.zip (145.3 KB, 6313 views)
File Type: zip SoxFilter_11_src.zip (61.9 KB, 1250 views)
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 3rd January 2006, 03:08   #7  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
that's awesome! thanks a lot!

i'll have to play around with this a tad now. the noise reduction looks interesting, as does the compander/ multiband companding (is there a peak limit as well?).

looks like i might be able to speed up some of my audio stuff now

btw, happy new year
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 3rd January 2006, 15:05   #8  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
excellent

it seems its frequency filters are perfectly reconstructible. i would expect it that way anyway, but it's good to know.

try this line - it cuts a source into 3 bands, then mixes them back together, then subtracts that from the source. the point being that if you hear anything at all, the filters are not PR.

Code:
mixaudio(last,\
mixaudio(last.soxfilter("filter 3000-6000 128"),\
mixaudio(last.soxfilter("filter 0-3000 128"),last.soxfilter("filter 6000-24000 128"),1,1)\
,1,1)\
,1,-1)
though it seems to take a bit of playback for it to go silent... they start out of sync, then each band gets back in sync 1 by 1 in the space of a few seconds.

[edit] disregard that. it's because i couldn't find a decent source on my home machine.... ensureVBRmp3sync fixed it. all is right with the world.

[edit 2]

i'm playing with this a fair bit (as you can no doubt tell), and have noticed that mixaudio seems to be returning 16-bit even though it's fed with float audio. is something amiss?

i'm doing my own multiband compression (sox's one seems to only support 2 bands, which is enough for speech but not music if you really want to smash it but avoid pumping) and i need mixaudio at the end to put the bands back together again. i'm getting clipping in the bass and 16-bit audio output though

here's my script:

Code:
avisource("blah.avi").ensurevbrmp3sync()
audiodub(last,wavsource("Led Zeppelin - II.wav"))

convertaudiotofloat()
c=last

band1 = c.soxfilter("filter 0-250 192","compand .05,1. -30,-30,-0,-27.3")
band2 = c.soxfilter("filter 250-2500 192","compand .01,.5 -34.3,-34.3,-0,-31.3")
band3 = c.soxfilter("filter 2500-12000 192","compand .01,.5 -38.3,-38.3,-0,-34.8")
band4 = c.soxfilter("filter 12000-24000 192","compand .01,.5 -34.9,-34.9,-0,-31.8")
band2
mixaudio(mixaudio(band1,band2,1,1),mixaudio(band3,band4,1,1),1,1)
hehe... it took me a while to realise i couldn't do a 0-250Hz band with an fft size of 128... though i'm not sure if power-of-2 fft sizes are faster or not.

just in case you're interested, the numbers in the compander are exported from audition, and based on -20dB pink noise with 8:1 compression above -20dB (numbers are different due to each band having different power... i wish i had the maths to do this analytically). the idea behind it is no matter how much you amplify the input (assuming float values that don't have a problem with positive dB), it will always give you a nice eq curve. works okay in audition, but it's hellishly slow and requires intermediate files.
__________________
sucking the life out of your videos since 2004

Last edited by Mug Funky; 3rd January 2006 at 16:42.
Mug Funky is offline   Reply With Quote
Old 3rd January 2006, 21:22   #9  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Quote:
i'm playing with this a fair bit (as you can no doubt tell), and have noticed that mixaudio seems to be returning 16-bit even though it's fed with float audio. is something amiss?
If the sample type is float, when AviSynth has to output the data, it will be converted to 16 bit, since float cannot be passed as valid AVI data.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 4th January 2006, 03:36   #10  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
hmm. i could have sworn i was seeing 32 bit audio when not using mixaudio...? i'm trying it here at work and it appears you're right about it returning 16 bit. is it possible my (newer) version of virtualdub at home is actually accepting 32 bits? or is it more likely i was looking at it wrong

btw, is it possible to get 32 bit audio out using avs2wav?

sorry to bug you with these questions. i'm quite eager to replace a 2 hour cool edit operation with a 5 min avs one . i'm already getting nice results, but perhaps i should ease back on the loudness and the clipping will go away (i'm still not sure it isn't coming from mixaudio... how does that deal with beyond fullscale stuff in float?)
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 5th March 2007, 10:40   #11  |  Link
TheBashar
Registered User
 
TheBashar's Avatar
 
Join Date: Jan 2002
Posts: 112
Silence Hangs Sox Plugin

Quote:
Originally Posted by sh0dan View Post
Please test, and report your findings here!
I've been trying to use the compander filter via this sox plugin to do some DRC on some videos I'm splicing together with Aligned Splices. I have to that make avisynth / sox / compander lock up with ++ but not with +. Do you have any suggestions how I might accomplish the aligned splice without causing compander to go off in the weeds?

Thanks!

More Info:

Okay, it looks like the pure silence that AlignedSplice adds is sending the compander off to never-never land. Here is an example of what bombs when encoding in MeGUI and how to hack around it:

Code:
clipA = DirectShowSource("clipA.avi").ConvertToMono().SoxFilter("compand 0.1,0.3 -90,-90,-70,-55,-50,-35,-31,-31,-21,-21,0,-20 0 0 0.1")
# NOTE: clipA audio duration <  clipA video duration
clipB = DirectShowSource("clipB.avi").ConvertToMono().SoxFilter("compand 0.1,0.3 -90,-90,-70,-55,-50,-35,-31,-31,-21,-21,0,-20 0 0 0.1")

blank = BlankClip(A)
tonal = Tone(blank.AudiolengthF/blank.Audiorate, 440, clipA.Audiorate, 1, "silence", 0.0)

works1 = clipA + clipB
hangs1 = clipA ++ clipB

hangs2 = AudioDubEx(clipA, MixAudio(blank, clipA, 0.0, 1.0)) + clipB
works2 = AudioDubEx(clipA, MixAudio(tonal, clipA, 0.0, 1.0)) + clipB
What befuddles me so much is how can mixing in the silent audio from the BlankClip cause a hang, but mixing in the silence from a Tone(type="silence", level=0.0) with a 0.0 clip_factor in MixAudio not cause the hang??

Solution:

It seems that the last parameter in the "compand" function is what is causing the problem. I copied this black magic from this post: http://forum.doom9.org/showpost.php?...5&postcount=60 As it turns out, even after my ++ replacement hackery, it was still crashing on other samples. Increasing that last parameter from 0.1 to 0.2 made the filter able to accept more and more of my test samples. So far, at 0.2, I am not getting any hangs.

Last edited by TheBashar; 5th March 2007 at 21:13. Reason: Added Solution
TheBashar is offline   Reply With Quote
Old 25th April 2009, 11:03   #12  |  Link
nikio
Registered User
 
Join Date: Feb 2009
Posts: 9
Hello everyone,
I'm not very familiar with this, I need to upmix an audio trace and my behappy seems to need this SoxFilter.dll. After a long serch I found the 1.1 version dated 2006, is this the newest version?
nikio is offline   Reply With Quote
Old 26th April 2009, 00:04   #13  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,881
Yes, this is the newest I know.

At least this is the last tested with BeHappy.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 4th September 2010, 09:07   #14  |  Link
royia
Drazick
 
Join Date: May 2003
Location: Israel
Posts: 139
Is there a better Audio Noise Reduction plug ins for AVI Synth or this is as good as it gets?

Thanks.
royia is offline   Reply With Quote
Old 14th December 2011, 05:14   #15  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
sh0dan

Need following.
.
I have two video clip with sound track in each.
Parameters of sound tracks in different video clips are equal.
I need following with sound tracks in video clips, like as video contetnt,
Sound1 - Sound2 (mines) or similar to function Subtract() in video content, but for sound tracks...

Sound1=A1 * Sin(2 * PI * f1 * t1 + fi1)
Sound2=A2 * Sin(2 * PI * f2 * t2 + fi2)
where
A1, A2 - amplitude of sound wave
f1, f2 - frequency of sound wave
t1, t2 - time, in our case are equal t1 = t2 = t
fi1, fi2 - phase of sound wave
PI = 3.1415926

Sound = Sound1 - Sound2 = A1 * Sin(2 * PI * f1 * t + fi1) - A2 * Sin(2 * PI * f2 * t + fi2)
for each time counting

How can I do this ?

Maybe update SoxFilter() for subtraction audio tracks in clips, for (as) example,

SoxFilter(clip1, clip2, string "subtract")
and return result subtraction clip (audio subtraction), if (clip2 != NULL) ...
And so on...

Last edited by Jenyok; 14th December 2011 at 10:22.
Jenyok is offline   Reply With Quote
Old 14th December 2011, 12:18   #16  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Tone will generate a sine wave of a given frequency.
You can't set the phase, although I suppose you could use Trim() to achieve that.

To subtract the audio of two clips, use
MixAudio(clip1, clip2, 1.0, -1.0)
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 14th December 2011, 16:57   #17  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
This is a simple Pseudo Stereo Algorythm for mono audio track.
Based on physic's laws.
For you usage...
It works fine (for me)...
.
Code:
#
# Pseudo Stereo algorythm
# Based on physic's laws
#

audio               = BassAudioSource("...your sound file...")

audio               = GetChannel(audio, 1)                   # Get MONO signal Left channel -> Получаем левый канал, звук "МОНО"
audio               = ConvertToMono(audio)
left_channel        = audio
right_channel       = DelayAudio(audio, 0.0121)              # t=0.0121 sec (v=331 m/sec) ~4 m between sound source L and R in room -> 0.0121 сек (331 м/сек) ~ 4 м между источниками звука L и R
left_channel        = Normalize(left_channel, 0.99)
right_channel       = Normalize(right_channel, 0.99)
left_channel_delay  = DelayAudio(left_channel, 0.000755)     # t=0.000775 sec (v=331 m/sec) ~0.25 m between ears -> 0.000755 сек (331 м/сек) ~ 0.25 м (25 см) среднее расстояние между "ушами"
right_channel_delay = DelayAudio(right_channel, -0.000755)   # t=0.000775 sec (v=331 m/sec) ~0.25 m between ears -> 0.000755 сек (331 м/сек) ~ 0.25 м (25 см) среднее расстояние между "ушами"
left_channel        = MixAudio(left_channel, right_channel_delay, 0.6, 0.4)
right_channel       = MixAudio(right_channel, left_channel_delay, 0.6, 0.4)
left_channel        = Normalize(left_channel, 0.99)
right_channel       = Normalize(right_channel, 0.99)
stereo              = MergeChannels(left_channel, right_channel)
stereo              = Normalize(stereo, 0.99)
.
This is a New Pseudo Stereo Algorythm for mono audio track.
Algorythm is described in Russian magazine "Radio" №7 1982 year.
For you usage...
It works fine (for me)...
.
Code:
#
# New pseudo Stereo algorythm
# Radio Magazine 07-1982, page 47-50
#
#
# Plugins:
#
# SoxFilter()
#



LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SOXFILTER_11\soxfilter.dll")



# Constants
#
K2       = 0.5           # K2 = [0.00 .. 1.00]
FNCH     = 300.00        # Low Pass Filter (ФНЧ) = [150 .. 500] Hz (Гц)
SLevel   = 1.00          # Sound Volume Level (Уровень звука) = [0.75 .. 1.00]

# Constants
# ! Do not change this constants !
#
Kf1      = 0.17          # ! Do not change this constant !
Kf2      = 0.83          # ! Do not change this constant !
Kf3      = 1.83          # ! Do not change this constant !
Kf4      = 2.00          # ! Do not change this constant !
KLevel   = 0.85          # ! Do not change this constant !   # Требует небольшой подстройки под конктретный звук
SQRT2    = 1.414         # Square root 2 (Корень из 2)

# Constants
#
LChannel = 1             # Get Left Channel (Левый канал)
LowPass  = "lowpass "    # Low Pass Filter (ФНЧ)
HighPass = "highpass "   # High Pass Filter (ФВЧ)
VLevel   = "vol "        # Volume Level normalization

# Constants
#
SLevel2  = 2.00          # Sound Volume Level (Уровень звука) = [1.00 .. 3.00]   # First Sound Volume Level normalization
SLevel3  = 10.0          # Final Sound Volume Level normalization


# Variables
#
# RightChannel
# LeftChannel
# LeftChannel2           # Mono signal (Моно сигнал), work variable...
# Afnch
# Bfvch
# Stereo
#
# EqC1                   # Variable
# EqC2                   # Variable
# EqC3                   # Variable
# EqC4                   # Variable
#
# EqZL                   # Variable
# EqZR                   # Variable



K2           = (K2 < 0.00) ? 0.00 : (K2 > 1.00) ? 1.00 : K2
FNCH         = (FNCH < 150.00) ? 150.00 : (FNCH > 500.00) ? 500.00 : FNCH
SLevel       = (SLevel < 0.75) ? 0.75 : (SLevel > 1.00) ? 1.00 : SLevel
SLevel2      = (SLevel2 < 1.00) ? 1.00 : (SLevel2 > 3.00) ? 3.00 : SLevel2



BlankClip(length=72250, width=768, height=576, audio_rate=44100, fps=25.0)   # Only for test

Left=WAVSource("C:\Z_DISK_C\PICTURE\JENYOK\SCHOOL_47_KURGAN\VIDEO\DVD 25YEARS DISK6 ФИЛЬМ УЧИТЕЛЬ V1_00 (OLD, +AVI, +AVS)\ZAVS\teacher t01 2_0ch 256kbps 44.1khz.wav")


LeftChannel2 = Left.KillVideo()                 # Get Audio Channel, kill Video content
#LeftChannel2 = GetChannel(LeftChannel2, LChannel).KillVideo()                 # Get Audio Channel, kill Video content
LeftChannel2 = ConvertToMono(LeftChannel2)
LeftChannel2 = SoxFilter(LeftChannel2, VLevel+String(SLevel2))  # Normalize sound Volume Level = SLevel2


#
# Afnch = LowPass_Filter(LeftChannel2, FNCH)
#
#
# Bfvch = LeftChannel2 - Afnch
#
# Bfvch = HighPass_Filter(Bfvch, FNCH)
#
#
# LeftChannel  = SQRT(2) * (Afnch - 2 * K2 * Afnch + 1.83 * K2 * LeftChannel2 - 0.83 * K2 * K2 * LeftChannel2)
#
# RightChannel = SQRT(2) * (Bfvch + 2 * K2 * Afnch - 0.17 * K2 * LeftChannel2 - 0.83 * K2 * K2 * LeftChannel2)
#


Afnch        = SoxFilter(LeftChannel2, LowPass+String(FNCH))    # 300 Hz (Гц) Low Pass Filter (ФНЧ 300 Гц)
Afnch        = SoxFilter(Afnch, VLevel+String(SLevel))          # Normalize sound Volume Level = SLevel

Bfvch        = MixAudio(LeftChannel2, Afnch, 1.0, -1.0)         # 
Bfvch        = SoxFilter(Bfvch, VLevel+String(SLevel*KLevel))   # Normalize sound Volume Level = SLevel*KLevel
Bfvch        = SoxFilter(Bfvch, HighPass+String(FNCH))          # 300 Hz (Гц) High Pass Filter (ФВЧ 300 Гц)
Bfvch        = SoxFilter(Bfvch, VLevel+String(SLevel))          # Normalize sound Volume Level = SLevel

EqC1         = SoxFilter(Afnch, VLevel+String(Kf4 * K2))
EqC2         = SoxFilter(LeftChannel2, VLevel+String(Kf3 * K2))
EqC3         = SoxFilter(LeftChannel2, VLevel+String(Kf2 * K2 * K2))
EqC4         = SoxFilter(LeftChannel2, VLevel+String(Kf1 * K2))


EqZL         = MixAudio(Afnch, EqC1, 1.0, -1.0)
EqZL         = SoxFilter(EqZL, VLevel+String(SLevel))           # Normalize sound Volume Level = SLevel
EqZL         = MixAudio(EqZL, EqC2, 0.5, 0.5)
EqZL         = SoxFilter(EqZL, VLevel+String(SLevel))           # Normalize sound Volume Level = SLevel
EqZL         = MixAudio(EqZL, EqC3, 1.0, -1.0)
EqZL         = SoxFilter(EqZL, VLevel+String(SLevel))           # Normalize sound Volume Level = SLevel

EqZR         = MixAudio(Bfvch, EqC1, 0.5, 0.5)
EqZR         = SoxFilter(EqZR, VLevel+String(SLevel))           # Normalize sound Volume Level = SLevel
EqZR         = MixAudio(EqZR, EqC4, 1.0, -1.0)
EqZR         = SoxFilter(EqZR, VLevel+String(SLevel))           # Normalize sound Volume Level = SLevel
EqZR         = MixAudio(EqZR, EqC3, 1.0, -1.0)
EqZR         = SoxFilter(EqZR, VLevel+String(SLevel))           # Normalize sound Volume Level = SLevel


LeftChannel  = SoxFilter(EqZL, VLevel+String(SQRT2))
RightChannel = SoxFilter(EqZR, VLevel+String(SQRT2))
	

Stereo       = MergeChannels(LeftChannel, RightChannel)
Stereo       = SoxFilter(Stereo, VLevel+String(SLevel3))        # Normalize sound Volume Level = SLevel3
Stereo       = ConvertAudioTo16bit(Stereo)

AudioDub(last, Stereo)

ConvertToYUY2()

Last edited by Jenyok; 15th December 2011 at 20:40.
Jenyok is offline   Reply With Quote
Old 16th December 2011, 09:42   #18  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 299
What happens when the audio is mixed back down to mono?
markanini is offline   Reply With Quote
Old 8th January 2012, 12:35   #19  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
This is a 5.1 Audio Algorythm for stereo audio track.
Algorythm is described in internet.
For you usage...
It works fine (for me)...
Only it is needed more better reverberation effect from SoxFolter() function, such as for example, "Adobe Audition CS5.5 -> Effects -> Reverb -> Big Drum Room" ...
Reverberation effect in SoxFilter() function is very slow.

Code:
#
# 5.1 Audio Algorythm for stereo audio track
#
#
# Plugins:
#
# SoxFilter()
#


LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SOXFILTER_11\soxfilter.dll")

function StereoTo51(clip clp)
{
  # Output
  #
  # 5.1 sound 24 bits

  # Constants
  #
  # WAV 2.0 stereo
  #   1 - Left channel
  #   2 - Right channel
  #
  # WAV 5.1 channels
  #   1 - Lf Front Left channel
  #   2 - Rf Front Right channel
  #   3 - C Front Central channel
  #   4 - LFE Subwoofer
  #   5 - Ls Rear Left channel
  #   6 - Rs Rear Right channel
  #
  LChannel  = 1                        # Set default Left Channel (Левый канал)
  RChannel  = 2                        # Set default Right Channel (Правый канал)
  
  VLevel0   = "vol 0.0 dB"             # Volume Level normalization to 0.0 dB
  VLevel03  = "vol 3.0 dB"             # Volume Level normalization to 3.0 dB
  VLevel361 = "vol 3.61 dB"            # Volume Level normalization to 3.61 dB
  VLevel6   = "vol 6.0 dB"             # Volume Level normalization to 6.0 dB
  VLevel9   = "vol 9.0 dB"             # Volume Level normalization to 9.0 dB
  VLevel3   = "vol -3.0 dB"            # Volume Level normalization to -3.0 dB
  VLevel12  = "vol -12.0 dB"           # Volume Level normalization to -12.0 dB

  HPass     = "highpass 200.0"         # HighPass Filter 200 Hz "/---"
  LPass     = "lowpass 200.0"          # LowPass Filter 200 Hz  "---\"

  Reverb    = "reverb 0.4 700 262 350 175"     # reverbe time 700 -> delay time [350 .. 175]



  Stereo = KillVideo(clp)                                # Get Audio Channels, kill Video content
  Stereo = GetChannels(Stereo, LChannel, RChannel)       # Get Left and Right Audio Channels (stereo)

  # Convert audio stereo signal to 32 bits (SoxFilter() function)
  # Normalize to 0.0 dB
  #
  Stereo = SoxFilter(Stereo, VLevel0)                    # Normilize audio Stereo to 0.0 dB

  # Work audio stereo signal
  # Normalize to -12.0 dB
  #
  LR = SoxFilter(Stereo, VLevel12)                       # Normilize audio LR to -12.0 dB

  # Work audio stereo signal2
  # LRm = HighPass_Filter(LR, 200)
  #
  LRm = SoxFilter(LR, HPass)                             # HighPass Filter 200 Hz LRm "/---" 

  # LFE = LR - LRm
  # LFE = LowPass_Filter(LFE, 200)
  #
  LFE  = MixAudio(LR, LRm, 1.0, -1.0)                    # LFE = LR - LRm
  LFE  = SoxFilter(LFE, LPass)                           # LowPass Filter 200 Hz LFE "---\"
  LFE  = SoxFilter(LFE, VLevel9)                         # Normilize audio LFE to 9.0 dB
  LFEl = GetChannel(LFE, LChannel)                       # LFEl = Left_channel(LFE)
  LFEl = ConvertToMono(LFEl)
  LFEr = GetChannel(LFE, RChannel)                       # LFEr = Right_channel(LFE)
  LFEr = ConvertToMono(LFEr)
  LFE  = MixAudio(LFEl, LFEr, 0.5, 0.5)                  # LFE = LFEl + LFEr
  LFE  = ConvertToMono(LFE)
  LFE  = ConvertAudioTo24bit(LFE)                        # LFE (Subwoofer) audio mono signal 24 bits

  #
  #
  C  = SoxFilter(LRm, VLevel3)                           # Normilize audio C to -3.0 dB
  Cl = GetChannel(C, LChannel)                           # Cl = Left_channel(C)
  Cl = ConvertToMono(Cl)
  Cr = GetChannel(C, RChannel)                           # Cr = Right_channel(C)
  Cr = ConvertToMono(Cr)
  C  = MixAudio(Cl, Cr, 0.5, 0.5)                        # C = 0.707 * Cl + 0.707 * Cr
  C  = SoxFilter(C, VLevel03)                            # Normilize audio C to 3.0 dB
  C  = ConvertToMono(C)
  C  = ConvertAudioTo24bit(C)                            # C central audio mono signal 24 bits

  #
  #
  Lc1  = GetChannel(LRm, LChannel)                       # Lc1 = Left_channel(LRm)
  Lc1  = ConvertToMono(Lc1)
  Rc1  = GetChannel(LRm, RChannel)                       # Rc1 = Right_channel(LRm)
  Rc1  = ConvertToMono(Rc1)
  NLc1 = MixAudio(Lc1, Rc1, 0.99, -0.33)                 # Lc = 0.99 * Lc - 0.33 * Rc
  NRc1 = MixAudio(Rc1, Lc1, 0.99, -0.33)                 # Rc = 0.99 * Rc - 0.33 * Lc
  LfRf = MergeChannels(NLc1, NRc1)                       # Merge channels to stereo singal LfRf
  LfRf = SoxFilter(LfRf, VLevel361)                      # Normilize audio LfRf to 3.61 dB, 32 bits

  #
  #
  LRm_reverb = SoxFilter(LRm, Reverb)                    # LRm_reverb = Reverberation(LRm)
  LRm_reverb = MixAudio(LRm_reverb, LRm, 1.0, -1.0)      # LRm_reverb = LRm_reverb - LRm
  LRm_reverb = SoxFilter(LRm_reverb, VLevel6)            # Normilize audio LRm_reverb to 6.0 dB
  Ls         = GetChannel(LRm_reverb, LChannel)          # Ls = Left_channel(LRm_reverb)
  Ls         = ConvertToMono(Ls)
  Ls         = ConvertAudioTo24bit(Ls)                   # Ls rear left channel mono signal 24 bits
  Rs         = GetChannel(LRm_reverb, RChannel)          # Rs = Right_channel(LRm_reverb)
  Rs         = ConvertToMono(Rs)
  Rs         = ConvertAudioTo24bit(Rs)                   # Rs rear right channel mono signal 24 bits

  #
  #
  LfRf = MixAudio(LfRf, LRm_reverb, 1.0, -1.0)           # LfRf = LfRf - LRm_reverb
  Lf   = GetChannel(LfRf, LChannel)                      # Lf = Left_channel(LfRf)
  Lf   = ConvertToMono(Lf)
  Lf   = ConvertAudioTo24bit(Lf)                         # Lf front left channel mono signal 24 bits
  Rf   = GetChannel(LfRf, RChannel)                      # Rf = Right_channel(LfRf)
  Rf   = ConvertToMono(Rf)
  Rf   = ConvertAudioTo24bit(Rf)                         # Rf front right channel mono signal 24 bits

  Lf      = SoxFilter(Lf, VLevel0)
  Rf      = SoxFilter(Rf, VLevel0)
  C       = SoxFilter(C, VLevel0)
  LFE     = SoxFilter(LFE, VLevel0)
  Ls      = SoxFilter(Ls, VLevel0)
  Rs      = SoxFilter(Rs, VLevel0)
  Sound51 = MergeChannels(Lf, Rf, C, LFE, Ls, Rs)
  Sound51 = ConvertAudioTo24bit(Sound51)
  
  return (Sound51)

# Only for debugging
#  return (ConvertAudioTo16bit(MergeChannels(Lf, Rf, C, LFE, Ls, Rs)))
#  return (ConvertAudioTo16bit(Stereo))
#  return (ConvertAudioTo16bit(LR))
#  return (ConvertAudioTo16bit(LRm))
#  return (ConvertAudioTo16bit(LFE))
#  return (ConvertAudioTo16bit(C))
#  return (ConvertAudioTo16bit(LfRf))
#  return (ConvertAudioTo16bit(LRm_reverb))
}
.
sh0dan
If you are not hard,
please,
see "Adobe Audition CS5.5 -> Effects -> Reverb -> Big Drum Room" function
and try to do SoxFilter() as copy of this Adobe function...
Very very need it !!!
5.1 Audio Algorythm will work more good, more better...
.
Thanks a lot...

Last edited by Jenyok; 8th January 2012 at 13:10.
Jenyok is offline   Reply With Quote
Old 11th January 2012, 10:10   #20  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
sh0dan

Are you here ?
Jenyok 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 03:53.


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