Table of Contents

Interface ISunVox

Namespace
SunSharp
Assembly
SunSharp.dll

Allows for object-oriented approach to using the SunVox library.

public interface ISunVox

Properties

Channels

Number of channels SunVox was initialized with on startup.

AudioChannels Channels { get; }

Property Value

AudioChannels

Deinitialized

bool Deinitialized { get; }

Property Value

bool

Library

The underlying library interface. Direct use may break existing abstractions.

ISunVoxLib Library { get; }

Property Value

ISunVoxLib

NeedsUserCallback

bool NeedsUserCallback { get; }

Property Value

bool

OutputType

OutputType? OutputType { get; }

Property Value

OutputType?

SampleRate

int SampleRate { get; }

Property Value

int

SingleThreaded

bool SingleThreaded { get; }

Property Value

bool

Slots

ISlots Slots { get; }

Property Value

ISlots

Version

SunVoxVersion Version { get; }

Property Value

SunVoxVersion

Methods

AudioCallback(short[], short[], AudioChannels, int, uint)

Send audio to the Input module and get the next piece of audio from the Output module.

bool AudioCallback(short[] outputBuffer, short[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)

Parameters

outputBuffer short[]

Output buffer to write audio data to.

inputBuffer short[]

Input buffer. Stereo data must be interleaved.

inputChannels AudioChannels

Number of input channels.

latency int

Audio latency in frames.

outTime uint

Buffer output time in system ticks. See GetTicks().

Returns

bool

true if buffer contains any non-0 samples.

Remarks

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 outputBuffer or inputBuffer is null.

AudioCallback(short[], int, uint)

Get the next piece of audio from the Output module.

bool AudioCallback(short[] outputBuffer, int latency, uint outTime)

Parameters

outputBuffer short[]

Output buffer to write audio data to.

latency int

Audio latency in frames.

outTime uint

Buffer 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 outputBuffer is null.

AudioCallback(short[], float[], AudioChannels, int, uint)

Send audio to the Input module and get the next piece of audio from the Output module.

bool AudioCallback(short[] outputBuffer, float[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)

Parameters

outputBuffer short[]

Output buffer to write audio data to.

inputBuffer float[]

Input buffer. Stereo data must be interleaved.

inputChannels AudioChannels

Number of input channels.

latency int

Audio latency in frames.

outTime uint

Buffer output time in system ticks. See GetTicks().

Returns

bool

true if buffer contains any non-0 samples.

Remarks

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 outputBuffer or inputBuffer is null.

AudioCallback(float[], short[], AudioChannels, int, uint)

Send audio to the Input module and get the next piece of audio from the Output module.

bool AudioCallback(float[] outputBuffer, short[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)

Parameters

outputBuffer float[]

Output buffer to write audio data to.

inputBuffer short[]

Input buffer. Stereo data must be interleaved.

inputChannels AudioChannels

Number of input channels.

latency int

Audio latency in frames.

outTime uint

Buffer output time in system ticks. See GetTicks().

Returns

bool

true if buffer contains any non-0 samples.

Remarks

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 outputBuffer or inputBuffer is null.

AudioCallback(float[], int, uint)

Get the next piece of audio from the Output module.

bool AudioCallback(float[] outputBuffer, int latency, uint outTime)

Parameters

outputBuffer float[]

Output buffer to write audio data to.

latency int

Audio latency in frames.

outTime uint

Buffer 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 outputBuffer is null.

AudioCallback(float[], float[], AudioChannels, int, uint)

Send audio to the Input module and get the next piece of audio from the Output module.

bool AudioCallback(float[] outputBuffer, float[] inputBuffer, AudioChannels inputChannels, int latency, uint outTime)

Parameters

outputBuffer float[]

Output buffer to write audio data to.

inputBuffer float[]

Input buffer. Stereo data must be interleaved.

inputChannels AudioChannels

Number of input channels.

latency int

Audio latency in frames.

outTime uint

Buffer output time in system ticks. See GetTicks().

Returns

bool

true if buffer contains any non-0 samples.

Remarks

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 outputBuffer or inputBuffer is null.

GetLog(int)

Get the latest log messages from the SunVox engine.

string? GetLog(int length)

Parameters

length int

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

GetTicks()

Get the current system tick counter.

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.

uint GetTicksPerSecond()

Returns

uint

Remarks

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.

void UpdateInputDevices()

Remarks

Exceptions

SunVoxException

Thrown when the operation fails.