Struct PatternHandle
- Namespace
- SunSharp
- Assembly
- SunSharp.dll
Represents a handle to a pattern. The handle may be invalid if the pattern does not exist.
public readonly struct PatternHandle : IPatternHandle
- Implements
Constructors
PatternHandle(Timeline, int)
public PatternHandle(Timeline timeline, int id)
Parameters
timelineTimelineidint
Properties
Id
Gets the pattern ID.
public int Id { get; }
Property Value
- int
Methods
GetData()
Get the pattern data (all events).
public (PatternEvent[] data, int tracks, int lines)? GetData()
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).GetEventValue(int, int, Column)
Get a specific column value from a pattern event.
public int GetEventValue(int track, int line, Column column)
Parameters
trackintTrack number.
lineintLine number.
columnColumnColumn to read.
Returns
- int
Column value.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetExists()
Check if a pattern exists.
public bool GetExists()
Returns
Remarks
GetLength()
Get the number of lines in the pattern. Can be used to check if a pattern exists (lines > 0).
public int GetLength()
Returns
- int
Number of lines.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
GetMuted()
Get the pattern mute state.
public bool GetMuted()
Returns
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_pattern_mute(int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
GetName()
Get the pattern name.
public string? GetName()
Returns
- string
Pattern name, or null if unavailable.
Remarks
GetPosition()
Get the pattern position on the timeline.
public (int x, int y) GetPosition()
Returns
- (int x, int y)
Tuple containing X and Y coordinates.
Remarks
GetTrackCount()
Get the number of tracks in the pattern.
public int GetTrackCount()
Returns
- int
Number of tracks.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetData(PatternEvent[], int, int)
Set the pattern data (all events). Resizes the pattern and sets all event data.
public void SetData(PatternEvent[] data, int tracks, int lines)
Parameters
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.
SetEvent(int, int, PatternEvent)
Set a pattern event at a specific location.
public void SetEvent(int track, int line, PatternEvent patternEvent)
Parameters
trackintTrack number.
lineintLine number.
patternEventPatternEvent
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetEvent(int, int, int, int, int, int, int)
Set a pattern event at a specific location.
public void SetEvent(int track, int line, int nn, int vv, int mm, int ccee, int xxyy)
Parameters
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.
SetMuted(bool)
Set the pattern mute state.
public void SetMuted(bool mute)
Parameters
mutebool
Remarks
Requires LockSlot(int) / UnlockSlot(int).
Calls sv_pattern_mute(int, int, int).Exceptions
- SunVoxException
Thrown when the operation fails.
SetName(string)
Set the pattern name.
public void SetName(string name)
Parameters
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.
SetPatternSize(int?, int?)
Set the pattern size (number of tracks and/or lines).
public void SetPatternSize(int? tracks = null, int? lines = null)
Parameters
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.
SetPosition(int, int)
Set the pattern position on the timeline.
public void SetPosition(int x, int y)
Parameters
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.