Most of what I see for examples of building your own use of Playables involve Animation mixing, blending, and so on. Are there any examples of doing similar tricks with Audio? or is the underlying Audio playables work not yet ready for that sort of effort? For instance, if I wanted to build my own Playable that faded between two audio clips, how would I go about doing so? I attempted to mimic the Animation example using AudioPlayableOutput, AudioClipPlayable and AudioMixerPlayable, assuming they must work in a similar way, but I'm not actually able to get it to work. I've been able to: a) get an AudioClipPlayable to play b) flip between multiple AudioClipPlayables at the start based on script properties But I haven't been able to figure out how to connect multiple AudioClipPlayables and mix between clips in pretty much the same way the Timeline seems to do itself. Maybe I'm not supposed to do that, but I'm interested to know what's going on.
Here's an example that should help you out, it somewhat mimics how Timeline does it. Code (CSharp): public class AudioClipPlayableAsset : PlayableAsset { public AudioClip audioClip; public AudioClipPlayable audioPlayable1; public AudioClipPlayable audioPlayable2; public AudioMixerPlayable audioMixer; public override double duration { get { return kClipDuration * 2; } } public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { audioPlayable1 = AudioClipPlayable.Create(graph, audioClip, true); audioPlayable2 = AudioClipPlayable.Create(graph, audioClip, true); audioMixer = AudioMixerPlayable.Create(graph, 2); graph.Connect(audioPlayable1, 0, audioMixer, 0); graph.Connect(audioPlayable2, 0, audioMixer, 1); audioPlayable1.Seek(0, 0, kClipDuration); audioPlayable2.Seek(0, kBlendStart, kClipDuration); audioMixer.SetInputWeight(0, 1); audioMixer.SetInputWeight(1, 1); var output = AudioPlayableOutput.Create(graph, string.Empty, null); output.SetSourcePlayable(audioMixer); return audioMixer; } }