📄 anwtfilter.java
字号:
* allows to filter columns of a 2-D signal, when it is stored in a line
* by line order in inSig, without having to copy the data, in this case
* the inStep argument should be the line width.</p>
*
* <p>The low-pass output signal is placed in the lowSig array. The lowOff
* and lowStep arguments are analogous to the inOff and inStep ones, but
* they apply to the lowSig array. The lowSig array must be long enough to
* hold the low-pass output signal.</p>
*
* <p>The high-pass output signal is placed in the highSig array. The
* highOff and highStep arguments are analogous to the inOff and inStep
* ones, but they apply to the highSig array. The highSig array must be
* long enough to hold the high-pass output signal.</p>
*
* @param inSig This is the array that contains the input signal. It must
* be of the correct type (e.g., it must be int[] if getDataType() returns
* TYPE_INT).
*
* @param inOff This is the index in inSig of the first sample to filter.
*
* @param inLen This is the number of samples in the input signal to
* filter.
*
* @param inStep This is the step, or interleave factor, of the input
* signal samples in the inSig array. See above.
*
* @param lowSig This is the array where the low-pass output signal is
* placed. It must be of the same type as inSig and it should be long
* enough to contain the output signal.
*
* @param lowOff This is the index in lowSig of the element where to put
* the first low-pass output sample.
*
* @param lowStep This is the step, or interleave factor, of the low-pass
* output samples in the lowSig array. See above.
*
* @param highSig This is the array where the high-pass output signal is
* placed. It must be of the same type as inSig and it should be long
* enough to contain the output signal.
*
* @param highOff This is the index in highSig of the element where to put
* the first high-pass output sample.
*
* @param highStep This is the step, or interleave factor, of the
* high-pass output samples in the highSig array. See above.
*
* @see WaveletFilter#getDataType
* */
public abstract
void analyze_hpf(Object inSig, int inOff, int inLen, int inStep,
Object lowSig, int lowOff, int lowStep,
Object highSig, int highOff, int highStep);
/**
* Returns the time-reversed low-pass synthesis waveform of the filter,
* which is the low-pass filter. This is the time-reversed impulse
* response of the low-pass synthesis filter. It is used to calculate the
* L2-norm of the synthesis basis functions for a particular subband (also
* called energy weight).
*
* <p>The returned array may not be modified (i.e. a reference to the
* internal array may be returned by the implementation of this
* method).</p>
*
* @return The time-reversed low-pass synthesis waveform of the filter.
* */
public abstract float[] getLPSynthesisFilter();
/**
* Returns the time-reversed high-pass synthesis waveform of the filter,
* which is the high-pass filter. This is the time-reversed impulse
* response of the high-pass synthesis filter. It is used to calculate the
* L2-norm of the synthesis basis functions for a particular subband (also
* called energy weight).
*
* <p>The returned array may not be modified (i.e. a reference to the
* internal array may be returned by the implementation of this
* method).</p>
*
* @return The time-reversed high-pass synthesis waveform of the filter.
* */
public abstract float[] getHPSynthesisFilter();
/**
* Returns the equivalent low-pass synthesis waveform of a cascade of
* filters, given the syhthesis waveform of the previous stage. This is
* the result of upsampling 'in' by 2, and concolving it with the low-pass
* synthesis waveform of the filter. The length of the returned signal is
* 2*in_l+lp_l-2, where in_l is the length of 'in' and 'lp_l' is the
* lengthg of the low-pass synthesis filter.
*
* <p>The length of the low-pass synthesis filter is
* getSynLowNegSupport()+getSynLowPosSupport().</p>
*
* @param in The synthesis waveform of the previous stage.
*
* @param out If non-null this array is used to store the resulting
* signal. It must be long enough, or an IndexOutOfBoundsException is
* thrown.
*
* @see #getSynLowNegSupport
* @see #getSynLowPosSupport
* */
public float[] getLPSynWaveForm(float in[], float out[]) {
return upsampleAndConvolve(in,getLPSynthesisFilter(),out);
}
/**
* Returns the equivalent high-pass synthesis waveform of a cascade of
* filters, given the syhthesis waveform of the previous stage. This is
* the result of upsampling 'in' by 2, and concolving it with the
* high-pass synthesis waveform of the filter. The length of the returned
* signal is 2*in_l+hp_l-2, where in_l is the length of 'in' and 'hp_l' is
* the lengthg of the high-pass synthesis filter.
*
* <p>The length of the high-pass synthesis filter is
* getSynHighNegSupport()+getSynHighPosSupport().</p>
*
* @param in The synthesis waveform of the previous stage.
*
* @param out If non-null this array is used to store the resulting
* signal. It must be long enough, or an IndexOutOfBoundsException is
* thrown.
*
* @see #getSynHighNegSupport
* @see #getSynHighPosSupport
* */
public float[] getHPSynWaveForm(float in[], float out[]) {
return upsampleAndConvolve(in,getHPSynthesisFilter(),out);
}
/**
* Returns the signal resulting of upsampling (by 2) the input signal 'in'
* and then convolving it with the time-reversed signal 'wf'. The returned
* signal is of length l_in*2+l_wf-2, where l_in is the length of 'in',
* and l_wf is the length of 'wf'.
*
* <p>The 'wf' signal has to be already time-reversed, therefore only a
* dot-product is performed (instead of a convolution). This is equivalent
* to convolving with the non-time-reversed 'wf' signal.</p>
*
* @param in The signal to upsample and filter. If null it is considered
* to be a dirac.
*
* @param wf The time-reversed impulse response used for filtering.
*
* @param out If non-null this array is used to store the resulting
* signal, it must be of length in.length*2+wf.length-2 at least. An
* IndexOutOfBoundsException is thrown if this is not the case.
*
* @return The resulting signal, of length in.length*2+wf.length-2
* */
private static
float[] upsampleAndConvolve(float in[], float wf[], float out[]) {
// NOTE: the effective length of the signal 'in' upsampled by
// 2 is 2*in.length-1 (not 2*in.length), so the resulting signal
// (after convolution) is of length 2*in.length-1+wf.length-1,
// which is 2*in.length+wf.length-2
int i,k,j;
float tmp;
int maxi,maxk;
// If in null, then simulate dirac
if (in == null) {
in = new float[1];
in[0] = 1.0f;
}
// Get output buffer if necessary
if (out == null) {
out = new float[in.length*2+wf.length-2];
}
// Convolve the signals
for (i=0, maxi=in.length*2+wf.length-2; i<maxi; i++) {
tmp = 0.0f;
// Calculate limits of loop below
k = (i-wf.length+2)/2;
if (k<0) k = 0;
maxk = i/2+1;
if (maxk > in.length) maxk = in.length;
// Calculate dot-product with upsampling of 'in' by 2.
for (j = 2*k-i+wf.length-1; k<maxk; k++, j+=2) {
tmp += in[k]*wf[j];
}
// Store result
out[i] = tmp;
}
return out;
}
/**
* Returns the type of filter used according to the FilterTypes interface.
*
* @see FilterTypes
*
* @return The filter type.
* */
public abstract int getFilterType();
/**
* Returns the parameters that are used in this class and implementing
* classes. It returns a 2D String array. Each of the 1D arrays is for a
* different option, and they have 3 elements. The first element is the
* option name, the second one is the synopsis, the third one is a long
* description of what the parameter is and the fourth is its default
* value. The synopsis or description may be 'null', in which case it is
* assumed that there is no synopsis or description of the option,
* respectively. Null may be returned if no options are supported.
*
* @return the options name, their synopsis and their explanation, or null
* if no options are supported.
* */
public static String[][] getParameterInfo() {
return pinfo;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -