public abstract class Window extends Object implements CopyingDataProcessor, InlineDataProcessor
Modifier and Type | Field and Description |
---|---|
static int |
BARTLETT |
static int |
BLACKMAN |
protected boolean |
evenLength |
static int |
FLATTOP |
static int |
GAUSS |
static int |
HAMMING |
static int |
HANNING |
protected double |
prescalingFactor |
static int |
RECT |
protected double[] |
window
This array, whose length is the window length, holds the multiplication factors for each sample across the window.
|
Modifier | Constructor and Description |
---|---|
protected |
Window()
Default constructor for subclasses that need to do something themselves before calling initialise().
|
|
Window(int length)
Create a new window of length length.
|
|
Window(int length,
double prescalingFactor)
Create a new window of length length, and apply the given prescaling factor to each point.
|
Modifier and Type | Method and Description |
---|---|
double[] |
apply(double[] src) |
double[] |
apply(double[] src,
int pos)
Apply this window on the given source data array, at the given position.
|
void |
apply(double[] src,
int srcPos,
double[] target,
int targetPos)
Apply this window on the given source data array, at the given position.
|
void |
apply(double[] src,
int srcPos,
double[] target,
int targetPos,
int len)
Apply this window on the given source data array, at the given position.
|
void |
apply(double[] src,
int srcPos,
double[] target,
int targetPos,
int off,
int len)
Apply a part of this window on the given source data array, at the given position.
|
void |
applyInline(double[] data) |
void |
applyInline(double[] data,
int pos) |
void |
applyInline(double[] data,
int pos,
int len)
Apply the window function in-line, i.e.
|
static Window |
get(int windowType,
int length)
Convenience method for requesting a window of the requested type.
|
static Window |
get(int windowType,
int length,
double prescale)
Convenience method for requesting a window of the requested type.
|
static int[] |
getAvailableTypes()
List all available window types
|
double[] |
getCoeffs() |
double[] |
getCoeffsLeftHalf() |
double[] |
getCoeffsRightHalf() |
int |
getLength()
Return the length of this window, in samples.
|
static int |
getTypeByName(String typeName)
For a given type name (e.g., "Hanning window", or "BARTLETT"), return the type code.
|
static String |
getTypeName(int windowType)
Get the type name of a window type.
|
protected abstract void |
initialise()
The initialisation of the window array with multiplication factors corresponding to the specific windowing function.
|
void |
normalize() |
void |
normalize(float val) |
void |
normalizePeakValue(float desiredPeakValue) |
void |
normalizeRange(float minVal,
float maxVal) |
void |
normalizeSquaredSum(float val) |
int |
type()
Return this window's type, as defined by the constants in Window, or -1 if the window is not of a known type.
|
double |
value(int i)
Get the value of the window function at index position i
|
public static final int RECT
public static final int HAMMING
public static final int BLACKMAN
public static final int HANNING
public static final int GAUSS
public static final int BARTLETT
public static final int FLATTOP
protected double prescalingFactor
protected boolean evenLength
protected double[] window
protected Window()
public Window(int length)
length
- the window length, in samples; this should be an odd number, so that the window can be symmetric around the
center point.IllegalArgumentException
- if length is an even number.public Window(int length, double prescalingFactor)
length
- the window length, in samples; this should be an odd number, so that the window can be symmetric around the
center point.prescalingFactor
- a factor to apply to each window point.IllegalArgumentException
- if length is an even number.public double[] apply(double[] src, int pos)
src
- the source data array to apply the windowing function to.pos
- the position from which to apply the windowing functionIllegalArgumentException
- if targetLength is smaller than this window's length as returned by #getLength().public double[] apply(double[] src)
public void applyInline(double[] data, int pos, int len)
applyInline
in interface InlineDataProcessor
data
- datapos
- the position in the data array where to start applying the window function.len
- the amount of data after position pos to process. len must be less than or equal to getLength(). If it is less
than getLength(), a truncated window will be applied.IllegalArgumentException
- if len != getLength().public void applyInline(double[] data, int pos)
public void applyInline(double[] data)
public void apply(double[] src, int srcPos, double[] target, int targetPos)
src
- the source data array to apply the windowing function to.srcPos
- the position in the source array from which to apply the windowing functiontarget
- an array to receive the target data, computed by applying this window to the source data. The target array must
be long enough to receive getLength() bytes after targetPos. if target == source and targetPos == srcPos, then
the window function is applied in-place.targetPos
- targetPosIllegalArgumentException
- if target.length-targetPos is smaller than this window's length as returned by #getLength().public void apply(double[] src, int srcPos, double[] target, int targetPos, int len)
apply
in interface CopyingDataProcessor
src
- the source data array to apply the windowing function to.srcPos
- the position in the source array from which to apply the windowing function. If srcPos is negative, abs(srcPos)
zeroes will be pre-pended before the first data from src is taken into account; if it is greater than
src.length-getLength(), the result will be filled up with trailing zeroes behind the last data.target
- an array to receive the target data, computed by applying this window to the source data. The target array must
be long enough to receive getLength() bytes after targetPos. if target == source and targetPos == srcPos, then
the window function is applied in-place.targetPos
- target Poslen
- the number of samples of the window to apply; this must be less than or equal getLength(). If it is less than
getLength(), a truncated window will be applied.IllegalArgumentException
- if target.length-targetPos is smaller than this window's length as returned by #getLength(), or if len is
greater or equals to getLength.public void apply(double[] src, int srcPos, double[] target, int targetPos, int off, int len)
src
- the source data array to apply the windowing function to.srcPos
- the position in the source array from which to apply the windowing function. If srcPos is negative, abs(srcPos)
zeroes will be pre-pended before the first data from src is taken into account; if it is greater than
src.length-getLength(), the result will be filled up with trailing zeroes behind the last data.target
- an array to receive the target data, computed by applying this window to the source data. The target array must
be long enough to receive getLength() bytes after targetPos. if target == source and targetPos == srcPos, then
the window function is applied in-place.targetPos
- targetPosoff
- the offset from the start of the window from where on the window is to be applied.len
- the number of samples of the window to apply; off+len must be less than or equal getLength().IllegalArgumentException
- if target.length-targetPos is smaller than this window's length as returned by #getLength(), or if len is
greater or equals to getLength.protected abstract void initialise()
public int getLength()
NullPointerException
- if the window has not yet been initialised.public double value(int i)
i
- the index position in the window for which to return the valueIllegalArgumentException
- if i<0 or i>getLength().NullPointerException
- if the window has not yet been initialised.public int type()
public static Window get(int windowType, int length)
windowType
- one of the constants defined in Window.length
- window length (should be an odd number)IllegalArgumentException
- if windowType is not a valid window type, or if length is an even numberpublic static Window get(int windowType, int length, double prescale)
windowType
- one of the constants defined in Window.length
- window length (should be an odd number)prescale
- a prescaling factor applied to all points in the windowIllegalArgumentException
- if windowType is not a valid window type, or if length is an even numberpublic static int[] getAvailableTypes()
public static int getTypeByName(String typeName)
typeName
- the type name.public static String getTypeName(int windowType)
windowType
- a valid window typeIllegalArgumentException
- if windowType is not a valid window typepublic void normalize()
public void normalizePeakValue(float desiredPeakValue)
public void normalize(float val)
public void normalizeSquaredSum(float val)
public void normalizeRange(float minVal, float maxVal)
public double[] getCoeffs()
public double[] getCoeffsLeftHalf()
public double[] getCoeffsRightHalf()
Copyright © 2000–2016 DFKI GmbH. All rights reserved.