public class SelfSimilarity<I extends AudioBuffer> extends Object implements SignalProcessor<I,AudioMatrix>
AudioBuffer
features.
The actual value is produced on flush()
.Modifier and Type | Field and Description |
---|---|
static int |
FULL_MATRIX |
Constructor and Description |
---|
SelfSimilarity()
Self similarity processor using a full matrix (i.e.
|
SelfSimilarity(int bandwidth)
Self similarity processor with a limited bandwidth around the main diagonal.
|
SelfSimilarity(Object id)
Self similarity processor using a full matrix (i.e.
|
SelfSimilarity(Object id,
int bandwidth,
DistanceFunction<I> distanceFunction)
Self similarity processor with a limited bandwidth around the main diagonal.
|
Modifier and Type | Method and Description |
---|---|
<O2> SignalProcessor<AudioMatrix,O2> |
connectTo(SignalProcessor<AudioMatrix,O2> signalProcessor)
Connects this processor to another processor to forward processed data to.
|
protected MutableMatrix |
createMatrix(int previousLength,
int length,
int bandwidth)
By default this creates a symmetric,
float -backed, zero-padded Matrix . |
<O2> SignalProcessor<AudioMatrix,O2> |
disconnectFrom(SignalProcessor<AudioMatrix,O2> signalProcessor)
Disconnects a child processor.
|
void |
flush()
Asks to complete all pending operations.
|
int |
getBandwidth()
Matrix bandwidth for matrices created by
createMatrix(int, int, int) . |
SignalProcessor<AudioMatrix,?>[] |
getConnectedProcessors()
Lists all connected processors.
|
Object |
getId()
Arbitrary object to identify a processor.
|
AudioMatrix |
getOutput()
First calls
SignalProcessor.flush() , then returns the pending output, should there be any. |
boolean |
isCopyOnMatrixEnlargement()
Indicates whether the similarity matrix should be copied or enlarged
(see
Matrix.enlarge(com.tagtraum.jipes.math.Matrix) )
with a new matrix. |
void |
process(I input)
Asks this processor to work on the provided data and pipe the
output to the connected processors' own
SignalProcessor.process(Object) method.Implementing methods must not modify or hold on to the provided data. |
void |
setBandwidth(int bandwidth)
Sets the maximal distance between two
AudioBuffer s that is still compared and
computed for the AudioMatrix . |
void |
setCopyOnMatrixEnlargement(boolean copyOnMatrixEnlargement)
Copy the whole matrix, if we need to increase its size?
|
void |
setDistanceFunction(DistanceFunction<I> distanceFunction)
Sets the distance function used to compute the self similarity matrix.
|
void |
setId(Object id) |
public static final int FULL_MATRIX
public SelfSimilarity(int bandwidth)
bandwidth
- bandwidthpublic SelfSimilarity(Object id, int bandwidth, DistanceFunction<I> distanceFunction)
id
- iddistanceFunction
- distance functionpublic SelfSimilarity(Object id)
id
- idpublic SelfSimilarity()
public void setId(Object id)
public void setBandwidth(int bandwidth)
AudioBuffer
s that is still compared and
computed for the AudioMatrix
. If this is set to a positive value, a
SymmetricBandMatrix
is used internally to preserve memory
even when the input is long.bandwidth
- bandwidth, must be odd. Values 0 or less indicate full bandwidthSymmetricBandMatrix
,
createMatrix(int, int, int)
public int getBandwidth()
createMatrix(int, int, int)
.SymmetricBandMatrix
public void setDistanceFunction(DistanceFunction<I> distanceFunction)
distanceFunction
- distance functionDistanceFunctions.createCosineDistanceFunction()
public boolean isCopyOnMatrixEnlargement()
Matrix.enlarge(com.tagtraum.jipes.math.Matrix)
)
with a new matrix.public void setCopyOnMatrixEnlargement(boolean copyOnMatrixEnlargement)
copyOnMatrixEnlargement
- if true, the similarity matrix will be copied, if we need to increase its sizeisCopyOnMatrixEnlargement()
public void process(I input) throws IOException
SignalProcessor
SignalProcessor.process(Object)
method.Object.clone()
method.
It is the responsibility of implementing classes to call the SignalProcessor.process(Object)
method of any connected processors. To manage connected processors classes may want
to use a SignalProcessorSupport
instance.process
in interface SignalProcessor<I extends AudioBuffer,AudioMatrix>
input
- data to processIOException
- if a processing error occursSignalProcessor.getConnectedProcessors()
public void flush() throws IOException
SignalProcessor
SignalProcessor.flush()
method.flush
in interface SignalProcessor<I extends AudioBuffer,AudioMatrix>
IOException
- if a processing error occursprotected MutableMatrix createMatrix(int previousLength, int length, int bandwidth)
float
-backed, zero-padded Matrix
.
If a positive bandwidth (see getBandwidth()
) is set, the matrix may be banded.
You may override this method to use a different matrix implementation,
e.g. one that is backed by an UnsignedByteBackingBuffer
to preserve memory.previousLength
- the length of the previously used matrix, in essence information about the part
that does not need to be covered by the new matrix (may be ignored).length
- lengthbandwidth
- bandwidthpublic AudioMatrix getOutput() throws IOException
SignalProcessor
SignalProcessor.flush()
, then returns the pending output, should there be any.
Note that this call may only succeed once to preserve memory.getOutput
in interface SignalProcessor<I extends AudioBuffer,AudioMatrix>
null
is returnedIOException
- if a processing error occurspublic Object getId()
SignalProcessor
SignalProcessor.getOutput()
.getId
in interface SignalProcessor<I extends AudioBuffer,AudioMatrix>
SignalPump.pump()
public <O2> SignalProcessor<AudioMatrix,O2> disconnectFrom(SignalProcessor<AudioMatrix,O2> signalProcessor)
SignalProcessor
disconnectFrom
in interface SignalProcessor<I extends AudioBuffer,AudioMatrix>
O2
- output type of the processor we want to disconnect fromsignalProcessor
- processorSignalProcessor.connectTo(SignalProcessor)
,
SignalProcessor.getConnectedProcessors()
public SignalProcessor<AudioMatrix,?>[] getConnectedProcessors()
SignalProcessor
getConnectedProcessors
in interface SignalProcessor<I extends AudioBuffer,AudioMatrix>
null
SignalProcessor.disconnectFrom(SignalProcessor)
,
SignalProcessor.connectTo(SignalProcessor)
public <O2> SignalProcessor<AudioMatrix,O2> connectTo(SignalProcessor<AudioMatrix,O2> signalProcessor)
SignalProcessor
connectTo
in interface SignalProcessor<I extends AudioBuffer,AudioMatrix>
O2
- output type of the processor we want to connect tosignalProcessor
- processorSignalProcessor.disconnectFrom(SignalProcessor)
,
SignalProcessor.getConnectedProcessors()
,
SignalPipeline
Copyright © 2011–2020 tagtraum industries incorporated. All rights reserved.