Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Creating my custom timeline audio track

Discussion in 'Timeline' started by attar033, Aug 28, 2017.

  1. attar033

    attar033

    Joined:
    Nov 21, 2012
    Posts:
    9
    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.

    Code (CSharp):
    1. [TrackColor(0, 0.8623f, 0.3f)]
    2. [TrackClipType(typeof(AudioClip))]
    3. [TrackBindingType(typeof(AudioSource))]
    4. public class AudioTimeLineTrack : TrackAsset {
    5.  
    6.     public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    7.     {
    8.         return ScriptPlayable<AudioTimeLineMixerBehaviour>.Create (graph, inputCount);
    9.     }
    10.  
    11.     protected override Playable CreatePlayable (PlayableGraph graph, GameObject go, TimelineClip clip)
    12.     {
    13.         var p = base.CreatePlayable (graph, go, clip);
    14.         ScriptPlayable<AudioTimeLineBehaviour > playable = (ScriptPlayable<AudioTimeLineBehaviour >) p;
    15.         return p;
    16.     }
    17. }

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

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    177
    Hello! You do not need to call the base class in order to create your playable.
    Code (CSharp):
    1. protected override Playable CreatePlayable (PlayableGraph graph, GameObject go, TimelineClip clip)
    2. {
    3.     return ScriptPlayable<AudioTimeLineBehaviour>.Create(graph);
    4. }
    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 https://docs.unity3d.com/Manual/Playables-ScriptPlayable.html
     
  3. attar033

    attar033

    Joined:
    Nov 21, 2012
    Posts:
    9
    Perfect!
     
    julienb likes this.
  4. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    @attar033 How far did you get? I'm playing with something similar and it would be useful to compare notes.
     
  5. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Hi i try create custom AudioPlayableAsset

    for get add option after loop





    thank's
     
  6. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    @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)