I'm working on a waveform generator that displays the wave visually.
Github: https://github.com/djleprechaunz/OscProject (https://github.com/djleprechaunz/OscProject)
Currently I'm wanting to implement and attack/release compressor, so it looks like I need to create a Envelope follower first.
So I figure it's a basic RMS of the (bufferSize) samples before it:
Here's my function:
Code: Select all (#)
public double getValue(double t)
{
buffer.add(t);
Iterator<Double> itr = buffer.iterator();
double sum = 0;
while (itr.hasNext())
{
double value = itr.next();
sum += Math.pow(value, 2.0);
}
sum = sum/buffer.size();
sum = Math.sqrt(sum);
return sum;
}
increasing the buffer size doesn't help.
Have I totally misunderstood how I implement an envelope follower, or am I on the right track?