Class Voice

Namespace
SpessaSharp.Synthesizer.Engine.Voice
Assembly
SpessaSharp.dll

Voice represents a single instance of the SoundFont2 synthesis model. That is:
A wavetable oscillator (sample)
A volume envelope (volEnv)
A modulation envelope (modEnv)
Generators (generators and modulatedGenerators)
Modulators (modulators)
And MIDI params such as channel, MIDI note, velocity

public sealed class Voice
Inheritance
Voice
Inherited Members

Constructors

Voice(int, int)

public Voice(int sampleRate, int bufferSize)

Parameters

sampleRate int
bufferSize int

Fields

Channel

MIDI channel number of the voice.

public MidiChannel? Channel

Field Value

MidiChannel

ChorusSend

Chorus send of the voice, used for drum parts, otherwise 1.

public float ChorusSend

Field Value

float

CurrentPan

From -500 to 500. Used for smoothing.

public int CurrentPan

Field Value

int

DelaySend

Delay send of the voice, used for drum parts, otherwise 1.

public float DelaySend

Field Value

float

ExclusiveClass

Exclusive class number for hi-hats etc.

public int ExclusiveClass

Field Value

int

Filter

Lowpass filter applied to the voice.

public LowpassFilter Filter

Field Value

LowpassFilter

GainModifier

Linear gain of the voice. Used with Key Modifiers.

public float GainModifier

Field Value

float

Generators

The unmodulated (copied to) generators of the voice.

public readonly short[] Generators

Field Value

short[]

HasRendered

Indicates if the voice has rendered at least one buffer. Used for exclusive class to prevent killing voices set on the same note.

public bool HasRendered

Field Value

bool

IsHeld

Indicates if the voice is currently held by the sustain pedal.

public bool IsHeld

Field Value

bool

IsInRelease

Indicates if the voice is in the release phase.

public bool IsInRelease

Field Value

bool

LoopingMode

public Synthesizer.SampleLoopingMode LoopingMode

Field Value

Synthesizer.SampleLoopingMode

MidiNote

MIDI note number of the voice. Direct number from the Note On message and is used for Note Off and external parameters: MTS and Per note Pitch Wheel.

public int MidiNote

Field Value

int

ModEnv

Modulation envelope.

public ModulationEnvelope ModEnv

Field Value

ModulationEnvelope

ModLFOPhase

public float ModLFOPhase

Field Value

float

ModLFOStartTime

public float ModLFOStartTime

Field Value

float

ModulatedGenerators

The generators in real-time, affected by modulators. This is used during rendering.

public readonly short[] ModulatedGenerators

Field Value

short[]

ModulatorValues

The current values for the respective modulators. If there are more modulators, the array must be resized.

public short[] ModulatorValues

Field Value

short[]

Modulators

The voice's modulators.

public readonly List<Voice.Modulator> Modulators

Field Value

List<Voice.Modulator>

NoteID

Grouping voices for specific Note On messages. Used for overlapping Note Ons.

public int NoteID

Field Value

int

OverridePan

From -500 to 500, where zero means disabled (use the channel pan). Used for random pan.

public int OverridePan

Field Value

int

OverrideReleaseVolEnv

In timecents, where zero means disabled (use the modulatedGenerators table). Used for exclusive notes and killing notes.

public int OverrideReleaseVolEnv

Field Value

int

PitchOffset

In cents.

public int PitchOffset

Field Value

int

PortamentoDuration

uration of the linear glide, in seconds.

public float PortamentoDuration

Field Value

float

PortamentoFromKey

Initial key to glide from, MIDI Note number. If -1, the portamento is OFF.

public int PortamentoFromKey

Field Value

int

Pressure

The pressure of the voice

public int Pressure

Field Value

int

Priority

Priority of the voice. Used for stealing.

public int Priority

Field Value

int

ReleaseStartTime

Start time of the release phase, absolute.

public float ReleaseStartTime

Field Value

float

ResonanceOffset

Resonance offset, it is affected by the default resonant modulator

public float ResonanceOffset

Field Value

float

ReverbSend

Reverb send of the voice, used for drum parts, otherwise 1.

public float ReverbSend

Field Value

float

RootKey

The root key of the voice.

public int RootKey

Field Value

int

StartTime

Start time of the voice, absolute.

public float StartTime

Field Value

float

TargetKey

Target key of the voice. This is the effective MIDI note number, used to calculate scale tuning and envelope times, and can be overridden by generators. It is also used

public int TargetKey

Field Value

int

TuningCents

Current tuning in cents.

public int TuningCents

Field Value

int

TuningRatio

Current calculated tuning. (as in ratio)

public float TuningRatio

Field Value

float

Velocity

MIDI Velocity of the voice. This can be overridden by generators and is the effective velocity. MIDI Note On velocity is only used for zone filtering.

public int Velocity

Field Value

int

VibLFOPhase

public float VibLFOPhase

Field Value

float

VibLFOStartTime

public float VibLFOStartTime

Field Value

float

VolEnv

Volume envelope.

public VolumeEnvelope VolEnv

Field Value

VolumeEnvelope

WaveTable

The oscillator currently used by this voice.

public WaveTableOscillator WaveTable

Field Value

WaveTableOscillator

Methods

ExclusiveRelease(float, float)

Releases the voice as exclusiveClass.

public void ExclusiveRelease(float currentTime, float minExclusiveLength = 0.07)

Parameters

currentTime float
minExclusiveLength float

GetModulatedGenerator(Type)

public short GetModulatedGenerator(Generator.Type type)

Parameters

type Generator.Type

Returns

short

ReleaseVoice(float, float)

Stops the voice

public void ReleaseVoice(float currentTime, float minNoteLength = 0.03)

Parameters

currentTime float
minNoteLength float

minimum note length in seconds

SetModulatedGenerator(Type, short)

public void SetModulatedGenerator(Generator.Type type, short value)

Parameters

type Generator.Type
value short

Setup(MidiChannel, float, int, int)

public void Setup(MidiChannel channel, float currentTime, int midiNote, int noteID)

Parameters

channel MidiChannel
currentTime float
midiNote int
noteID int