I
- type of the input valuesO
- type of the output valuespublic abstract class AbstractSignalProcessor<I,O> extends Object implements SignalPullProcessor<I,O>, SignalProcessor<I,O>
Convenience super class for both SignalPullProcessor
and
SignalProcessor
.
This class is a good starting point for processors that do not change the flow of data, i.e. don't collect data before they forward it. In other words, each processing step has one input and one output value.
Modifier and Type | Field and Description |
---|---|
protected O |
lastOut |
protected SignalProcessorSupport<O> |
signalProcessorSupport |
Modifier | Constructor and Description |
---|---|
protected |
AbstractSignalProcessor() |
protected |
AbstractSignalProcessor(Object id) |
Modifier and Type | Method and Description |
---|---|
<O2> SignalProcessor<O,O2> |
connectTo(SignalProcessor<O,O2> signalProcessor)
Connects this processor to another processor to forward processed data to.
|
<O2> SignalPullProcessor<O2,I> |
connectTo(SignalPullProcessor<O2,I> source)
Sets the source to use for this
SignalPullProcessor . |
void |
connectTo(SignalSource<I> source)
Sets the source to use for this
SignalPullProcessor . |
<O2> SignalProcessor<O,O2> |
disconnectFrom(SignalProcessor<O,O2> signalProcessor)
Disconnects a child processor.
|
void |
flush()
Flushes this processor and its kids.
|
SignalProcessor<O,?>[] |
getConnectedProcessors()
Lists all connected processors.
|
SignalSource<I> |
getConnectedSource()
Get the current source/generator.
|
Object |
getId()
If no explicit id is set, this simply calls
Object.toString() . |
O |
getOutput()
The last object created by this processor.
|
void |
process(I in)
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 abstract O |
processNext(I input)
Processes the given input and returns some output.
|
O |
read()
Provide the next chunk of output data.
|
void |
reset()
Calls
SignalSource.reset() , if a source is set. |
void |
setId(Object id)
Lets you provide an id.
|
protected O lastOut
protected SignalProcessorSupport<O> signalProcessorSupport
protected AbstractSignalProcessor()
protected AbstractSignalProcessor(Object id)
id
- id to retrieve the last outputSignalProcessor.getId()
public void flush() throws IOException
flush
in interface SignalProcessor<I,O>
IOException
public O getOutput() throws IOException
getOutput
in interface SignalProcessor<I,O>
IOException
public Object getId()
Object.toString()
.getId
in interface SignalProcessor<I,O>
setId(Object)
public void setId(Object id)
id
- some identifierpublic <O2> SignalProcessor<O,O2> connectTo(SignalProcessor<O,O2> signalProcessor)
SignalProcessor
connectTo
in interface SignalProcessor<I,O>
O2
- output type of the processor we want to connect tosignalProcessor
- processorSignalProcessor.disconnectFrom(SignalProcessor)
,
SignalProcessor.getConnectedProcessors()
,
SignalPipeline
public <O2> SignalProcessor<O,O2> disconnectFrom(SignalProcessor<O,O2> signalProcessor)
SignalProcessor
disconnectFrom
in interface SignalProcessor<I,O>
O2
- output type of the processor we want to disconnect fromsignalProcessor
- processorSignalProcessor.connectTo(SignalProcessor)
,
SignalProcessor.getConnectedProcessors()
public SignalProcessor<O,?>[] getConnectedProcessors()
SignalProcessor
getConnectedProcessors
in interface SignalProcessor<I,O>
null
SignalProcessor.disconnectFrom(SignalProcessor)
,
SignalProcessor.connectTo(SignalProcessor)
public <O2> SignalPullProcessor<O2,I> connectTo(SignalPullProcessor<O2,I> source)
SignalPullProcessor
SignalPullProcessor
.
Because the method returns its parameter, it encourages
method chaining
to build processing chains/pipelines.connectTo
in interface SignalPullProcessor<I,O>
O2
- input type of the source processorsource
- sourceSignalPullProcessor
public void connectTo(SignalSource<I> source)
SignalPullProcessor
SignalPullProcessor
.connectTo
in interface SignalPullProcessor<I,O>
source
- sourcepublic SignalSource<I> getConnectedSource()
SignalPullProcessor
getConnectedSource
in interface SignalPullProcessor<I,O>
public void reset()
SignalSource.reset()
, if a source is set.reset
in interface SignalSource<O>
public O read() throws IOException
SignalSource
SignalSource
data, typically an SignalPullProcessor
.read
in interface SignalSource<O>
AudioBuffer
, null
if no more data is availableIOException
- if something goes wrongpublic void process(I in) 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,O>
in
- data to processIOException
- if a processing error occursSignalProcessor.getConnectedProcessors()
protected abstract O processNext(I input) throws IOException
input
- input guaranteed not to be null
.IOException
- if an IO error occursCopyright © 2011–2020 tagtraum industries incorporated. All rights reserved.