I’m emulating volumetric sound by doing a player trace to the volume and playing a sound at that location and switching the sound’s channel to head-relative once the player enters the volume.
I noticed whenever I’m switching between world and head-relative, the sound stops playing. I have logic in my game that manually loops a 10 second sound. The sound plays correctly world-relative, and once I enter the volume no more sound is heard. Once that sound on that channel stops playing and is restarted, I then hear it head-relative like I’m supposed to. This behavior is also present when leaving the volume. Sound starts playing head-relative, player walks out of volume, sound cuts out… but once it loops around (manual looping) it is world-relative.
Is real-time transitioning of a Channel between HEADRELATIVE and WORLDRELATIVE supported without sound interruption?
Here’s some snippets:
// Initialize FMOD.
result = FModSystem->init(MAX_AUDIOCHANNELS, FMOD_INIT_NORMAL, 0);[/code:2oaeunq4]
Here’s where the channel is created
[code:2oaeunq4] // Play the sound now (start it in paused mode) so we can get a valid channel from FMod
FMOD_RESULT Result = FModSystem->playSound(DesiredFMODChanIndex, // specified channel index
Buffer->FModSound, // FMODSound reference (with wave data) to play
true, // start paused
&FModChannel); // Channel for sound (should be grouped appropriately)[/code:2oaeunq4]
Initializing the channel to WORLDRELATIVE or HEADRELATIVE depending on the sound’s needs at creation-time (can dynamically change)
[code:2oaeunq4] FModChannel->setMode(WaveInstance->bUseSpatialization ? FMOD_3D_WORLDRELATIVE : FMOD_3D_HEADRELATIVE);[/code:2oaeunq4]
Here’s the code that creates the Sound played on the previously created Channel
[code:2oaeunq4] FMOD_RESULT Result = FModSystem->createSound(
(char*) Wave->RawData.Lock(LOCK_READ_ONLY), // Data pointer
FMOD_OPENMEMORY | FMOD_CREATECOMPRESSEDSAMPLE | FMOD_3D, // Flags
&ExtendedSoundInfo, // Extended info
Here’s the code that runs every frame, bUseSpatialization gets changed to false whenever the player enters the volume.
[code:2oaeunq4] // We’re using a relative coordinate system for un-spatialized sounds.
if( !bUseSpatialization ) // if no spatialization wanted
Location = FVector( 0.f, 0.f, 0.f );
FModChannel->setMode( FMOD_3D_HEADRELATIVE );
else // world-relative sound (spatialized)
FModChannel->setMode( FMOD_3D_WORLDRELATIVE );
- Dogbert asked 11 years ago
I’m also noticing that this code:
[code:267j8pyb] float PanLevel;
FModChannel->set3DPanLevel( 0.0f );
FModChannel->get3DPanLevel( &PanLevel );
printf( "Set PanLevel to 0, new PanLevel is %f", PanLevel );[/code:267j8pyb]
Always prints out:
"Set PanLevel to 0, new PanLevel is 1.000000"
If this value isn’t sticking, that could possibly explain some of the issues I’m having (although the fact that I’m noticing any change in the spatialization if this value isn’t changing worries me a bit as well).
Thanks! I can’t believe I neglected to check the error codes.
Now I’m noticing better behavior (uniform pan according to the speaker mix when 3dPanLevel is set to 0) [b:g40wfah1]however I’m still hearing that the overall volume is attenuated based on how far away I am from 0,0,0[/b:g40wfah1]
edit: I’ve also verified that the volume passed to the channel each frame in setVolume() is always the same
(I’m also noticing that whenever 3dPanLevel is 0, the sound is actually quieter than it is when 3dPanLevel is 1.0 and the sound is almost on top of me, but that’s something I can probably fix with volume adjustments)
I abandoned my attempt to use set3dPanLevel to accomplish my goal, since I could not solve the problem of the volume attenuating based on the player’s position in the world (even with PanLevel = 0.0)
However after making the change over to FMOD_SOFTWARE I’m noticing that I can dynamically switch between WORLDRELATIVE and HEADRELATIVE correctly, even in the middle of a playing sound.
So, fixed my problem, but took the long way around.
3dpanlevel = 0 does not attenuate with volume. Simply modify the 3d example and it sounds loud and on top of you no matter what 3d settings you set. It is not attenuated.
I’ve adjusted the function to attenuate doppler though, it was still doing this.
Yeah, that’s definitely what the docs say, but that’s not been my experience. I haven’t done any super rigorous testing, but we’ve actually had a few bugs with sounds getting left at 3d pan level 0 and staying at full volume even as the player moved away from the source of the sound. I hope it’s not a bug, because the current behavior is exactly what I want
I have noticed that doppler is still in effect when 3d pan level is 0. It hasn’t been a problem for us, but I would prefer it if the doppler was "faded out" as well.
Also, the docs have this to say about 3d pan level "Useful for morhping a sound between 3d and 2d. This is most common in volumetric sound, when the sound goes from directional, to ‘all around you’ (and doesnt pan). " So it sounds like the intent of the feature is the same as what you and I want.
Hm I think in the old days the volume was still attenuated, but we changed that, so yeah the docs will need a tweak there :). It is correctly, when panlevel is 0, the sound is fully 2d. I guess we might have missed doppler but you can scale doppler factor for the voice seperately.
So I’ve started trying to use set3dPanLevel() but it’s not working. I was under the impression that the 3dPanLevel overrides the 3d position and attenuation.
When I transition the sound to 3dPanLevel( 0 ), I find that both the pan of the sound is based on the player’s position relative to the world’s xyz (0, 0, 0)
The pan also does not change if I rotate around, however it does change (along with the volume) if I walk around 0, 0, 0
I am also calling SetSpeakerMix() with all 1.0s to make sure that the pan/volume should be uniformly distributed, but am still seeing (hearing?) this issue.
Are there any normal 3d-related calls that I should not be making on FModChannel when I’ve set the 3d pan level to 0?
Please login first to submit.