Struct SunVoxLib
Friendlier interface for SunVox native library functions.
public readonly struct SunVoxLib : ISunVoxLib
- Implements
Constructors
SunVoxLib(ISunVoxLibC)
public SunVoxLib(ISunVoxLibC nativeLibrary)
Parameters
nativeLibraryISunVoxLibC
Methods
AudioCallback(short[], AudioChannels, short[], AudioChannels, int, uint)
Send audio to the Input module and get the next piece of audio from the Output module.
public bool AudioCallback(short[] outputBuffer, AudioChannels outputChannels, short[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)
Parameters
outputBuffershort[]Output buffer to write audio data to.
outputChannelsAudioChannelsNumber of channels the library was initialized with.
inputBuffershort[]Input buffer. Stereo data must be interleaved.
inputChannelsAudioChannelsNumber of input channels.
latencyintAudio latency in frames.
outTimeuintBuffer output time in system ticks. See GetTicks().
Returns
- bool
true if buffer contains any non-0 samples.
Remarks
UserAudioCallback must be set in Initialize(int, string?, AudioChannels, SunVoxInitOptions) to use this function.
Calls sv_audio_callback2(IntPtr, int, int, uint, int, int, IntPtr).Exceptions
- ArgumentException
Thrown when buffer sizes are invalid for the channel count or not equal length.
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
outputBufferorinputBufferis null.
AudioCallback(short[], AudioChannels, int, uint)
Get the next piece of audio from the Output module.
public bool AudioCallback(short[] outputBuffer, AudioChannels channels, int latency, uint outTime)
Parameters
outputBuffershort[]Output buffer to write audio data to.
channelsAudioChannelsNumber of channels the library was initialized with.
latencyintAudio latency in frames.
outTimeuintBuffer output time in system ticks. See GetTicks().
Returns
- bool
true if buffer contains any non-0 samples.
Remarks
UserAudioCallback must be set in Initialize(int, string?, AudioChannels, SunVoxInitOptions) to use this function.
Make sure to call the correct overload for the buffer data type.
Calls sv_audio_callback(IntPtr, int, int, uint).Exceptions
- ArgumentException
Thrown when buffer size is invalid for the channel count.
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
outputBufferis null.
AudioCallback(short[], AudioChannels, float[], AudioChannels, int, uint)
Send audio to the Input module and get the next piece of audio from the Output module.
public bool AudioCallback(short[] outputBuffer, AudioChannels outputChannels, float[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)
Parameters
outputBuffershort[]Output buffer to write audio data to.
outputChannelsAudioChannelsNumber of channels the library was initialized with.
inputBufferfloat[]Input buffer. Stereo data must be interleaved.
inputChannelsAudioChannelsNumber of input channels.
latencyintAudio latency in frames.
outTimeuintBuffer output time in system ticks. See GetTicks().
Returns
- bool
true if buffer contains any non-0 samples.
Remarks
UserAudioCallback must be set in Initialize(int, string?, AudioChannels, SunVoxInitOptions) to use this function.
Calls sv_audio_callback2(IntPtr, int, int, uint, int, int, IntPtr).Exceptions
- ArgumentException
Thrown when buffer sizes are invalid for the channel count or not equal length.
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
outputBufferorinputBufferis null.
AudioCallback(float[], AudioChannels, short[], AudioChannels, int, uint)
Send audio to the Input module and get the next piece of audio from the Output module.
public bool AudioCallback(float[] outputBuffer, AudioChannels outputChannels, short[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)
Parameters
outputBufferfloat[]Output buffer to write audio data to.
outputChannelsAudioChannelsNumber of channels the library was initialized with.
inputBuffershort[]Input buffer. Stereo data must be interleaved.
inputChannelsAudioChannelsNumber of input channels.
latencyintAudio latency in frames.
outTimeuintBuffer output time in system ticks. See GetTicks().
Returns
- bool
true if buffer contains any non-0 samples.
Remarks
UserAudioCallback must be set in Initialize(int, string?, AudioChannels, SunVoxInitOptions) to use this function.
Calls sv_audio_callback2(IntPtr, int, int, uint, int, int, IntPtr).Exceptions
- ArgumentException
Thrown when buffer sizes are invalid for the channel count or not equal length.
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
outputBufferorinputBufferis null.
AudioCallback(float[], AudioChannels, int, uint)
Get the next piece of audio from the Output module.
public bool AudioCallback(float[] outputBuffer, AudioChannels channels, int latency, uint outTime)
Parameters
outputBufferfloat[]Output buffer to write audio data to.
channelsAudioChannelsNumber of channels the library was initialized with.
latencyintAudio latency in frames.
outTimeuintBuffer output time in system ticks. See GetTicks().
Returns
- bool
true if buffer contains any non-0 samples.
Remarks
UserAudioCallback must be set in Initialize(int, string?, AudioChannels, SunVoxInitOptions) to use this function.
Make sure to call the correct overload for the buffer data type.
Calls sv_audio_callback(IntPtr, int, int, uint).Exceptions
- ArgumentException
Thrown when buffer size is invalid for the channel count.
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
outputBufferis null.
AudioCallback(float[], AudioChannels, float[], AudioChannels, int, uint)
Send audio to the Input module and get the next piece of audio from the Output module.
public bool AudioCallback(float[] outputBuffer, AudioChannels outputChannels, float[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)
Parameters
outputBufferfloat[]Output buffer to write audio data to.
outputChannelsAudioChannelsNumber of channels the library was initialized with.
inputBufferfloat[]Input buffer. Stereo data must be interleaved.
inputChannelsAudioChannelsNumber of input channels.
latencyintAudio latency in frames.
outTimeuintBuffer output time in system ticks. See GetTicks().
Returns
- bool
true if buffer contains any non-0 samples.
Remarks
UserAudioCallback must be set in Initialize(int, string?, AudioChannels, SunVoxInitOptions) to use this function.
Calls sv_audio_callback2(IntPtr, int, int, uint, int, int, IntPtr).Exceptions
- ArgumentException
Thrown when buffer sizes are invalid for the channel count or not equal length.
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
outputBufferorinputBufferis null.
ClonePattern(int, int, int, int)
Clone a pattern.
public int ClonePattern(int slotId, int originalPatternId, int x, int y)
Parameters
slotIdintSlot number (0 to 15).
originalPatternIdintPattern to clone.
xintLine number on which the pattern starts (horizontal).
yintVertical position on the timeline.
Returns
- int
The number of the newly created pattern.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_new_pattern(int, int, int, int, int, int, int, IntPtr).Exceptions
- SunVoxException
Thrown when the operation fails.
CloseSlot(int)
Close the slot and free its resources.
public void CloseSlot(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_close_slot(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
ConnectModules(int, int, int)
Connect the source module to the destination module.
public void ConnectModules(int slotId, int source, int destination)
Parameters
slotIdintslot number (0 to 15).
sourceintSource module number (0-based).
destinationintDestination module number (0-based).
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_connect_module(int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
CreateModule(int, SynthModuleType, string?, int, int, int)
Create a new module.
public int CreateModule(int slotId, SynthModuleType type, string? name = null, int x = 0, int y = 0, int z = 0)
Parameters
slotIdintslot number (0 to 15).
typeSynthModuleTypeType of module to create.
namestringName of the module.
xintX coordinate (0 to 1024, center: 512).
yintY coordinate (0 to 1024, center: 512).
zintLayer number (0 to 7).
Returns
- int
The identifier of the newly created module (0-based).
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_new_module(int, IntPtr, IntPtr, int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
typeis null.- ArgumentOutOfRangeException
Thrown when the module type is not valid.
CreateModule(int, string, string?, int, int, int)
Create a new module.
public int CreateModule(int slotId, string type, string? name = null, int x = 0, int y = 0, int z = 0)
Parameters
slotIdintslot number (0 to 15).
typestringType of module to create.
namestringName of the module.
xintX coordinate (0 to 1024, center: 512).
yintY coordinate (0 to 1024, center: 512).
zintLayer number (0 to 7).
Returns
- int
The identifier of the newly created module (0-based).
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_new_module(int, IntPtr, IntPtr, int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
typeis null.
CreatePattern(int, int, int, int, int, int, string?)
Create a new pattern.
public int CreatePattern(int slotId, int x, int y, int tracks, int lines, int iconSeed = 0, string? name = null)
Parameters
slotIdintSlot number (0 to 15).
xintLine number on which the pattern starts.
yintY coordinate on timeline.
tracksintNumber of tracks.
linesintNumber of lines.
iconSeedintIcon seed for pattern appearance.
namestringPattern name.
Returns
- int
The number of the newly created pattern.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_new_pattern(int, int, int, int, int, int, int, IntPtr).Exceptions
- SunVoxException
Thrown when the operation fails.
Deinitialize()
Deinitialize the SunVox engine and free all resources.
public void Deinitialize()
Remarks
Calls sv_deinit().
Exceptions
- SunVoxException
Thrown when the operation fails, or when already deinitialized.
DisconnectModules(int, int, int)
Disconnect the source module from the destination module.
public void DisconnectModules(int slotId, int source, int destination)
Parameters
slotIdintslot number (0 to 15).
sourceintSource module number (0-based).
destinationintDestination module number (0-based).
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_disconnect_module(int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
FindModule(int, string)
Find a module by name.
public int? FindModule(int slotId, string name)
Parameters
slotIdintslot number (0 to 15).
namestringModule name to search for.
Returns
- int?
module number (0-based) if found.
Remarks
Calls sv_find_module(int, IntPtr).
Exceptions
- SunVoxException
Thrown when an error occurs during the search.
- ArgumentNullException
Thrown if
nameis null.
FindPattern(int, string)
Find a pattern by name.
public int? FindPattern(int slotId, string name)
Parameters
slotIdintSlot number (0 to 15).
namestringPattern name to search for.
Returns
- int?
Pattern number if found.
Remarks
Calls sv_find_pattern(int, IntPtr).
Exceptions
- SunVoxException
Thrown when an error occurs during the search.
- ArgumentNullException
Thrown if
nameis null.
GetAutomaticStop(int)
Get the autostop mode. When false, the project loops endlessly.
public bool GetAutomaticStop(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- bool
true if automatic stop is enabled.
Remarks
Calls sv_get_autostop(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
GetCurrentLine(int)
Get the current line number on the timeline.
public int GetCurrentLine(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- int
Current line number (playback position).
Remarks
Calls sv_get_current_line(int).
GetCurrentLineWithTenthPart(int)
Get the current line number in fixed point format. The value contains the tenth part of the line for higher precision.
public int GetCurrentLineWithTenthPart(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- int
Current line number in fixed point format.
Remarks
Calls sv_get_current_line2(int).
GetCurrentSignalLevel(int, AudioChannel)
Get the current signal level from the Output module.
public int GetCurrentSignalLevel(int slotId, AudioChannel channel)
Parameters
slotIdintSlot number (0 to 15).
channelAudioChannelAudio channel.
Returns
- int
Signal level (0 to 255).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetLog(int)
Get the latest log messages from the SunVox engine.
public string? GetLog(int size)
Parameters
sizeintMaximum number of characters to read.
Returns
- string
Log messages, or null if unavailable.
Remarks
Log messages are typically written when a call to another function fails.
Calls sv_get_log(int).GetModuleColor(int, int)
Get the module color.
public (byte r, byte g, byte b) GetModuleColor(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- (byte R, byte G, byte B)
RGB color tuple (r, g, b).
Remarks
GetModuleControllerCount(int, int)
Get the number of controllers in the module.
public int GetModuleControllerCount(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- int
Number of controllers.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetModuleControllerGroup(int, int, int)
Get the controller group number.
public int GetModuleControllerGroup(int slotId, int moduleId, int controllerId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintcontroller number (0-based).
Returns
- int
Controller group number.
Remarks
GetModuleControllerMaxValue(int, int, int, ValueScalingMode)
Get the controller maximum value.
public int GetModuleControllerMaxValue(int slotId, int moduleId, int controllerId, ValueScalingMode scalingMode)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintController number (0-based).
scalingModeValueScalingModeValue scaling mode.
Returns
- int
Maximum controller value.
Remarks
GetModuleControllerMinValue(int, int, int, ValueScalingMode)
Get the controller minimum value.
public int GetModuleControllerMinValue(int slotId, int moduleId, int controllerId, ValueScalingMode scalingMode)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintController number (0-based).
scalingModeValueScalingModeValue scaling mode.
Returns
- int
Minimum controller value.
Remarks
GetModuleControllerName(int, int, int)
Get the controller name.
public string? GetModuleControllerName(int slotId, int moduleId, int controllerId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintController number (0-based).
Returns
- string
Controller name, or null if unavailable.
Remarks
GetModuleControllerOffset(int, int, int)
Get the controller display value offset.
public int GetModuleControllerOffset(int slotId, int moduleId, int controllerId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintController number (0-based).
Returns
- int
Display value offset.
Remarks
GetModuleControllerType(int, int, int)
Get the controller type.
public ControllerType GetModuleControllerType(int slotId, int moduleId, int controllerId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintController number (0-based).
Returns
- ControllerType
Controller type.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetModuleControllerValue(int, int, int, ValueScalingMode)
Get the controller value.
public int GetModuleControllerValue(int slotId, int moduleId, int controllerId, ValueScalingMode scalingMode)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintController number (0-based).
scalingModeValueScalingModeValue scaling mode.
Returns
- int
Controller value.
Remarks
GetModuleExists(int, int)
Check if a module exists.
public bool GetModuleExists(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- bool
true if module exists.
Remarks
GetModuleFineTune(int, int)
Get the module fine tune and relative note values.
public FineTunePair GetModuleFineTune(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- FineTunePair
Fine tune pair containing fine tune value and relative note.
Remarks
GetModuleFlags(int, int)
Get the module flags.
public ModuleFlags GetModuleFlags(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- ModuleFlags
Module flags indicating existence, type, state, and connections.
Remarks
GetModuleInputs(int, int)
Get the array of input module numbers connected to this module.
public int[] GetModuleInputs(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- int[]
Array of connected input module numbers.
Remarks
GetModuleName(int, int)
Get the module name.
public string? GetModuleName(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- string
Module name, or null if unavailable.
Remarks
Calls sv_get_module_name(int, int).
GetModuleOutputs(int, int)
Get the array of output module numbers connected from this module.
public int[] GetModuleOutputs(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- int[]
Array of connected output module numbers.
Remarks
GetModulePosition(int, int)
Get the module position on the canvas.
public (int x, int y) GetModulePosition(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- (int x, int y)
Tuple containing X and Y coordinates.
Remarks
Calls sv_get_module_xy(int, int).
GetModuleType(int, int)
Get the module type string.
public string? GetModuleType(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Returns
- string
Module type string, or null if unavailable.
Remarks
Calls sv_get_module_type(int, int).
GetPatternData(int, int)
Get the pattern data (all events).
public (PatternEvent[] data, int tracks, int lines)? GetPatternData(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
- (PatternEvent[] data, int tracks, int lines)?
Tuple containing event data array, number of tracks, and number of lines if pattern exists.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_get_pattern_data(int, int).GetPatternEventValue(int, int, int, int, Column)
Get a specific column value from a pattern event.
public int GetPatternEventValue(int slotId, int patternId, int track, int line, Column column)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
trackintTrack number.
lineintLine number.
columnColumnColumn to read.
Returns
- int
Column value.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetPatternExists(int, int)
Check if a pattern exists.
public bool GetPatternExists(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
Remarks
GetPatternLines(int, int)
Get the number of lines in the pattern. Can be used to check if a pattern exists (lines > 0).
public int GetPatternLines(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
- int
Number of lines.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetPatternMuted(int, int)
Get the pattern mute state.
public bool GetPatternMuted(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_pattern_mute(int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
GetPatternName(int, int)
Get the pattern name.
public string? GetPatternName(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
- string
Pattern name, or null if unavailable.
Remarks
GetPatternPosition(int, int)
Get the pattern position on the timeline.
public (int x, int y) GetPatternPosition(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
- (int x, int y)
Tuple containing X and Y coordinates.
Remarks
GetPatternTracks(int, int)
Get the number of tracks in the pattern.
public int GetPatternTracks(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
- int
Number of tracks.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetPatternX(int, int)
Get the pattern X coordinate on the timeline.
public int GetPatternX(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
- int
X coordinate.
Remarks
Calls sv_get_pattern_x(int, int).
GetPatternY(int, int)
Get the pattern Y coordinate on the timeline.
public int GetPatternY(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Returns
- int
Y coordinate.
Remarks
Calls sv_get_pattern_y(int, int).
GetSampleRate()
Get the current sampling rate (may differ from the value specified in Initialize(int, string?, AudioChannels, SunVoxInitOptions)).
public int GetSampleRate()
Returns
- int
Current sample rate in Hz.
Remarks
Calls sv_get_sample_rate().
Exceptions
- SunVoxException
Thrown when the operation fails.
GetSamplerSampleParameter(int, int, int, int)
Get a Sampler sample parameter value.
public int GetSamplerSampleParameter(int slotId, int moduleId, int sampleSlot, int parameter)
Parameters
slotIdintslot number (0 to 15).
moduleIdintSampler module number (0-based).
sampleSlotintSample slot number.
parameterintParameter number.
Returns
- int
Parameter value.
Remarks
GetSongBaseVersion(int)
Get the SunVox version used to create this project.
public SunVoxVersion GetSongBaseVersion(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- SunVoxVersion
SunVox version used to create the project.
Remarks
Calls sv_get_base_version(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
GetSongBpm(int)
Get the project BPM (Beats Per Minute).
public int GetSongBpm(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- int
Remarks
The value can be set using pattern effects.
Calls sv_get_song_bpm(int).Exceptions
- SunVoxException
Thrown when the operation fails.
- See Also
GetSongLengthInFrames(int)
Get the project length in frames.
public uint GetSongLengthInFrames(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- uint
Remarks
A frame is a pair of samples for stereo audio, or a single sample for mono audio.
Calls sv_get_song_length_frames(int).GetSongLengthInLines(int)
Get the project length in lines.
public uint GetSongLengthInLines(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- uint
Remarks
GetSongName(int)
Get the project name.
public string? GetSongName(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- string
Project name, or null if unavailable.
Remarks
Calls sv_get_song_name(int).
GetSongTpl(int)
Get the project TPL (Ticks Per Line).
public int GetSongTpl(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- int
Remarks
The value can be set using pattern effects.
Calls sv_get_song_tpl(int).Exceptions
- SunVoxException
Thrown when the operation fails.
GetTicks()
Get the current system tick counter.
public uint GetTicks()
Returns
- uint
Remarks
SunVox engine uses system-provided time space, measured in system ticks (don't confuse it with the project ticks). System ticks are used for timing in functions like AudioCallback(float[], AudioChannels, int, uint) and SetEventTiming(int, int).
Calls sv_get_ticks().GetTicksPerSecond()
Get the number of system ticks per second.
public uint GetTicksPerSecond()
Returns
- uint
Remarks
Calls sv_get_ticks_per_second().
GetTimeMapFrames(int, int, int)
Get the project time map.
public uint[] GetTimeMapFrames(int slotId, int startLine, int length)
Parameters
slotIdintSlot number (0 to 15).
startLineintFirst line to read (usually 0).
lengthintNumber of lines to read.
Returns
- uint[]
Array with frame counts for each line.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetTimeMapSpeed(int, int, int)
Get the project time map.
public Speed[] GetTimeMapSpeed(int slotId, int startLine, int length)
Parameters
slotIdintSlot number (0 to 15).
startLineintFirst line to read (usually 0).
lengthintNumber of lines to read.
Returns
- Speed[]
Array with information about speed for each line.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetUpperModuleCount(int)
Get the upper limit of module count (one more than the highest module number).
public int GetUpperModuleCount(int slotId)
Parameters
slotIdintslot number (0 to 15).
Returns
- int
Upper limit of module count.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetUpperPatternCount(int)
Get the upper limit of pattern count (one more than the highest pattern number).
public int GetUpperPatternCount(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- int
Upper limit of pattern count.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
Initialize(int, string?, AudioChannels, SunVoxInitOptions)
Initialize the SunVox engine.
public SunVoxVersion Initialize(int sampleRate, string? config = null, AudioChannels channels = AudioChannels.Stereo, SunVoxInitOptions options = SunVoxInitOptions.None)
Parameters
sampleRateintDesired sample rate (Hz); minimum 44100. The actual rate may differ if offline mode is not set.
configstringConfiguration string in pipe-separated format (e.g., "param1=value1|param2=value2"). Use null for automatic configuration.
channelsAudioChannelsNumber of audio channels.
optionsSunVoxInitOptionsInitialization flags.
Returns
Remarks
Exceptions
- SunVoxException
Thrown when initialization fails, or when already initialized.
IsPlaying(int)
Check if the project is currently playing.
public bool IsPlaying(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Returns
- bool
Remarks
Calls sv_end_of_song(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
Load(int, byte[])
Load a SunVox project from memory.
public void Load(int slotId, byte[] data)
Parameters
slotIdintSlot number (0 to 15).
databyte[]Byte array with project data.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
Load(int, string)
Load a SunVox project from file.
public void Load(int slotId, string path)
Parameters
slotIdintSlot number (0 to 15).
pathstringFile path (relative or absolute).
Remarks
Calls sv_load(int, IntPtr).
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
pathis null.
LoadIntoMetaModule(int, int, byte[])
Load a file into a MetaModule from memory. Supported file formats: sunvox, mod, xm, midi.
public void LoadIntoMetaModule(int slotId, int moduleId, byte[] data)
Parameters
slotIdintslot number (0 to 15).
moduleIdintMetamodule number (0-based).
databyte[]Byte array with project data.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
datais null.
LoadIntoMetaModule(int, int, string)
Load a file into a MetaModule. Supported file formats: sunvox, mod, xm, midi.
public void LoadIntoMetaModule(int slotId, int moduleId, string path)
Parameters
slotIdintslot number (0 to 15).
moduleIdintMetamodule number (0-based).
pathstringFile path (relative or absolute).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
pathis null.
LoadIntoVorbisPlayer(int, int, byte[])
Load a file into a Vorbis Player module from memory. Supported file formats: ogg.
public void LoadIntoVorbisPlayer(int slotId, int moduleId, byte[] data)
Parameters
slotIdintslot number (0 to 15).
moduleIdintVorbis Player module number (0-based).
databyte[]Byte array with audio file data.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
datais null.
LoadIntoVorbisPlayer(int, int, string)
Load a file into a Vorbis Player module. Supported file formats: ogg.
public void LoadIntoVorbisPlayer(int slotId, int moduleId, string path)
Parameters
slotIdintslot number (0 to 15).
moduleIdintVorbis Player module number (0-based).
pathstringFile path (relative or absolute).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
pathis null.
LoadModule(int, byte[], int, int, int)
Load a module or sample from memory. Supported file formats: sunsynth, xi, wav, aiff.
public int LoadModule(int slotId, byte[] data, int x = 0, int y = 0, int z = 0)
Parameters
slotIdintslot number (0 to 15).
databyte[]Byte array with module data.
xintX coordinate (0 to 1024, center: 512).
yintY coordinate (0 to 1024, center: 512).
zintLayer number (0 to 7).
Returns
- int
The number of the loaded module.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
datais null.
LoadModule(int, string, int, int, int)
Load a module or sample from file. Supported file formats: sunsynth, xi, wav, aiff.
public int LoadModule(int slotId, string path, int x = 0, int y = 0, int z = 0)
Parameters
slotIdintslot number (0 to 15).
pathstringFile path (relative or absolute).
xintX coordinate (0 to 1024, center: 512).
yintY coordinate (0 to 1024, center: 512).
zintLayer number (0 to 7).
Returns
- int
The number of the loaded module.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
pathis null.
LoadSamplerSample(int, int, byte[], int?)
Load a sample into a Sampler module from memory.
Supported file formats: xi, wav, aiff.
Set sampleSlot to null to apply the sample to all sample slots.
public void LoadSamplerSample(int slotId, int moduleId, byte[] data, int? sampleSlot = null)
Parameters
slotIdintslot number (0 to 15).
moduleIdintSampler module number (0-based).
databyte[]Byte array with sample data.
sampleSlotint?Sample slot number (-1 for auto/all slots).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
datais null.
LoadSamplerSample(int, int, string, int?)
Load a sample into a Sampler module.
Supported file formats: xi, wav, aiff.
Set sampleSlot to null to apply the sample to all sample slots.
public void LoadSamplerSample(int slotId, int moduleId, string path, int? sampleSlot = null)
Parameters
slotIdintslot number (0 to 15).
moduleIdintSampler module number (0-based).
pathstringFile path (relative or absolute).
sampleSlotint?Sample slot number (-1 for auto/all slots).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
pathis null.
LockSlot(int)
Lock the slot for thread-safe access. Use when reading/modifying SunVox data from different threads on the same slot. Some functions require lock/unlock. Remember to call UnlockSlot(int)!
public void LockSlot(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
The library uses a recursive mutex, so the same thread may call LockSlot(int) multiple times without deadlocking itself.
Calls sv_lock_slot(int).Exceptions
- SunVoxException
Thrown when the operation fails.
OpenSlot(int)
Open a slot.
public void OpenSlot(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_open_slot(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
PauseAudioStream(int)
Pause the audio stream from a slot.
public void PauseAudioStream(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_pause(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
ReadModuleCurve(int, int, int, float[])
Read data from a module curve.
public int ReadModuleCurve(int slotId, int moduleId, int curveId, float[] data)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
curveIdintCurve number.
datafloat[]Array to receive curveId data.
Returns
- int
Number of values read.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
datais null.
ReadModuleScope(int, int, AudioChannel, short[])
Read oscilloscope data from a module.
public int ReadModuleScope(int slotId, int moduleId, AudioChannel channel, short[] buffer)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
channelAudioChannelAudio channel.
buffershort[]Buffer to receive scope data.
Returns
- int
Number of samples read.
Remarks
Exceptions
- ArgumentNullException
Thrown if
bufferis null.
ReadPatternData(int, int, PatternEvent[], int, int, int, int, int, int, int?, int?)
Read a section or all of the pattern data into a buffer.
public int ReadPatternData(int slotId, int patternId, PatternEvent[] buffer, int bufferTracks, int bufferLines, int bufferOffsetTracks = 0, int bufferOffsetLines = 0, int readOffsetTracks = 0, int readOffsetLines = 0, int? maxTracks = null, int? maxLines = null)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
bufferPatternEvent[]Buffer to receive pattern data.
bufferTracksintWidth of the buffer.
bufferLinesintHeight of the buffer.
bufferOffsetTracksintNumber of tracks in the buffer to skip.
bufferOffsetLinesintNumber of lines in the buffer to skip.
readOffsetTracksintNumber of tracks in the pattern to skip.
readOffsetLinesintNumber of lines in the pattern to skip.
maxTracksint?Maximum number of tracks to read.
maxLinesint?Maximum number of lines to read.
Returns
- int
Number of events read.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_get_pattern_data(int, int).Exceptions
- ArgumentOutOfRangeException
Thrown if any offset or size parameter is negative.
- ArgumentException
Thrown if buffer length doesn't match bufferTracks * bufferLines.
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
bufferis null.
RemoveModule(int, int)
Remove (delete) a module.
public void RemoveModule(int slotId, int moduleId)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_remove_module(int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
RemovePattern(int, int)
Delete a pattern.
public void RemovePattern(int slotId, int patternId)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
Remarks
Deleting the original pattern also deletes all its clones.
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_remove_pattern(int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
ResetEventTiming(int)
Reset the timestamp of events sent by SendEvent(int, int, PatternEvent). If timestamp is zero: event is heard as quickly as possible.
public void ResetEventTiming(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
ResumeAudioStream(int)
Resume the audio stream from a slot.
public void ResumeAudioStream(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_resume(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
ResumeStreamOnSyncEffect(int)
Wait for sync (pattern effect 0x33 in any slot) and resume the audio stream.
public void ResumeStreamOnSyncEffect(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_sync_resume(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
Rewind(int, int)
Jump to the specified line on the timeline.
public void Rewind(int slotId, int line)
Parameters
slotIdintSlot number (0 to 15).
lineintLine number on the timeline.
Remarks
Calls sv_rewind(int, int).
Exceptions
- SunVoxException
Thrown when the operation fails.
SaveToFile(int, string)
Save the SunVox project to a file.
public void SaveToFile(int slotId, string path)
Parameters
slotIdintSlot number (0 to 15).
pathstringFile path where the project will be saved.
Remarks
Calls sv_save(int, IntPtr).
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
pathis null.
SendEvent(int, int, PatternEvent)
Send an event to the SunVox engine. Sends the specified pattern event to the given track. The event will be processed according to the last set timing.
public void SendEvent(int slotId, int track, PatternEvent data)
Parameters
slotIdintSlot number (0 to 15).
trackintTrack number within the virtual pattern.
dataPatternEventPattern event data.
Remarks
- See Also
SendEvent(int, int, int, int, int, int, int)
Send an event to the SunVox engine. Sends the specified pattern event to the given track. The event will be processed according to the last set timing.
public void SendEvent(int slotId, int track, int nn = 0, int vv = 0, int mm = 0, int ccee = 0, int xxyy = 0)
Parameters
slotIdintSlot number (0 to 15).
trackintTrack number within the virtual pattern.
nnintNote.
vvintVelocity.
mmintModule.
cceeintController and effect.
xxyyintValue.
Remarks
Consider using PatternEvent and the overload that accepts it for better readability.
Calls sv_send_event(int, int, int, int, int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
SetAutomaticStop(int, bool)
Set autostop mode. When OFF, the project loops endlessly.
public void SetAutomaticStop(int slotId, bool enable)
Parameters
slotIdintSlot number (0 to 15).
enablebooltrue - stop at the end.
Remarks
Calls sv_set_autostop(int, int).
Exceptions
- SunVoxException
Thrown when the operation fails.
SetEventTiming(int, int)
Set the timestamp of events sent by SendEvent(int, int, PatternEvent). Every event has a timestamp (when it was generated, e.g., key press time). If nonzero: event is heard at timestamp + sound latency * 2.
public void SetEventTiming(int slotId, int timestamp)
Parameters
slotIdintSlot number (0 to 15).
timestampintTimestamp (in system ticks) for future events. If not zero, must be ≥ previous value for same slot. See GetTicks() and GetTicksPerSecond().
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetModuleColor(int, int, byte, byte, byte)
Set the module color.
public void SetModuleColor(int slotId, int moduleId, byte r, byte g, byte b)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
rbyteRed component (0 to 255).
gbyteGreen component (0 to 255).
bbyteBlue component (0 to 255).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetModuleControllerValue(int, int, int, int, ValueScalingMode)
Set a controller value. Note: SendEvent(int, int, PatternEvent) will be used internally, which may introduce latency.
public void SetModuleControllerValue(int slotId, int moduleId, int controllerId, int value, ValueScalingMode scalingMode)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
controllerIdintcontroller number (0-based).
valueintController value.
scalingModeValueScalingModeValue scaling mode.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetModuleFineTune(int, int, int)
Set the module fine tune value.
public void SetModuleFineTune(int slotId, int moduleId, int fineTune)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
fineTuneintFine tune value (-256 to 256, 1/256 of a semitone).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetModuleName(int, int, string)
Set the module name.
public void SetModuleName(int slotId, int moduleId, string name)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
namestringNew module name.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
nameis null.
SetModulePosition(int, int, int, int)
Set the module position.
public void SetModulePosition(int slotId, int moduleId, int x, int y)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
xintX coordinate (center: 512, working area: 0 to 1024).
yintY coordinate (center: 512, working area: 0 to 1024).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetModuleRelativeNote(int, int, int)
Set the module relative note value.
public void SetModuleRelativeNote(int slotId, int moduleId, int relativeNote)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
relativeNoteintRelative note in semitones.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetPatternData(int, int, PatternEvent[], int, int)
Set the pattern data (all events). Resizes the pattern and sets all event data.
public void SetPatternData(int slotId, int patternId, PatternEvent[] data, int tracks, int lines)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
dataPatternEvent[]Event data array (length must equal tracks * lines).
tracksintNumber of tracks.
linesintNumber of lines.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls:Exceptions
- ArgumentOutOfRangeException
Thrown if tracks or lines are negative.
- ArgumentException
Thrown if data length doesn't match tracks * lines.
- SunVoxException
Thrown when the operation fails or pattern doesn't exist.
- ArgumentNullException
Thrown if
datais null.
SetPatternEvent(int, int, int, int, PatternEvent)
Set a pattern event at a specific location.
public void SetPatternEvent(int slotId, int patternId, int track, int line, PatternEvent ev)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
trackintTrack number.
lineintLine number.
evPatternEventPattern event data.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetPatternEvent(int, int, int, int, int, int, int, int, int)
Set a pattern event at a specific location.
public void SetPatternEvent(int slotId, int patternId, int track, int line, int nn, int vv, int mm, int ccee, int xxyy)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
trackintTrack number.
lineintLine number.
nnintNote: 0 - nothing; 1 to 127 - note; 128 - note off; 129+ - see NOTECMD_*.
vvintVelocity: 1 to 129; 0 - default.
mmintModule: 0 (empty) or module number + 1 (1 to 65535).
cceeintController/effect: 0xCCEE. CC - controller (1 to 255); EE - effect.
xxyyintValue: 0xXXYY. Controller value (0 to 32768) or effect parameter (0 to 65535).
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetPatternMuted(int, int, bool)
Set the pattern mute state.
public void SetPatternMuted(int slotId, int patternId, bool muted)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
mutedbool
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_pattern_mute(int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
SetPatternName(int, int, string)
Set the pattern name.
public void SetPatternName(int slotId, int patternId, string name)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
namestringNew pattern name.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_set_pattern_name(int, int, IntPtr).Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
nameis null.
SetPatternPosition(int, int, int, int)
Set the pattern position on the timeline.
public void SetPatternPosition(int slotId, int patternId, int x, int y)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
xintLine number on which the pattern starts.
yintY coordinate on timeline.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_set_pattern_xy(int, int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
SetPatternSize(int, int, int?, int?)
Set the pattern size (number of tracks and/or lines).
public void SetPatternSize(int slotId, int patternId, int? tracks = null, int? lines = null)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
tracksint?Number of tracks (null to keep current).
linesint?Number of lines (null to keep current).
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_set_pattern_size(int, int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
SetSamplerSampleParameter(int, int, int, int, int)
Set a Sampler sample parameter value.
public void SetSamplerSampleParameter(int slotId, int moduleId, int sampleSlot, int parameter, int parameterValue)
Parameters
slotIdintslot number (0 to 15).
moduleIdintSampler module number (0-based).
sampleSlotintSample slot number.
parameterintParameter number.
parameterValueintParameter value.
Remarks
This method does not throw exceptions on failure. Ensure that the provided parameters are valid.
Calls sv_sampler_par(int, int, int, int, int, int).SetSongName(int, string)
Set the project name.
public void SetSongName(int slotId, string value)
Parameters
slotIdintSlot number (0 to 15).
valuestringNew project name.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
StartPlayback(int)
Play from the current position.
public void StartPlayback(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_play(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
StartPlaybackFromBeginning(int)
Play from the beginning (line 0).
public void StartPlaybackFromBeginning(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_play_from_beginning(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
StopPlayback(int)
Stop playing. First call stops playback. The sound engine continues working (e.g., reverb tail may be heard). Second call resets all activity and enters standby mode.
public void StopPlayback(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_stop(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
UnlockSlot(int)
Unlock the slot. Must be called after LockSlot(int).
public void UnlockSlot(int slotId)
Parameters
slotIdintSlot number (0 to 15).
Remarks
Calls sv_unlock_slot(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
UpdateInputDevices()
Handle input ON/OFF requests to enable/disable sound card input ports (e.g., after Input module creation). Call from the main thread only, where the SunVox sound stream is not locked.
public void UpdateInputDevices()
Remarks
Calls sv_update_input().
Exceptions
- SunVoxException
Thrown when the operation fails.
Volume(int, int)
Set the project volume.
public int Volume(int slotId, int volume)
Parameters
slotIdintSlot number (0 to 15).
volumeintVolume: 0 (min) to 256 (max/100%). Negative values are ignored.
Returns
- int
Previous volume (0 to 256).
Remarks
Calls sv_volume(int, int).
Exceptions
- SunVoxException
Thrown when the operation fails.
WriteModuleCurve(int, int, int, float[])
Write data to a module curve.
public int WriteModuleCurve(int slotId, int moduleId, int curveId, float[] data)
Parameters
slotIdintslot number (0 to 15).
moduleIdintmodule number (0-based).
curveIdintCurve number.
datafloat[]Array containing curveId data to write.
Returns
- int
Number of values written.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
datais null.
WritePatternData(int, int, PatternEvent[], int, int, int, int, int, int, int?, int?)
Write a section or all of a buffer into the pattern data.
public int WritePatternData(int slotId, int patternId, PatternEvent[] buffer, int bufferTracks, int bufferLines, int bufferOffsetTracks = 0, int bufferOffsetLines = 0, int writeOffsetTracks = 0, int writeOffsetLines = 0, int? maxTracks = null, int? maxLines = null)
Parameters
slotIdintSlot number (0 to 15).
patternIdintPattern number.
bufferPatternEvent[]Buffer containing pattern data to write.
bufferTracksintWidth of the buffer.
bufferLinesintHeight of the buffer.
bufferOffsetTracksintNumber of tracks in the buffer to skip.
bufferOffsetLinesintNumber of lines in the buffer to skip.
writeOffsetTracksintNumber of tracks in the pattern to skip.
writeOffsetLinesintNumber of lines in the pattern to skip.
maxTracksint?Maximum number of tracks to write.
maxLinesint?Maximum number of lines to write.
Returns
- int
Number of events written.
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_get_pattern_data(int, int).Exceptions
- ArgumentOutOfRangeException
Thrown if any offset or size parameter is negative.
- ArgumentException
Thrown if buffer length doesn't match bufferTracks * bufferLines.
- ArgumentNullException
Thrown if
bufferis null.