public class FrameOverlapAddSource extends BlockwiseDoubleDataSource
---|++++++++ --|+++++++++ -|++++++++++ |+++++++++++ ++++++++++++ ++++++++++++ ++++++++++++ +++++++++++| ++++++++++|- +++++++++|-- ++++++++|---With a synthesis frameshift of 1/4th of the frame length, implying that four frames need to be overlapped to reconstruct the signal, this becomes:
---|++++++++ --|+++++++++ -|++++++++++ |+++++++++++ *** first usable ++++++++++++ ++++++++++++ ++++++++++++ +++++++++++| ++++++++++|- +++++++++|-- ++++++++|--- *** last usable: first 3 of thisIt can be seen that three times the input frameshift needs to be zero-padded before the signal, and discarded to reach proper signal reconstruction. Similarly, the last frame to be used is the one to which three times the input shift has been zero-padded; only the first output frameshift samples of it can be used. 2. Assuming an input frameshift of 1/24th of the frame length, and a signal length equal to (frame length+4*frameshift), we cover the input data as follows: (+=valid data points, -=zero, |=valid data point at start/end of input)
--------|+++++++++++++++ -------|++++++++++++++++ ------|+++++++++++++++++ -----|++++++++++++++++++ ----|+++++++++++++++++++ ---|++++++++++++++++++++ --|+++++++++++++++++++++ -|++++++++++++++++++++++ |+++++++++++++++++++++++ ++++++++++++++++++++++++ ++++++++++++++++++++++++ ++++++++++++++++++++++++ +++++++++++++++++++++++| ++++++++++++++++++++++|- +++++++++++++++++++++|-- ++++++++++++++++++++|--- +++++++++++++++++++|---- ++++++++++++++++++|----- +++++++++++++++++|------ ++++++++++++++++|------- +++++++++++++++|--------With a synthesis frameshift of 1/8th of the frame length, implying that eight frames need to be overlapped to reconstruct the signal, this becomes:
-------|++++++++++++++++ ------|+++++++++++++++++ -----|++++++++++++++++++ ----|+++++++++++++++++++ ---|++++++++++++++++++++ --|+++++++++++++++++++++ -|++++++++++++++++++++++ |+++++++++++++++++++++++ *** first usable ++++++++++++++++++++++++ ++++++++++++++++++++++++ ++++++++++++++++++++++++ +++++++++++++++++++++++| ++++++++++++++++++++++|- +++++++++++++++++++++|-- ++++++++++++++++++++|--- +++++++++++++++++++|---- ++++++++++++++++++|----- +++++++++++++++++|------ ++++++++++++++++|------- *** last usable: first 3 of thisIt can be seen that seven times the input frameshift needs to be zero-padded before the signal, and discarded to reach proper signal reconstruction. Similarly, the last frame to be used is the one to which seven times the input shift has been zero-padded; only the first output frameshift samples of it can be used. 3. Assuming an input frameshift of 1/3rd of the frame length, and a signal length equal to (frame length+4*frameshift), we cover the input data as follows: (+=valid data points, -=zero, |=valid data point at start/end of input)
--------|+++ ----|+++++++ |+++++++++++ ++++++++++++ ++++++++++++ ++++++++++++ +++++++++++| +++++++|---- +++|--------With a synthesis frameshift of 1/4th of the frame length, implying that four frames need to be overlapped to reconstruct the signal, this becomes:
--------|+++ ----|+++++++ |+++++++++++ ++++++++++++ *** first usable ++++++++++++ ++++++++++++ +++++++++++| +++++++|---- +++|-------- *** last usable: first 3 of thisIt can be seen that only two times the input frameshift needs to be zero-padded before the signal; nevertheless, the first three frames need to be procesesed but discarded to reach proper signal reconstruction. Similarly, the last frame to be used is the one to which two times the input shift has been zero-padded; only the first output frameshift samples of it can be used. 4. Assuming an input frameshift of 1/2rd of the frame length, and a signal length equal to (frame length+4*frameshift), we cover the input data as follows: (+=valid data points, -=zero, |=valid data point at start/end of input)
------|+++++ |+++++++++++ ++++++++++++ ++++++++++++ ++++++++++++ +++++++++++| +++++|------With a synthesis frameshift of 1/4th of the frame length, implying that four frames need to be overlapped to reconstruct the signal, this becomes:
------|+++++ |+++++++++++ ++++++++++++ ++++++++++++ *** first usable ++++++++++++ +++++++++++| +++++|------ *** last usable: first 3 of thisIt can be seen that only two times the input frameshift needs to be zero-padded before the signal; nevertheless, the first three frames need to be procesesed but discarded to reach proper signal reconstruction. Similarly, the last frame to be used is the one to which two times the input shift has been zero-padded; only the first output frameshift samples of it can be used. Generalising: May ro be the output overlap ratio, ro = output frameshift / framelength, and ri be the input overlap ratio, ri = input frameshift / framelength, then n = 1/(1-ro) is the number of frames to be overlapped so that the signal is reconstructed. The amount of zeroes to be padded before and after the signal is (n-1)*input frameshift, or in the case of speeding up, (m-1)*input frameshift where m = 1/ri. (n-1) frames must be read and discarded before the actual data. If the signal length can be described as l = framelength + n*frameshift, exactly output frameshift samples are to be used from the last frame. If the signal is a bit shorter, i.e. l = framelength + n*frameshift - delta, then (output frameshift - delta) samples can be read from the last frame.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_WINDOWTYPE |
protected FrameProvider |
frameProvider |
protected double[] |
memory |
protected Window |
outputWindow |
protected InlineDataProcessor |
processor |
blockSize
buf, dataProcessor, DEFAULT_BUFFERSIZE, readPos, writePos
dataLength, inputSource
NOT_SPECIFIED
Modifier | Constructor and Description |
---|---|
protected |
FrameOverlapAddSource()
Default constructor for subclasses who want to call initialise() themselves.
|
|
FrameOverlapAddSource(DoubleDataSource inputSource,
int windowType,
boolean applySynthesisWindow,
int frameLength,
int samplingRate,
InlineDataProcessor processor) |
|
FrameOverlapAddSource(DoubleDataSource inputSource,
int frameLength,
int samplingRate,
InlineDataProcessor processor) |
Modifier and Type | Method and Description |
---|---|
protected int |
getBlockSize()
Provide the size of the next block.
|
protected int |
getInputFrameshift(int outputFrameshift) |
protected double[] |
getNextFrame()
Get the next frame of input data.
|
boolean |
hasMoreData()
Whether or not any more data can be read from this data source.
|
protected void |
initialise(DoubleDataSource inputSource,
int windowType,
boolean applySynthesisWindow,
int frameLength,
int samplingRate,
InlineDataProcessor processor)
To be called by constructor in order to set up this frame overlap add source.
|
static void |
main(String[] args) |
protected void |
prepareBlock()
Prepare one block of data for output.
|
protected int |
readBlock(double[] target,
int targetPos)
Provide a block of data.
|
readIntoBuffer
available, bufferSpaceLeft, compact, currentlyInBuffer, getData, increaseBufferSize
getAllData, getData, getData, getDataLength
public static final int DEFAULT_WINDOWTYPE
protected FrameProvider frameProvider
protected Window outputWindow
protected double[] memory
protected InlineDataProcessor processor
protected FrameOverlapAddSource()
public FrameOverlapAddSource(DoubleDataSource inputSource, int frameLength, int samplingRate, InlineDataProcessor processor)
public FrameOverlapAddSource(DoubleDataSource inputSource, int windowType, boolean applySynthesisWindow, int frameLength, int samplingRate, InlineDataProcessor processor)
protected void initialise(DoubleDataSource inputSource, int windowType, boolean applySynthesisWindow, int frameLength, int samplingRate, InlineDataProcessor processor)
inputSource
- input sourcewindowType
- window typeapplySynthesisWindow
- apply synthesis windowframeLength
- frame lengthsamplingRate
- sampling rateprocessor
- processorprotected double[] getNextFrame()
protected void prepareBlock()
prepareBlock
in class BlockwiseDoubleDataSource
protected int getBlockSize()
BlockwiseDoubleDataSource
getBlockSize
in class BlockwiseDoubleDataSource
protected int readBlock(double[] target, int targetPos)
readBlock
in class BlockwiseDoubleDataSource
target
- targettargetPos
- posprotected int getInputFrameshift(int outputFrameshift)
public boolean hasMoreData()
BufferedDoubleDataSource
hasMoreData
in interface DoubleDataSource
hasMoreData
in class BufferedDoubleDataSource
Copyright © 2000–2016 DFKI GmbH. All rights reserved.