Table of Contents

Class Slot

Namespace
SunSharp
Assembly
SunSharp.dll

Represents a SunVox slot.

public sealed class Slot : ISlot
Inheritance
object
Slot
Implements

Properties

Id

Gets the slot ID.

public int Id { get; }

Property Value

int

IsOpen

Gets a value indicating whether the slot is currently open.

public bool IsOpen { get; }

Property Value

bool

Library

Underlying library instance.

public SunVoxLib Library { get; }

Property Value

SunVoxLib

SunVox

SunVox instance this slot belongs to.

public SunVox SunVox { get; }

Property Value

SunVox

Synthesizer

Project synthesizer, containing all the existing modules.

public Synthesizer Synthesizer { get; }

Property Value

Synthesizer

Timeline

Project timeline, containing all the existing patterns.

public Timeline Timeline { get; }

Property Value

Timeline

VirtualPattern

Virtual, 16-track pattern for sending events to the engine.

public VirtualPattern VirtualPattern { get; }

Property Value

VirtualPattern

Methods

AcquireLock()

Can be used instead of the Lock() and Unlock() methods, taking advantage of the using keyword.

public IDisposable AcquireLock()

Returns

IDisposable

Close()

Closes the slot. Uses the shared slot management lock for thread safety.

public void Close()

Remarks

GetAutomaticStop()

Get the autostop mode. When false, the project loops endlessly.

public bool GetAutomaticStop()

Returns

bool

true if automatic stop is enabled.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

GetCurrentLine()

Get the current line number on the timeline.

public int GetCurrentLine()

Returns

int

Current line number (playback position).

Remarks

GetCurrentLineWithTenthPart()

Get current line in fixed point format (with tenth part).

public int GetCurrentLineWithTenthPart()

Returns

int

Current line number in fixed point format.

Remarks

GetCurrentSignalLevel(AudioChannel)

Get the current signal level from the Output module.

public int GetCurrentSignalLevel(AudioChannel channel = AudioChannel.Left)

Parameters

channel AudioChannel

Audio channel.

Returns

int

Signal level (0 to 255).

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

GetSongBpm()

Get the project BPM (Beats Per Minute).

public int GetSongBpm()

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()

Get the project length in frames.

public uint GetSongLengthInFrames()

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()

Get the project length in lines.

public uint GetSongLengthInLines()

Returns

uint

Remarks

GetSongName()

Get the project name.

public string? GetSongName()

Returns

string

Project name, or null if unavailable.

Remarks

GetSongTpl()

Get the project TPL (Ticks Per Line).

public int GetSongTpl()

Returns

int

Remarks

The value can be set using pattern effects.

Calls sv_get_song_tpl(int).

Exceptions

SunVoxException

Thrown when the operation fails.

GetTimeMapFrames(int, int)

Get the project time map.

public uint[] GetTimeMapFrames(int startLine, int length)

Parameters

startLine int

First line to read (usually 0).

length int

Number of lines to read.

Returns

uint[]

Array with frame counts for each line.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

GetTimeMapSpeed(int, int)

Get the project time map.

public Speed[] GetTimeMapSpeed(int startLine, int length)

Parameters

startLine int

First line to read (usually 0).

length int

Number of lines to read.

Returns

Speed[]

Array with information about speed for each line.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

GetVolume()

Set the project volume.

public int GetVolume()

Returns

int

Previous volume (0 to 256).

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

IsPlaying()

Check if the project is currently playing.

public bool IsPlaying()

Returns

bool

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

Load(byte[])

Load a SunVox project from memory.

public void Load(byte[] data)

Parameters

data byte[]

Byte array with project data.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

Load(string)

Load a SunVox project from file.

public void Load(string path)

Parameters

path string

File path (relative or absolute).

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if path is null.

Lock()

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 Lock()

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.

Open()

Opens the slot for use. Uses the shared slot management lock for thread safety.

public void Open()

Remarks

PauseAudioStream()

Pause the audio stream from a slot.

public void PauseAudioStream()

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ResumeAudioStream()

Resume the audio stream from a slot.

public void ResumeAudioStream()

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ResumeStreamOnSyncEffect()

Wait for sync (pattern effect 0x33 in any slot) and resume the audio stream.

public void ResumeStreamOnSyncEffect()

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

Rewind(int)

Jump to the specified line on the timeline.

public void Rewind(int lineNumber)

Parameters

lineNumber int

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

SaveToFile(string)

Save the SunVox project to a file.

public void SaveToFile(string path)

Parameters

path string

File path where the project will be saved.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

ArgumentNullException

Thrown if path is null.

SetAutomaticStop(bool)

Set autostop mode. When OFF, the project loops endlessly.

public void SetAutomaticStop(bool enable)

Parameters

enable bool

true - stop at the end.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

SetSongName(string)

Set the project name.

public void SetSongName(string value)

Parameters

value string

New project name.

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

SetVolume(int)

Set the project volume.

public void SetVolume(int value)

Parameters

value int

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

StartPlayback()

Play from the current position.

public void StartPlayback()

Remarks

Calls sv_play(int).

Exceptions

SunVoxException

Thrown when the operation fails.

StartPlaybackFromBeginning()

Play from the beginning (line 0).

public void StartPlaybackFromBeginning()

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.

StopPlayback()

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()

Remarks

Calls sv_stop(int).

Exceptions

SunVoxException

Thrown when the operation fails.

Unlock()

Unlock the slot. Must be called after LockSlot(int).

public void Unlock()

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.