Is 97% of correct volume at 7040Hz acceptable?

...and how to do so...
Post Reply New Topic
RELATED
PRODUCTS

Post

This graph 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.)

Post

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. Image
My MusicCalc is served over https!!

Post

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?

Post

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. Image
My MusicCalc is served over https!!

Post

BertKoor wrote: Wed Nov 17, 2021 2:26 pm So if I understand right, because you have a bandlimited signal (exclusion of highest harmonics) you raise the overall amplitude as compensation?
Nope. If I generate a properly bandlimited signal for a sawtooth, let's say, it has an amplitude range from -1 to 1. If I generate an alias-suppressed sawtooth from a fourth-order polynomial derived back to the original function, it has an amplitude range of for example -0.000000000000019347 to 0.000000000000019347 and needs to be gain-corrected. The amount of attenuation is related to the fundamental frequency.

There are two formulae to correct for this. One of them is somewhat more complex than the other, and becomes less accurate as the fundamental frequency increases. The other computes the adjustment with full correction for the fundamental frequency.

I was trying to figure on if it'd matter if I used the less-accurate one and skipped the real division operation, since I'll also be mixing in signals generated in other ways and so their amplitude won't be affected by frequency; but eventually I just looked up how to do binary division, spent 2 hours solving a 60-year-old problem related to SRT division (it requires a look-up table that's huge and slow—a problem people are still trying to solve in really weird ways today, since this has significant architectural impacts, cost, complexity, and power usage issues, hence why some DSPs come in a version with and without hardware division, and a lot of microcontrollers don't have hardware integer DIV even if they have hardware MUL—so I invented a real-time generator to replace the LUT with something that's 1/178 as big as its addressing circuit and doesn't need a table thus no ROM, and is only 8 transistors deep instead of like 60 so can be clocked higher), and created a pipeline that's small, fast, cheap, and low-power. So…yeah, now that I've invented the most advanced binary divider circuit in the world, I can finally generate an alias-suppressed sawtooth wave correctly.

At least I'm starting to figure out what I'm doing, kind of.

Post Reply

Return to “DIY: Build it and they will come”