Get Audio Attenuation during Timeline

I’m looking to control a simple 2D animation based on the attenuation of audio clips being played on an audio source.

Ordinarily, I’d do something like…

audioSource.clip.GetData (audioData, audioSource.timeSamples)

…and then check the largest value in audioData and use that as the approximate current attenuation. That’s crude, but suits my purposes and can be used to flap a mouth to a variety of audio without manual animation work.

However, it looks like audioSource.clip is never assigned when audio is played using Timeline, even if the audioSource is assigned to the track (this is optional but impacts settings). Does anyone know an alternative approach which would work with Timeline? I really want to avoid adding a new custom Timeline track to control this animation manually.

Any suggestions welcome :slight_smile:

Silly of me not to have found this earlier: Unity - Scripting API: AudioSource.GetOutputData

Very similar call made to the AudioSource itself WORKS! Automatic mouth-flapping success!

However, one issue which I suppose is more of a Timeline problem: This call ONLY works at runtime, and returns empty when the Timeline is playing during edit time.