Table of Contents

Class RainSoundscape

Namespace
DFA.Puddlecraft

Procedural rain: ten frequency bands, from deep rumble to bright hiss, each a pair of stems that crossfade into an endless loop. How loud each band is comes from preset curves (light, medium, heavy, covered) blended by the rain intensity and by whether the listener is under cover. A band's gain is its level cubed.

[Serializable]
public sealed class RainSoundscape
Inheritance
RainSoundscape

Fields

BandCount

Number of frequency bands.

public const int BandCount = 10

Field Value

int

Properties

bands

The ten bands, from deepest (0) to brightest (9). Always BandCount long; assign stems to its elements.

public RainStem[] bands { get; }

Property Value

RainStem[]

covered

Band levels heard from under cover in a downpour. Across: band, deepest (0) to brightest (1). Up: level, 0 to 1.

public AnimationCurve covered { get; set; }

Property Value

AnimationCurve

heavy

Band levels in a downpour. Across: band, deepest (0) to brightest (1). Up: level, 0 to 1.

public AnimationCurve heavy { get; set; }

Property Value

AnimationCurve

light

Band levels in light rain. Across: band, deepest (0) to brightest (1). Up: level, 0 to 1.

public AnimationCurve light { get; set; }

Property Value

AnimationCurve

medium

Band levels in medium rain. Across: band, deepest (0) to brightest (1). Up: level, 0 to 1.

public AnimationCurve medium { get; set; }

Property Value

AnimationCurve

Methods

Gain(float)

Gain for a band level: the level cubed, so the curves read like a mixing desk.

public static float Gain(float level)

Parameters

level float

Returns

float

Level(int, float, float)

The level (0 to 1) of a band for a rain intensity, and for how exposed the listener is (1 out in the rain, 0 under cover). Silent when it isn't raining.

public float Level(int band, float intensity, float exposure)

Parameters

band int
intensity float
exposure float

Returns

float

Preset(params float[])

A preset curve through the given band levels, deepest first.

public static AnimationCurve Preset(params float[] levels)

Parameters

levels float[]

Returns

AnimationCurve

PresetWeights(float, out float, out float, out float)

How much of the light, medium and heavy presets a rain intensity uses. They add up to 1.

public static void PresetWeights(float intensity, out float light, out float medium, out float heavy)

Parameters

intensity float
light float
medium float
heavy float