Class SpessaSharpProcessor

Namespace
SpessaSharp.Synthesizer
Assembly
SpessaSharp.dll

The core synthesis engine of spessasynth.

public sealed class SpessaSharpProcessor
Inheritance
SpessaSharpProcessor
Inherited Members

Constructors

SpessaSharpProcessor(int, Options?)

Creates a new synthesizer engine.

public SpessaSharpProcessor(int sampleRate, Synthesizer.Options? opts = null)

Parameters

sampleRate int

sample rate, in Hertz.

opts Synthesizer.Options?

The processor's options.

Fields

OnEvent

public Action<Event>? OnEvent

Field Value

Action<Event>

SampleRate

Sample rate in Hertz.

public readonly int SampleRate

Field Value

int

Properties

ChorusMacro

public Macro.Chorus ChorusMacro { get; set; }

Property Value

Macro.Chorus

ChorusProcessor

Synthesizer's Chorus processor.

public Effect.ChorusProcessor ChorusProcessor { get; }

Property Value

Effect.ChorusProcessor

CurrentTime

The current time of the synthesizer, in seconds. You probably should not modify this directly.

public double CurrentTime { get; }

Property Value

double

DelayMacro

public Macro.Delay DelayMacro { get; set; }

Property Value

Macro.Delay

DelayProcessor

Synthesizer's Delay processor.

public Effect.DelayProcessor DelayProcessor { get; }

Property Value

Effect.DelayProcessor

KeyModifierManager

Handles the custom key overrides: velocity and preset

public KeyModifier.Manager KeyModifierManager { get; }

Property Value

KeyModifier.Manager

MidiChannels

All MIDI channels of the synthesizer.

public ReadOnlySpan<MidiChannel> MidiChannels { get; }

Property Value

ReadOnlySpan<MidiChannel>

MidiParameters

The global MIDI parameters of the synthesizer. These are only editable via MIDI messages.

public ReadOnlySpan<GlobalMidiParameter> MidiParameters { get; }

Property Value

ReadOnlySpan<GlobalMidiParameter>

ReverbMacro

public Macro.Reverb ReverbMacro { get; set; }

Property Value

Macro.Reverb

ReverbProcessor

Synthesizer's reverb processor.

public Effect.ReverbProcessor ReverbProcessor { get; }

Property Value

Effect.ReverbProcessor

SoundBankManager

The sound bank manager, which manages all sound banks and presets.

public SoundBankManager SoundBankManager { get; }

Property Value

SoundBankManager

SystemParameters

The global system parameters of the synthesizer. These are only editable via the API.

public ReadOnlySpan<GlobalSystemParameter> SystemParameters { get; }

Property Value

ReadOnlySpan<GlobalSystemParameter>

VoiceCount

Current total amount of voices that are currently playing.

public int VoiceCount { get; }

Property Value

int

Methods

Apply(SynthesizerSnapshot)

Applies the snapshot to the synth.

public void Apply(SynthesizerSnapshot snapshot)

Parameters

snapshot SynthesizerSnapshot

The snapshot to apply.

ChannelPressure(int, int)

Executes a MIDI Channel Pressure (Aftertouch) message on the specified channel.

public void ChannelPressure(int channel, int pressure)

Parameters

channel int

The MIDI channel to send the channel pressure on.

pressure int

The pressure value, from 0 to 127.

ClearCache()

Clears the synthesizer's voice cache.

public void ClearCache()

ControllerChange(int, CC, int)

Executes a MIDI controller change message on the specified channel.

public void ControllerChange(int channel, Midi.CC controller, int value)

Parameters

channel int

The MIDI channel to change the controller on.

controller Midi.CC

The MIDI controller number (0-127).

value int

The value of the controller (0-127).

CreateMIDIChannel()

Creates a new MIDI channel and adds it to the synthesizer.

public void CreateMIDIChannel()

DestroySynthProcessor()

Destroy the synthesizer processor, clearing all channels and voices. This is irreversible, so use with caution.

public void DestroySynthProcessor()

GetSnapshot()

Gets a synthesizer snapshot from this processor instance.

public SynthesizerSnapshot GetSnapshot()

Returns

SynthesizerSnapshot

LockParameter(Type, bool)

Locks or unlocks a given Global MIDI Parameter. This prevents any changes to it until it's unlocked.

public void LockParameter(GlobalMidiParameter.Type parameter, bool isLocked)

Parameters

parameter GlobalMidiParameter.Type

The Global MIDI Parameter to lock.

isLocked bool

If the parameter should be locked.

NoteOff(int, int)

Executes a MIDI Note Off message on the specified channel. Stops playing a note.

public void NoteOff(int channel, int midiNote)

Parameters

channel int

The MIDI channel to send the note off.

midiNote int

The MIDI note number to stop playing.

NoteOn(int, int, int)

Executes a MIDI Note On message on the specified channel. Starts playing a note.

public void NoteOn(int channel, int midiNote, int velocity)

Parameters

channel int

The MIDI channel to send the note on.

midiNote int

The MIDI note number to play.

velocity int

The velocity of the note, from 0 to 127.

Remarks

If the velocity is 0, it will be treated as a Note Off message.

OnMissingPreset(MidiPatch, System)

A handler for missing presets during program change. By default, it warns to console.

public BasicPreset? OnMissingPreset(MidiPatch patch, Midi.System system)

Parameters

patch MidiPatch

The MIDI patch that was requested.

system Midi.System

The MIDI System for the request.

Returns

BasicPreset

If a BasicPreset instance is returned, it will be used by the channel.

PitchWheel(int, int, int?)

Executes a MIDI Pitch Wheel message on the specified channel.

public void PitchWheel(int channel, int pitch, int? midiNote = null)

Parameters

channel int

The MIDI channel to send the pitch wheel on.

pitch int

The new pitch value: 0-16383

midiNote int?

The MIDI note number (optional), pass -1 for the regular pitch wheel.

PolyPressure(int, int, int)

Executes a MIDI Poly Pressure (Aftertouch) message on the specified channel. This differs from the Channel Pressure in that it's per-note and not for the whole channel.

public void PolyPressure(int channel, int midiNote, int pressure)

Parameters

channel int

The MIDI channel to send the poly pressure on.

midiNote int

The MIDI note number to apply the pressure to.

pressure int

The pressure value, from 0 to 127.

Process(ArraySegment<float>, ArraySegment<float>, int?, int?)

Renders float32 audio data to stereo outputs; buffer size must be equal or smaller than maxBufferSize. All float arrays must have the same length.

public void Process(ArraySegment<float> left, ArraySegment<float> right, int? startIndex = 0, int? sampleCount = null)

Parameters

left ArraySegment<float>

The left output channel.

right ArraySegment<float>

The right output channel.

startIndex int?

Start offset of the passed arrays, rendering starts at this index, defaults to 0.

sampleCount int?

The length of the rendered buffer, defaults to float32array length - startOffset.

Process(Span<short>, int?, int?)

public void Process(Span<short> output, int? startIndex = 0, int? sampleCount = null)

Parameters

output Span<short>
startIndex int?
sampleCount int?

ProcessMessage(ReadOnlySpan<byte>, int?, double?)

Processes a raw MIDI message and allows scheduling it at a specific time.

public void ProcessMessage(ReadOnlySpan<byte> message, int? channelOffset = null, double? time = null)

Parameters

message ReadOnlySpan<byte>

The MIDI message to process.

channelOffset int?

The channel offset for the message. It will be added to message's channel number if applicable

time double?

The audio context time when the event should execute, in seconds.

ProcessSplit(ReadOnlySpan<(ArraySegment<float> Left, ArraySegment<float> Right)>, Span<float>, Span<float>, int?, int?)

Renders float32 audio data to stereo outputs; buffer size must be equal or smaller than maxBufferSize. All float arrays must have the same length.

public void ProcessSplit(ReadOnlySpan<(ArraySegment<float> Left, ArraySegment<float> Right)> outputs, Span<float> effectsLeft, Span<float> effectsRight, int? startIndex, int? samples = null)

Parameters

outputs ReadOnlySpan<(ArraySegment<float> Left, ArraySegment<float> Right)>

Any number stereo pairs (L, R) to render channels separately into.

effectsLeft Span<float>

The left stereo effect output buffer.

effectsRight Span<float>

The right stereo effect output buffer.

startIndex int?

Start offset of the passed arrays, rendering starts at this index, defaults to 0.

samples int?

The length of the rendered buffer, defaults to float32array length - startOffset.

ProgramChange(int, int)

Executes a MIDI Program Change message on the specified channel.

public void ProgramChange(int channel, int programNumber)

Parameters

channel int

The MIDI channel to send the program change on.

programNumber int

programNumber The program number to change to, from 0 to 127.

Reset()

Executes a full synthesizer reset. This will reset all controllers to their default values, except for the locked controllers.

public void Reset()

SendAddress(int, int, int, ReadOnlySpan<byte>, int)

public void SendAddress(int a1, int a2, int a3, ReadOnlySpan<byte> data, int offset = 0)

Parameters

a1 int
a2 int
a3 int
data ReadOnlySpan<byte>
offset int

Set(GlobalSystemParameter)

Sets a system parameter of the synthesizer.

public void Set(GlobalSystemParameter param)

Parameters

param GlobalSystemParameter

The type and value of the system parameter to set.

StopAllChannels(bool)

Stops all notes on all channels.

public void StopAllChannels(bool force = false)

Parameters

force bool

If true, all notes are stopped immediately, otherwise they are stopped gracefully.

SystemExclusive(ReadOnlySpan<byte>, int?)

Executes a system exclusive message for the synthesizer.

public void SystemExclusive(ReadOnlySpan<byte> syx, int? channelOffset = null)

Parameters

syx ReadOnlySpan<byte>

The system exclusive message as an array of bytes.

channelOffset int?

The channel offset to apply (default is 0).