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
DrumParams
Parameters for each drum instrument.
public readonly DrumParameters[] DrumParams
Field Value
DynamicModulators
A system for dynamic modulator assignment for advanced system exclusives.
public readonly DynamicModulatorManager DynamicModulators
Field Value
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
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
Voices
public readonly List<Voice> Voices
Field Value
Properties
DrumChannel
Indicates whether this channel is a drum channel.
public bool DrumChannel { get; }
Property Value
GetMidiControllers
All MIDI controller values for modulation.
public ReadOnlySpan<short> GetMidiControllers { get; }
Property Value
GetMidiParameters
Other MIDI parameters.
public (int Pressure, int PitchWheel, float PitchWheelRange) GetMidiParameters { get; }
Property Value
IsMuted
Indicates whether the channel is muted.
public bool IsMuted { get; }
Property Value
MidiParameters
The channel MIDI parameters of this channel. These are only editable via MIDI messages.
public ReadOnlySpan<ChannelMidiParameter> MidiParameters { get; }
Property Value
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
SystemParameters
The channel master parameters of this channel. These are only editable via the API.
public ReadOnlySpan<ChannelSystemParameter> SystemParameters { get; }
Property Value
VoiceCount
Channel's current voice count.
public int VoiceCount { get; }
Property Value
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
controllerMidi.CCThe MIDI controller number (0-127).
isLockedboolIf 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
parameterChannelMidiParameter.TypeThe Channel MIDI Parameter to lock.
isLockedboolIf the parameter should be locked.
MuteChannel(bool)
Mutes or unmutes a channel.
public void MuteChannel(bool isMuted)
Parameters
isMutedboolIf the channel should be muted.
Set(ChannelMidiParameter)
Sets a MIDI channel parameter of the synthesizer.
public void Set(ChannelMidiParameter parameter)
Parameters
parameterChannelMidiParameterThe 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
parameterChannelSystemParameterThe 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
isDrumboolIf the channel should be a drum preset or not.
Exceptions
SetOctaveTuning(ReadOnlySpan<byte>)
Sets the octave tuning for a given channel.
public void SetOctaveTuning(ReadOnlySpan<byte> tuning)
Parameters
tuningReadOnlySpan<byte>The tuning array of 12 values, each representing the tuning for a note in the octave.
Remarks
Cent tunings are relative.
Exceptions
StopAllNotes(bool)
Stops all notes on the channel.
public void StopAllNotes(bool force = false)
Parameters
forceboolIf true, stops all notes immediately, otherwise applies release time.