Normalize

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (added category)
(formatting, links, phrasing)
Line 1: Line 1:
{{Template:FuncDef|Normalize(clip ''clip'' [, float ''volume''] [, bool ''show''])}}
+
<div style="max-width:62em" >
 +
Raises (or lowers) the loudest part of the audio track to a given {{FuncArg|volume}}, which by default is the loudest possible without [[Wikipedia:Clipping_%28audio%29|clipping]]. <br>
 +
This process is called [[Wikipedia:Audio_normalization|''audio normalization'']].
  
Amplifies the entire waveform as much as possible, without clipping.
+
==== Syntax and Parameters ====
 +
{{FuncDef
 +
|Normalize(clip ''clip'' [, float ''volume'' , bool ''show'' ] )
 +
}}
  
By default the clip is amplified to 1.0, that is maximum without clipping - higher values are sure to clip, and create distortions. If one volume is supplied, the other channel will be amplified the same amount.  
+
:{{Par2|volume|float|1.0}}
 +
::Set the amplitude of the loudest audio peak. Default = 1.0, (or 0[[Wikipedia:DBFS|dB]], the maximum level possible without [[Wikipedia:Clipping_%28audio%29|clipping]]).
 +
::For a particular decibel level, use the equation {{FuncArg|volume}} = {{Serif|10}}<sup> {{Serif|'''dB''' / 20}}</sup>
 +
::For example, set a -3dB peak with {{FuncArg|volume}} = 10<sup>-3/20</sup> or 0.7079.
 +
::Where multiple audio channels are present, all channel gains are set in proportion. For example, if the loudest peak on the loudest channel comes to -10dB, by default a gain of +10dB is applied to all channels.
  
Starting from v2.08 there is an optional argument ''show'', if set to "true", it will show the maximum amplification possible without distortions.
+
:{{Par2|show|bool|false}}
 +
::If ''true'', a text overlay (see image below) will show the maximum amplification possible without distortions.
  
Stereo channels are never amplified separately by the filter, even if level between them is very different. The two volumes are applied AFTER the maximum peak has been found, and works in effect as a separate [[Amplify]]. That means if you have two channels that are very different the loudest channel will also be the peak for the lowest. If you want to normalize each channel separately, you must use [[GetChannel]] to split up the stereo source. Audio is converted to 16 bits as a side-result of this filter.
+
==== Examples ====
 +
* Normalize signal to 98%
 +
<div {{BoxWidthIndent|44|2}} >
 +
video = [[AviSource]]("video.avi")
 +
audio = [[WavSource]]("audio.wav").Normalize(0.98)
 +
return [[AudioDub]](video, audio)
 +
</div>
  
'''Examples:'''
+
* Normalize each channel separately (eg for separate language tracks)
 +
<div {{BoxWidthIndent|44|2}} >
 +
video = [[AviSource]]("video.avi")
 +
audio = [[WavSource]]("audio2ch.wav")
 +
left_ch = [[GetChannel]](audio,1).Normalize
 +
right_ch = [[GetChannel]](audio,2).Normalize
 +
return [[AudioDub]](video, [[MergeChannels]](left_ch, right_ch))
 +
</div>
  
# normalizes signal to 98%:
+
* Effect of {{FuncArg|show}}=true with added [[Histogram]], [[Waveform]] and [[Runtime_environment#Special_runtime_variables_and_functions|current_frame]] overlays
  video = AviSource("C:\video.avi")
+
<div {{BoxWidthIndent|44|2}} >
  audio = WavSource("c:\autechre.wav")
+
  LoadPlugin(p + "[[Waveform]]\waveform.dll")  
  audio = Normalize(audio, 0.98)
+
  V=[[BlankClip]](pixel_type="YV12", width=480, height=360).[[Loop]]
  return AudioDub(video, audio)
+
A=[[WavSource]]("music.wav")
 +
  [[AudioDub]](V, A).[[AudioTrim]](0.0, A.[[Clip_properties|AudioDuration]])
 +
[[ScriptClip]](Last,
 +
\ """[[Subtitle]](Last, "frame "+[[Internal_functions#String|String]]([[Runtime_environment#Special_runtime_variables_and_functions|current_frame]]), align=5)""")
 +
Normalize({{FuncArg|volume}}=1.0, {{FuncArg|show}}=true)
 +
[[Histogram]](mode="audiolevels")
 +
[[Waveform]](window=3)
 +
  return Last
 +
</div>
 +
:[[File:NormalizeEx2_v1,0.png]]
 +
:(showing frame 2744, where the loudest peak was detected, but ''Amplify Factor'' is the same for all frames)
  
# normalizes each channel separately:
 
video = AviSource("C:\video.avi")
 
audio = WavSource("bjoer7000.wav")
 
left_ch = GetChannel(audio,1).Normalize()
 
right_ch = GetChannel(audio,2).Normalize()
 
audio = MergeChannels(left_ch, right_ch)
 
return AudioDub(video, audio)
 
 
# normalizes each channel separately:
 
clip = AviSource("D:\Video\rawstuff\stereo-test file_left(-6db).avi")
 
left_ch = GetChannel(clip,1).Normalize()
 
right_ch = GetChannel(clip,2).Normalize()
 
audio = MergeChannels(left_ch, right_ch)
 
AudioDub(clip, audio)
 
  
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 
[[Category:Audio_filters]]
 
[[Category:Audio_filters]]

Revision as of 15:00, 23 February 2016

Raises (or lowers) the loudest part of the audio track to a given volume, which by default is the loudest possible without clipping.
This process is called audio normalization.

Syntax and Parameters

Normalize(clip clip [, float volume , bool show ] )

float  volume = 1.0
Set the amplitude of the loudest audio peak. Default = 1.0, (or 0dB, the maximum level possible without clipping).
For a particular decibel level, use the equation volume = 10 dB / 20
For example, set a -3dB peak with volume = 10-3/20 or 0.7079.
Where multiple audio channels are present, all channel gains are set in proportion. For example, if the loudest peak on the loudest channel comes to -10dB, by default a gain of +10dB is applied to all channels.
bool  show = false
If true, a text overlay (see image below) will show the maximum amplification possible without distortions.

Examples

  • Normalize signal to 98%
video = AviSource("video.avi")
audio = WavSource("audio.wav").Normalize(0.98)
return AudioDub(video, audio)
  • Normalize each channel separately (eg for separate language tracks)
video = AviSource("video.avi")
audio = WavSource("audio2ch.wav")
left_ch = GetChannel(audio,1).Normalize
right_ch = GetChannel(audio,2).Normalize
return AudioDub(video, MergeChannels(left_ch, right_ch))
LoadPlugin(p + "Waveform\waveform.dll") 
V=BlankClip(pixel_type="YV12", width=480, height=360).Loop
A=WavSource("music.wav")
AudioDub(V, A).AudioTrim(0.0, A.AudioDuration)
ScriptClip(Last, 
\ """Subtitle(Last, "frame "+String(current_frame), align=5)""")
Normalize(volume=1.0, show=true)
Histogram(mode="audiolevels")
Waveform(window=3)
return Last
NormalizeEx2 v1,0.png
(showing frame 2744, where the loudest peak was detected, but Amplify Factor is the same for all frames)
Personal tools