AudioAPI reference
Class Song
Namespace: MicroEngine.Audio.Retro
Assembly: MicroEngine.Audio.dll
Guide: Synthesized sound effects
A tiny step sequencer. Patterns are whitespace-separated tokens, one per step: a note (“C4”, “F#3”, “Bb5”), “-” to hold the previous note, “.” to rest, “|” is ignored (bar lines). Drum tracks use “k” (kick), “s” (snare), “h” (hat), “o” (open hat) and “.” for rests. Shorter tracks loop to the song length, so a four-step drum loop can drive a long melody.
public sealed class SongInheritance
Constructors
Song(float, int)
Creates an empty song.
public Song(float bpm, int stepsPerBeat = 4)Parameters
bpm float
Tempo in beats per minute; must be positive.
stepsPerBeat int
Pattern steps per beat; must be positive.
Exceptions
bpm or stepsPerBeat is not positive.
Properties
Bpm
Tempo in beats per minute.
public float Bpm { get; }Property Value
DrumVolume
Volume of the drum tracks (default 0.5).
public float DrumVolume { get; set; }Property Value
Echo
Feedback echo mix (0 disables). Adds space to otherwise dry chip voices.
public float Echo { get; set; }Property Value
EchoDelayBeats
Delay of the echo in beats (default 0.75).
public float EchoDelayBeats { get; set; }Property Value
LengthInSteps
Number of steps in the longest track; the rendered song is this long.
public int LengthInSteps { get; }Property Value
StepSeconds
Length of one step in seconds.
public float StepSeconds { get; }Property Value
StepsPerBeat
Pattern steps per beat (4 by default: each step is a sixteenth note in 4/4).
public int StepsPerBeat { get; }Property Value
Methods
Drums(params string[])
Adds a drum track of “k”, “s”, “h”, “o” and “.” tokens; the patterns are joined in order.
public Song Drums(params string[] patterns)Parameters
patterns string[]
Returns
This song, for chaining.
Render(int)
Renders the whole song to stereo PCM, sized to loop seamlessly (echo tails wrap around).
public AudioClip Render(int sampleRate = 44100)Parameters
sampleRate int
Returns
Exceptions
The song has no steps.
A track has an invalid note or a drum track an unknown drum.
Track(Instrument, params string[])
Adds a melodic track. The patterns are joined in order into one sequence of steps.
public Song Track(Instrument instrument, params string[] patterns)Parameters
instrument Instrument
The voice that plays the notes.
patterns string[]
Note patterns (see the class remarks for the token format).
Returns
This song, for chaining.