Skip to main content

Audio API

If you are using a third-party plugin for audio in Unity, then you may need to use the Luna Replay Audio API in order to correctly capture and replay the sound for your video.

Luna Replay is able to capture audio bytes when Unity's audio system is used. However, when a third-party plugin is used, we don't have access to these audio bytes.

The API has the following methods.

// Accepts data in Unity UnityEngine.AudioRenderer's format
public static void SetFrameAudioSample( NativeArray<float> sample );
// Accepts data in s16le format
// (see https://trac.ffmpeg.org/wiki/audio%20types for description).
public static void SetFrameAudioBytes( IReadOnlyCollection<byte> s16LeBytes );

Example:

public class AudioTest : MonoBehaviour {
public void Awake() {
StartCoroutine( Coroutine() );
}
private IEnumerator Coroutine() {
while ( true ) {
var sample = GetSample(); // Get audio sample from 3rd party audio engine.
Audio.SetFrameAudioSample( sample );
}
}
}