Class Slot
- Namespace
- SunSharp
- Assembly
- SunSharp.dll
Represents a SunVox slot.
public sealed class Slot : ISlot
- Inheritance
-
objectSlot
- 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
SunVox
SunVox instance this slot belongs to.
public SunVox SunVox { get; }
Property Value
Synthesizer
Project synthesizer, containing all the existing modules.
public Synthesizer Synthesizer { get; }
Property Value
Timeline
Project timeline, containing all the existing patterns.
public Timeline Timeline { get; }
Property Value
VirtualPattern
Virtual, 16-track pattern for sending events to the engine.
public VirtualPattern VirtualPattern { get; }
Property Value
Methods
AcquireLock()
public IDisposable AcquireLock()
Returns
- IDisposable
Close()
Closes the slot. Uses the shared slot management lock for thread safety.
public void Close()
Remarks
Calls sv_close_slot(int).
GetAutomaticStop()
Get the autostop mode. When false, the project loops endlessly.
public bool GetAutomaticStop()
Returns
- bool
true if automatic stop is enabled.
Remarks
Calls sv_get_autostop(int).
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
Calls sv_get_current_line(int).
GetCurrentLineWithTenthPart()
Get current line in fixed point format (with tenth part).
public int GetCurrentLineWithTenthPart()
Returns
- int
Current line number in fixed point format.
Remarks
Calls sv_get_current_line2(int).
GetCurrentSignalLevel(AudioChannel)
Get the current signal level from the Output module.
public int GetCurrentSignalLevel(AudioChannel channel = AudioChannel.Left)
Parameters
channelAudioChannelAudio 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
-
GetSongTpl(int)
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
Calls sv_get_song_name(int).
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
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)
Get the project time map.
public Speed[] GetTimeMapSpeed(int startLine, int length)
Parameters
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.
GetVolume()
Set the project volume.
public int GetVolume()
Returns
- int
Previous volume (0 to 256).
Remarks
Calls sv_volume(int, int).
Exceptions
- SunVoxException
Thrown when the operation fails.
IsPlaying()
Check if the project is currently playing.
public bool IsPlaying()
Returns
- bool
Remarks
Calls sv_end_of_song(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
Load(byte[])
Load a SunVox project from memory.
public void Load(byte[] data)
Parameters
databyte[]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
pathstringFile path (relative or absolute).
Remarks
Calls sv_load(int, IntPtr).
Exceptions
- SunVoxException
Thrown when the operation fails.
- ArgumentNullException
Thrown if
pathis 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
Calls sv_open_slot(int).
PauseAudioStream()
Pause the audio stream from a slot.
public void PauseAudioStream()
Remarks
Calls sv_pause(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
ResumeAudioStream()
Resume the audio stream from a slot.
public void ResumeAudioStream()
Remarks
Calls sv_resume(int).
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
Calls sv_sync_resume(int).
Exceptions
- SunVoxException
Thrown when the operation fails.
Rewind(int)
Jump to the specified line on the timeline.
public void Rewind(int lineNumber)
Parameters
lineNumberint
Remarks
Calls sv_rewind(int, int).
Exceptions
- SunVoxException
Thrown when the operation fails.
SaveToFile(string)
Save the SunVox project to a file.
public void SaveToFile(string path)
Parameters
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.
SetAutomaticStop(bool)
Set autostop mode. When OFF, the project loops endlessly.
public void SetAutomaticStop(bool enable)
Parameters
enablebooltrue - stop at the end.
Remarks
Calls sv_set_autostop(int, int).
Exceptions
- SunVoxException
Thrown when the operation fails.
SetSongName(string)
Set the project name.
public void SetSongName(string value)
Parameters
valuestringNew project name.
Remarks
Exceptions
- SunVoxException
Thrown when the operation fails.
SetVolume(int)
Set the project volume.
public void SetVolume(int value)
Parameters
valueint
Remarks
Calls sv_volume(int, int).
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
Calls sv_play_from_beginning(int).
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
Calls sv_unlock_slot(int).
Exceptions
- SunVoxException
Thrown when the operation fails.