Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Possible to access Unity's internal FMOD or AudioUnit instance (if Unity uses iOS AudioUnit)?

Discussion in 'iOS and tvOS' started by Iamdain, Jul 3, 2015.

  1. Iamdain

    Iamdain

    Joined:
    Feb 3, 2010
    Posts:
    90
    The plugin for the full 'FMOD Studio' seems to have a public handle to it's instance but does anyone know if there's any way to access the FMOD object (singleton or however it's structured) in the regular FMOD built into Unity either Unity or native objc side?

    Background:
    I'd like to save game audio in realtime and synch it up with an AVAssetwriter video recording of gameplay which is done in native iOS code, ultimately creating a screen capture with sound of the Unity scene. So I need access to the stream of audio data, I see that FMOD allows access to output buffers so I thought that would be a good place to try and hook in but there's seemingly very little that's publicly exposed of the FMOD system in Unity and I can't find anything helpful in docs or online.

    Alternatively, I'm not sure how the whole system is wrapped up in iOS, I would think using AudioUnits or an AUGraph, but maybe there's some way to get a reference to and read out of whatever Obj-c class is being utilised to run the FMOD system. AudioUnits allow access to live buffer data too so that could work.

    Backup would be to stream the data from the AudioFilter in Unity either to file or passing through to Obj-c on the fly but would be a bit more work. Hoping there's a way to get at the audio stream directly from Xcode...
     
  2. PDZ

    PDZ

    Joined:
    Sep 12, 2013
    Posts:
    18
    Did you ever get a solution to this?
     
  3. Iamdain

    Iamdain

    Joined:
    Feb 3, 2010
    Posts:
    90
    @PDZ I didn't find a way to intercept Unity audio on the native side but did write / adapt code to catch it Unity-side. Check out the open source for iVidCapPro for an example of approach. I then used native functions to combine the recorded audio from Unity and captured video from native.
     
    PDZ likes this.
  4. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    Since 5.3 Unity uses AVAudioSession API internally. You could try to utilize the same APIs to adapt Unity behavior, but this is not supported officially. If you think certain enhancement could fit within Unity itself, please submit public bug requests and vote for them on the issuetracker. Widely requested features will be given more priority.
     
    Nyarlathothep and PDZ like this.