# Integrating with head tracking on android

**URL:** <https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410>\
**Category:** FMOD Engine\
**Tags:** android\
**Created:** [March 27, 2024, 11:55am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410 "2024-03-27T11:55:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [March 27, 2024, 11:55am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/1 "2024-03-27T11:55:35Z")

</div>

The latest versions of android (13+) support head tracking. The architecture is described here: [空間音頻和頭部跟踪 &nbsp;|&nbsp; Android Open Source Project](https://source.android.com/docs/core/audio/spatial)

From the diagrams on that page, it should be as simple as outputting 5.1 / 7.1.4 from the app and making sure that head tracking is enabled (on a compatible device, such as the Google Pixel Buds Pros).

They provide callbacks for checking spatialisation support here: [Spatializer &nbsp;|&nbsp; Android Developers](https://developer.android.com/reference/android/media/Spatializer)

and there’s a general description for devs here: [Spatial Audio &nbsp;|&nbsp; Android media &nbsp;|&nbsp; Android Developers](https://developer.android.com/media/grow/spatial-audio)

Has anyone tried/succeeded/failed with this? Are there any problems, such as with the output of fmod in the signal chain described above?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [April 2, 2024, 4:26am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/2 "2024-04-02T04:26:02Z")

</div>

I don’t believe that there is anything special needed from FMOD, just the usual [spatial audio](https://www.fmod.com/docs/2.03/api/white-papers-spatial-audio.html) workflow should be enough as the positioning is all handled on the game engine side.

---

<div class="post-metadata">

**Author:** ![davecraig](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@davecraig](https://qa.fmod.com/u/davecraig)\
**Post date:** [June 20, 2024, 10:57am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/3 "2024-06-20T10:57:07Z")

</div>

Hi,

I have also been trying to get this working with Pixel Bud Pros and a pixel 8.  
Running on Android the driver returned by `getDriverInfo` is “Android audio output” and it’s stereo at 48kHz. That matches the documentation as the expected default driver.

The software mixer is set to FMOD\_SPEAKERMODE\_SURROUND and I can see that there’s a mixdown taking place:

```auto
2024-06-20 11:33:34.104 10422-10422 AudioEngine com.kersnazzle.soundscapealpha D 27 of ../../src/fmod_downmix.cpp: dspbuffersize: 512 rate: 48000. output speaker mode: 3, input speaker mode 5

```

Because I have spatialization enabled on the headphones I would expect it to be possible to send them multi-channel audio and then the Android spatializer could do its thing. If only stereo audio is sent, then the spatializer won’t do anything.

Perhaps I should be calling `System::setOutput()` but there doesn’t seem to be an `FMOD_OUTPUTTYPE` appropriate on Android that isn’t `FMOD_OUTPUTTYPE_AAUDIO`.

Any suggestions gratefully received,

Many Thanks

Dave Craig

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [June 20, 2024, 12:42pm UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/4 "2024-06-20T12:42:53Z")

</div>

Did you try setting to `FMOD_SPEAKERMODE_7POINT1POINT4` with `System::setSoftwareFormat()`? I read somewhere in the android documentation that that’s the highest spatialisation setup supported.

Also, did you check in the android code that all the spatialisation setup is correct? (checklist below)

> **[Spatial Audio  |  Android media  |  Android Developers](https://developer.android.com/media/grow/spatial-audio#query)**

| Does the device support spatialization? | [`getImmersiveAudioLevel()`](https://developer.android.com/reference/android/media/Spatializer#getImmersiveAudioLevel()) is not [`SPATIALIZER_IMMERSIVE_LEVEL_NONE`](https://developer.android.com/reference/android/media/Spatializer#SPATIALIZER_IMMERSIVE_LEVEL_NONE) |
| --- | --- |
| Is spatialization available? | |
| Availability depends on compatibility with the current audio output routing. | [`isAvailable()`](https://developer.android.com/reference/android/media/Spatializer#isAvailable()) is `true` |
| Is spatialization [enabled](https://developer.android.com/media/grow/spatial-audio#testing)? | [`isEnabled()`](https://developer.android.com/reference/android/media/Spatializer#isEnabled()) is `true` |
| Can an audio track with the [given parameters](https://developer.android.com/media/grow/spatial-audio#content) be spatialized? | [`canBeSpatialized()`](https://developer.android.com/reference/android/media/Spatializer#canBeSpatialized(android.media.AudioAttributes,%20android.media.AudioFormat)) is `true` |

There’s also an interesting bit about setting the max number of channels on android: [Spatial Audio &nbsp;|&nbsp; Android media &nbsp;|&nbsp; Android Developers](https://developer.android.com/media/grow/spatial-audio#default-behavior)

---

<div class="post-metadata">

**Author:** ![davecraig](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@davecraig](https://qa.fmod.com/u/davecraig)\
**Post date:** [June 21, 2024, 10:17am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/5 "2024-06-21T10:17:52Z")

</div>

> [@joshechoes](#):
>
> Did you try setting to `FMOD_SPEAKERMODE_7POINT1POINT4` with `System::setSoftwareFormat()`?

Yes, that made no difference. It still results in a mixdown taking place, just from a different surround format.

> [@joshechoes](#):
>
> Also, did you check in the android code that all the spatialisation setup is correct?

Yes I had done this too, it’s all setup and spatialization is available. I think that the underlying issue is that the FMOD code needs to do these checks and then based on the result it should be setting the audio device output format to a surround format and not stereo. That will allow the Android Spatializer to then do the mixdown to the headphones.  
From my application’s perspective, it will need to stop controlling the FMOD listener direction if head tracking and spatialization is active (it currently uses the orientation of the phone). I’m assuming that the FMOD surround “stage” would be held constant e.g. with the L C R speakers on the “north wall”, and then the Spatializer head tracking would then deal with the listener’s orientation.  
Hopefully that all makes sense! For background, the application here is for an Android port of [a navigation app for the visually impaired](https://www.scottishtecharmy.org/soundscape).

Thanks

Dave.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [June 28, 2024, 6:15am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/6 "2024-06-28T06:15:54Z")

</div>

Thanks for all the information, we are currently investigating this and will get back to you shortly.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [June 28, 2024, 6:49am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/7 "2024-06-28T06:49:45Z")

</div>

> Yes I had done this too, it’s all setup and spatialization is available. I think that the underlying issue is that the FMOD code needs to do these checks and then based on the result it should be setting the audio device output format to a surround format and not stereo. That will allow the Android Spatializer to then do the mixdown to the headphones.

@davecraig My guess is that fmod is detecting internally it’s on android and always mixing down to stereo regardless of what we set in `setSoftwareFormat()` – i.e. doing its own spatialization. Now it needs to respect what we set (i.e. `FMOD_SPEAKERMODE_7POINT1POINT4`) and just pass it to the internal engine.

@cameron-fmod the audio spatialisation workflow changed in android 13 - see here: [서라운드 오디오 및 머리 추적 &nbsp;|&nbsp; Android 오픈소스 프로젝트 &nbsp;|&nbsp; Android Open Source Project](https://source.android.com/docs/core/audio/spatial#spatial-arch)

You’d need to check that the current android SDK version is \>= 33, getting the android SDK version in the NDK, then allow setting other speaker setups.

This is [from SO here](https://stackoverflow.com/a/19356010/5349993).

```auto
#include <cutils/properties.h>

// ...

int myfunction() {
    char sdk_ver_str[PROPERTY_VALUE_MAX] = "0";
    property_get("ro.build.version.sdk", sdk_ver_str, "0");
    sdk_ver = atoi(sdk_ver_str);
    // ...   
}

```

Sorry if this is all obvious, just thought I’d paste here in case it helps.

Thanks so much! I feel like it’s getting closer.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [July 9, 2024, 2:35am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/8 "2024-07-09T02:35:27Z")

</div>

Thank you for your patience, it looks like we will need to update our API to allow for Android Spatial Audio. I have raised this as a task to fix in an upcoming release.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [July 9, 2024, 6:06am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/9 "2024-07-09T06:06:52Z")

</div>

Amazing, thank you @cameron-fmod 👏 – keep us updated and let me know if you need any more info from us, we’ve been looking at this in some depth.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [August 6, 2024, 9:26am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/10 "2024-08-06T09:26:19Z")

</div>

Just checking if there’s any movement on this @cameron-fmod ?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [August 20, 2024, 6:45am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/11 "2024-08-20T06:45:44Z")

</div>

It looks like this is to be scheduled for an upcoming release, all I can say at this point is that it will not be until after 2.02.24.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [August 20, 2024, 10:27am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/12 "2024-08-20T10:27:52Z")

</div>

Thanks @cameron-fmod I’ll keep an eye on the releases. Really look forward to testing this!

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [August 23, 2024, 6:15am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/13 "2024-08-23T06:15:38Z")

</div>

Hey @cameron-fmod just to say we have two quite notable projects that would benefit from this, and that should receive some national press coverage (in Germany and the UK).

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [November 8, 2024, 10:46am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/14 "2024-11-08T10:46:10Z")

</div>

@cameron-fmod checking in on this – I saw that 2.02.25 (as well as the 2.03.x releases) has been released. Was the above addressed / API updated? It would be amazing to try this out!

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [November 18, 2024, 6:07am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/15 "2024-11-18T06:07:10Z")

</div>

It has not been added as of yet and it is still in the backlog.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [February 3, 2025, 12:10pm UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/16 "2025-02-03T12:10:09Z")

</div>

Hi @cameron-fmod – just to say there is still interest in this, and it’d be great to see if it’s going to be implemented, otherwise I’ll have to look at other solutions.

…or in fact if there’s some way to ‘hack’ it to output multichannel/7.1 on android?

Many thanks!

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [February 4, 2025, 4:09am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/17 "2025-02-04T04:09:35Z")

</div>

Support for the Android Spatial API has been added and will be available in the next release of 2.03, which will support up to 7.1.4 as long as all of the requirements set by Android are met.

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [February 6, 2025, 3:00pm UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/18 "2025-02-06T15:00:02Z")

</div>

Wow! This is amazing news. I can’t wait to test it!

---

<div class="post-metadata">

**Author:** ![davecraig](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@davecraig](https://qa.fmod.com/u/davecraig)\
**Post date:** [June 24, 2025, 9:21am UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/19 "2025-06-24T09:21:06Z")

</div>

Hi Josh,

How did the testing go? Having recently upgraded the fmod release in our app the audio behaviour changed on phones with spatial audio enabled so definitely something happened! I had to switch to FMOD\_SPEAKERMODE\_STEREO in order to restore the previous behaviour. I’ve got other fish to fry right now, but just wondered what your experience was and whether it all worked as you needed?

Cheers,

Dave

---

<div class="post-metadata">

**Author:** ![joshechoes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joshechoes/32/558_2.png) [@joshechoes](https://qa.fmod.com/u/joshechoes)\
**Post date:** [June 24, 2025, 6:20pm UTC](https://qa.fmod.com/t/integrating-with-head-tracking-on-android/21410/20 "2025-06-24T18:20:10Z")

</div>

Hey, thanks for chasing up. Yes, we got it working and the spatialisation is great! All I needed to do was change the speaker mode to `FMOD_SPEAKERMODE_7POINT1POINT4` and it spatialised and head tracked successfully.

One thing is that I was confused about the ‘official’ channel ordering for 7.1.4 on android, since I also have a separate DSP (for ambisonics) that would write content out to channels directly, but this did also work when I guessed them, so it must be pretty close.

Another bigger issue that I was thinking about is that we deal with users IRL, ie an XR experience, and they could be frequently pointing South ie towards the rear speakers, where there’s less speaker density. This is obviously something they haven’t currently thought of with their Dolby-focused layouts (and the upcoming Atmos compatibility on android).
