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 30th January 2012, 18:18   #21  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
New algorithm.
Convert MONO signal (1 channel) into PSEUDO STEREO signals (2 channels).

Code:
#
# New Stereo algorythm for MONO audio track
#
# Plugins:
# SoxFilter()
#
function PseudoStereo3(clip clp, float "SLevel", float "SLevel2", int "Channel")
{
  # Default variables
  #
  Channel  = Default(Channel, 1)       # Set default Left Channel (Левый канал)
  SLevel   = Default(SLevel,  1.00)    # Work Sound Volume Level (Уровень звука) = [0.75 ... 1.00] normalization
  SLevel2  = Default(SLevel2,  1.00)   # Output Sound Volume Level (Уровень звука) = [0.75 ... 1.00] normalization

  # Constants
  #
  Delay1   = 0.012000                 # t=0.0120 sec (v=331 m/sec) ~4 m between sound source L and R in room
                                      # 0.0120 сек (331 м/сек) ~ 4 м между источниками звука L и R

  # Constants
  #
  F1 = 200
  F2 = 2000
  dF = 50

  # Constants
  #
  LowPass  = "lowpass "               # Low Pass Filter (ФНЧ)
  HighPass = "highpass "              # High Pass Filter (ФВЧ)
  VLevel   = "vol "                   # Volume Level normalization
  
  # Variables
  #
  # LeftChannel
  # RightChannel
  # Stereo
  # LeftChannel2 = Input sound
  # Left1
  # Left2
  # Left3

  SLevel       = (SLevel < 0.75) ? 0.75 : (SLevel > 1.00) ? 1.00 : SLevel
  SLevel2      = (SLevel2 < 0.75) ? 0.75 : (SLevel2 > 1.00) ? 1.00 : SLevel2

  LeftChannel2 = KillVideo(clp)                                   # Get Audio Channel(s), kill Video content
  LeftChannel2 = GetChannel(LeftChannel2, Channel)                # Get Left (Right) Audio Channel
  LeftChannel2 = ConvertToMono(LeftChannel2)
  LeftChannel2 = SoxFilter(LeftChannel2, VLevel+String(SLevel))   # Normalize First Sound Volume Level = SLevel

  Left1 = LeftChannel2
  Left2 = LeftChannel2
  Left3 = LeftChannel2

  Left1 = SoxFilter(Left1, LowPass+String(F1 - dF))     # 150 Hz (Гц) Low Pass Filter (ФНЧ 150 Гц)
  Left1 = SoxFilter(Left1, VLevel+String(SLevel))       # Normalize First Sound Volume Level = SLevel

  Left2 = SoxFilter(Left2, HighPass+String(F1 + dF))    # 250 Hz (Гц) High Pass Filter (ФВЧ 250 Гц)
  Left2 = SoxFilter(Left2, VLevel+String(SLevel))       # Normalize First Sound Volume Level = SLevel
  Left2 = SoxFilter(Left2, LowPass+String(F2 - dF))     # 1950 Hz (Гц) Low Pass Filter (ФНЧ 1950 Гц)
  Left2 = SoxFilter(Left2, VLevel+String(SLevel))       # Normalize First Sound Volume Level = SLevel

  Left3 = SoxFilter(Left3, HighPass+String(F2 + dF))    # 2050 Hz (Гц) High Pass Filter (ФВЧ 2050 Гц)
  Left3 = SoxFilter(Left3, VLevel+String(SLevel))       # Normalize First Sound Volume Level = SLevel

  LeftChannel  = MixAudio(Left1, Left2, 0.5, 0.5)
  LeftChannel  = SoxFilter(LeftChannel, VLevel+String(SLevel))       # Normalize First Sound Volume Level = SLevel
  LeftChannel  = MixAudio(LeftChannel, Left3, 0.5, 0.5)
  LeftChannel  = SoxFilter(LeftChannel, VLevel+String(SLevel))       # Normalize First Sound Volume Level = SLevel
  LeftChannel  = AmplifydB(LeftChannel, 8)                           # Amplify volume of LeftChannel to 8 dB. Need to tune.

  RightChannel = MixAudio(LeftChannel, LeftChannel2, 1.0, -1.0)
  RightChannel = DelayAudio(RightChannel, Delay1)
  RightChannel = SoxFilter(RightChannel, VLevel+String(SLevel))      # Normalize First Sound Volume Level = SLevel

  Stereo       = MergeChannels(LeftChannel, RightChannel)
  Stereo       = SoxFilter(Stereo, VLevel+String(SLevel2))           # Normalize First Sound Volume Level = SLevel2
  Stereo       = ConvertAudioTo16Bit(Stereo)

  return (Stereo)
}
sh0dan

Are you here, mate ?
__________________
Warm and fuzzy (white and fluffy)

Last edited by Jenyok; 30th January 2012 at 18:32.
Jenyok is offline   Reply With Quote
Old 30th March 2013, 08:39   #22  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
There are some functions to convert MONO audio signal to PSEUDO STEREO.
There is a function to convert stereo audio signal to 5.1 audio signal.
.
See description in code section.
See attached RAR file.
.
.
Code:
#
#
# File:     Stereo.avsi
#
#
# Date:     30.03.2013 year
# Version:  1.3
#
#
# License:  GNU GENERAL PUBLIC LICENSE
#
#
# Author:   Jenyok  (Evgeniy Gurovskikh, Russia, Moscow)
# E-Mail:   e_gurovskikh@mail.ru
#
#
#
# Functions (pseudo Stereo and other sound functions) for AVISynth
#
# For all occasions of life (На все случаи жизни) ...
#
#
#
# Plugin and Import
#
#   SoxFilter.dll
#
#
#
# function PhaseShift(clip clp, float "freq", float "phi", int "Channel")         Shift (rotate) phase of audio to a different angle (corner)
#
# function PseudoStereo3(clip clp, int "Channel", bool "isDelay")                 Described: Magazine "Radio" № 6, 1985 year, page 62 (USSR, Russia)
# function PseudoStereo33(clip clp, int "Channel", bool "isDelay")                Described: Magazine "Radio" № 6, 1985 year, page 62 (USSR, Russia)
#
# function PseudoStereo4(clip clp, int "Channel", bool "isDelay")                 US Patent No 6,636,608 B1
# function PseudoStereo43(clip clp, int "Channel", bool "isDelay")                US Patent No 6,636,608 B1
#
# function PseudoStereo5(clip clp, int "Channel", bool "isDelay")                 Analog: Philips chip TDA3810 (sound porcessor)
# function PseudoStereo52(clip clp, int "Channel", bool "isDelay")                Analog: Philips chip TDA3810 (sound porcessor)
#
# function StereoEnhancer(clip clp)                                               Analog: Philips chip TDA3810 (sound porcessor)
#
#
# function StereoTo51(clip clp, bool "is24bit")                                   Build 5.1 Sound Audio track from stereo signal, 
#                                                                                 24 bits output (24 bits is a standard ?)
#
#
# function Dmix3Stereo(clip a)                                                    Downmix sound functions
# function Dmix3Dpl(clip a)                                                       Downmix sound functions
# function Dmix4lStereo(clip a)                                                   Downmix sound functions
# function Dmix4qStereo(clip a)                                                   Downmix sound functions
# function Dmix4sDpl(clip a)                                                      Downmix sound functions
# function Dmix5Stereo(clip a)                                                    Downmix sound functions
# function Dmix5Dpl(clip a)                                                       Downmix sound functions
# function Dmix5Dpl2(clip a)                                                      Downmix sound functions
# function Dmix6Stereo(clip a)                                                    Downmix sound functions
# function Dmix6Dpl(clip a)                                                       Downmix sound functions
# function Dmix6Dpl2(clip a)                                                      Downmix sound functions
# function Dmix6StereoLfe(clip a)                                                 Downmix sound functions
# function Dmix6StereoLfe2(clip a)                                                Downmix sound functions
# function Dmix6DplLfe(clip a)                                                    Downmix sound functions
# function Dmix6Dpl2Lfe(clip a)                                                   Downmix sound functions
#
#
.
Attached Files
File Type: rar stereo.rar (6.6 KB, 71 views)
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 1st April 2013, 15:48   #23  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
There is an error in AVISynth, see atteched file.
.
What must I do in this case ?
.
Attached Images
 
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 1st April 2013, 16:27   #24  |  Link
steptoe
Registered User
 
steptoe's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 360
I'm taking a wild guess, as the screenshot is pending approval, but after looking at the script it is loading the soxfilter.dll from a specific folder. If it isn't there then the script WILL fail


Might be better to delete the line below from the script and autoload it by putting it in the avisynth/plugins folder, or to be 100% sure it loads simply copy the soxfilter.dll to where the script is looking for it by default as shown below

LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SOXFILTER_11\soxfilter.dll")
steptoe is offline   Reply With Quote
Old 3rd April 2013, 10:30   #25  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
sh0dan
.
I tested SoxFiler and found very strange results of working SoxFilter .
.
See very simple script below.
.
Code:
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SOXFILTER_11\soxfilter.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\WAVEFORM_0_2\waveform.dll")

Import("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEDIRT\utils2.avsi")

BlankClipNS(length=6250)   # Blank clip without sound

audio1=Tone(length=1500, frequency=25,   samplerate=44100, channels=1, type="sine", level=0.707)   # 0.707=-3dB, 25Hz, 44.1 kHz, MONO 1-channel

audio=audio1

audio1=Normalize(audio1, 1.0)             # +0dB, 25Hz, MONO 1-channel
audio1=SoxFilter(audio1, "vol +0.0 dB")   # Nothing to do, +0dB, 25Hz, MONO 1-channel

audio=MergeChannels(audio, audio1)        # Left=-3dB, 25Hz, Right=+0dB, 25Hz, STEREO 2-channels

AudioDub(last, audio)

waveform()

ConvertToYUY2()
.
See attached file "test01.jpg" as a result of this script.
There are Strange vertical lines in wave form in Right channel (low audio channel in picture).
.
Then I remarked following line, see below code section.
.
Code:
#audio1=SoxFilter(audio1, "vol +0.0 dB")   # Nothing to do, +0dB, 25Hz, MONO 1-channel
.
See attached file "test02.jpg" as a result of this script without remarked line, see upper code section.
There are no Strange vertical lines in wave form in Right channel (low audio channel in picture).
.
Attached Images
  
__________________
Warm and fuzzy (white and fluffy)

Last edited by Jenyok; 3rd April 2013 at 10:51.
Jenyok is offline   Reply With Quote
Old 4th April 2013, 13:45   #26  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
New improvements and changes.
Version 1.4
.
See attached RAR file.
.
.
Code:
#
# File:     Stereo.avsi
#
#
# Date:     04.04.2013 year
# Version:  1.4
#
#
# License:  GNU GENERAL PUBLIC LICENSE
#
#
# Author:   Jenyok  (Evgeniy Gurovskikh, Russia, Moscow)
# E-Mail:   e_gurovskikh@mail.ru
#
#
# Functions (pseudo Stereo and other sound functions) for AVISynth
#
# For all occasions of life (На все случаи жизни) ...
#
#
# Plugin and Import
#
#   SoxFilter.dll
#
#
# function PhaseDelay(clip clp, float "freq", float "phi")                       Shift (rotate) phase of audio to a different angle
# function PhaseShift(clip clp, float "freq", float "phi")                       Shift (rotate) phase of audio to a different angle
# function PhaseShift2(clip clp, float "freq", float "freq2", float "phi")       Shift (rotate) phase of audio to a different angle
#
# function PseudoStereo1(clip clp, int "Channel", float "Delay")                  Only DELAY between channels, Delay in Sec
# function PseudoStereo12(clip clp, int "Channel", float "Delay", float "KMix")   DELAY, L=L*k1+R*k2, R=R*k1+L*k2 (Addition)
# function PseudoStereo13(clip clp, int "Channel", float "Delay", float "KMix")   DELAY, L=L*k1-R*k2, R=R*k1-L*k2 (Substraction)
#
# function PseudoStereo2(clip clp, int "Channel", float "LowFreq", float "HighFreq", bool "isDelay") 
#
# function PseudoStereo3(clip clp, int "Channel", bool "isDelay")                 Described: Magazine "Radio" № 6, 1985 year, page 62 (USSR, Russia)
# function PseudoStereo33(clip clp, int "Channel", bool "isDelay")                Described: Magazine "Radio" № 6, 1985 year, page 62 (USSR, Russia)
#
# function PseudoStereo4(clip clp, int "Channel", bool "isDelay")                 US Patent No 6,636,608 B1
# function PseudoStereo43(clip clp, int "Channel", bool "isDelay")                US Patent No 6,636,608 B1
#
# function PseudoStereo5(clip clp, int "Channel", bool "isDelay")                 Analog: Philips chip TDA3810 (sound porcessor)
# function PseudoStereo52(clip clp, int "Channel", bool "isDelay")                Analog: Philips chip TDA3810 (sound porcessor)
#
# function StereoEnhancer(clip clp)                                               Analog: Philips chip TDA3810 (sound porcessor)
#
#
# function StereoTo51(clip clp, bool "is24bit")                                   Build 5.1 Sound Audio track from stereo signal, 
#                                                                                 24 bits output (24 bits is a standard ?)
#
#
# function Dmix3Stereo(clip a)                                                    Downmix sound functions
# function Dmix3Dpl(clip a)                                                       Downmix sound functions
# function Dmix4lStereo(clip a)                                                   Downmix sound functions
# function Dmix4qStereo(clip a)                                                   Downmix sound functions
# function Dmix4sDpl(clip a)                                                      Downmix sound functions
# function Dmix5Stereo(clip a)                                                    Downmix sound functions
# function Dmix5Dpl(clip a)                                                       Downmix sound functions
# function Dmix5Dpl2(clip a)                                                      Downmix sound functions
# function Dmix6Stereo(clip a)                                                    Downmix sound functions
# function Dmix6Dpl(clip a)                                                       Downmix sound functions
# function Dmix6Dpl2(clip a)                                                      Downmix sound functions
# function Dmix6StereoLfe(clip a)                                                 Downmix sound functions
# function Dmix6StereoLfe2(clip a)                                                Downmix sound functions
# function Dmix6DplLfe(clip a)                                                    Downmix sound functions
# function Dmix6Dpl2Lfe(clip a)                                                   Downmix sound functions
#
#
.
Attached Files
File Type: rar stereo2.rar (8.2 KB, 51 views)
__________________
Warm and fuzzy (white and fluffy)

Last edited by Jenyok; 4th April 2013 at 13:55.
Jenyok is offline   Reply With Quote
Old 8th April 2013, 06:35   #27  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
sh0dan
.
One more question to you.
.
What string parameters in SoxFilter(...) function for AVISynth could I use to achive following result "Concert Hall Light, No combine sourse Left аnd Right" ?
.
Thanks.
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 8th April 2013, 13:20   #28  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
New improvments and changes.
.
There are some functions to convert MONO audio signal to PSEUDO STEREO.
There are some functions to convert STEREO audio signal to 5.1 audio signal.
Added new functions to script.
.
Version 1.5 .
.
See description in code section.
See attached RAR file (LINK).
.
Code:
#
# File:     Stereo.avsi
#
#
# Date:     08.04.2013 year
# Version:  1.5
#
#
# License:  GNU GENERAL PUBLIC LICENSE
#
#
# Author:   Jenyok  (Evgeniy Gurovskikh, Russia, Moscow)
# E-Mail:   e_gurovskikh@mail.ru
#
#
# Functions (pseudo Stereo and other sound functions) for AVISynth
#
# For all occasions of life (На все случаи жизни) ...
#
#
# Plugin and Import
#
#   SoxFilter.dll
#
#
#
# function GetLeftChannel(clip clp)
# function GetRightChannel(clip clp)
# function Phase180(clip clp)
#
#
# function PhaseDelay(clip clp, float "freq", float "phi")                        Shift (rotate) phase of audio to a different angle
# function PhaseShift(clip clp, float "freq", float "phi")                        Shift (rotate) phase of audio to a different angle
# function PhaseShift2(clip clp, float "freq", float "freq2", float "phi")        Shift (rotate) phase of audio to a different angle
#
# function MonoToStereo(clip clp)                                                 Convert MONO audio to STEREO audio
# function PseudoStereo1(clip clp, int "Channel", float "Delay")                  Only DELAY between channels, Delay in Sec
# function PseudoStereo12(clip clp, int "Channel", float "Delay", float "KMix")   DELAY, L=L*k1+R*k2, R=R*k1+L*k2 (Addition)
# function PseudoStereo13(clip clp, int "Channel", float "Delay", float "KMix")   DELAY, L=L*k1-R*k2, R=R*k1-L*k2 (Substraction)
#
# function PseudoStereo2(clip clp, int "Channel", float "LowFreq", float "HighFreq", bool "isDelay")
#
# function PseudoStereo3(clip clp, int "Channel", bool "isDelay")                 Described: Magazine "Radio" № 6, 1985 year, page 62 (USSR, Russia)
# function PseudoStereo33(clip clp, int "Channel", bool "isDelay")                Described: Magazine "Radio" № 6, 1985 year, page 62 (USSR, Russia)
#
# function PseudoStereo4(clip clp, int "Channel", bool "isDelay")                 US Patent No 6,636,608 B1
# function PseudoStereo43(clip clp, int "Channel", bool "isDelay")                US Patent No 6,636,608 B1
#
# function PseudoStereo5(clip clp, int "Channel", bool "isDelay")                 Analog: Philips chip TDA3810 (sound porcessor)
# function PseudoStereo52(clip clp, int "Channel", bool "isDelay")                Analog: Philips chip TDA3810 (sound porcessor)
#
#
# function StereoEnhancer(clip clp)                                               Analog: Philips chip TDA3810 (sound porcessor)
#
#
# function StereoTo51(clip clp, bool "is24bit", bool "isStereo")                  Convert STEREO to 5.1 audio, 24 bits output
#                                                                                 
# function UpDialog(clip clp)                                                     Convert STEREO to 5.1 audio
# function UpDialog2(clip clp)                                                    Convert STEREO to 5.1 audio
# function UpAction(clip clp)                                                     Convert STEREO to 5.1 audio
# function UpAction2(clip clp)                                                    Convert STEREO to 5.1 audio
# function UpGerzen(clip clp)                                                     Convert STEREO to 5.1 audio
# function UpFarina(clip clp)                                                     Convert STEREO to 5.1 audio
# function UpMultisonic(clip clp)                                                 Convert STEREO to 5.1 audio
# function UpSoundOnSound(clip clp)                                               Convert STEREO to 5.1 audio
#
#
# function Dmix3Stereo(clip a)                                                    Downmix sound functions
# function Dmix3Dpl(clip a)                                                       Downmix sound functions
# function Dmix4lStereo(clip a)                                                   Downmix sound functions
# function Dmix4qStereo(clip a)                                                   Downmix sound functions
# function Dmix4sDpl(clip a)                                                      Downmix sound functions
# function Dmix5Stereo(clip a)                                                    Downmix sound functions
# function Dmix5Dpl(clip a)                                                       Downmix sound functions
# function Dmix5Dpl2(clip a)                                                      Downmix sound functions
# function Dmix6Stereo(clip a)                                                    Downmix sound functions
# function Dmix6Dpl(clip a)                                                       Downmix sound functions
# function Dmix6Dpl2(clip a)                                                      Downmix sound functions
# function Dmix6StereoLfe(clip a)                                                 Downmix sound functions
# function Dmix6StereoLfe2(clip a)                                                Downmix sound functions
# function Dmix6DplLfe(clip a)                                                    Downmix sound functions
# function Dmix6Dpl2Lfe(clip a)                                                   Downmix sound functions
#
#
.
http://forum.doom9.org/attachment.ph...2&d=1365423562
__________________
Warm and fuzzy (white and fluffy)

Last edited by Jenyok; 8th April 2013 at 13:39.
Jenyok is offline   Reply With Quote
Old 20th May 2013, 14:47   #29  |  Link
der_andi
Registered User
 
der_andi's Avatar
 
Join Date: Jul 2006
Posts: 26
SoxFilter won't accept parameters of transfer function for COMPAND

Hi sh0dan,

there's a small problem with compand. I am using the compand filter in an *.avs for compressing the dynamic range of an audio file. The AVS file is then processed via MeGUI. The relevant script line:

Code:
SoxFilter("compand 0.3,1 6:-70,-60,-20 -8 -90 0.2")
The error message in the MeGUI log says:

Quote:
SoxFilter: (compand) Parameter error:
compander: Odd number of transfer function parameters
Each input value in dB must have a corresponding output value.
As I don't want to compress levels below -70, I omit the first dbOut parameter. But even when I set it to -70, it just says:
Quote:
dB values are relative to maximum input, and, ipso facto, cannot exceed 0
I must admit, I don't know, what the last message means. Am I doing something wrong here or is this a bug in the filter?


Kind regards,
Andi
der_andi is offline   Reply With Quote
Old 29th July 2015, 06:48   #30  |  Link
speedyrazor
Registered User
 
Join Date: Mar 2003
Posts: 194
Hi, I am wanting to change the tempo of an audio file in avisynth but keep the same pitch, is this possible with this plugin, if so, where can I download the latest avisynth plugin version please?

Kind regards.
speedyrazor is offline   Reply With Quote
Old 29th July 2015, 08:12   #31  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Quote:
Originally Posted by speedyrazor View Post
I am wanting to change the tempo of an audio file in avisynth but keep the same pitch
You can do this with the built-in Avisynth function TimeStretch(), using the tempo parameter.

Great for slowing down fast guitar solos to work out how to play them!
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 29th July 2015, 08:26   #32  |  Link
speedyrazor
Registered User
 
Join Date: Mar 2003
Posts: 194
The built-in Avisynth function TimeStretch() is not multi-channel aware, so is not good if you have 6 monos and a stereo, for example, the resulting file sounds all 'phasey'.
speedyrazor is offline   Reply With Quote
Old 29th July 2015, 15:53   #33  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 2,543
Quote:
Originally Posted by speedyrazor View Post
Hi, I am wanting to change the tempo of an audio file in avisynth but keep the same pitch, is this possible with this plugin, if so, where can I download the latest avisynth plugin version please?

Kind regards.
AFAIK version 1.1 beta from 2006 is the latest.

It is quite old, and for your intended purpose the newer SoX effect "tempo" is not included in the plugin. Instead you would have to use the "stretch" effect which has much poorer quality (according to the SoX manual).

If you want to use SoX you should export the audio from the AVS using avs2pipemod or Wavi and then process the WAV file using SoX.exe directly.


Cheers
manolito
manolito is offline   Reply With Quote
Old 2nd August 2015, 20:22   #34  |  Link
thescrapyard
Registered User
 
thescrapyard's Avatar
 
Join Date: Feb 2008
Posts: 54
I use AVStoDVD for converting pretty much any video file to DVD using HCEnc and uses AviSynth, but it doesn't support any kind of upsampling for audio sources to 5.1, but does support downsampling

I've tried understanding how to use sox within avisynth scripts but still can't get to grips the commands needs for sox to process a 2-channel source to pseudo 5.1 audio


If anybody can point me in the right direction how to integrate sox and the script would help me out


The basic avisynth script layout is pretty much standard :

Import("C:\Program Files (x86)\Applications\Video\AVstoDVD\Lib\A2DSource.avsi")
LoadPlugin("C:\Program Files (x86)\Applications\Video\AVstoDVD\Lib\ffms2.dll")

Audio = FFAudioSource("L:\testvideo.avi", track=1)
Video = A2DVideoSource("L:\testvideo.avi", CacheFolder="C:\Temp-AVStoDVD", FrameRateNum=25, FrameRateDen=1, FrameRate=25.000)

Audio = Audio.SSRC(48000) ## Just examples of the audio commands and how they are used to change the audio
Audio = Audio.DelayAudio(0) ##
Audio = Audio.AmplifyDB(0) ##

AudioDub(Video, Audio)


This is the script I'm trying to use :


Import("C:\Program Files (x86)\Applications\Video\AVstoDVD\Lib\A2DSource.avsi")
LoadPlugin("C:\Program Files (x86)\Applications\Video\AVstoDVD\Lib\ffms2.dll")

LoadPlugin("C:\Program Files (x86)\Applications\Video\AVstoDVD\Lib\soxfilter.dll")
Import("C:\Program Files (x86)\Applications\Video\AVstoDVD\Lib\stereo.avsi")


Audio = FFAudioSource("L:\testvideo.avi", track=1)
Video = A2DVideoSource("L:\testvideo.avi", CacheFolder="C:\Temp-AVStoDVD", FrameRateNum=25, FrameRateDen=1, FrameRate=25.000)

## video filters ##

Video = Video.ConvertToYV12()
Video = Video.AddBorders(0,34,0,34)
Video = Video.Spline36Resize(720,576)

## audio filters ##

Audio = Audio.SSRC(48000) ## Just examples of the audio commands and how they are used to change the audio
Audio = Audio.DelayAudio(0) ##
Audio = Audio.AmplifyDB(0) ##


#######################
## sox 2 channel to 5.1
#######################

audio = audio.stereoenhancer()
audio = audio.upaction()



AudioDub(Video, Audio)
thescrapyard is offline   Reply With Quote
Old 8th August 2015, 01:19   #35  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 2,543
Quote:
Originally Posted by thescrapyard View Post
#######################
## sox 2 channel to 5.1
#######################

audio = audio.stereoenhancer()
audio = audio.upaction()

It is not hard to use these functions, but all I get from using them is a terribly distorted 6-ch audio track...

Replace your upmix commands with the following:
Code:
Last = Audio
# stereoenhancer()
Upaction()
Audio = Last
Jenyok's stereo.avsi has a hard coded command at the beginning to load SoxFillter.dll, make sure to delete this line if you load the dll manually.

I tried all the different upmix functions from stereo.avsi, but the result was always distorted. No idea if the culprit lies within SoxFilter.dll or if the MergeChannels(..) command is to blame - I suspect that SoxFilter is the reason.


If you want to check out the script within AVStoDVD keep in mind that the requirements of my Wavi_Mod plugin do also apply, and these are:

1. Make sure that the DirectShow Audio Mixer does not get in the way (disable the audio mixer plus under "Preferences/Misc" make sure that A2S does not alter the mixer settings at runtime.

2. After loading the source edit the title properties and change the number of channels from 2 to 6.

3. Under "View/Edit Title settings / Audio" uncheck auto settings and choose a bitrate of 448 kbps.


Other things to note:
If you use AviSynth normalizing move this command to a position after upmixing. Put it right before the AudioDub command.
With this script the preview will not have audio (at least on my computer).


My conclusion:
Upmixing within AviSynth just does not work. Do the upmixing outside of AviSynth using the Wavi_Mod plugin.


Cheers
manolito

Last edited by manolito; 8th August 2015 at 01:22.
manolito is offline   Reply With Quote
Old 8th August 2015, 14:08   #36  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,559
About stereoenhancer()

Of course is not recommended before Upaction(), stereoenhancer() convert a stereo audio (FL,FR) in another (FL',FR') with:

FL' = Normalize(Normalize(FL,1) + Normalize(SoxFilter(Normalize(FR,1), BandPass 3500 2000), 0.66), 1)
FR' = Normalize(Normalize(FR,1) + Normalize(SoxFilter(Normalize(FL,1), BandPass 3500 2000), 0.66), 1)

Thats enhance only the voice frequencies adding this frequencies from FR to FL and viceversa. But:

1) Destroy original balance normalizing separately FL and FR. Normalice always stereo.
2) Destroy stereo effect in voice frequencies mixing FL and FR.
3) Can produce peak clips when mix (add) integer samples with peaks at 1 and 0.66 dB. Before that mix convert to float samples and after Normalize and convert to integer.

Suggested changes to enhance vocal frequencies:

Vocal = SoxFilter(Input, BandPass 3500 2000).ConvertAudioTofloat()
Input = ConvertAudioTofloat(Input)
MixAudio(Input, Volcal, 1.0, 0.66).Normalice().ConvertAudioTo16bit()

About Upmix functions

I can't understand how the mixes between FL and FR can produce a coherent upmix. Only the UpSoundOnSound function have some sense for me.

BTW remember ConvertAudioTofloat before mix and after normalize.
Also I recommend use always a empty LFE channel, for instance:

lfe = GetLeftChannel(a).Amplify(0)
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Old 8th August 2015, 16:34   #37  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 2,543
Thanks tebasuna for the tips, much appreciated.

But it still does not fix the main problem which is distorted output no matter which upmix method is used.

BTW my previous statement that this calling format
Quote:
Last = Audio
Upaction()
Audio = Last
must be used was wrong. As soon as the "loadplugin" line for SoxFilter is removed from stereo.avsi you can call the upmix function like you did:
Quote:
audio = audio.upaction()
This does also work:
Quote:
upaction(Audio)
Audio = Last

Cheers
manolito
manolito is offline   Reply With Quote
Old 8th August 2015, 20:40   #38  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,559
Quote:
Originally Posted by manolito View Post
But it still does not fix the main problem which is distorted output no matter which upmix method is used.
- I never recommend upmix 2.0 to 5.1, use DSP functions of amplifier/receiver at play time to do the job.

- If still want upmix I recommend the method http://forum.doom9.org/showthread.ph...141#post768141

- I can't recommend AviSynth methods, not always work like desired.
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Old 8th August 2015, 22:47   #39  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 2,543
I do not even have a multichannel Home Theater setup, the only reason I got into this was a request by steptoe (thescrapyard) to integrate this function into AVStoDVD...

Selur translated Northpole's methods for use with SoX here:
http://forum.doom9.org/showthread.ph...73#post1385573

and this works fine within my Wavi_Mod plugin for AVStoDVD. The same method using SoxFilter causes distortion, and I have no idea why.

BTW you mentioned that only the SoundOnSound method makes sense to you. Since I cannot test the results, do you think that this method is "more universal" than the other methods? If so I would add it to my plugin.


Cheers
manolito
manolito is offline   Reply With Quote
Old 9th August 2015, 13:29   #40  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,559
Quote:
Originally Posted by manolito View Post
Selur translated Northpole's methods for use with SoX here:
http://forum.doom9.org/showthread.ph...73#post1385573

and this works fine within my Wavi_Mod plugin for AVStoDVD. The same method using SoxFilter causes distortion, and I have no idea why.
Maybe because first Selur pass is "lower volume to avoid clipping" and next mixes don't clip peaks. AviSynth functions from Jenyok mix int samples and can distort sources with high volume.

The clip can be avoided also using float samples and a final Normalize and Convert to int samples (if necesary, some encoders support float samples).

Quote:
BTW you mentioned that only the SoundOnSound method makes sense to you. Since I cannot test the results, do you think that this method is "more universal" than the other methods? If so I would add it to my plugin.
Well, all (except SoundOnSound) have the same method (with different coeficients cx) to construct the front channels. A input stereo source (FLi,FRi) produce a surround output (FLo,FRo,FCo,...) with:

FLo = mixaudio(FLi, FRi, c1, -c1)
FRo = mixaudio(FRi, FLi, c1, -c1)
FCo = mixaudio(mixaudio(FLi, FLo, 1.0, -1.0), mixaudio(FRi, FRo, 1.0, -1.0), c2, c2)

Like you can see FLo = -FRo, and only the diferences between FLi and FRi are sended to front speakers.

The FCo mix is a trap, seems mix the common parts between FLi and FRi but is not true because:
Fco = c2 * ((FLi - FLo) + (FRi - FRo))
= c2 * ((FLi - c1 * (FLi - FRi)) + (FRi - c1 * (FRi - FLi)))
= c2 * (FLi - c1 * FLi + c1 * FRi + FRi - c1 * FRi + c1 * FLi)
= c2 * (FLi + FRi)

Is equivalent to:
FCo = mixaudio(FLi, FRi, c2, c2)

All audio is sended to the FC speaker. That can cause, for me, two problems:

1) When Normalize (or using low coeficient c2) the overall volume can decrease (only one speaker FC must play the volume than before play two speakers).

2) Many audio systems have the FL-FR speakers better than FC speaker and the overall quality of sound can be reduced.

Like UpSoundOnSound preserve the front channels untouched is my better option.
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 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 14:54.


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