public class Novelty<I extends AudioBuffer> extends AbstractSignalProcessor<I,AudioBuffer>
setPadSimilarityMatrixWithZeros(boolean)
.
The similarity matrix is created using a DistanceFunction
, which is then turned into a
similarity function via a FloatMapFunction
. Both functions can be set via their respective setters.
Modifier and Type | Class and Description |
---|---|
static class |
Novelty.GaussianCheckerboardKernel
Gaussian checkboard kernel.
|
static interface |
Novelty.Kernel
Kernel.
|
static class |
Novelty.NormGaussianCheckerboardKernel
Normalized Gaussian checkerboard kernel.
Aggregate values are divided by the maximal possible value a Novelty.GaussianCheckerboardKernel would deliver
before they are returned, assuming the input values are between -1 and 1. |
Modifier and Type | Field and Description |
---|---|
static FloatMapFunction |
EXP_NEG_DISTANCE
Converts a distance value into a similarity value by calculating
exp(-distance) . |
static FloatMapFunction |
ONE_MINUS_DISTANCE
Converts a distance value into a similarity value by calculating
1 - distance . |
lastOut, signalProcessorSupport
Constructor and Description |
---|
Novelty()
Default processor with a 64 frames normalized Gaussian kernel and no padding.
|
Novelty(Object id)
Default processor with a 64 frames normalized Gaussian kernel and no padding.
|
Novelty(Object id,
DistanceFunction<I> distanceFunction,
boolean padSimilarityMatrixWithZeros)
Default processor with a 64 frames normalized Gaussian checkerboard kernel.
|
Novelty(Object id,
Novelty.Kernel kernel,
DistanceFunction<I> distanceFunction,
boolean padSimilarityMatrixWithZeros)
Processor with
DistanceFunctions.COSINE_DISTANCE and EXP_NEG_DISTANCE mapping to similarity. |
Modifier and Type | Method and Description |
---|---|
static DistanceFunction<float[]> |
createCosineDistanceFunction(int kernelSize,
int minBin,
int maxBin)
Creates a special cosine distance function implementation specifically for how it is called from a
Novelty with a given kernel size. |
void |
flush()
Flushes this processor and its kids.
|
DistanceFunction<I> |
getDistanceFunction()
Returns the distance function used to compute the self similarity matrix.
|
FloatMapFunction |
getDistanceToSimilarityFunction()
Returns the function used to map a distance value (the result of
getDistanceFunction() })
to a similarity value. |
Novelty.Kernel |
getKernel()
Returns the Kernel, a specialized
AggregateFunction . |
boolean |
isPadSimilarityMatrixWithZeros()
Indicates whether the self-similarity matrix is zero padded.
|
void |
process(I buffer)
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. |
protected AudioBuffer |
processNext(I buffer)
Processes the given input and returns some output.
|
AudioBuffer |
read()
Provide the next chunk of output data.
|
void |
reset()
Calls
SignalSource.reset() , if a source is set. |
void |
setDistanceFunction(DistanceFunction<I> distanceFunction)
Sets the distance function used to compute the self similarity matrix.
|
void |
setDistanceToSimilarityFunction(FloatMapFunction distanceToSimilarityFunction)
Sets the mapping function from distance values to similarity values.
|
void |
setKernel(Novelty.Kernel kernel)
Sets the kernel.
|
void |
setPadSimilarityMatrixWithZeros(boolean padSimilarityMatrixWithZeros)
Configures the processor to zero pad the internal self-similarity matrix, so that novelty values
can be computed for the beginning and the end of the matrix' diagonal, where the kernel only partially overlaps
with the matrix.
|
String |
toString() |
connectTo, connectTo, connectTo, disconnectFrom, getConnectedProcessors, getConnectedSource, getId, getOutput, setId
public static final FloatMapFunction ONE_MINUS_DISTANCE
1 - distance
.public static final FloatMapFunction EXP_NEG_DISTANCE
exp(-distance)
.public Novelty(Object id, Novelty.Kernel kernel, DistanceFunction<I> distanceFunction, boolean padSimilarityMatrixWithZeros)
DistanceFunctions.COSINE_DISTANCE
and EXP_NEG_DISTANCE
mapping to similarity.id
- idkernel
- kerneldistanceFunction
- distance functionpadSimilarityMatrixWithZeros
- true or falsepublic Novelty(Object id, DistanceFunction<I> distanceFunction, boolean padSimilarityMatrixWithZeros)
id
- iddistanceFunction
- distance functionpadSimilarityMatrixWithZeros
- true or falseNovelty.NormGaussianCheckerboardKernel
public Novelty(Object id)
id
- idpublic Novelty()
public boolean isPadSimilarityMatrixWithZeros()
public void setPadSimilarityMatrixWithZeros(boolean padSimilarityMatrixWithZeros)
padSimilarityMatrixWithZeros
- true or falsepublic Novelty.Kernel getKernel()
AggregateFunction
.public void setKernel(Novelty.Kernel kernel)
kernel
- kernelpublic DistanceFunction<I> getDistanceFunction()
DistanceFunctions.COSINE_DISTANCE
public void setDistanceFunction(DistanceFunction<I> distanceFunction)
distanceFunction
- distance functioncreateCosineDistanceFunction(int, int, int)
public FloatMapFunction getDistanceToSimilarityFunction()
getDistanceFunction()
})
to a similarity value.
The default value is EXP_NEG_DISTANCE
public void setDistanceToSimilarityFunction(FloatMapFunction distanceToSimilarityFunction)
distanceToSimilarityFunction
- map functionprotected AudioBuffer processNext(I buffer) throws IOException
AbstractSignalProcessor
processNext
in class AbstractSignalProcessor<I extends AudioBuffer,AudioBuffer>
buffer
- input guaranteed not to be null
.IOException
- if an IO error occurspublic void reset()
AbstractSignalProcessor
SignalSource.reset()
, if a source is set.reset
in interface SignalSource<AudioBuffer>
reset
in class AbstractSignalProcessor<I extends AudioBuffer,AudioBuffer>
public AudioBuffer read() throws IOException
SignalSource
SignalSource
data, typically an SignalPullProcessor
.read
in interface SignalSource<AudioBuffer>
read
in class AbstractSignalProcessor<I extends AudioBuffer,AudioBuffer>
AudioBuffer
, null
if no more data is availableIOException
- if something goes wrongpublic void process(I buffer) 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,AudioBuffer>
process
in class AbstractSignalProcessor<I extends AudioBuffer,AudioBuffer>
buffer
- data to processIOException
- if a processing error occursSignalProcessor.getConnectedProcessors()
public void flush() throws IOException
AbstractSignalProcessor
flush
in interface SignalProcessor<I extends AudioBuffer,AudioBuffer>
flush
in class AbstractSignalProcessor<I extends AudioBuffer,AudioBuffer>
IOException
- if a processing error occurspublic static DistanceFunction<float[]> createCosineDistanceFunction(int kernelSize, int minBin, int maxBin)
Novelty
with a given kernel size.kernelSize
- kernel sizeminBin
- min binmaxBin
- max binCopyright © 2011–2020 tagtraum industries incorporated. All rights reserved.