Table of Contents

Class SoundLibrary

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

Every synthesised clip, made once on first request and kept for the life of the process.

public static class SoundLibrary
Inheritance
SoundLibrary
Inherited Members

Remarks

Made off the main thread. A recipe is pure arithmetic (SoundSynth), so it runs on the thread pool and only the clip is made back on the main thread, when Get(string, Func<float[]>, int) is next asked. Until then Get(string, Func<float[]>, int) returns null and the caller stays silent for those few frames: a rain loop that starts a quarter of a second late is better than a frame that hitches to make it. A recipe must not call Unity — on a worker that throws, and the sound would never be heard.

WebGL has no threads: there the recipe runs where it is asked for.

Methods

Get(string, Func<float[]>, int)

The clip made by recipe under key, or null while it is being made. The key names the sound and must change when the recipe does.

public static AudioClip Get(string key, Func<float[]> recipe, int rate = 44100)

Parameters

key string
recipe Func<float[]>
rate int

Returns

AudioClip

GetNow(string, Func<float[]>, int)

Makes the clip now, on this thread, if it is not made yet: for a test or a scene's first frame.

public static AudioClip GetNow(string key, Func<float[]> recipe, int rate = 44100)

Parameters

key string
recipe Func<float[]>
rate int

Returns

AudioClip