Struct Modulator

Namespace
SpessaSharp.SoundBank
Assembly
SpessaSharp.dll

Parses soundfont modulators and the source enums, also includes the default modulators list

public readonly record struct Modulator : IEquatable<Modulator>
Implements
Inherited Members

Constructors

Modulator(Source, Source, Type, short, TransformType)

Parses soundfont modulators and the source enums, also includes the default modulators list

public Modulator(Modulator.Source PrimarySource, Modulator.Source SecondarySource, Generator.Type Destination = Type.Invalid, short TransformAmount = 0, Modulator.TransformType TType = TransformType.Linear)

Parameters

PrimarySource Modulator.Source

The primary source of this modulator.

SecondarySource Modulator.Source
Destination Generator.Type

The generator destination of this modulator.

TransformAmount short

The transform amount for this modulator.

TType Modulator.TransformType

The transform type for this modulator.

Modulator(Source?, Source?, Type, short, TransformType)

Creates a new SF2 Modulator

public Modulator(Modulator.Source? primarySource = null, Modulator.Source? secondarySource = null, Generator.Type destination = Type.Invalid, short amount = 0, Modulator.TransformType transformType = TransformType.Linear)

Parameters

primarySource Modulator.Source?
secondarySource Modulator.Source?
destination Generator.Type
amount short
transformType Modulator.TransformType

Fields

ByteSize

public const int ByteSize = 10

Field Value

int

DefaultResonantModSource

public static readonly short DefaultResonantModSource

Field Value

short

DefaultSoundFont2Modulators

public static readonly Modulator[] DefaultSoundFont2Modulators

Field Value

Modulator[]

DefaultSpessaSynthModulators

public static readonly Modulator[] DefaultSpessaSynthModulators

Field Value

Modulator[]

MODULATOR_TRANSFORMS

To get the value, you do MODULATOR_RESOLUTION * (MOD_CURVE_TYPES_AMOUNT * curveType + transformType) + your raw value as 14-bit number (0 - 16,383)

public static readonly float[] MODULATOR_TRANSFORMS

Field Value

float[]

Properties

Destination

The generator destination of this modulator.

public Generator.Type Destination { get; init; }

Property Value

Generator.Type

PrimarySource

The primary source of this modulator.

public Modulator.Source PrimarySource { get; init; }

Property Value

Modulator.Source

SPESSASYNTH_DEFAULT_MODULATORS

public static ReadOnlySpan<Modulator> SPESSASYNTH_DEFAULT_MODULATORS { get; }

Property Value

ReadOnlySpan<Modulator>

SecondarySource

public Modulator.Source SecondarySource { get; init; }

Property Value

Modulator.Source

TType

The transform type for this modulator.

public Modulator.TransformType TType { get; init; }

Property Value

Modulator.TransformType

TransformAmount

The transform amount for this modulator.

public short TransformAmount { get; init; }

Property Value

short

Methods

Decoded(short, short, short, short, short)

public static Modulator Decoded(short sourceEnum, short secondarySourceEnum, short destination, short amount, short transformType)

Parameters

sourceEnum short
secondarySourceEnum short
destination short
amount short
transformType short

Returns

Modulator

GetModSourceEnum(Type, bool, bool, bool, Index)

public static short GetModSourceEnum(ModulatorCurve.Type curveType, bool isBipolar, bool isNegative, bool isCC, Modulator.Source.Index index)

Parameters

curveType ModulatorCurve.Type
isBipolar bool
isNegative bool
isCC bool
index Modulator.Source.Index

Returns

short

ID(TransformType)

public static int ID(Modulator.TransformType t)

Parameters

t Modulator.TransformType

Returns

int

IsIdentical(Modulator, Modulator, bool)

Checks if the pair of modulators is identical (in SF2 terms)

public static bool IsIdentical(Modulator mod1, Modulator mod2, bool checkAmount = false)

Parameters

mod1 Modulator

Modulator 1

mod2 Modulator

Modulator 2

checkAmount bool

If the amount should be checked too.

Returns

bool

If they are identical

SumTransform(Modulator)

Sums transform and create a NEW modulator

public Modulator SumTransform(Modulator mod)

Parameters

mod Modulator

The modulator to sum with

Returns

Modulator

The new modulator

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Write(ref Span<byte>, SoundFontWriteIndexes?)

public void Write(ref Span<byte> modData, SoundFontWriteIndexes? indexes = null)

Parameters

modData Span<byte>
indexes SoundFontWriteIndexes