2.11.14 fft_filters
Menu Information
Analysis: Signal Processing: FFT Filters
Brief Information
Perform FFT Filtering
Command Line Usage
1. fft_filters Col(2) cutoff:=5;
2. fft_filters Col(2) filter:=bandpass Freq1:=3 Freq2:=3.6;
3. fft_filters Col(2) filter:=threshold threshold:=1;
4. fft_filters Col(2) filter:=bandblock Freq1:=1.1 Freq2:=1.3 oy:= (Col(3), Col(4));
XFunction Execution Options
Please refer to the page for additional option switches when accessing the xfunction from script
Variables
Display Name

Variable Name

I/O and Type

Default Value

Description

Input

iy

Input
XYRange

<active>

Specifies the input range

Filter Type

filter

Input
int

Low Pass

Specifies the type of the filter
Option list
 low:Low Pass
 Allows only low frequency components to pass
 high:High Pass
 Allows only high frequency components to pass
 bandpass:Band Pass
 Allow only frequency components within a specified range to pass
 bandblock:Band Block
 Allow only frequency components outside a specified range to pass
 threshold:Threshold
 Allow only frequency components whose amplitudes are larger than the threshold to pass
 lowpp :
 This is a parabolic lowpass filter.

Lower Cutoff Frequency

freq1

Input
double

0

This option is available only when the filter type is band pass or band block. It specifies the lower cutoff frequency.

Upper Cutoff Frequency

freq2

Input
double

1

This option is available only when the filter type is band pass or band block. It specifies the upper cutoff frequency.

Cutoff Frequency

cutoff

Input
double

0

This option is available only when the filter type is low pass or high pass. It specifies the cutoff frequency. If no cutoff frequency is specified ("Auto"), an arbitrary cutoff of 25% and 75% of the frequency range of raw data, is used.

Pass Frequency

pass

Input
double

1

This option is available only when the filter type is Low Pass Parabolic. All frequencies below this value will be kept unchanged after being filtered.

Stop Frequency

stop

Input
double

1

This option is available only when the filter type is Low Pass Parabolic. All frequencies above this value will be removed completely.

Threshold

threshold

Input
double

1

This option is available only when the filter type is threshold. It specifies the amplitude threshold.

Keep DC Offset

offset

Input
int

1

This option is available only when the filter type is high pass, band pass or band block. If this option is checked, the DC offset will remain unchanged during the filtering.

Output

oy

Output
XYRange

<new>

Specifies the output
See the syntax here.

Description
Filtering is a process of selecting frequency components from a signal. A FFT filter performs filtering by using Fourier transforms to analyze the frequency components in the input signal.
There are six types of filters available in this function: lowpass, highpass, bandpass, bandblock, lowpass parabolic and threshold. The first four types are actually ideal filters. The lowpass filters block all frequency components above the cutoff frequency, allowing only the low frequency components to pass. Highpass filters are just the opposite: they block frequency components that are below the cutoff frequency. Bandpass filters only allow frequencies within a specific range determined by the lower and upper cutoff frequencies to pass the filters, while bandblock filters remove all frequencies within the chosen range. The lowpass parabolic filter is different from the ideal lowpass filter in that its window function does not jump abruptly at the cutoff frequency. Between the pass frequency and the stop frequency, the window function used to select the frequencies looks like a parabolic curve. On the other hand, you can choose to use the threshold filter, which removes frequencies whose amplitudes are below a specific threshold value.
The dialog of this function allows you to see the realtime preview of the filtered signal when you change the variables. The cutoff frequencies, pass frequency, stop frequency or the threshold can be selected by dragging the lines on the preview pane.
Examples
 To perform low pass filtering using cutoff frequency as 3, to XY data in columns 2 of the active worksheet, use the script command:
fft_filters iy:=col(2) cutoff:=3
 To perform fft_filtering to data using a presaved theme file, save your preferences in the fft_filter dialog, and then execute it by typing the script command as follows, using your own savedtheme title:
fft_filters t "my fft filter theme.oth"
/*
This script remove the high frequency part of a section of sound.
The sample data is located in exe_path\Samples\Signal Processing\.
1. Import a wav file to a new book.
2. Perform lowpass filters on the data to remove the high frequency part of the sound.
3. Export the data to a new wav file.
*/
// Import the wav file
fnin$ = system.path.program$ + "Samples\Signal Processing\sample.wav";
fnout$ = system.path.program$ + "Samples\Signal Processing\Lowpass sample.wav";
newbook s:=0;
newsheet col:=1;
impWav fnin$;
string bkn$=%H;
// Remove the high frequency part
fft_filters [bkn$]1!col(1) cutoff:=2000 oy:=(<input>,<new name:="Low Frequency of the Sound">);
// Set the new wav column's format to be short(2) type for later export
wks.col2.format=1;
wks.col2.numerictype=3;
// Export to a new wav file;
expWav iw:=[bkn$]1! left:=2 fname:=fnout$;
Algorithm
The Fourier transform of the input signal is first computed. Then for low pass, high pass, band pass, band block and low pass parabolic filters, a window (determined by the filter type) is used to multiply the Fourier transform. If 1 is chosen for the variable Keep DC Offset, the first point of the window will be set as 1. For threshold filter, the power of every frequency component is examined. If it is not larger than the threshold, the corresponding frequency component will be discarded. After the altering of the frequencies, a backward or inverse Fourier transform is applied to gain the filtered signal.
Window for low pass filter:
Let be the cutoff frequency. The window function can be expressed by:
Window for high pass filter:
Let be the cutoff frequency. The window function can be expressed by:
Window for band pass filter:
Let be the lower cutoff frequency and be the upper cutoff frequency. The window function can be expressed by:
Window for band block filter
Let be the lower cutoff frequency and be the upper cutoff frequency. The window function can be expressed by:
Window for lowpass parabolic filter
Let be the pass frequency and be the stop frequency. The window function can be expressed by:
Related XFunctions
fft1, ifft1
Keywords:fourier, fft, window, band, block, threshold
