Affecting all audio with slow motion but can't reset to original pitc

The script can slow down the pitch when it goes into slow motion but it can’t go back to the original pitch, it just stays slowed down.Also the more I go in and out of slow-mo the slower the pitch gets.

using UnityEngine;
using System.Collections;

public class SoundModifier : MonoBehaviour 
{	
	public float[] pitchs;
	public float[] oldPitchs;
	
	public AudioSource[] audioSources;
	
	void Update () 
	{
		StartCoroutine("GetPitch");
	}
	
	IEnumerator GetPitch()
	{
		audioSources = FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
		
		if(OverClock.isOverClock == false){
			oldPitchs = new float[audioSources.Length];
			pitchs = new float[audioSources.Length];
		}
		
		for(int i = 0; i <= audioSources.Length; i++)
		{	
			pitchs _= audioSources*.pitch;*_

* if(OverClock.isOverClock == false){*
audioSources_.pitch = oldPitchs*;_
oldPitchs _= audioSources.pitch;_
//pitchs _= oldPitchs;*_

* }*
* //when i press q it slow down time and this becomes true*
* if(OverClock.isOverClock == true)*
* { *
//pitchs = oldPitchs * Time.timeScale;
audioSources.pitch = oldPitchs * Time.timeScale;
* }*

* if(i == audioSources.Length)*
* break;*
* }*
* yield return null;*
* }*
}

Its hard to pin down your problem, because the code looks way too complicated to me for what it’s doing, so I slapped this together. It currently uses the mouse wheel to dynamically control the pitch, but you can easily change it back to using a button.

AudioPitchController.cs

using UnityEngine;
using System.Collections;

public class AudioPitchController : MonoBehaviour
{
	public delegate void PitchChange(float value);
	public static event PitchChange OnPitchChange;

	private float lastPitch;

	void Update()
	{
		float pitch = Input.GetAxis("Mouse ScrollWheel");
		if (pitch != lastPitch)
		{
			lastPitch = pitch;
			if (OnPitchChange != null)
				OnPitchChange(pitch * Time.deltaTime);
		}
	}
}

AudioPitchModifier.cs

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(AudioSource))]
public class AudioPitchModifier : MonoBehaviour
{
	const float PITCH_LIMIT = 3;

	void OnEnable()
	{
		AudioPitchController.OnPitchChange += HandleOnPitchChange;
	}

	void OnDisable()
	{
		AudioPitchController.OnPitchChange -= HandleOnPitchChange;
	}

	void HandleOnPitchChange (float value)
	{
		audio.pitch = Mathf.Clamp(audio.pitch + value, -PITCH_LIMIT, PITCH_LIMIT);
	}
}

I would think the issue comes from your update. You are calling a new coroutine each frame. You should use a boolean to get only one call:

bool isSlow = false;

void Update ()
{
   if(!isSlow)
   {
       StartCoroutine("GetPitch");
       isSlow = true;
   }
}

Then wherever you stop the slow effect you set isSlow back to false when getting back to normal speed.

I would think you need to modify your scripts in a way that new audio sources are taken care as well. I mean that if during slow motion you create a new sound then it won*t be affected so you need to make it in a way that when creating new ones, they check the value of that boolean and change their pitch in accordance.