Question: Code in JAVA E CHO F ILTER : ( 10p ) public class EchoFilter extends BufferedFilter This filter uses the memory of previous inputs to
Code in JAVA
ECHOFILTER: (10p) public class EchoFilter extends BufferedFilter This filter uses the memory of previous inputs to produce an echo effect. At every step, it will output a value which is the sum of the current input and an input from some n steps ago. To do this, the following needs to be implemented:
public EchoFilter(DataSource src, int echo) initializes the filter with the given data source and an echo delay of echo. To produce an echo which is delayed by a certain number of steps, Think about how big of a buffer we need: if we want a delay of 1 step, for example, then our memory would need to store both the current step and the previous step, so two steps. What about if we want an echo delay of 5 steps? We'd need the previous five steps plus the current step, so a 6 step memory. So if we wanted a delay of length echo, how big of a buffer do we need to ask for?
@Override public Double next() produces an output which is the result of adding the current input to the input from echo steps ago.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
