I’m looking a way to redirect audio stream from media player to external audio system (Wwise).
We are making game to low-end mobile platforms (700Mb ram) and to reduce memory consumption we are disabled AudioMixer and MetaSounds in our project (AudioMixerModuleName is set to empty for all platforms and MetaSound plugin is disabled). Whole project uses Wwise except built-in UMediaPlayer + UMediaSoundComponent and now it’s working without audio.
Because it’s only one place in the project where native ue audio system is used I would like to try to manually get audio stream and put it into the Wwise if it’s not hard to implement. Wwise provides component AkAudioInputComponent (documentation) which can receive audio from external source but I’m not fully understand how is to properly collect audio samples from media player.
I spent some time to investigate how UMediaPlayer works and how audio stream can be obtained, this is what I was able to find out:
- UMediaPlayer owns FMediaPlayerFacade. Facade is responsible for playing media file. When player is started it makes a copy of audio samples from file to FMediaAudioSampleQueue in worker thread
- FMediaAudioSampleQueue is created in UMediaSoundComponent and it adds queue to FMediaPlayerFacade. Then FMediaAudioSampleQueue to FMediaSoundGenerator and looks like this generator is used for obtaining audio stream somewhere under the hood of the ue audio system
- I found only FMediaSoundGenerator::GetNextBuffer method for obtaining audio samples from generator but I don’t understand how to get audio buffer split it between different audio channels
Based on the above, I have the following questions:
- Could you recommend the best way to retrieve audio buffers from a media player for stereo sound?
- Need I process buffers somehow before sending to wwise?
- Is there anything specific I should pay special attention to in this solution, for example, to ensure synchronization between audio and video?
- Do you see any potential pitfalls in the approach I’ve chosen to solve this problem? In particular, I’m interested in whether there are any planned major changes to the player’s architecture that could require rewriting the component or significantly altering the current approach in the future.