[Lesson] On the math of audio
Posted: Fri Dec 16, 2016 11:19 am
I wanted to post this in tutorials but that is apparently for special users so I'll just deposit this information here and hope some of you might like it.
I present to you this information as a university student of electrical engineer and a maths fanatic. Perhaps this knowledge is less obvious for some of you which might help out with your programming.
In the audio world our human perception is much more exponential than it is linear. Volume levels dictated in the digital domain (values between 0 and 1 or 0 and 255 (or more) depending on the data format) is the language every computer understands. Once this value is converted into a voltage and amplified by an amp the speaker will hopefully deviate its rest position accordingly and hence audio is produces. The human ear however doesn't work like this at all.
Values between 0 and 1 do not scale linearly in our perception. Besides the fact that our brain compresses audio volume to become more sensitive in silent situations, sound levels are perceived exponentially or (logarithmically depending on what you like). Its the same thing. Equal steps in volume occur with exponential steps in volume. So if you make a sound twice as loud, you add about 6dB of volume on a linear scale. Double it again and you only notice a 6dB increace etc.
In programming audio, you might notice that the audio sensitivity does not respond like you expect it at all. That might be due to the fact that you aren't using a logarithmic scale for your audio, especially if you use specific frequency ranges and you have to amplify your signal even more.
The best way to make the software respond more realistically is by adding a logarithmic function. Experiment with this. Inside your modifier, put the expression unit and type:
A*log10(B*x)
Here A and B can be set by yourself. Generally I pick B close to 10 and then A between 1 and 10 depending on the frequencies I select for. So something like 3*log10(10*x) is very common. The problem with logarithmic functions however is that values close to 0 become negative. Therefor you do need some form of capping. I suggest using a gate after this to limit the value on the lower bound to 0. You could also use a clamp for a similar problem on the high values especially if you use the smooth feature which might blow up to infinite values over longer periods of time.
The usage of the log10 function will make your effects respond much more naturally to audio compared to linear sensitivity. I hope this information will be helpful to some of you! In the subforum on videos made by magic you can find one video I created to show of something that essentially uses only logarithmic values to change the behavior of shader speeds, colours and much more.
I hope you enjoyed! Questions are always welcome and I'm sorry if this is such obvious information that no one really cares.
I apologize for putting this in the wrong forum.
With kind regards,
Robert
I present to you this information as a university student of electrical engineer and a maths fanatic. Perhaps this knowledge is less obvious for some of you which might help out with your programming.
In the audio world our human perception is much more exponential than it is linear. Volume levels dictated in the digital domain (values between 0 and 1 or 0 and 255 (or more) depending on the data format) is the language every computer understands. Once this value is converted into a voltage and amplified by an amp the speaker will hopefully deviate its rest position accordingly and hence audio is produces. The human ear however doesn't work like this at all.
Values between 0 and 1 do not scale linearly in our perception. Besides the fact that our brain compresses audio volume to become more sensitive in silent situations, sound levels are perceived exponentially or (logarithmically depending on what you like). Its the same thing. Equal steps in volume occur with exponential steps in volume. So if you make a sound twice as loud, you add about 6dB of volume on a linear scale. Double it again and you only notice a 6dB increace etc.
In programming audio, you might notice that the audio sensitivity does not respond like you expect it at all. That might be due to the fact that you aren't using a logarithmic scale for your audio, especially if you use specific frequency ranges and you have to amplify your signal even more.
The best way to make the software respond more realistically is by adding a logarithmic function. Experiment with this. Inside your modifier, put the expression unit and type:
A*log10(B*x)
Here A and B can be set by yourself. Generally I pick B close to 10 and then A between 1 and 10 depending on the frequencies I select for. So something like 3*log10(10*x) is very common. The problem with logarithmic functions however is that values close to 0 become negative. Therefor you do need some form of capping. I suggest using a gate after this to limit the value on the lower bound to 0. You could also use a clamp for a similar problem on the high values especially if you use the smooth feature which might blow up to infinite values over longer periods of time.
The usage of the log10 function will make your effects respond much more naturally to audio compared to linear sensitivity. I hope this information will be helpful to some of you! In the subforum on videos made by magic you can find one video I created to show of something that essentially uses only logarithmic values to change the behavior of shader speeds, colours and much more.
I hope you enjoyed! Questions are always welcome and I'm sorry if this is such obvious information that no one really cares.
I apologize for putting this in the wrong forum.
With kind regards,
Robert