Creating my custom timeline audio track

I know its early days but the audio track capabilities of the timeline are still very primitive which makes it almost unusable for my needs. I am thinking that the ultimate direction of unity is to literally have the sort of audio channel capabilities that you see in all DAWs but maybe this is beyond the scope of what unity has in mind. So instead of using an Audioclip, the user would reference a mixer channel track on the time line. This would open up support for transport curves that allow me to dynamically change the volume along the track.

I am trying to write my own but I am having problems creating my custom playablebehaviour from the audioclip timeline asset.

The following is an attempt to create a track mixer that requires AudioClip clipTypes but unfortunately it can create my playables from this clip type.

[TrackColor(0, 0.8623f, 0.3f)]
[TrackClipType(typeof(AudioClip))]
[TrackBindingType(typeof(AudioSource))]
public class AudioTimeLineTrack : TrackAsset {

    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
        return ScriptPlayable<AudioTimeLineMixerBehaviour>.Create (graph, inputCount);
    }

    protected override Playable CreatePlayable (PlayableGraph graph, GameObject go, TimelineClip clip)
    {
        var p = base.CreatePlayable (graph, go, clip);
        ScriptPlayable<AudioTimeLineBehaviour > playable = (ScriptPlayable<AudioTimeLineBehaviour >) p;
        return p;
    }
}

The createPlayable is returning a null object. Can anyone point me in the right direction? is this even possible?

Hello! You do not need to call the base class in order to create your playable.

protected override Playable CreatePlayable (PlayableGraph graph, GameObject go, TimelineClip clip)
{
    return ScriptPlayable<AudioTimeLineBehaviour>.Create(graph);
}

Calling ScriptPlayable.Create will create a fresh and new playable with your custom script attached to it (you can get it by calling playable.GetBehaviour(), which will return an instance of AudioTimeLineBehaviour).

See Unity - Manual: ScriptPlayable and PlayableBehaviour

Perfect!

1 Like

@attar033 How far did you get? I’m playing with something similar and it would be useful to compare notes.

Hi i try create custom AudioPlayableAsset

for get add option after loop

thank’s

@attar033 sorry for ressurecting the thread, would you mind sharing a bit more about your approach to get a custom track that is able to play back audio as well? (if I understand correctly what you were trying to achieve)