After I played the audio for the entity the sound was very low and I wanted to adjust the sound size. No api is found. What should I do
if let audio = audioResources {
entity.playAudio(audio)
}
Hi @Liangmu
To adjust the volume, assign an audio component to an entity then adjust its gain property. The gain level is in relative decibels, in the range [-Decibel.infinity, Decibel.zero], where Decibel.zero is the default. The volume increases as the gain approaches zero.
There are 3 audio components. Refer to the documentation to pick the one that works best for your use case. Let me know if you need help picking.
For example, here's code to adjust the volume of spatial audio:
entity.spatialAudio = SpatialAudioComponent(gain: -10)
That said, gain defaults to zero so you can decrease the volume, but not increase it. Does the audio sound low when you play it outside of visionOS? If so, consider using an audio editor to increase its gain.
Finally, if you are testing in the simulator make sure you've considered the volume level on the simulator. You can control it via the simulator's I/O menu.