Skip to content

AudioAPI reference

Class Synth

Namespace: MicroEngine.Audio.Retro
Assembly: MicroEngine.Audio.dll
Guide: Synthesized sound effects

Deterministic waveform synthesis for sound effects and music voices.

C#
public static class Synth

Inheritance

object ← Synth

Methods

Envelope(float, float, float, float)

A linear attack-sustain-decay envelope: 0..1 at t seconds.

C#
public static float Envelope(float t, float attack, float sustain, float decay)

Parameters

t float

attack float

sustain float

decay float

Returns

float

Layer(params (AudioClip Clip, float Offset)[])

Mixes several clips (mono) starting at given offsets in seconds.

C#
public static AudioClip Layer(params (AudioClip Clip, float Offset)[] parts)

Parameters

parts (AudioClip Clip, float Offset)[]

Returns

AudioClip

Exceptions

ArgumentException

A clip is not mono or not at DefaultSampleRate.

NoteFrequency(string)

Frequency of a note name such as “C4”, “F#3” or “Bb5” (A4 = 440 Hz).

C#
public static float NoteFrequency(string note)

Parameters

note string

Returns

float

Oscillator(Wave, float, float)

The value of wave at phase, in -1..1.

C#
public static float Oscillator(Wave wave, float phase, float noise)

Parameters

wave Wave

The waveform.

phase float

Position in the cycle, 0..1.

noise float

The value returned for Noise.

Returns

float

Render(SfxParams, int)

Synthesizes a mono sound effect. The same parameters always produce the same samples.

C#
public static AudioClip Render(SfxParams p, int sampleRate = 44100)

Parameters

p SfxParams

The sound description.

sampleRate int

Samples per second of the result.

Returns

AudioClip

A mono clip, ready for AddSound.