summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
commitc55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch)
treeee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio
downloadProject-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio')
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs13
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs45
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs133
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs.meta11
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs129
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs.meta11
8 files changed, 364 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs
new file mode 100644
index 0000000..0c5894b
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs
@@ -0,0 +1,13 @@
+using System;
+using UnityEngine.Playables;
+
+namespace UnityEngine.Timeline
+{
+ [Serializable]
+ [NotKeyable]
+ class AudioClipProperties : PlayableBehaviour
+ {
+ [Range(0.0f, 1.0f)]
+ public float volume = 1.0f;
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs.meta
new file mode 100644
index 0000000..a044757
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioClipProperties.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0d60a406ab64c434e9d731914e11a51e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs
new file mode 100644
index 0000000..c5bdf8c
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs
@@ -0,0 +1,45 @@
+using System;
+using UnityEngine.Audio;
+using UnityEngine.Playables;
+
+namespace UnityEngine.Timeline
+{
+ [Serializable]
+ class AudioMixerProperties : PlayableBehaviour
+ {
+ [Range(0.0f, 1.0f)]
+ public float volume = 1.0f;
+
+ [Range(-1.0f, 1.0f)]
+ public float stereoPan = 0.0f;
+
+ [Range(0.0f, 1.0f)]
+ public float spatialBlend = 0.0f;
+
+ public override void PrepareFrame(Playable playable, FrameData info)
+ {
+ if (!playable.IsValid() || !playable.IsPlayableOfType<AudioMixerPlayable>())
+ return;
+
+ var inputCount = playable.GetInputCount();
+
+ for (int i = 0; i < inputCount; ++i)
+ {
+ if (playable.GetInputWeight(i) > 0.0f)
+ {
+ var input = playable.GetInput(i);
+
+ if (input.IsValid() && input.IsPlayableOfType<AudioClipPlayable>())
+ {
+ var audioClipPlayable = (AudioClipPlayable)input;
+ var audioClipProperties = input.GetHandle().GetObject<AudioClipProperties>();
+
+ audioClipPlayable.SetVolume(Mathf.Clamp01(volume * audioClipProperties.volume));
+ audioClipPlayable.SetStereoPan(Mathf.Clamp(stereoPan, -1.0f, 1.0f));
+ audioClipPlayable.SetSpatialBlend(Mathf.Clamp01(spatialBlend));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs.meta
new file mode 100644
index 0000000..fa975ef
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d8c4a920f001ca64680ed6fdb52d1753
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs
new file mode 100644
index 0000000..7ff40fc
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs
@@ -0,0 +1,133 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine.Audio;
+#if UNITY_EDITOR
+using System.ComponentModel;
+#endif
+using UnityEngine.Playables;
+
+namespace UnityEngine.Timeline
+{
+ /// <summary>
+ /// PlayableAsset wrapper for an AudioClip in Timeline.
+ /// </summary>
+ [Serializable]
+#if UNITY_EDITOR
+ [DisplayName("Audio Clip")]
+#endif
+ public class AudioPlayableAsset : PlayableAsset, ITimelineClipAsset
+ {
+ [SerializeField] AudioClip m_Clip;
+#pragma warning disable 649 //Field is never assigned to and will always have its default value
+ [SerializeField] bool m_Loop;
+ [SerializeField, HideInInspector] float m_bufferingTime = 0.1f;
+ [SerializeField] AudioClipProperties m_ClipProperties = new AudioClipProperties();
+
+ // the amount of time to give the clip to load prior to it's start time
+ internal float bufferingTime
+ {
+ get { return m_bufferingTime; }
+ set { m_bufferingTime = value; }
+ }
+
+#if UNITY_EDITOR
+ Playable m_LiveClipPlayable = Playable.Null;
+
+#endif
+
+ /// <summary>
+ /// The audio clip to be played
+ /// </summary>
+ public AudioClip clip
+ {
+ get { return m_Clip; }
+ set { m_Clip = value; }
+ }
+
+ /// <summary>
+ /// Whether the audio clip loops.
+ /// </summary>
+ /// <remarks>
+ /// Use this to loop the audio clip when the duration of the timeline clip exceeds that of the audio clip.
+ /// </remarks>
+ public bool loop
+ {
+ get { return m_Loop; }
+ set { m_Loop = value; }
+ }
+
+ /// <summary>
+ /// Returns the duration required to play the audio clip exactly once
+ /// </summary>
+ public override double duration
+ {
+ get
+ {
+ if (m_Clip == null)
+ return base.duration;
+
+ // use this instead of length to avoid rounding precision errors,
+ return (double)m_Clip.samples / m_Clip.frequency;
+ }
+ }
+
+ /// <summary>
+ /// Returns a description of the PlayableOutputs that may be created for this asset.
+ /// </summary>
+ public override IEnumerable<PlayableBinding> outputs
+ {
+ get { yield return AudioPlayableBinding.Create(name, this); }
+ }
+
+ /// <summary>
+ /// Creates the root of a Playable subgraph to play the audio clip.
+ /// </summary>
+ /// <param name="graph">PlayableGraph that will own the playable</param>
+ /// <param name="go">The GameObject that triggered the graph build</param>
+ /// <returns>The root playable of the subgraph</returns>
+ public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
+ {
+ if (m_Clip == null)
+ return Playable.Null;
+
+ var audioClipPlayable = AudioClipPlayable.Create(graph, m_Clip, m_Loop);
+ audioClipPlayable.GetHandle().SetScriptInstance(m_ClipProperties.Clone());
+
+#if UNITY_EDITOR
+ m_LiveClipPlayable = audioClipPlayable;
+#endif
+
+ return audioClipPlayable;
+ }
+
+ /// <summary>
+ /// Returns the capabilities of TimelineClips that contain an AudioPlayableAsset
+ /// </summary>
+ public ClipCaps clipCaps
+ {
+ get
+ {
+ return ClipCaps.ClipIn |
+ ClipCaps.SpeedMultiplier |
+ ClipCaps.Blending |
+ (m_Loop ? ClipCaps.Looping : ClipCaps.None);
+ }
+ }
+
+#if UNITY_EDITOR
+ internal void LiveLink()
+ {
+ if (!m_LiveClipPlayable.IsValid())
+ return;
+
+ var audioMixerProperties = m_LiveClipPlayable.GetHandle().GetObject<AudioClipProperties>();
+
+ if (audioMixerProperties == null)
+ return;
+
+ audioMixerProperties.volume = m_ClipProperties.volume;
+ }
+
+#endif
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs.meta
new file mode 100644
index 0000000..1b64816
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioPlayableAsset.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4f10dd60657c6004587f237a7e90f8e4
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs
new file mode 100644
index 0000000..d35fac6
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine.Audio;
+using UnityEngine.Playables;
+
+namespace UnityEngine.Timeline
+{
+ /// <summary>
+ /// A Timeline track that can play AudioClips.
+ /// </summary>
+ [Serializable]
+ [TrackClipType(typeof(AudioPlayableAsset), false)]
+ [TrackBindingType(typeof(AudioSource))]
+ [ExcludeFromPreset]
+ public class AudioTrack : TrackAsset
+ {
+ [SerializeField]
+ AudioMixerProperties m_TrackProperties = new AudioMixerProperties();
+
+#if UNITY_EDITOR
+ Playable m_LiveMixerPlayable = Playable.Null;
+
+#endif
+
+ /// <summary>
+ /// Create an TimelineClip for playing an AudioClip on this track.
+ /// </summary>
+ /// <param name="clip">The audio clip to play</param>
+ /// <returns>A TimelineClip with an AudioPlayableAsset asset.</returns>
+ public TimelineClip CreateClip(AudioClip clip)
+ {
+ if (clip == null)
+ return null;
+
+ var newClip = CreateDefaultClip();
+
+ var audioAsset = newClip.asset as AudioPlayableAsset;
+ if (audioAsset != null)
+ audioAsset.clip = clip;
+
+ newClip.duration = clip.length;
+ newClip.displayName = clip.name;
+
+ return newClip;
+ }
+
+ internal override Playable CompileClips(PlayableGraph graph, GameObject go, IList<TimelineClip> timelineClips, IntervalTree<RuntimeElement> tree)
+ {
+ var clipBlender = AudioMixerPlayable.Create(graph, timelineClips.Count);
+
+#if UNITY_EDITOR
+ clipBlender.GetHandle().SetScriptInstance(m_TrackProperties.Clone());
+ m_LiveMixerPlayable = clipBlender;
+#else
+ if (hasCurves)
+ clipBlender.GetHandle().SetScriptInstance(m_TrackProperties.Clone());
+#endif
+
+ for (int i = 0; i < timelineClips.Count; i++)
+ {
+ var c = timelineClips[i];
+ var asset = c.asset as PlayableAsset;
+ if (asset == null)
+ continue;
+
+ var buffer = 0.1f;
+ var audioAsset = c.asset as AudioPlayableAsset;
+ if (audioAsset != null)
+ buffer = audioAsset.bufferingTime;
+
+ var source = asset.CreatePlayable(graph, go);
+ if (!source.IsValid())
+ continue;
+
+ if (source.IsPlayableOfType<AudioClipPlayable>())
+ {
+ // Enforce initial values on all clips
+ var audioClipPlayable = (AudioClipPlayable)source;
+ var audioClipProperties = audioClipPlayable.GetHandle().GetObject<AudioClipProperties>();
+
+ audioClipPlayable.SetVolume(Mathf.Clamp01(m_TrackProperties.volume * audioClipProperties.volume));
+ audioClipPlayable.SetStereoPan(Mathf.Clamp(m_TrackProperties.stereoPan, -1.0f, 1.0f));
+ audioClipPlayable.SetSpatialBlend(Mathf.Clamp01(m_TrackProperties.spatialBlend));
+ }
+
+ tree.Add(new ScheduleRuntimeClip(c, source, clipBlender, buffer));
+ graph.Connect(source, 0, clipBlender, i);
+ source.SetSpeed(c.timeScale);
+ source.SetDuration(c.extrapolatedDuration);
+ clipBlender.SetInputWeight(source, 1.0f);
+ }
+
+ ConfigureTrackAnimation(tree, go, clipBlender);
+
+ return clipBlender;
+ }
+
+ /// <inheritdoc/>
+ public override IEnumerable<PlayableBinding> outputs
+ {
+ get { yield return AudioPlayableBinding.Create(name, this); }
+ }
+
+#if UNITY_EDITOR
+ internal void LiveLink()
+ {
+ if (!m_LiveMixerPlayable.IsValid())
+ return;
+
+ var audioMixerProperties = m_LiveMixerPlayable.GetHandle().GetObject<AudioMixerProperties>();
+
+ if (audioMixerProperties == null)
+ return;
+
+ audioMixerProperties.volume = m_TrackProperties.volume;
+ audioMixerProperties.stereoPan = m_TrackProperties.stereoPan;
+ audioMixerProperties.spatialBlend = m_TrackProperties.spatialBlend;
+ }
+
+#endif
+
+ void OnValidate()
+ {
+ m_TrackProperties.volume = Mathf.Clamp01(m_TrackProperties.volume);
+ m_TrackProperties.stereoPan = Mathf.Clamp(m_TrackProperties.stereoPan, -1.0f, 1.0f);
+ m_TrackProperties.spatialBlend = Mathf.Clamp01(m_TrackProperties.spatialBlend);
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs.meta
new file mode 100644
index 0000000..2a826c9
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioTrack.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8b22792c3b570444eb18cb78c2af3a74
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: