Not worth the effort: Fixing the varying amplitude problem

In my previous post, I mentioned a small problem I had encountered: due to the imprecision involved in digital audio processing, there are some instances where the peaks and valleys of a periodic function will be slightly different from each other at different frequencies. This will particularly be true at higher frequencies.

So, I came up with a means of adjusting the x-values so that the peaks and valleys are always at the maximum amplitude. It's much more complex than the current method for calculating the x-value because you have to calculate which quarter of the period you are in, find out how many samples there should be in the period, calculate how far the x-values should be from each other, and then come up with a precise number.

My conclusion is that while it may improve the variability in amplitude, it may not be worth it. It will involve more processing, less efficiency, and there are other ways of improving the precision (I could increase the sample rate from 44.1 khz to 48 khz, for example). And on top of that, it might be even less noticeable at lower amplitudes: right now I'm multiplying by the max amplitude, but in reality I probably don't want to do that to keep volumes at a reasonable level.

So, I'll update the repository to include my alternate method in Oscillator.kt, but I don't think I'm actually going to use it.

In my next update, I'm planning on introducing decay values - I'll probably skip most of the ADSR envelop, but I'll include decay so that I can get notes to stop playing more easily.

Comments