Ctrl+K

ManagedSynthBackend

Declaration

public sealed class Strawberry.Sound.Midi.ManagedSynthBackend

Pure managed C# MIDI synthesizer backend. Produces basic waveform output (sine, square, sawtooth, triangle, noise) with simple ADSR envelopes.

Remarks: This backend has ZERO native dependencies and is fully compatible with WebAssembly, AOT compilation, and any platform where .NET runs. It produces recognisable but not SoundFont-quality audio. For high-quality rendering on desktop, use TinySoundFontBackend. Waveform selection is mapped loosely from General MIDI program numbers: program ranges 0-7 → sine/triangle (piano-like), 8-15 → triangle (bell-like), 16-31 → square/saw (organ/guitar-like), etc.

Implements: Strawberry.Sound.Midi.ISynthBackend

Constructors

ManagedSynthBackend

void ManagedSynthBackend(int sampleRate = 44100, int channels = 2)

Parameters:

Name Type Description
sampleRate System.Int32 = 44100
channels System.Int32 = 2

Properties

SampleRate

int SampleRate { get }

Channels

int Channels { get }

Methods

NoteOn

void NoteOn(int channel, int key, float velocity)

Parameters:

Name Type Description
channel System.Int32
key System.Int32
velocity System.Single

NoteOff

void NoteOff(int channel, int key)

Parameters:

Name Type Description
channel System.Int32
key System.Int32

NoteOffAll

void NoteOffAll()

ProgramChange

void ProgramChange(int channel, int program)

Parameters:

Name Type Description
channel System.Int32
program System.Int32

ControlChange

void ControlChange(int channel, int controller, int value)

Parameters:

Name Type Description
channel System.Int32
controller System.Int32
value System.Int32

PitchWheel

void PitchWheel(int channel, int value)

Parameters:

Name Type Description
channel System.Int32
value System.Int32

Reset

void Reset()

RenderShort

int RenderShort(short[] buffer, int offset, int sampleFrames)

Parameters:

Name Type Description
buffer System.Int16[]
offset System.Int32
sampleFrames System.Int32

Dispose

void Dispose()