LabSound/LabSound

HRTF - default to EQUAL POWER if hrtf database is not found

Closed this issue · 14 comments

dug9 commented

On windows 11 I can hear the ex_hrtf_spatialization clicking sounds but I don't hear the train. If I setPanningModel(PanningModel:::EQUAL_POWER) then I hear the train. Console shows the hrtf .wav database files loaded successfully.
Q. is HRTF working / supposed to be working?
If so any hypotheses for my case? If not, is there a fix? Thanks.

This change modified the loading strategy 3e13b27 I'll double check the merge.

Quick update; it's working on MacOS. So the problem might be Windows specific. I'll update when I've had a chance to check it on Windows.

dug9 commented

Thanks for update - I will need HRTF working to comply with new web3d.org specs. Let me know if you want me to do a specific test on my machine.

Ok, confirmed that on a Windows 11 machine, I too get a pop at the beginning and end of the hrtf example, and that the equal power mode works fine.

Try pulling now. The problem was that the RenderLock in the demo was being held too long, so it was deadlocking. I scoped the lock to setting the audio bus and pushed that fix. The bigger question is why the two platforms are behaving differently. I'll look into it, but in the mean time, I think you should be unblocked.

dug9 commented

Thanks very much for the update.
You had left it on EQUALPOWER., which was working for me before. When I switch to HRTF I don't hear the train as before. But I've been building Debug.
When I build in Release, HRTF works a bit, sometimes clean end-to-end, and sometime there are beeps on startup, and static and/or blank sections in the middle (H: when switching HRTF .wav)

That's what I get for debugging in the middle of the night! I'll redo the test.

It regressed with this change: cdbc041

Note that the last tagged release, 1.1.0 was just before that commit. https://github.com/LabSound/LabSound/releases/tag/v1.1.0 So if you fetch the tagged release and work from there, you will be unblocked.

Now that I found the problem, I need to work through that rather big commit to find what I messed up.

dug9 commented

Thanks very much for the suggestion. I have v1.1.0 working with PannerMode::HRTF.

dug9 commented

more. background on application ..
A wish-list for freewrl: if it can't find HRTF .wavs, it has a way to thunk to EQUALPOWER and continue. For example If Panner was set internally to EQUALPOWER during initialization, and could start rendering sound, and then switch to HRTF (if requested) if and when wav are found, loaded, initialized, that would work for us since we could set it up and leave it to run. A Panner->load_status() NOT_FOUND freewrl could check on each frame and if set could give a one-time console message to user.

That's a good idea. It would also be nice if the hrtf wavs could be prebaked into a single binary chunk ready to use. That would probably also mitigate the load time.

@dug9 ~ the problem was that during the merge I optimized the audio FloatArray routines, and didn't realize that the FFT assumed it's allocations are pre-zeroed. Uninitialized memory therefore caused the hrtf routines to fail. I just pushed a fix to main, so now I can look at the other issues and suggestions. After a little more testing, I'll tag a new release with this fix.

I changed the title to reflect the feature request.

Loading of the hrtf database is now explicit by the user, so if the database load fails, the user can decide to use EQUAL POWER instead.

        if (!ac.loadHrtfDatabase("hrtf")) {
            std::string path = std::string(SAMPLE_SRC_DIR) + "/hrtf";
            if (!ac.loadHrtfDatabase(path)) {
                printf("Could not load spatialization database");
                return;
            }
        }

I think this meets the intent of the wishlist for freewrl. If not, please feel free to continue the discussion here.