Interface ISoundEmitter
A sound emitter allows to bind an audio clip to an entity which is moving on a screen. Playing a sound from the emitter will pan it or set the volume (both can be turned off) to sound like it coming from the same location the entity is in. You can also assign the emitter to automatically play the sound on specific animation frames (so it's a perfect fit for footsteps, for example).
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public interface ISoundEmitter : ISoundPlayer
Examples
var footstep = await game.Factory.Sound.LoadAudioClipAsync("Sounds/footstep.ogg");
ISoundEmitter emitter = new AGSSoundEmitter(game);
emitter.AudioClip = footstep;
emitter.Object = cHero;
emitter.Assign(cHero.Outfit[AGSOutfit.Walk], 1, 5); //will play the footstep on frames 1 and 5 of the walking animation
Properties
| Improve this Doc View SourceAudioClip
Gets or sets the audio clip that is bound to the emitter.
Declaration
IAudioClip AudioClip { get; set; }
Property Value
Type | Description |
---|---|
IAudioClip | The audio clip. |
AutoAdjustVolume
Gets or sets a value indicating whether this ISoundEmitter auto adjusts volume when the bound entity is standing on a volume changing area. This is on by default.
Declaration
bool AutoAdjustVolume { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
AutoPan
Gets or sets a value indicating whether this ISoundEmitter auto pans the sound based on the location (panning is the act of distributing the sound across left/right speakers to make the sound appear more to the left/right). This is on by default.
Declaration
bool AutoPan { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EntityID
Gets or sets the entity identifier. This is used by the emitter to check if the entity is in a volume altering area, to change the volume of the sound accordingly. You can set the Object property instead a short-hand convience.
Declaration
string EntityID { get; set; }
Property Value
Type | Description |
---|---|
System.String | The entity identifier. |
HasRoom
Gets or sets the room component, for the emitter to not play the sound if the entity is not in currently rendered room. You can set the Object property instead a short-hand convience.
Declaration
IHasRoomComponent HasRoom { get; set; }
Property Value
Type | Description |
---|---|
IHasRoomComponent | The has room. |
Object
Sets the object which is bound to the emitter. This is a short-hand to set the translate, room and entity id components.
Declaration
IObject Object { set; }
Property Value
Type | Description |
---|---|
IObject | The object. |
WorldPosition
Gets or sets the world position component (for binding to location). You can set the Object property instead a short-hand convience.
Declaration
IWorldPositionComponent WorldPosition { get; set; }
Property Value
Type | Description |
---|---|
IWorldPositionComponent | The translate. |
Methods
| Improve this Doc View SourceAssign(IAnimation, Int32[])
Assign the specified animation frames to play the sound whenever the frames are showing.
Declaration
void Assign(IAnimation animation, params int[] frames)
Parameters
Type | Name | Description |
---|---|---|
IAnimation | animation | The animation. |
System.Int32[] | frames | The frame numbers (where 0 is the first frame). |
Assign(IAnimationFrame[])
Assign the specified animation frames to play the sound whenever the frames are showing.
Declaration
void Assign(params IAnimationFrame[] frames)
Parameters
Type | Name | Description |
---|---|---|
IAnimationFrame[] | frames | Frames. |
Assign(IDirectionalAnimation, Int32[])
Assign the specified animation frames (in all directions) to play the sound whenever the frames are showing. This assumes all animations in all directions have matching frames, otherwise use the more specific overloads.
Declaration
void Assign(IDirectionalAnimation animation, params int[] frames)
Parameters
Type | Name | Description |
---|---|---|
IDirectionalAnimation | animation | The animation. |
System.Int32[] | frames | The frame numbers (where 0 is the first frame). |