I have an audio track on a timeline. I'd like to be able to change the volume of this track by code. I've tried accessing the volume of the audiosource which is attached to it, but this doesn't change the timeline's volume. Is there a way to access the volume of a timeline audio track? Thanks!
assign an Audiosource to the Audiotrack, then control the volume of that Audiosource, either directly or via a mixer.
The volume can be accessed from the inspector, or from the the curve editor. If you select a clip, you can edit the volume in the inspector (but it is not animated, except for using ease/blend in/out).
Unfortunately, the necessary fields don't seem to in the public API so it can't be used to set their value directly. However, you can set an animated value for them using the following: Code (CSharp): audioTrack.CreateCurves("nameOfAnimationClip"); audioTrack.curves.SetCurve(string.Empty, typeof(AudioTrack), "volume", AnimationCurve.Linear(0,0,1,1)); audioTrack.curves.SetCurve(string.Empty, typeof(AudioTrack), "stereoPan", AnimationCurve.Linear(0,-1,1,1)); audioTrack.curves.SetCurve(string.Empty, typeof(AudioTrack), "spatialBlend", AnimationCurve.Linear(0,0,1,1));