From Avisynth wiki
Jump to: navigation, search
Author kiraru2002
Version v0.3
Category Audio filters
License GPLv2


[edit] Description

BeFa: Band Eliminate Filter for Audio. This plugin is designed to remove time signals by removing only specific frequency bands.
This is a ported version of the AviUtl Filter Plug-in made by (MOGI, Kazuhiro).

Note: the following documentation was translated from Japanese with online translators, it may not be 100% accurate.

[edit] Requirements

[edit] Syntax and Parameters

Befa (clip, float "sec", int "freq", int "bandwidth", int "freq2", int "bandwidth2", int "dftsize", int "fade", int "window", int "mode", int "show", int "scale", int "plevel")

clip   =
Input clip; must have audio and only 16-bit audio is supported.

float  sec = 1.3
Specify the time to apply the effect from the beginning in seconds.
Specify in 0-xx.0 seconds. (However, when 0.0 is specified, Befa is inactive).
When mode=1, this parameter has no effect.

int  freq = 1000
Sets the first removal frequency. The unit is Hz.
Specify in the range of 0-(sampling freq/2)Hz. When 0 is specified, the band is not blocked.

int  bandwidth = 40
Sets the width of the removal frequency. Range: 1 to 1024
Units are the number of points in the frequency domain after the discrete Fourier transform.
One unit of width is = sampling frequency / 2 / (2^dftsize) [Hz].
If you specify 10 (1024) for FFT, the data at the sampling frequency of 48000 Hz is:
Real discrete Fourier transform
       0       0.0000 Hz
       1      23.4375 Hz
      40     937.5000 Hz
      41     960.9375 Hz
      42     984.3750 Hz
      43    1007.8125 Hz
      44    1031.2500 Hz
      45    1054.6875 Hz
      46    1071.1250 Hz
    1023   23976.5625 Hz
However, even if the source does not contain a 1 kHz component, it will be decomposed into the form including the signal other than the 43rd frequency component due to the calculation error.
A width value of n means that frequency components in the range ±n are also removed from the desired frequency component.
When width 10 is specified with FFT 10, the frequency components of 773.4375 to 1242.1875 Hz are removed.

int  freq2 = -1
Sets the second removal frequency, the unit is Hz. Range: -1 to (sampling freq/2)Hz.
  • No bandwidth blocking when 0 is specified.
  • If -1 is specified, then (freq * 2)Hz is assumed if freq is 9000Hz or less.
Since the band is independent of the first removal frequency, if the same band as the first removal frequency band is specified, the band is removed twice. If you specify a window and the effect is weak, it may be interesting to try that.

int  bandwidth2 = -1
Set the width of the second removal frequency. Range: 1 to 1024
When -1 is specified, bandwidth2 = (bandwidth+7)/8

int  dftsize = 11
Sets the block size for Fourier transform. Range: 8 to 14
The unit is 2^n, where 9 gives an FFT size of 512, 10 gives 1024, 11 gives 2048, and 12 gives 4096.
The higher the value, the better the frequency resolution, but the less responsive to the change in time.

int  fade = 25
Specify the length of fade-in processing. The unit is %.
If you specify 25 here and the time is set to 2 seconds, it means that the fade-in process will be performed for 0.5 seconds.
When mode=1, it is approximately % of 1 second.

int  window = 1
Specifies whether to multiply the band stop filter by the window function. Range: 0 to 3
  • 0 : none, simply sets the specified frequency band to all zeros.
  • 1 : Hann(Hanning) window
  • 2 : Hamming window
  • 3 : Blackman window (Wide band, lacking sharpness, not suitable for time signal removal)
When specified, the frequency region specified by the width is not set to 0, but it is processed with a gentle characteristic so that it is close to 0 at the center and close to the original signal at the edges.
When checking, use a wider width than usual.

int  mode = 0
Specify the operation mode:
  • 0 : Target (sec) seconds from the beginning, and thereafter through output.
  • 1 : Filter the whole.

int  show = 0
Spectrum graph is displayed.
Actually, it takes a positive or negative value, but it is displayed as an absolute value (gain).
Note that the graph after filtering is before the inverse DFT, so it is not actually cut and output in this way.
  • 0 : Run only
  • 1 : Display the spectrum of frequency band component on the image
  • 2 : Limit the frequency band displayed according to the screen width

int  scale = 1024
Specify the scaling factor for spectrum graph values. Range: 1 to ?
The smaller the value, the more sensitive it becomes. The sensitivity decreases as it gets larger.

int  plevel = 100
Specifies the brightness level of the background image.
Specify from 0 to 100%. If the graph is hard to see, lower the gain to make it easier to see.

[edit] Operation Overview

This filter is implemented as a FIR filter having a linear phase (group delay flat) characteristic by a real discrete Fourier transform (DFT). The product of the input sequence and the impulse response of the filter is convolved and the inverse DFT is performed to obtain the output sequence.

The value specified for dftsize (2048 points by default) is set as one block, and 1/4 blocks are overlapped and the following filter processing is performed. (Overlap method)
In addition, in the overlapping portion, the ratio is linearly reduced in the front block and increased in the rear block, and finally added. It is decomposed into dftzise frequency components by real number DFT, and the band of radius (bandwidth+1) is blocked around the designated frequency band component.

(By default, one bandwidth is sampling frequency/2/dftsize, which is 10Hz at 44.1KHz (11Hz at 48KHz), so 1000Hz is the center of -400 to +400Hz and 2000Hz is the center of -110 to +. Block 110Hz.)

However, if simply blocked by a rectangle, vibration (noise) with a frequency characteristic called the Gibbs phenomenon occurs. Therefore, as a preventive measure, an impulse sequence multiplied by a window function can be used. (Because this is cut off by a finite number of Fourier coefficients, the input sequence is in Audio 16bit format and is not normalized at the time of actual conversion, so 32768 times the actual value is calculated.

[edit] Examples

BeFa with default values filters for 1.3 seconds from the beginning and fades in for 0.3 seconds.


When sampled at 44.1kHz with CT5880 (SB PCI 128 digital), it disappeared with the following setting values:

Befa(show=1, mode=1, freq=990, scale=512, plavel=50)  # Graph display and filter all

If you are filtering in the middle, discard the two frames before and after as buffer areas.

last.trim(0,99) + last.trim(98,202).Befa().trim(2,101) + last.trim(200,0)

[edit] Changelog

Version      Date            Changes
v0.3 2003/09/24 - Fixed bug: It corrects that the blank might be made on audio track, in mode=0. - Fixed bug: It corrects that A did not become effective, in freq2=0. - Changes default value. v0.2 2003/05/05 - Added show=1,2 (power spectrum analysis graph) and mode=1(effect all range) v0.1 2002/12/27 - Ported (from 'Befa ver.0.3.1' created by MOGI, Kazuhiro as AviUtl's filter)

[edit] Archived Downloads

Version Download Mirror

[edit] External Links

Back to External Filters

Personal tools