Table of Contents

Struct SynthModuleHandle

Namespace
SunSharp
Assembly
SunSharp.dll

Represents a handle to a generic synthesizer module, providing access to module properties and operations regardless of the underlying module type.

public readonly struct SynthModuleHandle : ISynthModuleHandle, IGenericSynthModuleHandle
Implements

Constructors

SynthModuleHandle(Slot, int)

public SynthModuleHandle(Slot slot, int id)

Parameters

slot Slot
id int

Properties

Id

Gets the ID of the synthesizer module.

public int Id { get; }

Property Value

int

Slot

Gets the slot associated with this instance.

public Slot Slot { get; }

Property Value

Slot

Methods

AsAdsr()

public AdsrModuleHandle AsAdsr()

Returns

AdsrModuleHandle

AsAmplifier()

public AmplifierModuleHandle AsAmplifier()

Returns

AmplifierModuleHandle

AsAnalogGenerator()

public AnalogGeneratorModuleHandle AsAnalogGenerator()

Returns

AnalogGeneratorModuleHandle

AsCompressor()

public CompressorModuleHandle AsCompressor()

Returns

CompressorModuleHandle

AsControlToNote()

public ControlToNoteModuleHandle AsControlToNote()

Returns

ControlToNoteModuleHandle

AsDcBlocker()

public DcBlockerModuleHandle AsDcBlocker()

Returns

DcBlockerModuleHandle

AsDelay()

public DelayModuleHandle AsDelay()

Returns

DelayModuleHandle

AsDistortion()

public DistortionModuleHandle AsDistortion()

Returns

DistortionModuleHandle

AsDrumSynth()

public DrumSynthModuleHandle AsDrumSynth()

Returns

DrumSynthModuleHandle

AsEcho()

public EchoModuleHandle AsEcho()

Returns

EchoModuleHandle

AsEq()

public EqModuleHandle AsEq()

Returns

EqModuleHandle

AsFeedback()

public FeedbackModuleHandle AsFeedback()

Returns

FeedbackModuleHandle

AsFft()

public FftModuleHandle AsFft()

Returns

FftModuleHandle

AsFilter()

public FilterModuleHandle AsFilter()

Returns

FilterModuleHandle

AsFilterPro()

public FilterProModuleHandle AsFilterPro()

Returns

FilterProModuleHandle

AsFlanger()

public FlangerModuleHandle AsFlanger()

Returns

FlangerModuleHandle

AsFm()

public FmModuleHandle AsFm()

Returns

FmModuleHandle

AsFmx()

public FmxModuleHandle AsFmx()

Returns

FmxModuleHandle

AsGenerator()

public GeneratorModuleHandle AsGenerator()

Returns

GeneratorModuleHandle

AsGlide()

public GlideModuleHandle AsGlide()

Returns

GlideModuleHandle

AsGpio()

public GpioModuleHandle AsGpio()

Returns

GpioModuleHandle

AsInput()

public InputModuleHandle AsInput()

Returns

InputModuleHandle

AsKicker()

public KickerModuleHandle AsKicker()

Returns

KickerModuleHandle

AsLfo()

public LfoModuleHandle AsLfo()

Returns

LfoModuleHandle

AsLoop()

public LoopModuleHandle AsLoop()

Returns

LoopModuleHandle

AsMetaModule()

public MetaModuleModuleHandle AsMetaModule()

Returns

MetaModuleModuleHandle

AsModulator()

public ModulatorModuleHandle AsModulator()

Returns

ModulatorModuleHandle

AsMultiControl()

public MultiControlModuleHandle AsMultiControl()

Returns

MultiControlModuleHandle

AsMultiSynth()

public MultiSynthModuleHandle AsMultiSynth()

Returns

MultiSynthModuleHandle

AsOutput()

public OutputModuleHandle AsOutput()

Returns

OutputModuleHandle

AsPitchDetector()

public PitchDetectorModuleHandle AsPitchDetector()

Returns

PitchDetectorModuleHandle

AsPitchShifter()

public PitchShifterModuleHandle AsPitchShifter()

Returns

PitchShifterModuleHandle

AsPitchToControl()

public PitchToControlModuleHandle AsPitchToControl()

Returns

PitchToControlModuleHandle

AsReverb()

public ReverbModuleHandle AsReverb()

Returns

ReverbModuleHandle

AsSampler()

public SamplerModuleHandle AsSampler()

Returns

SamplerModuleHandle

AsSoundToControl()

public SoundToControlModuleHandle AsSoundToControl()

Returns

SoundToControlModuleHandle

AsSpectraVoice()

public SpectraVoiceModuleHandle AsSpectraVoice()

Returns

SpectraVoiceModuleHandle

AsVelocityToControl()

public VelocityToControlModuleHandle AsVelocityToControl()

Returns

VelocityToControlModuleHandle

AsVibrato()

public VibratoModuleHandle AsVibrato()

Returns

VibratoModuleHandle

AsVocalFilter()

public VocalFilterModuleHandle AsVocalFilter()

Returns

VocalFilterModuleHandle

AsVorbisPlayer()

public VorbisPlayerModuleHandle AsVorbisPlayer()

Returns

VorbisPlayerModuleHandle

AsWaveShaper()

public WaveShaperModuleHandle AsWaveShaper()

Returns

WaveShaperModuleHandle

ConnectInput(SynthModuleHandle)

Connect the input of this module to the output of another module.

public void ConnectInput(SynthModuleHandle targetModule)

Parameters

targetModule SynthModuleHandle

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ConnectInput(int)

Connect the input of this module to the output of another module.

public void ConnectInput(int targetModuleId)

Parameters

targetModuleId int

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ConnectOutput(SynthModuleHandle)

Connect the output of this module to the input of another module.

public void ConnectOutput(SynthModuleHandle targetModule)

Parameters

targetModule SynthModuleHandle

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ConnectOutput(int)

Connect the output of this module to the input of another module.

public void ConnectOutput(int targetModuleId)

Parameters

targetModuleId int

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

DisconnectInput(SynthModuleHandle)

Disconnect the input of this module from the output of another module.

public void DisconnectInput(SynthModuleHandle targetModule)

Parameters

targetModule SynthModuleHandle

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

DisconnectInput(int)

Disconnect the input of this module from the output of another module.

public void DisconnectInput(int targetModuleId)

Parameters

targetModuleId int

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

DisconnectOutput(SynthModuleHandle)

Disconnect the output of this module from the input of another module.

public void DisconnectOutput(SynthModuleHandle targetModule)

Parameters

targetModule SynthModuleHandle

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

DisconnectOutput(int)

Disconnect the output of this module from the input of another module.

public void DisconnectOutput(int targetModuleId)

Parameters

targetModuleId int

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

GetColor()

Get the module color.

public (byte R, byte G, byte B) GetColor()

Returns

(byte R, byte G, byte B)

RGB color tuple (r, g, b).

Remarks

GetControllerCount()

Get the number of controllers in the module.

public int GetControllerCount()

Returns

int

Number of controllers.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

GetControllerGroup(int)

Get the controller group number.

public int GetControllerGroup(int controllerId)

Parameters

controllerId int

controller number (0-based).

Returns

int

Controller group number.

Remarks

GetControllerMaxValue(int, ValueScalingMode)

Get the controller maximum value.

public int GetControllerMaxValue(int controllerId, ValueScalingMode scaling)

Parameters

controllerId int

Controller number (0-based).

scaling ValueScalingMode

Returns

int

Maximum controller value.

Remarks

GetControllerMinValue(int, ValueScalingMode)

Get the controller minimum value.

public int GetControllerMinValue(int controllerId, ValueScalingMode scaling)

Parameters

controllerId int

Controller number (0-based).

scaling ValueScalingMode

Returns

int

Minimum controller value.

Remarks

GetControllerName(int)

Get the controller name.

public string? GetControllerName(int controllerId)

Parameters

controllerId int

Controller number (0-based).

Returns

string

Controller name, or null if unavailable.

Remarks

GetControllerOffset(int)

Get the controller display value offset.

public int GetControllerOffset(int controllerId)

Parameters

controllerId int

Controller number (0-based).

Returns

int

Display value offset.

Remarks

GetControllerType(int)

Get the controller type.

public ControllerType GetControllerType(int controllerId)

Parameters

controllerId int

Controller number (0-based).

Returns

ControllerType

Controller type.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

GetControllerValue(int, ValueScalingMode)

Get the controller value.

public int GetControllerValue(int controllerId, ValueScalingMode scaling = ValueScalingMode.Displayed)

Parameters

controllerId int

Controller number (0-based).

scaling ValueScalingMode

Returns

int

Controller value.

Remarks

GetExists()

Check if a module exists.

public bool GetExists()

Returns

bool

true if module exists.

Remarks

GetFineTune()

Get the module fine tune and relative note values.

public FineTunePair GetFineTune()

Returns

FineTunePair

Fine tune pair containing fine tune value and relative note.

Remarks

GetFlags()

Get the module flags.

public ModuleFlags GetFlags()

Returns

ModuleFlags

Module flags indicating existence, type, state, and connections.

Remarks

GetInputModules()

Get the array of input modules connected to this module.

public SynthModuleHandle[] GetInputModules()

Returns

SynthModuleHandle[]

Array of connected input module numbers.

Remarks

GetInputs()

Get the array of input module numbers connected to this module.

public int[] GetInputs()

Returns

int[]

Array of connected input module numbers.

Remarks

GetModuleType()

Returns the module type. If the module does not exist, returns null. If the module type is unknown (due to library mismatch or otherwise), returns Unknown.

public SynthModuleType? GetModuleType()

Returns

SynthModuleType?

GetName()

Get the module name.

public string? GetName()

Returns

string

Module name, or null if unavailable.

Remarks

GetOutputModules()

Gets the array of output modules connected to this module.

public SynthModuleHandle[] GetOutputModules()

Returns

SynthModuleHandle[]

Array of connected output module numbers.

Remarks

GetOutputs()

Get the array of output module numbers connected from this module.

public int[] GetOutputs()

Returns

int[]

Array of connected output module numbers.

Remarks

GetPosition()

Get the module position on the canvas.

public (int x, int y) GetPosition()

Returns

(int x, int y)

Tuple containing X and Y coordinates.

Remarks

LoadIntoMetaModule(byte[])

Load a file into a MetaModule from memory. Supported file formats: sunvox, mod, xm, midi.

public void LoadIntoMetaModule(byte[] data)

Parameters

data byte[]

Byte array with project data.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if data is null.

LoadIntoMetaModule(string)

Load a file into a MetaModule. Supported file formats: sunvox, mod, xm, midi.

public void LoadIntoMetaModule(string path)

Parameters

path string

File path (relative or absolute).

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if path is null.

LoadIntoVorbisPlayer(byte[])

Load a file into the Vorbis Player. Supported file formats: ogg.

public void LoadIntoVorbisPlayer(byte[] data)

Parameters

data byte[]

Byte array with audio file data.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if data is null.

LoadIntoVorbisPlayer(string)

Load a file into the Vorbis Player. Supported file formats: ogg.

public void LoadIntoVorbisPlayer(string path)

Parameters

path string

File path (relative or absolute).

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if path is null.

LoadSamplerSample(byte[], int?)

Load a sample (xi, wav, aiff) to a Sampler module from memory.

public void LoadSamplerSample(byte[] data, int? sampleSlot = null)

Parameters

data byte[]

Byte array with sample data.

sampleSlot int?

Sample slot number (-1 for auto/all slots).

Remarks

Set sampleSlot to null to apply the sample to all sample slots.

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if data is null.

LoadSamplerSample(string, int?)

Load a sample (xi, wav, aiff) to a Sampler module from file.

public void LoadSamplerSample(string path, int? sampleSlot = null)

Parameters

path string

File path (relative or absolute).

sampleSlot int?

Sample slot number (-1 for auto/all slots).

Remarks

Set sampleSlot to null to apply the sample to all sample slots.

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if path is null.

MakeEvent(Note, byte?, byte?, Effect, ushort)

Creates a new generic pattern event with optional parameters for flexible event construction.

public PatternEvent MakeEvent(Note note = default, byte? velocity = null, byte? controller = null, Effect effect = Effect.None, ushort value = 0)

Parameters

note Note
Note value. Allows for explicit note commands.
velocity byte?
Note velocity. Returns null when default velocity is used. Automatically handles the +1 offset used in raw data.
controller byte?
Controller identifier (0-based). Returns null when no controller is specified. Module controllers: 0-126 (raw data: 1-127). MIDI controllers: 127+ (raw data: 0x80+). Automatically handles the +1 offset used in raw data.
effect Effect
Pattern event effect code.
value ushort
Parameter value for controller or effect (16-bit unsigned integer).

Range: 0-32768 (0x8000) for controllers, 0-65535 (0xFFFF) for effects.

For pitch commands: 0x0000 = highest pitch, 0x7800 = C0, 0x100 = one semitone.

Returns

PatternEvent

A new PatternEvent with the specified fields.

Remarks

This method provides maximum flexibility for creating events. For common scenarios, consider using specific factory methods like NoteEvent(Note, int?, byte?), ControllerEvent(int, byte, ushort), etc.

MakeNoteEvent(Note, byte?)

Creates a note event that triggers a note on the specified module.

public PatternEvent MakeNoteEvent(Note note, byte? velocity = null)

Parameters

note Note
Note value. Allows for explicit note commands.
velocity byte?
Note velocity. Returns null when default velocity is used. Automatically handles the +1 offset used in raw data.

Returns

PatternEvent

MakeSetControllerValueEvent(byte, ushort)

Creates a controller event that changes a module parameter.

public PatternEvent MakeSetControllerValueEvent(byte controllerId, ushort value)

Parameters

controllerId byte
value ushort
Parameter value for controller or effect (16-bit unsigned integer).

Range: 0-32768 (0x8000) for controllers, 0-65535 (0xFFFF) for effects.

For pitch commands: 0x0000 = highest pitch, 0x7800 = C0, 0x100 = one semitone.

Returns

PatternEvent

Remarks

For better type safety and readability, consider using typed module handles and extension methods.

MakeSetFrequencyEvent(double, byte?)

Creates a Set Pitch event by converting a frequency in Hz to the appropriate pitch value.

public PatternEvent MakeSetFrequencyEvent(double frequency, byte? velocity = null)

Parameters

frequency double

Frequency in Hz (e.g., 440.0 for A4).

velocity byte?

Velocity value (0-128). Use null for default velocity.

Returns

PatternEvent

A new PatternEvent with the calculated pitch value.

Examples

// Set pitch to A4 (440 Hz)
var a440 = PatternEvent.SetFrequencyEvent(0, 440.0, 100);
// Set pitch to middle C (261.63 Hz)
var c4 = PatternEvent.SetFrequencyEvent(0, 261.63);

MakeSetPitchEvent(ushort, byte?)

Creates a Set Pitch event with exact pitch value for microtonal or pitch-bend effects.

public PatternEvent MakeSetPitchEvent(ushort pitch, byte? velocity = null)

Parameters

pitch ushort

Pitch value where 0x0000 = highest pitch, 0x7800 = C0 (lowest), 0x100 = one semitone.

velocity byte?

Velocity value (0-128). Use null for default velocity.

Returns

PatternEvent

A new PatternEvent configured as a set pitch event.

Examples

// Set pitch to middle C (C4 = 0x3C00)
var middleC = PatternEvent.SetPitchEvent(0, 0x3C00);
// Set pitch to A4 (440Hz reference = 0x4500)
var a440 = PatternEvent.SetPitchEvent(0, 0x4500, 100);

ReadCurve(int, float[])

Read data from a module curve.

public int ReadCurve(int curveId, float[] buffer)

Parameters

curveId int

Curve number.

buffer float[]

Returns

int

Number of values read.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if data is null.

ReadScope(AudioChannel, short[])

Read module scope view, and write it to a buffer.

public int ReadScope(AudioChannel channel, short[] buffer)

Parameters

channel AudioChannel

Audio channel.

buffer short[]

Buffer to receive scope data.

Returns

int

Number of samples successfully read.

Remarks

Exceptions

ArgumentNullException

Thrown if buffer is null.

SetColor(byte, byte, byte)

Set the module color.

public void SetColor(byte r, byte g, byte b)

Parameters

r byte

Red component (0 to 255).

g byte

Green component (0 to 255).

b byte

Blue component (0 to 255).

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

SetControllerValue(int, int, ValueScalingMode)

Set a controller value. Note: SendEvent(int, int, PatternEvent) will be used internally, which may introduce latency.

public void SetControllerValue(int controller, int value, ValueScalingMode scaling = ValueScalingMode.Displayed)

Parameters

controller int
value int

Controller value.

scaling ValueScalingMode

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

SetFineTune(FineTunePair)

Sets the fine tune for the module.

public void SetFineTune(FineTunePair fineTune)

Parameters

fineTune FineTunePair

SetName(string)

Set the module name.

public void SetName(string name)

Parameters

name string

New module name.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if name is null.

SetPosition(int, int)

Set the module position.

public void SetPosition(int x, int y)

Parameters

x int

X coordinate (center: 512, working area: 0 to 1024).

y int

Y coordinate (center: 512, working area: 0 to 1024).

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

WriteCurve(int, float[])

Write data to a module curve.

public int WriteCurve(int curveId, float[] buffer)

Parameters

curveId int

Curve number.

buffer float[]

Returns

int

Number of values written.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if data is null.