Table of Contents

Class SoundEffectInfo

Namespace
MLEM.Sound
Assembly
MLEM.dll

A sound effect info is a wrapper around Microsoft.Xna.Framework.Audio.SoundEffect that additionally stores Volume, Pitch and Pan information. Additionally, a RandomPitchModifier can be applied, a Microsoft.Xna.Framework.Audio.SoundEffectInstance can be created using CreateInstance(bool), and more.

public class SoundEffectInfo
Inheritance
SoundEffectInfo
Inherited Members
Extension Methods

Constructors

SoundEffectInfo(SoundEffect, float, float, float)

Creates a new sound effect info with the given values.

public SoundEffectInfo(SoundEffect sound, float volume = 1, float pitch = 0, float pan = 0)

Parameters

sound SoundEffect

The sound to play

volume float

The volume to play the sound with

pitch float

The pitch to play the sound with

pan float

The pan to play the sound with

Fields

Pan

Pan value ranging from -1.0 (left speaker) to 0.0 (centered), 1.0 (right speaker).

public float Pan

Field Value

float

Pitch

Pitch adjustment, ranging from -1.0 (down an octave) to 0.0 (no change) to 1.0 (up an octave). To incorporate RandomPitchModifier, you can use GetRandomPitch().

public float Pitch

Field Value

float

RandomPitchModifier

A value that allows randomly modifying Pitch every time Play() or CreateInstance(bool) are used. The random modifier that is added onto Pitch will be between -RandomPitchModifier and RandomPitchModifier.

public float RandomPitchModifier

Field Value

float

Sound

The Microsoft.Xna.Framework.Audio.SoundEffect that is played by this info.

public readonly SoundEffect Sound

Field Value

SoundEffect

Volume

Volume, ranging from 0.0 (silence) to 1.0 (full volume). Volume during playback is scaled by SoundEffect.MasterVolume.

public float Volume

Field Value

float

Methods

CreateInstance(bool)

Creates a new Microsoft.Xna.Framework.Audio.SoundEffectInstance with this sound effect info's data.

public SoundEffectInstance CreateInstance(bool isLooped = false)

Parameters

isLooped bool

The value to set the returned instance's Microsoft.Xna.Framework.Audio.SoundEffectInstance.IsLooped to. Defaults to false.

Returns

SoundEffectInstance

A new sound effect instance, with this info's data applied

GetRandomPitch()

Returns a random pitch for this sound effect info that is between Pitch - RandomPitchModifier and Pitch + RandomPitchModifier. If RandomPitchModifier is 0, this method always returns Pitch.

public float GetRandomPitch()

Returns

float

A random pitch to use to play this sound effect

Play()

Plays this info's Sound once.

public bool Play()

Returns

bool

False if more sounds are currently playing than the platform allows