public abstract class WeightedWindowedAudioProcessor extends FixedSizeSampleAudioProcessor
Just one method needs to be overridden in the implementing class and that is the method that generates the window of weights to be applied to the signal. The weighting is then applied automatically. The method will only be called once and lazily.
Modifier and Type | Field and Description |
---|---|
protected boolean |
useWeights
Whether to apply the weights to the incoming signal
|
protected double[] |
weightTable
A table of weights
|
Constructor and Description |
---|
WeightedWindowedAudioProcessor(AudioStream stream,
int sizeRequired)
Chainable constructor.
|
WeightedWindowedAudioProcessor(AudioStream as,
int nSamplesInWindow,
int nSamplesOverlap)
Chainable constructor that takes the size of the window and
the number of samples overlap.
|
WeightedWindowedAudioProcessor(int sizeRequired)
Default constructor for non chainable processing.
|
WeightedWindowedAudioProcessor(int nSamplesInWindow,
int nSamplesOverlap)
Constructor that takes the size of the window and the number of samples
overlap.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
generateWeightTableCache(int length,
int nc)
Generate the cos table cache
|
double[] |
getWeights()
Get the weights used.
|
double |
getWindowSum(int length,
int numChannels)
Get the sum of the Hanning window for the given parameters
|
double |
getWindowSum(SampleChunk samples)
The sum of the Hanning window
|
SampleBuffer |
process(SampleBuffer b)
Process the given sample buffer with the Hanning window.
|
SampleChunk |
process(SampleChunk sample)
Process the given sample chunk.
|
SampleChunk |
processSamples(SampleChunk sample)
Process the Hanning samples.
|
getWindowSize, getWindowStep, isOverlapping, nextSampleChunk, setWindowSize, setWindowStep
getLength, getUnderlyingStream, process, processingComplete, reset, setUnderlyingStream
iterator, seek
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
protected double[] weightTable
protected boolean useWeights
public WeightedWindowedAudioProcessor(int sizeRequired)
sizeRequired
- Size of the window requiredpublic WeightedWindowedAudioProcessor(AudioStream stream, int sizeRequired)
stream
- The audio stream to processsizeRequired
- The size of window required.public WeightedWindowedAudioProcessor(int nSamplesInWindow, int nSamplesOverlap)
nSamplesInWindow
- Samples in windownSamplesOverlap
- Samples in window overlappublic WeightedWindowedAudioProcessor(AudioStream as, int nSamplesInWindow, int nSamplesOverlap)
as
- The chained audio streamnSamplesInWindow
- Samples in windownSamplesOverlap
- Samples in window overlapprotected abstract void generateWeightTableCache(int length, int nc)
length
- The length of the window to generate (per channel)nc
- The number of channels for which to generate a weight tablepublic final SampleChunk process(SampleChunk sample)
FixedSizeSampleAudioProcessor
is
simply to change the shape of the sample chunk. You may override this
method to process the samples directly.process
in class FixedSizeSampleAudioProcessor
sample
- The sample chunk to process.AudioProcessor.process(org.openimaj.audio.SampleChunk)
public final SampleBuffer process(SampleBuffer b)
b
- The sample bufferpublic SampleChunk processSamples(SampleChunk sample)
sample
- The samples to processpublic double getWindowSum(SampleChunk samples)
samples
- A representative samplepublic double getWindowSum(int length, int numChannels)
length
- The length of the windownumChannels
- The number of channels in the windowpublic double[] getWeights()