**AUTO-ADMIN:** *Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.*

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;

}

here's what it displays

increasing the buffer size doesn't help.

Have I totally misunderstood how I implement an envelope follower, or am I on the right track?