SISOFilter
, SISOThread.FilterIO
public class NonCausal extends ConsoleObj implements SISOFilter, SISOThread.FilterIO
Constructor | Description |
---|---|
NonCausal() |
Modifier and Type | Method | Description |
---|---|---|
void |
dispose() |
|
int |
extraN() |
|
float[] |
outIn(float[] sig,
int nzero) |
|
float[] |
outInFilter(float[] sig,
int nzero) |
|
void |
setMs(double sample_ms) |
|
void |
setParams(double[] params) |
setConsoleOut, setSystemOut
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setConsoleOut, setSystemOut
public void setParams(double[] params)
setParams
in interface SISOFilter
params
- is an array of double-precision floating-point values
configuring the filter. These values of type double have sufficient
precision to pass integer values as required. Implementation of this
method typically checks the length of the params array: if params.length
is less than the required number of parameters, default values are used.public void setMs(double sample_ms)
setMs
in interface SISOFilter
sample_ms
- is the time interval between input samples to the filter,
expressed in milliseconds (ms).
Invoking this method computes filter coefficients from the parameters specified in a prior call to setParams(). This action prepares the filter for processing a sequence of input samples supplied to outIn() below.
Reinvoking setMs() not only recalculates the filter coefficients, which is needed if another call is made to setParams. It also reinitializes any buffers holding samples in the "memory" of the filter.
public int extraN()
extraN
in interface SISOFilter
To output nBuf samples of from the filter, for example, nBuf + extraN() samples of input are required. For a non-causal filter that needs to look ahead to input x[n+M] to compute output y[n], extraN() == M immediately after setMs() is called to initialize the filter.
public float[] outInFilter(float[] sig, int nzero)
outInFilter
in interface SISOThread.FilterIO
public void dispose()
public float[] outIn(float[] sig, int nzero)
outIn
in interface SISOFilter
sig
- is the array of input samples.nzero
- extends the input with zero-valued samples. This "padding"
is useful if sig contains a pulse waveform and you want to compute the
"tail" of the filter response past the end of that pulse.You can call outIn(sig, 0) repeatedly and the filter will keep track of the state of the filter between successive calls. A call to setMs() resets the state of the filter to the initial condition, typically that where the input to the filter has been zero until supplying the next values in sig as input.
If you want to apply a non-causal filter with M-sample look ahead to an array sig in one step, and if you want sig.length samples of output to match the sig.length samples of input, invoke
float[] out = mySISOFilter.inOut(sig, mySISOFilter.extraN());
to properly extend input sig with extraN() zeroes to obtain the required number of output samples.