Editor freezes while playing audio loop.

Hi there. Recenty my unity editor started crashing. It freezes kompletely and I need to use the task manager to terminate it. It happens during testing my scene at random points and more frequent when I quit testing. I dug up the log in AppData\Local\Unity\Editor but nothing related to the crash appears there.

The problem occured first after I added background audio loops and never appeared when the corresponding gameobject was deactivated (so far). The audio loops are in the it format and the preview shows: 32bit, 48000Hz, stereo, unlimited, 167,7 kb (it).
The script which manages the audio clips works as intended (see below).

I have no idea what causes those crashes. Any help is appreciated.

BackgroundMusic.js :

var clips : AudioClip[];
private var _audio : AudioSource;

function Start () {
	_audio = GetComponent(AudioSource);
	if(clips.Length == 0) Debug.Log("No AudioClip assigned!");
	_audio.loop = true;
	PickRandom();
	_audio.Play();
}

function Update () {
	if(Input.GetKeyDown(KeyCode.M)){
		_audio.mute = !_audio.mute;
	}
	if(Input.GetKeyDown(KeyCode.N)){
		PickNext();
	}
}

function PickRandom() : void {
	var rand : int = Random.Range(0, clips.length);
	_audio.clip = clips[rand];
	Debug.Log("currently playing " + _audio.clip.name);
	_audio.Play();
}
function GetIndex() : int {
	for(var j : int = 0; j < clips.length ; j++){
		if(_audio.clip.name == clips[j].name){
			return j + 1 ;
		}
	}
	Debug.Log("BackgroundMusic: GetIndex() failed. return 0");
	return 0;
}
function PickNext() : void {
	var index = GetIndex();
	if(index == clips.Length) index = 0;
	_audio.clip = clips[index];
	Debug.Log("currently playing " + _audio.clip.name);
	_audio.Play();
}

@script RequireComponent(AudioSource)

Hey Lockstep,

I have had Unity crash out before when dealing with some of the higher bit / freq files. I generally convert them to 44.1khz 16bit Stereo when importing WAVS. Besides, the extra ‘sound quality’ on files that are 48khz or 96khz, and the extra work Unity has to do just isn’t worth it in my opinion, especially when they get converted to OGG. Also when converting 48khz/96khz files to OGG, you can find that sometimes the audio gets ‘distorted’ and cause all sorts of headaches. Sorry I don’t have an answer as such, but hopefully it may give further insight leading to one.

Paul