We could only partially fill the _scratchBuffer - .wav files may not
be exactly N frames long. Doh.
While at it, I needed to call finishLocalInjection() after local
injectors are done, and the access to the injector vector needs to
be locked, given that we do a QtDirectConnection with the networking
and thus the outputLocalInjectors is on a different thread.
The clicking was just 0-ing out the _scratchBuffer.
The original attenuation model seems wrong, under-attenuating at close distance but completely muting after 45m.
This uses a physics-based model of -6dB per doubling of distance in free space, for the injectors. The AudioMixer model and domain settings still need to be reworked in a future PR.
Adds a distance filter to model the frequency-dependent attenuation of sound propagation in open air.
Optimized using SIMD and computing all biquads in parallel. Performance impact is almost zero.
Filter updates are continuously interpolated and clean to -90dB.
Not enabled yet (distance hardcoded to 0.0f)
Since the stereo option is computed from the .wav file, if you call
setOptions later (like the cow.js does), it resets stereo to false.
So, I now just copy the stereo flag into the new options, since the
sound file is the same.
Also, calling AudioClient::outputLocalInjector on the AudioClient
thread now to avoid potential concurrency issues accessing the
vector of injectors.
So localOnly sounds get HRTF'd, one network frame at a time. Less
processing (upsampling, limiting, etc...) than doing this at the
end of the pipeline (in the AudioOutputIODevice::readData call).
A couple things Ken suggested. First off, there are now AudioSRC
calls for floats, which simplfied stuff a bit. Then, I switched to
grabbing network packets first, and only pulling at most that amount
of audio from the local injectors. That improves things - the
occasional artifacts (when the injectors got more data than the
network for instance) are gone.
Also, fixed build issue (unused variable warning) for mac and android.
Probably need to clean up a bit, but wanted to get this out there
for comment on more general issues, etc...
To test, I added a localOnly: true to the cow in the tutorial.