I wasn’t able to figure out what the second function did, so I couldn’t change it. Since, quality
was always set to eqQuality
, I removed those parameters and made the functions just use eqQuality
.
eqNums returns the necessary values required for the calculation in attenuationCalculation(freq)
. This function takes in a list, of which contains the values that eqNums returns.
After making my version, it doesn’t seem to work right… so I tested out the original one.
I was disappointed to see that it worked exactly the same. I tested out Lightning sounds, and expected to hear something like this.
Perhaps the effect isn’t strong enough. It should work like in real life, as the this table:
shows that lower frequencies get attenuated less compared to higher frequencies over a distance. Perhaps try increasing the quality factor, or try change the equation to use a higher humidity entry. It should be known, the default equation, that is:
return (math.pow(0.2866 * freq, 2) + 0.2033 * freq + 0.5444) * math.pow(10, -3)
which uses the 60% relative humidity entry in the table. During a storm the humidity generally reaches 100%. You can refer to the following pdf (https://cdn.standards.iteh.ai/samples/17426/3a2d69b767024b74805b83b063a91445/ISO-9613-1-1993.pdf) to see how sound is attenuated at 100% humidity. I may make my script use the tabulated values in that report.
I’ve also ordered an extremely comprehensive sound attenuation data list (ANSI/ASA S1.26-2014) so when that comes I will be switching to that.
The main things I changed is the whole sound source system and the folders. The idea that each part may only have one AudioPlayer is very restricting. You can only initialize all of them once, and new ones are impossible to initialize because the createEq
function initializes all of them over again, creating unnecessary equalizers and stuff. Very restricting! So instead, I made it so you have to initialize individual AudioPlayers (not soundSources), that don’t need to be parented to a specific folder…
This is a good change and I will implement this. I forgot in the real world some speakers can be multidirectional. The only issue with this is that some players may not want certain sound emitters to be affected by this script, so I think there would need to be a blacklist list correct?
The rest are good optimizations which I will implement. Thank you.