View Single Post
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