AudioSource.pitch Manual     Reference     Scripting  
Scripting > Runtime Classes > AudioSource
AudioSource.pitch

var pitch : float

Description

The pitch of the audio source.

JavaScripts
// Decreases the pitch in the given seconds

var startingPitch = 4;
var timeToDecrease = 5;

function Start() {
audio.pitch = startingPitch;
}

function Update() {
if(audio.pitch > 0)
audio.pitch -= ((Time.deltaTime * startingPitch) / timeToDecrease);
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public int startingPitch = 4;
public int timeToDecrease = 5;
void Start() {
audio.pitch = startingPitch;
}
void Update() {
if (audio.pitch > 0)
audio.pitch -= Time.deltaTime * startingPitch / timeToDecrease;

}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

public startingPitch as int = 4

public timeToDecrease as int = 5

def Start():
audio.pitch = startingPitch

def Update():
if audio.pitch > 0:
audio.pitch -= ((Time.deltaTime * startingPitch) / timeToDecrease)