- Home /
The question is answered, right answer was accepted
Audio Quality + Tiny Delay
The audio I'm using in my game sounds great when I preview it in the Unity Player, but going to play-mode decreases the audio quality to something like you'd hear on a 144p YouTube video.
Do I need to make separate files? Do I need to change the format of the file?
Here's the code I use, and yes, the track is an hour long... Which doesn't really make things better, does it?
using UnityEngine;
using System.Collections;
public class PlayLengthLoop : MonoBehaviour {
public AudioClip audioClip;
void Start()
{
//Add your own times here !
StartClip(418.500f,425.850f);
}
void StartClip(float timeStart, float timeEnd)
{
audio.clip = audioClip;
audio.time = timeStart;
audio.Play();
StartCoroutine(DelaySoundStop(timeEnd));
}
IEnumerator DelaySoundStop(float timeEnd)
{
while(audio.time < timeEnd)
yield return null;
audio.Stop();
//Add your own times here !
StartClip(418.500f,425.850f);
}
}
Also, a delay happens on the track after it finishes looping, in which it loops again, but is there anyway to keep it looping without the need for a delay happening in between?
Okay, I've nailed the Tiny Delay issue!
Here's the new code:
IEnumerator DelaySoundStop(float timeEnd)
{
while(audio.time < timeEnd)
yield return null;
StartClip(418.600f,425.850f);
//Add your own times here !
}
}
At the moment, I'm still having problems with Audio Quality.
I notice I have a +2 on this comment.
I set this to "OP Only" :D So that functionality is Broken.
Answer by screenname_taken · Jun 03, 2014 at 08:20 PM
Check in the audio file's panel to see it's compression. Most probably it's compressing the files to a really low bitrate. You can also loop it there (make sure to select gapless looping if the looping ads a small pop at the end of the file.
When you mean a "really low bitrate", do you mean a larger or smaller file size?
Low bit rate. $$anonymous$$eaning that the file will encode stuff with low quality settings ending in a really small file, but with low quality. The lower the bitrate, the worse the audio quality.