Audio emitters

BeginnerProgrammerDesigner Audio emitter components emit audio used to create spatialized audio. You can add them to any entity. audio listener moves closer to and away from the audio emitter.

Note

AudioListenerComponent in the scene to hear audio from audio emitters.

1. Set up an audio emitter asset

  • Scene view, select an entity you want to be an audio emitter.
  • Property Grid, click Add component and select Audio Emitter. Now we need to add audio to the emitter.
  • Audio Emitter, click (Add) and specify a name for the audio.
  • Asset View, drag and drop an audio asset to the audio you just added: (Select an asset). Then choose an audio asset:
  • Repeat steps 3 and 4 to add as many audio assets as you need.
  • Configure the properties for this audio emitter.

    2. Create a script to play the audio

    Now we need to create a script to play and configure the audio asset.
  • AudioEmitterSoundController for each sound you want to use in the script. MySound1 and MySound2:
    1. AudioEmitterComponent audioEmitterComponent = Entity.Get<AudioEmitterComponent>();AudioEmitterSoundController mySound1Controller = audioEmitterComponent["MySound1"];AudioEmitterSoundController mySound2Controller = audioEmitterComponent["MySound2"];
  • AudioEmitterSoundController properties and methods to play and configure the audio: For example:
    1. mySound1Controller.IsLooping = true;mySound1Controller.Pitch = 2.0f;mySound1Controller.Volume = 0.5f;mySound1Controller.Play();
    AudioEmitterSoundController Xenko API documentation.

    3. Add the script to the audio emitter entity

    Add component. Add the script to the audio emitter entity.
  • Scene view, select an entity you want to be an audio emitter.
  • Add component and select the script.

    See also

  • Spatialized audio
  • Audio listeners
  • Global audio settings