internal Transient Play(AudioClip clip, bool loop, TransientParams param) { volume = new AutomatedParameter(param.GetVolume(), 0.25f); pitch = new AutomatedParameter(param.GetPitch(), 0.25f); remainingLeftSilence = param.GetLeftSilenceLength(); remainingRightSilence = param.GetRightSilenceLength(); panStereo = new AutomatedParameter(param.GetPanStereo(), 0.25f); spatialBlend = new AutomatedParameter(param.GetSpatialBlend(), 0.25f); Source.clip = clip; Source.loop = loop; Source.volume = volume.CurrentValue; Source.pitch = pitch.CurrentValue; Source.panStereo = panStereo.CurrentValue; Source.spatialBlend = spatialBlend.CurrentValue; Source.outputAudioMixerGroup = param.GetMixerGroup(); // For some reason, Unity doesn't clamp this value so we need to // clamp it ourselves to ensure no exception will be thrown. Source.time = Mathf.Clamp(param.GetTime() * clip.length, 0, clip.length); // Play the clip right away if there is no silence to generate if (remainingLeftSilence == 0) { Source.Play(); } return(this); }
internal Transient Apply(TransientParams param) { volume.DesiredValue = param.GetVolume(); pitch.DesiredValue = param.GetPitch(); this.panStereo.DesiredValue = param.GetPanStereo(); this.spatialBlend.DesiredValue = param.GetSpatialBlend(); return(this); }