- Home /
wav "clicks" on audio.Stop() and audio.Play() on iPhone
I'm hearing an audible "click" when I call audio.Stop() and audio.Play() on my .wav files. But this click can only be heard on the iPhone, I can't hear it when testing the game via Unity and the Remote. Also there aren't any audible clicks in the .wav files when listening to them outside of Unity.
Here's an example of how I'm calling the Stop and Play:
var SFX_boost : GameObject; // linked to AudioSource var SFX_engine : GameObject;
// normal acceleration, stop boost sound and play engine function Accelerate() { SFX_boost.audio.Stop(); SFX_engine.audio.Play(); }
// booting, stop engine sound and play boost
function Boost() {
SFX_boost.audio.Play();
SFX_engine.audio.Stop();
}
// breaking, stop boost and engine sound
function Brake() {
SFX_boost.audio.Stop();
SFX_engine.audio.Stop();
}
By using the above method, the .wav's can be stopped abruptly at any point while they're playing, so I suspect this might be part of the problem. But since there's no click sound in the .wav itself, I'm not sure why I'm getting a click on audio.Play().
You should submit a bugreport on this. Remember to include your project or an example project.
I get this too, but on regular publish AND within the editor as well.
Do not submit a bug report; it behaves exactly as expected.
Answer by jtbentley · Sep 07, 2010 at 01:00 PM
Most likely this clip is the result of the audio waveform going from wherever it is to 0.
This is a common problem, what you could do as a workaround (if the Unity guys aren't on it already) is make a simple co-routine to very quickly terminate the sound..
function makeItShutup(fadeSpeed : float) { while(SFX_Boost.audio.volume > 0.01) { SFX_Boost.audio.volume -= fadeSpeed; yield WaitForSeconds(0.001); // Wait roughly 1/10th frame? why not :) }
{
Yeah it's a bit rough, but basically you're just lowering that volume so that no hard-clipping occurs.
Here's an explanation of what exactly is going on: http://forum.unity3d.com/viewtopic.php?p=225524#225524
Your answer
Follow this Question
Related Questions
Audio not coming out of speakers 1 Answer
App crashes due to FMOD error 0 Answers
iPhone pitch not working? 1 Answer
how to load ogg files from documents folder. 1 Answer
Footstep Sounds 1 Answer