AudioInstance
Namespace: MonineEngine.Audio
Plays audio as an instance. Supports loading audio both from RAM, and from streaming on the disk.
public class AudioInstance : System.IDisposable
Inheritance Object → AudioInstance
Implements IDisposable
Attributes NullableContextAttribute, NullableAttribute
Properties
IsStreamed
Tracks if the clip of the instance is loaded from memory, or streamed from the disk. True if the clip is streamed, false if the clip is preloaded.
public bool IsStreamed { get; }
Property Value
State
The current SoundState of the instance.
public SoundState State { get; }
Property Value
SoundState
Constructors
AudioInstance(SoundEffectInstance)
Constructs an instance that loads the audio from memory to play. Recommended for sound effects or short clips.
public AudioInstance(SoundEffectInstance memoryInstance)
Parameters
memoryInstance SoundEffectInstance
The SoundEffectInstance of the audio.
AudioInstance(String, Int32, AudioChannels, Single, Single, Single, Boolean)
Constructs an instance that loads the audio by streaming it from the disk. Recommended for songs or long clips, as it saves on RAM.
public AudioInstance(string path, int sampleRate, AudioChannels channels, float volume, float pitch, float pan, bool loop)
Parameters
path String
The path to the audio file in assets.
sampleRate Int32
The rate of streaming speed. Usually 44100.
channels AudioChannels
The channels the audio plays at. Can be either Mono or Stereo. Usually Stereo.
volume Single
The volume of the instance. Defaults to 1, ranges from 0 to 1.
pitch Single
The pitch of the instance. Defaults to 0, ranges from -1 to 1.
pan Single
The pan of the instance. Defaults to 0, ranges from -1 to 1.
loop Boolean
Whether the instance loops upon finishing clip playback.
Methods
Play()
public void Play()
Stop()
public void Stop()
SetVolume(Single)
public void SetVolume(float v)
Parameters
v Single
SetPitch(Single)
public void SetPitch(float p)
Parameters
p Single
SetPan(Single)
public void SetPan(float p)
Parameters
p Single
Dispose()
public void Dispose()