Wind up and Wind down script: Wind up at different speed than Wind down

Here is the script that we have so far:

using UnityEngine;
using System.Collections;
 
public class PitchChange : MonoBehaviour 
{
 
public AudioSource Audio;
public float StartingPitch = 1.0f;
public float EndingPitch = 2.0f; 
 
public int PitchScaleFactor = 3;
bool isMousePressed = false;
 
void OnMouseDown()
{
    isMousePressed=true;
 
}
 
void OnMouseUp()
{
    isMousePressed=false;
}
 
// Update is called once per frame
void Update () 
{
    //If mouse is pressed, increase pitch
    if(isMousePressed == true)
    {
       if(Audio.pitch <= StartingPitch)
       {
         Audio.Play();
       }
 
       //Only increase pitch if "EndingPitch" value has not been reached
       if(Audio.pitch <= EndingPitch)
       {
         Audio.pitch += ((Time.deltaTime * StartingPitch) / PitchScaleFactor);
       }
    }
    //Otherwise, decrease pitch back to normal, until we reach starting pitch
    else
    {
       if(Audio.pitch > StartingPitch)
       {
         Audio.pitch -= ((Time.deltaTime * StartingPitch) / PitchScaleFactor);
       }
       else
       {
         Audio.Stop();
       }
    }
 
    Debug.Log(Audio.pitch);
}
}

Basically looking to have the wind up of the audio be a certain length and then the wind down last longer/shorter than the wind up vice versa. Here is the project so far. link text

Any help is appreciated!

You need to break down the scale factor into “PitchUpScaleFactor” and “PitchDownScaleFactor” so that the pitch up and pitch down are scaled/timed at different speeds.

This should help:

using UnityEngine;
using System.Collections;

public class PitchChange : MonoBehaviour 
{
	
	public AudioSource Audio;
	public float StartingPitch = 1.0f;
	public float EndingPitch = 2.0f; 
	
	public float PitchUpScaleFactor = 3.0f;
	public float PitchDownScaleFactor = 2.0f;
	bool isMousePressed = false;
	
	void OnMouseDown()
	{
		isMousePressed=true;

	}
	
	void OnMouseUp()
	{
		isMousePressed=false;
	}
	
	// Update is called once per frame
	void Update () 
	{
		//If mouse is pressed, increase pitch
		if(isMousePressed == true)
		{
			if(Audio.pitch <= StartingPitch)
			{
				Audio.Play();
			}
			
			//Only increase pitch if "EndingPitch" value has not been reached
			if(Audio.pitch <= EndingPitch)
			{
				Audio.pitch += ((Time.deltaTime * StartingPitch) / PitchUpScaleFactor);
			}
		}
		//Otherwise, decrease pitch back to normal, until we reach starting pitch
		else
		{
			if(Audio.pitch > StartingPitch)
			{
				Audio.pitch -= ((Time.deltaTime * StartingPitch) / PitchDownScaleFactor);
			}
			else
			{
				Audio.Stop();
			}
		}
		
		Debug.Log(Audio.pitch);
	}
}

Just remember, smaller values are “faster” and larger values are “slower”.