Class Synthesizer
- Namespace
- SpessaSharp.Synthesizer
- Assembly
- SpessaSharp.dll
The core synthesis engine which interacts with channels and holds all the synth parameters.
public sealed class Synthesizer
- Inheritance
-
Synthesizer
- Inherited Members
Fields
ChorusInput
The chorus processor's input buffer.
public readonly float[] ChorusInput
Field Value
- float[]
ChorusProcessor
The synthesizer's chorus processor.
public readonly Effect.ChorusProcessor ChorusProcessor
Field Value
CurrentTime
The current time of the synthesizer, in seconds.
public double CurrentTime
Field Value
DEFAULT_PERCUSSION
public const int DEFAULT_PERCUSSION = 9
Field Value
DefaultMode
public const Midi.System DefaultMode = GS
Field Value
DefaultPreset
Synth's default (reset) preset.
public BasicPreset? DefaultPreset
Field Value
DelayActive
Delay is not used outside SC-88+ MIDIs, this is an optimization.
public bool DelayActive
Field Value
DelayInput
The reverb processor's input buffer.
public readonly float[] DelayInput
Field Value
- float[]
DelayProcessor
The synthesizer's delay processor.
public readonly Effect.DelayProcessor DelayProcessor
Field Value
DrumPreset
Synth's default (reset) drum preset.
public BasicPreset? DrumPreset
Field Value
EFX_SENDS_GAIN_CORRECTION
This is needed because effects (regular ones) are send straight from the mono signal, whereas insertion effects receive the panned audio (twice), which reduces gain by a factor of cos(pi/4) * cos(pi/4) (master pan + voice pan). This reverses it.
public static readonly float EFX_SENDS_GAIN_CORRECTION
Field Value
EventCallbackHandler
Calls when an event occurs.
public readonly Action<Event> EventCallbackHandler
Field Value
FreeVoices
Unused voices of this synthesizer
public readonly List<Voice> FreeVoices
Field Value
GENERATOR_OVERRIDE_NO_CHANGE_VALUE
public const short GENERATOR_OVERRIDE_NO_CHANGE_VALUE = 32767
Field Value
GainSmoothingFactor
Gain smoothing factor, adjusted to the sample rate.
public readonly float GainSmoothingFactor
Field Value
InsertionInputL
The insertion processor's left input buffer.
public readonly float[] InsertionInputL
Field Value
- float[]
InsertionInputR
The insertion processor's right input buffer.
public readonly float[] InsertionInputR
Field Value
- float[]
KeyModifierManager
Handles the custom key overrides: velocity and preset
public readonly KeyModifier.Manager KeyModifierManager
Field Value
MIDI_CHANNEL_COUNT
public const int MIDI_CHANNEL_COUNT = 16
Field Value
MIN_EXCLUSIVE_LENGTH
This sounds way nicer for an instant hi-hat cutoff
public const float MIN_EXCLUSIVE_LENGTH = 0.07
Field Value
MIN_NOTE_LENGTH
If the note is released faster than that, it forced to last that long This is used mostly for drum channels, where a lot of midis like to send instant note off after a note on
public const float MIN_NOTE_LENGTH = 0.03
Field Value
MaxBufferSize
The maximum allowed buffer size to render.
public readonly int MaxBufferSize
Field Value
MidiChannels
All MIDI channels of the synthesizer.
public readonly List<MidiChannel> MidiChannels
Field Value
MidiParameters
The global MIDI parameters of the synthesizer.
public readonly GlobalMidiParameter[] MidiParameters
Field Value
MissingPreset
public readonly Synthesizer.MissingPresetHandler MissingPreset
Field Value
PanSmoothingFactor
Pan smoothing factor, adjusted to the sample rate.
public readonly float PanSmoothingFactor
Field Value
ReverbInput
The reverb processor's input buffer.
public readonly float[] ReverbInput
Field Value
- float[]
ReverbProcessor
The synthesizer's reverb processor.
public readonly Effect.ReverbProcessor ReverbProcessor
Field Value
SPESSASYNTH_GAIN_FACTOR
This gain factor ensures that spessasynth doesn't stay too loud.
You can set the gain system parameter to an inverse of it to negate the effect.
public const float SPESSASYNTH_GAIN_FACTOR = 0.6
Field Value
SPESSA_BUFSIZE
Buffer size is recommended to be very small, as this is the interval between modulator updates and LFO updates
public const int SPESSA_BUFSIZE = 128
Field Value
SampleRate
public readonly int SampleRate
Field Value
SoundBankManager
The sound bank manager, which manages all sound banks and presets.
public readonly SoundBankManager SoundBankManager
Field Value
SystemParameters
The system parameters of the synthesizer.
public readonly GlobalSystemParameter[] SystemParameters
Field Value
Tunings
This.tunings[program * 128 + key] = midiNote,cents (fraction). All MIDI Tuning Standard tunings, 128 keys for each of 128 programs. -1 means no change.
public readonly float[] Tunings
Field Value
- float[]
VOICE_CAP
public const int VOICE_CAP = 350
Field Value
VoiceBuffer
The buffer to use when rendering a voice.
public readonly float[] VoiceBuffer
Field Value
- float[]
Voices
Active Voices of this synthesizer
public readonly List<Voice> Voices
Field Value
Properties
CustomChannelNumbers
A sysEx may set a "Part" (channel) to receive on a different channel number. This slows down the access, so this toggle tracks if it's enabled or not.
public bool CustomChannelNumbers { get; }
Property Value
VoiceCount
Current total amount of voices that are currently playing.
public int VoiceCount { get; }
Property Value
Methods
AssignVoice()
Assigns the first available voice for use. If none available, will assign priorities.
public Voice AssignVoice()
Returns
CallEvent(Event)
Copied callback so MIDI channels can call it.
public void CallEvent(Event ev)
Parameters
evEvent
ChannelPressure(int, int)
public void ChannelPressure(int channel, int pressure)
Parameters
ClearCache()
public void ClearCache()
ControllerChange(int, CC, int)
public void ControllerChange(int channel, Midi.CC controller, int value)
Parameters
CreateMIDIChannel(bool)
public void CreateMIDIChannel(bool sendEvent)
Parameters
sendEventbool
Destroy()
public void Destroy()
GetInsertionSnapshot()
public Effect.InsertionProcessorSnapshot GetInsertionSnapshot()
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)
public void NoteOff(int channel, int midiNote)
Parameters
NoteOn(int, int, int)
public void NoteOn(int channel, int midiNote, int velocity)
Parameters
PitchWheel(int, short, int?)
public void PitchWheel(int channel, short pitch, int? midiNote = null)
Parameters
PolyPressure(int, int, int)
public void PolyPressure(int channel, int midiNote, int pressure)
Parameters
Process(ArraySegment<float>, ArraySegment<float>, int, int?)
public void Process(ArraySegment<float> left, ArraySegment<float> right, int startIndex = 0, int? sampleCount = null)
Parameters
leftArraySegment<float>rightArraySegment<float>startIndexintsampleCountint?
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.
public void ProcessMessage(ReadOnlySpan<byte> message, int channelOffset = 0, double? time = null)
Parameters
messageReadOnlySpan<byte>The message to process.
channelOffsetintThe channel offset for the message.
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?)
The main rendering pipeline, renders all voices and processes the effects
public void ProcessSplit(ReadOnlySpan<(ArraySegment<float> Left, ArraySegment<float> Right)> outputs, Span<float> effectsLeft, Span<float> effectsRight, int startIndex = 0, int? samples = null)
Parameters
outputsReadOnlySpan<(ArraySegment<float> Left, ArraySegment<float> Right)>The stereo pairs for each MIDI channel's dry output, will be wrapped if less.
effectsLeftSpan<float>The left stereo effect output buffer.
effectsRightSpan<float>The right stereo effect output buffer.
startIndexintThe index to start writing at into the output buffer.
samplesint?The amount of samples to write.
Remarks
┌────────────────────────────────┐
│ Voice Processor │
└───────────────┬────────────────┘
│
┌───────────────┴────────────────┐
│ Insertion Processor │
│ (Bypass or Process) │
└───────────────┬────────────────┘
│
┌──────────┬─────────┼────────────────────────┐
│ │ │ │
│ │ v │
│ │ ┌───────┴───────┐ │
│ │ │ Chorus │ │
│ │ │ Processor ├──────────┐ │
│ │ └─┬──────────┬──┘ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ v v v
│ │ │ ┌────────┴───────┐ ┌─┴─────┴────────┐
│ └───┼>┤ Delay ├─>>┤ Reverb │
│ │ │ Processor │ │ Processor │
│ │ └────────┬───────┘ └───────┬────────┘
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
v v v v
┌─────────┴──────────┐ ┌─┴──────────┴───────────────────┴────┐
│ Dry Output Pairs │ │ Stereo Effects Output │
└────────────────────┘ └─────────────────────────────────────┘
The pipeline is quite similar to the one on SC-8850 manual page 78. All output arrays must be the same length, the method will crash otherwise.
ProgramChange(int, int)
public void ProgramChange(int channel, int programNumber)
Parameters
Reset(System)
Executes a full system reset of the synthesizer. This will reset all controllers to their default values, except for the locked controllers.
public void Reset(Midi.System system = System.GS)
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)
Parameters
forceboolIf true, all notes are stopped immediately, otherwise they are stopped gracefully.
SystemExclusive(ReadOnlySpan<byte>, int)
public void SystemExclusive(ReadOnlySpan<byte> syx, int channelOffset = 0)
Parameters
syxReadOnlySpan<byte>channelOffsetint