Open DrSanjeep opened 1 month ago
@DrSanjeep Steam Audio is designed to interpolate between successive frames for smooth variation of distance attenuation, direction, etc, so rapid teleportation of the AudioSource may not produce the results you might be expecting.
Also, what is the value of Doppler level in the Audio Source settings? If this is non-zero, Unity might be applying very aggressive Doppler effect to the audio clip, resulting in distortion.
@lakulish thank you. i have tried doppler 0 and 1 and it sounds the same. do you happen to know the recommended method to overcome or clear this interpolation? can this system make a bullet ricochet sound from a raycast for instance? do i have to recreate the unity audio source?
@DrSanjeep You can certainly use Steam Audio to make one-off sounds like a bullet ricochet. You will, however, have to use a separate Audio Source for each ricochet (you can use a pool of a finite number of Audio Sources for this).
@lakulish so i can only use an audio source once. i think i can do that but its going to be annoying. Wish i could just reset it
Using a pool of audio sources was not a good solution because 1. The pool runs out 2. It means continuously filling the pool
turns out the performance suffers having to create a new source for every sound played. will anything be done?
@DrSanjeep I'd like to understand more about the performance impact you're seeing. Is there a minimal Unity project you can share that exhibits this issue?
@lakulish I don't have a minimal Unity project to hand but the profiler image shows it costs around 1ms to create the sound
@lakulish or this
Hey, sounds like you’ve got a tricky issue there! It seems like the rapid position changes are messing with the audio playback. Here are a few more things you might try:
Check for Overlapping Audio Sources: Since you're changing the position so quickly, the AudioSource
might be getting confused or creating overlaps. Creating a new AudioSource
object each time you change positions, as you’re doing, is a smart move. Just make sure you’re cleaning up old ones properly to avoid clutter.
Debug with Simple Sounds: Sometimes, testing with a simple sound or a different clip can help rule out if the issue is with the clip itself or how it's being played.
Experiment with Audio Settings: Double-check all the audio settings in Unity and Steam Audio. Sometimes, small tweaks in distance attenuation or spatial settings can make a big difference.
Check Steam Audio Docs: There might be some specific settings or recommendations in the Steam Audio documentation that could help with this kind of setup.
Test in a New Scene: Sometimes, starting fresh in a new scene can help isolate the problem. Try setting up a new scene with just the basics to see if the issue persists.
Hopefully, this helps smooth things out a bit!
also i would like to avoid allocating 1KB every sound played
@DrSanjeep That does seem like a significant amount of time for instantiating the prefab. Can you share more details about how the Steam Audio Source is configured? Again, a minimal Unity project will help us diagnose the issue. Thanks!
steamaudio_unity_4.5.3 Unity version: 2022.3.38f1
I don't know ahead of time where the next sound will play I hoped that i could move an audio source and then immediately play a sound but it sounds like its interpolating
Steps To Reproduce create a blank unity 3d project set up steamaudio unity 4.5.3 create an empty game object add audio source with short audio clip e.g. footstep set the 3D slider to 3D add the steam sudio source Enable Distance Attenuation add the below script play the scene check Spatialize to hear distorted sounds
we expect to hear only one sound because the second sound its too far away but we hear two distorted sounds
the script below attempts to play the sound in one position, waits 0.5 seconds then plays the sound in the second position and repeats. And it sounds terrible