Plush

SoundVoice#

PlushEngine · Type index

Namespace: PlushEngine

One playing copy of a Sound, returned by Scene.PlaySound. Keep it to change the sound while it plays (an engine's pitch following its speed: voice.PitchCents = rpm * .5f), to move it, to stop it, or to wait for it in a coroutine (yield return voice.WaitUntilDone()). It is safe to keep after the sound ends and safe to ignore: finished voices release themselves. A play skipped by the Sound's cooldown returns a voice that has already finished.

public sealed class SoundVoice

Members: Entity · IsPlaying · MoveTo · Note · Off · Pan · PitchCents · Position · Sound · Stop · Time · Volume · WaitUntilDone

Entity#

public RuntimeEntity? Entity { get; }

The object it follows (null when played at a point or flat). It stops when the object is destroyed.

IsPlaying#

public bool IsPlaying { get; }

False once it has finished, been stopped, been replaced by a newer copy, or was skipped.

MoveTo#

public void MoveTo(Vector3 position);

Move a sound played at a point (a bullet's whizz).

Note#

public Note Note { get; }

The note it was played at.

Off#

public void Off();

Note-off: the Sound's envelopes release and the voice ends once they have faded (a held organ note let go). A Sound without a volume envelope has nothing to release, so it stops (without a click).

Pan#

public float Pan { get; set; }

Pan -1 (left) to 1 (right) for the flat part of the sound (a positioned sound is panned by the camera).

PitchCents#

public float PitchCents { get; set; }

Extra pitch on top of the note, in cents (100 is a semitone up).

Position#

public Vector3? Position { get; }

Where it plays from (world), or null for a flat sound.

Sound#

public SoundAsset Sound { get; }

Stop#

public void Stop(float fade = 0);

Stop, fading out over fade seconds (a very short fade even at 0, so nothing clicks).

Time#

public double Time { get; }

Seconds since it started (real time).

Volume#

public float Volume { get; set; }

Extra volume on top of the Sound and the note, as a gain (1 unchanged, 0 silent).

WaitUntilDone#

public Wait WaitUntilDone();

For coroutines: yield return voice.WaitUntilDone();

Note · RuntimeEntity · SoundAsset · Wait

Source#