Request for new data processors
Hi,
I'd like to propose two new data processors which I think will be useful but are cumbersome to implement with the current DSL.
1. Buffer (or delay) filter
- When a buffer in an Empty state receives an upstream value, it just stores the data token, changes it's state to Non-Empty and doesn't emit anything to the next processor in the route.
- When a buffer in a non-empty state receives an upstream value, it yields the previously stored value downstream, and stores the new value.
- Users can use .setState(..) to control Empty/Non-Empty and stored value
2. Const transformer
Given an array of constants, the processor ignores the input data and emits the array values upstream - one by one in a cycle
For example:
.process(new Const(new byte[]{1})) will always emit 1 upstream
.process(new Const(new float[]{1,2,3,4})) will emit 1,2,3,4,1,...
Thanks
I'd like to propose two new data processors which I think will be useful but are cumbersome to implement with the current DSL.
1. Buffer (or delay) filter
- When a buffer in an Empty state receives an upstream value, it just stores the data token, changes it's state to Non-Empty and doesn't emit anything to the next processor in the route.
- When a buffer in a non-empty state receives an upstream value, it yields the previously stored value downstream, and stores the new value.
- Users can use .setState(..) to control Empty/Non-Empty and stored value
2. Const transformer
Given an array of constants, the processor ignores the input data and emits the array values upstream - one by one in a cycle
For example:
.process(new Const(new byte[]{1})) will always emit 1 upstream
.process(new Const(new float[]{1,2,3,4})) will emit 1,2,3,4,1,...
Thanks
This discussion has been closed.
Comments
So, Sample(1) does exactly what I wanted for buffer.
On a side note, hooking Sample directly to a log .process( new Sample((byte) 1)).log("LOG") raises exception when downloading the logs. http://pastebin.com/JzTGeX2Q
Regarding the second one, I wanted it to be useful for directly defining convolution kernels as an array of float values. As you suggested, it can now be implemented as counter -> mod N -> comparison branches, but it doesn't scale well.
Here are the things I've tried http://pastebin.com/Ct4KrJHM in case it can be reproduced.
Might as well be specific to my app/board
- Case 1, Always emit a constant.
- To always emit "1", the comparison filter would work for this now.
- The general case, emit "x", I propose adding a constant output mode to the simplemath filter.
- Case 2, Emit a sequence of outputs.
- For the sequential case, we had considered adding the "count" to the timer notifications. This would cover upcounter and downcounter use cases on time delays.
- For the arbitrary sequence case, I propose adding a "Sequencer" data processor. It could have a mode for sequential runs, and a mode to output arbitrary sequences.
Regarding your end use case, convolution kernels, we have in the past considered adding a general purpose FIR/IIR DSP style filter which would take a coefficient array/filter kernel as a parameter. We should start up a new thread to discuss requirements and capabilities.I included the emit constant example just as a trivial case for the proposed transformer. If you implement the Sequencer DP for arbitrary sequences, it will cover this functionality, so no need to duplicate it in Maths, unless it supports modification of the constant token.
a use case:
emit(1) -> Accumulator will behave like Counter
but if at some point you change 1 to -1, it will start counting backwards form the current count
What do you suggest regarding the sequential mode of Sequencer?
The general case can be handled by Counter, as Eric pointed out.
Thanks