# Is 97% of correct volume at 7040Hz acceptable?

...and how to do so...
KVRer
4 posts since 4 Jul, 2021
This graph (https://www.desmos.com/calculator/344tfiwdd0) shows the error from using a simplified volume scaling formula versus a properly frequency-corrected one. At 96,000Hz sample rate and 7,040Hz fundamental frequency, the simplified scaling factor is 0.9738 times the correct factor; at 4,186 fundamental frequency (the highest key on most pianos), the simplified scaling factor is 0.9907 times the correct factor; below 520Hz, it's 0.9999 times the correct factor; and it's correct at 0Hz.

Is that acceptable error, or should I stick to scaling by the frequency-corrected formula? This is going to affect LFOs (but who cares, at 99.99% correct?) and saw/square/triangle waves used as modulators in phase modulator or ring modulation.

(I might need it to be frequency-corrected if I hard-sync sine waves, due to a slightly-cheaty method of anti-aliasing hard-sync I came up with one morning while confused and half-awake, but I'm considering just only allowing saw/square/triangle hard-sync and giving up on hard-sync sine.)

KVRAF
13203 posts since 8 Mar, 2005 from Utrecht, Holland
Can you explain what exactly frequency-corrected volume scaling is? I have an idea what you mean, but want to be sure.

Raw factors don't mean much in audio, we're used to decibels. The -0.1dB point is at 4.6kHz, around 8kHz the factor is 0.966 which is -0.3dB, further down it doesn't seem to hit -0.5dB. I'd say that ain't too bad, depending on what exactly your goals are. Concrete: it depends what proper (supposedly ideal) frequency-corrected volume scaling is.

The highest key on the piano has not much relevance. Audible audio goes from 20 Hz to 20 kHz, and for old guys like me the upper limit is closer to 14 kHz. The up-most octave is where the brilliance lives. Shave off something there, and you can tell the difference.

I'd advice you to compare audio results of the ideal and simplified formulas, let your ears guide you what's good enough for Rock'nRoll.
We are the KVR collective. Resistance is futile. You will be assimilated.
My MusicCalc is served over https!!

KVRer

Topic Starter

4 posts since 4 Jul, 2021
Repeatedly deriving a polynomial (numerically) gets you a smaller and smaller output, since you go from x^3 to x^2 to x. Band-limiting a waveform by generating it from a high-order polynomial requires scaling to restore it to the amplitude of a non-band-limited waveform; how much scaling depends on the precise frequency used to determine each value of x for each successive sample, in relation to the sample rate.

Only the fundamental frequency affects this, so if you're generating a saw at 4,000Hz, all harmonics are affected in the same way. If you're going to play noes at 14kHz that's…interesting, I don't actually represent above 8,192Hz internally for key-on though.

The difference between the two is basically coming down to where I stick a divider in practice. I think I'm going to miss 64 stages between needing the prior operator (for phase modulation) anyway, so I can't set this up to provide 16-operator FM synthesis (I can do 8-operator so long as I have 1,024 operators to work with). On the other hand, I'm assuming I need 32-bit sine functions internally, and I might only need 29 bits, so I might be able to squeeze this to around 55-59, which gives me enough registers easily to forward data back to just before the sine computation in the case of FM (these are not just FM operators; it turned out adding a couple extra bits of configuration and state and setting a register either zero or the modulator allowed me to apply several different types of modulation and various types of waveform generators in what would have been an FM operator, without missing timing).

I don't know how to turn those numbers into dB. Is there a reference online I can check out?

KVRAF
13203 posts since 8 Mar, 2005 from Utrecht, Holland
So if I understand right, because you have a bandlimited signal (exclusion of highest harmonics) you raise the overall amplitude as compensation? Interesting... Not sure you really need to do that though. The stuff you threw away wasn't audible in the first place, so I doubt it had contributed to the perceived loudness.
jrmoserbaltimore wrote:I don't know how to turn those numbers into dB. Is there a reference online I can check out?
One dB is a factor 10^0.05 = 1.122; see https://en.wikipedia.org/wiki/Decibel
Online calculator: http://www.sengpielaudio.com/calculator-db.htm
(that was the first one DuckDuckGo gave me when I asked for a decibel <--> factor converter)
We are the KVR collective. Resistance is futile. You will be assimilated.
My MusicCalc is served over https!!