libspatialaudio icon indicating copy to clipboard operation
libspatialaudio copied to clipboard

2nd order Binauralizer + MIT HRTF

Open joshkopecek opened this issue 5 years ago • 3 comments

Using the CAmbisonicBinauralizer, it works fine with 1st order. However, when I come to configure 2nd order, it fails because in AmbisonicLib.cpp, the speakers are initialised like this - note the Elevation of Loudspeaker 1 as -69.1º.

case kAmblib_Dodecahedron:
        // This arrangement is used for second and third orders
        m_nSpeakers = 20;
        m_pAmbSpeakers = new CAmbisonicSpeaker[m_nSpeakers];
        // Loudspeaker 1
        polPosition.fElevation = DegreesToRadians(-69.1f);
        polPosition.fAzimuth = DegreesToRadians(90.f);
        m_pAmbSpeakers[0].Configure(m_nOrder, m_b3D, 0);
        m_pAmbSpeakers[0].SetPosition(polPosition);
        // Loudspeaker 2
        polPosition.fAzimuth = DegreesToRadians(-90.f);
        m_pAmbSpeakers[1].Configure(m_nOrder, m_b3D, 0);
        m_pAmbSpeakers[1].SetPosition(polPosition);
        …

then when loading the MIT HRTF in mit_hrtf_lib.c:

unsigned int mit_hrtf_availability(int azimuth, int elevation, unsigned int samplerate)
{
    if(elevation > 90 || elevation < -40)
        return 0;

    if(azimuth > 180 || azimuth < -180)
        return 0;

    if(samplerate == 44100)
        return MIT_HRTF_44_TAPS;
    else if(samplerate == 48000)
        return MIT_HRTF_48_TAPS;
    else if(samplerate == 88200)
        return MIT_HRTF_88_TAPS;
    else if(samplerate == 96000)
        return MIT_HRTF_96_TAPS;

    return 0;
}

It fails because the Elevation of the speaker is below -40º, which seems like it is intended for MIT HRTF.

If I disable this check, it fails further down because the filters/taps are not available for below -40º.

The speaker arrangement is automatically configured as a kAmblib_Dodecahedron because of 2nd order in CAmbisonicBinauralizer.

Any help here or pointers as to how to set up 2nd (or 3rd?) order would be greatly appreciated.

joshkopecek avatar Mar 17 '21 22:03 joshkopecek

FYI, I'm going to try using SOFA instead with some data from York Uni's SADIE database

joshkopecek avatar Mar 18 '21 16:03 joshkopecek

Just to let you know I've had success with SOFA.

It might be good to put some info into the readme detailing that:

  1. MIT HRTF does not work with > FOA with the Binauralizer.
  2. libmysofa is required to use the SOFA files (along with a .sofa file, although libmysofa includes one).

Happy to PR the readme, if needed.

joshkopecek avatar Mar 19 '21 07:03 joshkopecek

@joshkopecek yes, more documentation and information would be nice.

jbkempf avatar Apr 10 '21 17:04 jbkempf