Class MidiChannel

Namespace
SpessaSharp.Synthesizer.Engine.Channel
Assembly
SpessaSharp.dll

This class represents a single MIDI Channel within the synthesizer.

public sealed class MidiChannel : ISf2Channel
Inheritance
MidiChannel
Implements
Inherited Members

Fields

Channel

The channel's number (0-based index)

public readonly int Channel

Field Value

int

DrumParams

Parameters for each drum instrument.

public readonly DrumParameters[] DrumParams

Field Value

DrumParameters[]

DynamicModulators

A system for dynamic modulator assignment for advanced system exclusives.

public readonly DynamicModulatorManager DynamicModulators

Field Value

DynamicModulatorManager

MidiControllers

An array of MIDI controllers for the channel. This array is used to store the state of various MIDI controllers such as volume, pan, modulation, etc.

public readonly short[] MidiControllers

Field Value

short[]

Remarks

A bit of an explanation:
The controller table is stored as an int16 array, it stores 14-bit values, allowing for full 14-bit LSB resolution. The only exception from this are the Registered and Non-Registered Parameter Numbers. Data entries do store it!

OctaveTuning

An array of octave tuning values for each note on the channel. Each index corresponds to a note (0 = C, 1 = C#, ..., 11 = B). Note: Repeated every 12 notes.

public readonly byte[] OctaveTuning

Field Value

byte[]

Patch

The currently selected MIDI patch of the channel. Note that the exact matching preset may not be available, but this represents exactly what MIDI asks for.

public MidiPatch Patch

Field Value

MidiPatch

PitchWheels

An array for the MIDI 2.0 Per-note pitch wheels.

public readonly short[] PitchWheels

Field Value

short[]

Sf2NRPNGeneratorLSB

SF2 NRPN LSB for selecting a generator value.

public int Sf2NRPNGeneratorLSB

Field Value

int

Voices

public readonly List<Voice> Voices

Field Value

List<Voice>

Properties

DrumChannel

Indicates whether this channel is a drum channel.

public bool DrumChannel { get; }

Property Value

bool

GetMidiControllers

All MIDI controller values for modulation.

public ReadOnlySpan<short> GetMidiControllers { get; }

Property Value

ReadOnlySpan<short>

GetMidiParameters

Other MIDI parameters.

public (int Pressure, int PitchWheel, float PitchWheelRange) GetMidiParameters { get; }

Property Value

(int Pressure, int PitchWheel, float PitchWheelRange)

IsMuted

Indicates whether the channel is muted.

public bool IsMuted { get; }

Property Value

bool

MidiParameters

The channel MIDI parameters of this channel. These are only editable via MIDI messages.

public ReadOnlySpan<ChannelMidiParameter> MidiParameters { get; }

Property Value

ReadOnlySpan<ChannelMidiParameter>

Preset

The preset currently assigned to the channel. Note that this may be undefined in some cases.
https://github.com/spessasus/spessasynth_core/issues/48

public BasicPreset? Preset { get; }

Property Value

BasicPreset

SystemParameters

The channel master parameters of this channel. These are only editable via the API.

public ReadOnlySpan<ChannelSystemParameter> SystemParameters { get; }

Property Value

ReadOnlySpan<ChannelSystemParameter>

VoiceCount

Channel's current voice count.

public int VoiceCount { get; }

Property Value

int

Methods

LockController(CC, bool)

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

public void LockController(Midi.CC controller, bool isLocked)

Parameters

controller Midi.CC

The MIDI controller number (0-127).

isLocked bool

If the controller should be locked.

LockParameter(Type, bool)

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

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

Parameters

parameter ChannelMidiParameter.Type

The Channel MIDI Parameter to lock.

isLocked bool

If the parameter should be locked.

MuteChannel(bool)

Mutes or unmutes a channel.

public void MuteChannel(bool isMuted)

Parameters

isMuted bool

If the channel should be muted.

Set(ChannelMidiParameter)

Sets a MIDI channel parameter of the synthesizer.

public void Set(ChannelMidiParameter parameter)

Parameters

parameter ChannelMidiParameter

The type and value of the MIDI channel parameter to set.

Set(ChannelSystemParameter)

Sets a system parameter of the channel.

public void Set(ChannelSystemParameter parameter)

Parameters

parameter ChannelSystemParameter

The type and value of the system parameter to set.

SetDrums(bool)

Changes the preset to, or from drums. Note that this executes a program change.

public void SetDrums(bool isDrum)

Parameters

isDrum bool

If the channel should be a drum preset or not.

Exceptions

Exception

SetOctaveTuning(ReadOnlySpan<byte>)

Sets the octave tuning for a given channel.

public void SetOctaveTuning(ReadOnlySpan<byte> tuning)

Parameters

tuning ReadOnlySpan<byte>

The tuning array of 12 values, each representing the tuning for a note in the octave.

Remarks

Cent tunings are relative.

Exceptions

Exception

StopAllNotes(bool)

Stops all notes on the channel.

public void StopAllNotes(bool force = false)

Parameters

force bool

If true, stops all notes immediately, otherwise applies release time.