SetPitch() public method

Sets the pitch value for the primary source.
public SetPitch ( float newPitch ) : void
newPitch float The value to set the pitch, between 0 (exclusive) and 3 (inclusive).
return void
        /// <summary>
        /// Sets the pitch value on active AudioEvents.
        /// </summary>
        /// <param name="eventName">The name associated with the AudioEvents.</param>
        /// <param name="newPitch">The value to set the pitch, between 0 (exclusive) and 3 (inclusive).</param>
        public void SetPitch(string eventName, float newPitch)
        {
            if (newPitch <= 0 || newPitch > 3)
            {
                Debug.LogErrorFormat(this, "Invalid pitch {0} set for event \"{1}\"", newPitch, eventName);
                return;
            }

            for (int i = activeEvents.Count - 1; i >= 0; i--)
            {
                ActiveEvent activeEvent = activeEvents[i];
                if (activeEvent.audioEvent.name == eventName)
                {
                    activeEvent.SetPitch(newPitch);
                }
            }
        }
示例#2
0
文件: RTPC.cs 项目: peted70/mr-250
        public void ApplyValues(ActiveEvent activeEvent)
        {
            switch (audioProperty)
            {
            case RTPCProperty.Volume:
                activeEvent.volDest     = Evaluate();
                activeEvent.currentFade = smoothingTime;
                break;

            case RTPCProperty.Pitch:
                activeEvent.SetPitch(Evaluate());
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }