Position, Index and Callback OnEnter attenuation of a listener

Sorry for a lame question.
Is it possible to get Position, Index and Callback onEnter of a listener in attenuation without Unity collisions?
I’m guessing FMOD is constantly receiving this info, maybe there is a way to get it.
By using Unity collisions we would duplicate process or I’m mistaken?

1 Like

Hi,

Could you elaborate on the functionality you are looking for? If you look at StudioListener.cs you are able to use ListnerCount() to retrieve the current index of the listener. There is also the listeners list that you can use to check all the other listeners. You could track the position of the listeners yourself using the list and avoid having to use collisions. Let me know if the helps.

Sorry, didn’t give you any context. I’m thinking about stereo audio system for split screen car game.
I want every event has panning parameter (every event that I need to be panned). This parameter depend on proximity of event to listeners. Which one is closer those channel gets more signal from event.
So thank you for
RuntimeManager.StudioSystem.getListenerAttributes(0, out FMOD.ATTRIBUTES_3D attributes); this is what I need to get distance to sound source (event).
But I need also to know if a listener is inside attenuation radius. I can calculate it by finding distance to event, but I don’t like an idea every event has a script to calculate distance to two listeners all the time.
So maybe there is a sort of event (delegate) which indicates that a listener is inside attenuation?

Hi,

Thank you for the explanation. A solution may be to use the FMOD_STUDIO_EVENT_CALLBACK_VIRTUAL_TO_REAL callback (FMOD Engine | Studio API Reference - FMOD_STUDIO_EVENT_CALLBACK_TYPE). With the events stealing behavior set to virtualization (FMOD Studio | Advanced Topics - Stealing)
image

The callback is triggered when an event becomes real and is heard by a listener. An example for setting up a callback can be found here: Unity Integration | Scripting Examples - Timeline Callbacks

Let me know if this is the behavior you are looking for.

Thank you. I didn’t have much time to experement this week.
I set a FMOD_STUDIO_EVENT_CALLBACK_VIRTUAL_TO_REAL but it works only if the same event is present on scene and it becomes real or virtual. With only one event present this callback isn’t triggered, at least I can’t make it happen, I might certainly miss something.
The only solution I can think of is to make one event for athmospheres so it would be only one real possible. Also first spawned event (possiblly) takes back voice once player leave another instances, means that it doesn’t leave current event virtual but passes virtual voice to first one.

Hi,

How many events are typically playing in the scene?

If there is a limited number of events, I feel this may be your best solution.

The virtualization solution should work if you have lots of events constantly moving in and out of audible range.

Apologies if I miss-understood, could I get another explanation or would it be possible to get the Unity and FMOD Studio project uploaded to your profile to test on my end? Keep in mind you will have to register a project with us to be able to upload.

You really helped me, thank you. And you understood right I don’t have a lot of objects on scene. 8 cars, 4-5 location based sounds, and some NPCs walking around. Cars have most complicated sound system, but in split screen it’s easy, all sounds will go to separate channel. So I’ll use distance calculation.

Still I’d love to share project I hope I’ll do it on weekend so we can discuss if my implementation of virtualization was right. If it’s possible. I have few questions about it. I need to make some basic project for that, because unity project I’m reseaching for isn’t ready and too big.

1 Like

Ok, I put project here GitHub - doudar41/SplitScreenFMODPan This is not a company project just test one so I’m not sure if I need to register it. If it’s better option I’ll do it.
The result is like this https://youtu.be/zaphUb9P-Uk
I couldn’t make singleton that would instantiate event for each game objects, so it’s a bit mess.
But hopefully an idea is understandable.

1 Like

Hi,

Thank you for the project. I can now see the issue with using the event callback. There is still an option but it is a bit more involved. There is the VOL0 Vritual init flag (FMOD Studio | White Papers - VOL0 Virtual) that will virtualize any channel that has its audibility drop below a certain threshold. However, this is for channels rather than events which is part of the core api system. Also, we will have to get the channel from the event instance which when using referenced events is a bit more confusing.

This is definitely an option but calculating the distance from each object may be an easier way to go. Let me know your thoughts.

Again, thank you for the project.

1 Like

Thank you for this. I think I need a bit more understanding of Core API to test this one. I want to finish different project I started before so I’ll let you this one to wait for some time. But if you can give a hint of how to get channel from event instance that would be great.
I appreciate your help. Thank you again.

1 Like

Hi,

Unfortunately, I was mistaken. This idea won’t work using referenced events as you won’t be able to access their channels. Would it be possible to change the Athmos event so that it does not use referenced events? If so, then the set up will also be a lot easier as well.

1 Like

Yeah, I just didn’t think that it might be a problem, because I don’t know how to access event channel yet. I used it to make a setup “solo” event easier)) more organized, because athmopheres will be not that simple as they are now. But anything is possible till I started to implement it into the game)

1 Like

Hi,

Thanks for the info. With the simpler setup, retrieving the channel is quite straightforward.

  1. We get the channel group from the event instance: FMOD Engine | Studio API Reference - getChannelGroup.
  2. Work down the channelgroups till we find the channel.
  1. Once the channel is found we will grab it: FMOD Engine | Core API Reference - getChannel.
  2. Now we will set the new callback: FMOD Engine | Core API Reference - setCallback.
  3. Using the flag VritualVoice: FMOD Engine | Core API Reference - FMOD_CHANNELCONTROL_CALLBACK_TYPE.

Hopefully, this will outline the process of retrieving the correct channel and assigning the correct callback.

1 Like