marytts.signalproc.filter
Class BandRejectFilter

java.lang.Object
  extended by marytts.signalproc.filter.FIRFilter
      extended by marytts.signalproc.filter.BandRejectFilter
All Implemented Interfaces:
InlineDataProcessor

public class BandRejectFilter
extends FIRFilter

Author:
Marc Schröder

Nested Class Summary
 
Nested classes/interfaces inherited from class marytts.signalproc.filter.FIRFilter
FIRFilter.FIROutput
 
Field Summary
static double DEFAULT_TRANSITIONBANDWIDTH
           
 double lowerNormalisedCutoffFrequency
           
 double upperNormalisedCutoffFrequency
           
 
Fields inherited from class marytts.signalproc.filter.FIRFilter
denumeratorCoefficients, impulseResponseLength, sliceLength, transformedIR
 
Constructor Summary
BandRejectFilter(double lowerNormalisedCutoffFrequencyIn, double upperNormalisedCutoffFrequencyIn)
          Create a new band reject filter with the given normalised cutoff frequencies and a default transition band width.
BandRejectFilter(double lowerNormalisedCutoffFrequencyIn, double upperNormalisedCutoffFrequencyIn, double normalisedTransitionBandwidth)
          Create a new band reject filter with the given normalised cutoff frequencies and a default transition band width.
BandRejectFilter(double lowerNormalisedCutoffFrequencyIn, double upperNormalisedCutoffFrequencyIn, int kernelLength)
          Create a new band reject filter with the given normalised cutoff frequencies and a default transition band width.
 
Method Summary
protected static int bandwidth2kernelLength(double normalisedTransitionBandwidth)
          Convert from normalisedTransitionBandwidth to filter kernel length, using the approximate formula l = 4/bw.
protected static double[] getKernel(double lowerNormalisedCutoffFrequencyIn, double upperNormalisedCutoffFrequencyIn, int kernelLength)
          Compute the band-reject filter kernel, as the sum of a low-pass filter kernel and a high-pass filter kernel.
 double getTransitionBandWidth(int samplingRate)
          For a given sampling rate, return the width of the transition band for this filter, in Hertz.
protected static double kernelLength2bandwidth(int kernelLength)
          Convert from filter kernel length to normalisedTransitionBandwidth, using the approximate formula l = 4/bw.
static void main(java.lang.String[] args)
           
 java.lang.String toString()
           
 
Methods inherited from class marytts.signalproc.filter.FIRFilter
apply, apply, applyInline, getDenumeratorCoefficients, getImpulseResponseLength, initialise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TRANSITIONBANDWIDTH

public static double DEFAULT_TRANSITIONBANDWIDTH

lowerNormalisedCutoffFrequency

public double lowerNormalisedCutoffFrequency

upperNormalisedCutoffFrequency

public double upperNormalisedCutoffFrequency
Constructor Detail

BandRejectFilter

public BandRejectFilter(double lowerNormalisedCutoffFrequencyIn,
                        double upperNormalisedCutoffFrequencyIn)
Create a new band reject filter with the given normalised cutoff frequencies and a default transition band width.

Parameters:
lowerNormalisedCutoffFrequency - the cutoff frequency corresponding to the lower end of the band, expressed as a fraction of the sampling rate. It must be in the range ]0, 0.5[. For example, with a sampling rate of 16000 Hz and a desired cutoff frequency of 4000 Hz, the lowerNormalisedCutoffFrequency would have to be 0.25.
upperNormalisedCutoffFrequency - the cutoff frequency corresponding to the upper end of the band, expressed as a fraction of the sampling rate. It must be in the range ]0, 0.5[. For example, with a sampling rate of 16000 Hz and a desired cutoff frequency of 6000 Hz, the upperNormalisedCutoffFrequency would have to be 0.375.

BandRejectFilter

public BandRejectFilter(double lowerNormalisedCutoffFrequencyIn,
                        double upperNormalisedCutoffFrequencyIn,
                        double normalisedTransitionBandwidth)
Create a new band reject filter with the given normalised cutoff frequencies and a default transition band width.

Parameters:
lowerNormalisedCutoffFrequency - the cutoff frequency corresponding to the lower end of the band, expressed as a fraction of the sampling rate. It must be in the range ]0, 0.5[. For example, with a sampling rate of 16000 Hz and a desired cutoff frequency of 4000 Hz, the lowerNormalisedCutoffFrequency would have to be 0.25.
upperNormalisedCutoffFrequency - the cutoff frequency corresponding to the upper end of the band, expressed as a fraction of the sampling rate. It must be in the range ]0, 0.5[. For example, with a sampling rate of 16000 Hz and a desired cutoff frequency of 6000 Hz, the upperNormalisedCutoffFrequency would have to be 0.375.
normalisedTransitionBandwidth - indicates the desired quality of the filter. The smaller the bandwidth, the more abrupt the cutoff at the cutoff frequency, but also the larger the filter kernel (impulse response) and computationally costly the filter. Usual range of this parameter is [0.002, 0.2].

BandRejectFilter

public BandRejectFilter(double lowerNormalisedCutoffFrequencyIn,
                        double upperNormalisedCutoffFrequencyIn,
                        int kernelLength)
Create a new band reject filter with the given normalised cutoff frequencies and a default transition band width.

Parameters:
lowerNormalisedCutoffFrequency - the cutoff frequency corresponding to the lower end of the band, expressed as a fraction of the sampling rate. It must be in the range ]0, 0.5[. For example, with a sampling rate of 16000 Hz and a desired cutoff frequency of 4000 Hz, the lowerNormalisedCutoffFrequency would have to be 0.25.
upperNormalisedCutoffFrequency - the cutoff frequency corresponding to the upper end of the band, expressed as a fraction of the sampling rate. It must be in the range ]0, 0.5[. For example, with a sampling rate of 16000 Hz and a desired cutoff frequency of 6000 Hz, the upperNormalisedCutoffFrequency would have to be 0.375.
kernelLength - length of the filter kernel (the impulse response). The kernel length must be an odd number. The longer the kernel, the sharper the cutoff, i.e. the narrower the transition band. Typical lengths are in the range of 10-1000.
Throws:
java.lang.IllegalArgumentException - if the kernel length is not a positive, odd number, or if normalisedCutoffFrequency is not in the range between 0 and 0.5.
Method Detail

getTransitionBandWidth

public double getTransitionBandWidth(int samplingRate)
For a given sampling rate, return the width of the transition band for this filter, in Hertz.

Parameters:
samplingRate - the sampling rate, in Hertz.

getKernel

protected static double[] getKernel(double lowerNormalisedCutoffFrequencyIn,
                                    double upperNormalisedCutoffFrequencyIn,
                                    int kernelLength)
Compute the band-reject filter kernel, as the sum of a low-pass filter kernel and a high-pass filter kernel.


bandwidth2kernelLength

protected static int bandwidth2kernelLength(double normalisedTransitionBandwidth)
Convert from normalisedTransitionBandwidth to filter kernel length, using the approximate formula l = 4/bw.

Parameters:
normalisedTransitionBandwidth -
Returns:
the corresponding filter kernel length (guaranteed to be an odd number).

kernelLength2bandwidth

protected static double kernelLength2bandwidth(int kernelLength)
Convert from filter kernel length to normalisedTransitionBandwidth, using the approximate formula l = 4/bw.

Parameters:
kernelLength -
Returns:
the corresponding normalised transition bandwidth.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception