Skip to content

SoundPlayer

namespace Griff.Scenes;
public sealed class SoundPlayer : Component

Plays its Sound when something happens, with no code: whenever its Message is sent (by a pickup, a switch, a counter, an enemy’s death message or Game.Send), and when it appears if OnStart is ticked. PitchVariation makes each play a little different, so a sound heard over and over doesn’t grate.

This is a component: its saved properties are on its component page.

public string? Message { get; set; }

The message that plays it, e.g. “Score”. Empty plays it only on start.

public bool OnStart { get; set; }

Plays it as soon as it appears: a scene’s opening sting, a spawned explosion.

public float Pitch { get; set; }

1 as recorded, 2 an octave up, 0.5 an octave down.

public float PitchVariation { get; set; }

How far each play’s pitch wanders at random either way: 0.1 is up to a tenth higher or lower.

public bool Positional { get; set; }

Heard from where it is (quieter off screen, from that side) rather than everywhere equally.

public string? Sound { get; set; }

The sound to play, e.g. “Sounds/door.wav”. Make one with Audio > New Sound.

public float Volume { get; set; }

How loud, 0 to 1, on top of the player’s sound volume.