Scriptable audio listener modes


#1

note: these APIs are not documented yet (so best to treat as experimental for now!)

Interface has excellent support for positional audio – so what you hear is usually in terms of your Avatar’s present position and orientation.

However, there are actually three different listening modes available: Head, Camera and Custom.

I was pretty excited to discover this API because of all the cool virtual tools that can be improvised just by adjusting listener position! (and have brainstormed a few below to consider)

It doesn’t seem like these modes have been mentioned before – so here is a quick rundown of how they work from the Scripting side:

// --------------------------------------------------------------
// hear from your Avatar's perspective
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeHead;

// --------------------------------------------------------------
// hear from the Camera's perspective
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeCamera;

// --------------------------------------------------------------
// hear from a Custom position and orientation
// for example, let an Entity be your ears:
var uuid  = Entities.findClosestEntity(MyAvatar.position, 10),
    props = Entities.getEntityProperties(uuid, ['position','rotation']);
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeCustom;
MyAvatar.customListenPosition = props.position;
MyAvatar.customListenOrientation = props.rotation;

Also, here is an extended example that demonstrates how to track changes to the audio mode.

Brainstorming

Contraptions that people should try making:

  • Microphone (wearable Entity)
  • Grabbable, directional and with a way for nearby Avatars to “opt into” hearing from its perspective.
  • Speakerphone (Entity)
  • Like an omnidirectional, fixed-location version of the above.
  • Walkie Talkies (paired Entities)
  • Virtual push-to-talk style – so instead of messing with global attenuation, two buddies can still be in faraway spots on a domain and crack jokes.
  • Judas Ear (wearable Entity)

Contraptions that people should not try making:

  • Megaphone (wearable Entity)
  • Don’t make something that forces all Avatars within a forward frustum to hear you barking orders at them.
  • Spy Cockroach (remote controlled Entity)
  • Don’t make this:

https://www.youtube.com/watch?v=DrHMBletjXg