x


Strange audio playback behaviour

I am loading and playing an .ogg file from the harddisk. To do this I use the method described in the WWW documentation:

WWW www = new WWW(url);
audio.clip = www.audioClip;

This seems to work, but when I start the clip after checking if clip.isReadyToPlay it starts playing but after a second or so it will start sound really weird, like it's played at too slow and inconsistent framerates.

To add some more weirdness, if I start the game in the editor and then tab to another application, so the editor runs in background the file plays back at a consistent framerate, but the rate seems to be too high, as the file is faster/higher pitched.

Any idea what might be causing this strange behaviour?

EDIT: The strange behaviour is a result of the audio clip being played back as a 3D sound per default, because my listener (which is attached to the camera) moves very fast and the AudioSource doesn't. I guess that's also why the behaviour is different when running in background as the listener does not move then.

Is there a way to mark the created clip as NOT being a 3D sound via scripting? I know I could circumvent this by attaching the audiosource to the camera/listener, but I'd rather not...

more ▼

asked Feb 20 '10 at 12:48 AM

StephanK gravatar image

StephanK
6k 39 53 93

Did you report a bug on this? in that case, can you post the 6-ciphered case number, so we can follow up on it and link this question to the case. Thanks.

Feb 23 '10 at 11:09 AM Nicolaj Schweitz ♦♦

If you want I can file a bug, but it's more a missing "feature" (not being able to create non 3d sounds on the fly) than a bug.

Feb 27 '10 at 11:37 AM StephanK
(comments are locked)
10|3000 characters needed characters left

4 answers: sort oldest

If the sound is stereo you uncheck the 3D sound checkbox for the sound, if sound is mono, it's always played 3D positioned.

--- Reaction on comment:

In that case I don't think you have many other options than add a sound source component to the camera and use this for playing back non-positioned sounds.

more ▼

answered Feb 20 '10 at 11:52 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

Well the sound is a stereo file (music) and the problem is, that I'm loading it during runtime, it's not an asset, so I can't uncheck the checkbox... I'd have to do it via scripting and I don't know how.

Feb 20 '10 at 12:08 PM StephanK
(comments are locked)
10|3000 characters needed characters left

Not tested but setting the rolloff to zero may be help.

more ▼

answered Feb 21 '10 at 04:10 AM

AliAzin gravatar image

AliAzin
2.5k 41 56 79

(comments are locked)
10|3000 characters needed characters left

Set doppler effect to 0 and see what happens.

more ▼

answered May 02 '10 at 09:02 AM

Ricky Helgesson gravatar image

Ricky Helgesson
59 1

(comments are locked)
10|3000 characters needed characters left

I found the problem to be "dopplerLevel" myself, adding some setup code to my audio source alleviated the problem:

// setup the audio source
AudioSource source = audioPoint.GetComponent( );
source.volume = volume;
source.dopplerLevel = 0f;  // <---- Set dopplerLevel to 0 and all should be well!
source.PlayOneShot( clip );
more ▼

answered Jan 31 at 05:38 PM

Lypheus gravatar image

Lypheus
292 28 35 49

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1027

asked: Feb 20 '10 at 12:48 AM

Seen: 1381 times

Last Updated: Jan 31 at 05:38 PM