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
sampleRateintsample rate, in Hertz.
optsSynthesizer.Options?The processor's options.
Fields
OnEvent
public Action<Event>? OnEvent
Field Value
SampleRate
Sample rate in Hertz.
public readonly int SampleRate
Field Value
Properties
ChorusMacro
public Macro.Chorus ChorusMacro { get; set; }
Property Value
ChorusProcessor
Synthesizer's Chorus processor.
public Effect.ChorusProcessor ChorusProcessor { get; }
Property Value
CurrentTime
The current time of the synthesizer, in seconds. You probably should not modify this directly.
public double CurrentTime { get; }
Property Value
DelayMacro
public Macro.Delay DelayMacro { get; set; }
Property Value
DelayProcessor
Synthesizer's Delay processor.
public Effect.DelayProcessor DelayProcessor { get; }
Property Value
KeyModifierManager
Handles the custom key overrides: velocity and preset
public KeyModifier.Manager KeyModifierManager { get; }
Property Value
MidiChannels
All MIDI channels of the synthesizer.
public ReadOnlySpan<MidiChannel> MidiChannels { get; }
Property Value
MidiParameters
The global MIDI parameters of the synthesizer. These are only editable via MIDI messages.
public ReadOnlySpan<GlobalMidiParameter> MidiParameters { get; }
Property Value
ReverbMacro
public Macro.Reverb ReverbMacro { get; set; }
Property Value
ReverbProcessor
Synthesizer's reverb processor.
public Effect.ReverbProcessor ReverbProcessor { get; }
Property Value
SoundBankManager
The sound bank manager, which manages all sound banks and presets.
public SoundBankManager SoundBankManager { get; }
Property Value
SystemParameters
The global system parameters of the synthesizer. These are only editable via the API.
public ReadOnlySpan<GlobalSystemParameter> SystemParameters { get; }
Property Value
VoiceCount
Current total amount of voices that are currently playing.
public int VoiceCount { get; }
Property Value
Methods
Apply(SynthesizerSnapshot)
Applies the snapshot to the synth.
public void Apply(SynthesizerSnapshot snapshot)
Parameters
snapshotSynthesizerSnapshotThe 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
channelintThe MIDI channel to send the channel pressure on.
pressureintThe 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
channelintThe MIDI channel to change the controller on.
controllerMidi.CCThe MIDI controller number (0-127).
valueintThe 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
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
parameterGlobalMidiParameter.TypeThe Global MIDI Parameter to lock.
isLockedboolIf 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
channelintThe MIDI channel to send the note off.
midiNoteintThe 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
channelintThe MIDI channel to send the note on.
midiNoteintThe MIDI note number to play.
velocityintThe 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
patchMidiPatchThe MIDI patch that was requested.
systemMidi.SystemThe 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
channelintThe MIDI channel to send the pitch wheel on.
pitchintThe new pitch value: 0-16383
midiNoteint?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
channelintThe MIDI channel to send the poly pressure on.
midiNoteintThe MIDI note number to apply the pressure to.
pressureintThe 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
leftArraySegment<float>The left output channel.
rightArraySegment<float>The right output channel.
startIndexint?Start offset of the passed arrays, rendering starts at this index, defaults to 0.
sampleCountint?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
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
messageReadOnlySpan<byte>The MIDI message to process.
channelOffsetint?The channel offset for the message. It will be added to message's channel number if applicable
timedouble?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
outputsReadOnlySpan<(ArraySegment<float> Left, ArraySegment<float> Right)>Any number stereo pairs (L, R) to render channels separately into.
effectsLeftSpan<float>The left stereo effect output buffer.
effectsRightSpan<float>The right stereo effect output buffer.
startIndexint?Start offset of the passed arrays, rendering starts at this index, defaults to 0.
samplesint?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
channelintThe MIDI channel to send the program change on.
programNumberintprogramNumber 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
Set(GlobalSystemParameter)
Sets a system parameter of the synthesizer.
public void Set(GlobalSystemParameter param)
Parameters
paramGlobalSystemParameterThe type and value of the system parameter to set.
StopAllChannels(bool)
Stops all notes on all channels.
public void StopAllChannels(bool force = false)
Parameters
forceboolIf 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
syxReadOnlySpan<byte>The system exclusive message as an array of bytes.
channelOffsetint?The channel offset to apply (default is 0).