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
Deinitialized
bool Deinitialized { get; }
Property Value
- bool
Library
The underlying library interface. Direct use may break existing abstractions.
ISunVoxLib Library { get; }
Property Value
NeedsUserCallback
bool NeedsUserCallback { get; }
Property Value
- bool
OutputType
OutputType? OutputType { get; }
Property Value
SampleRate
int SampleRate { get; }
Property Value
- int
SingleThreaded
bool SingleThreaded { get; }
Property Value
- bool
Slots
ISlots Slots { get; }
Property Value
Version
SunVoxVersion Version { get; }
Property Value
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
outputBuffershort[]Output buffer to write audio data to.
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[], int, uint)
Get the next piece of audio from the Output module.
bool AudioCallback(short[] outputBuffer, int latency, uint outTime)
Parameters
outputBuffershort[]Output buffer to write audio data to.
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[], 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
outputBuffershort[]Output buffer to write audio data to.
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[], 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
outputBufferfloat[]Output buffer to write audio data to.
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[], int, uint)
Get the next piece of audio from the Output module.
bool AudioCallback(float[] outputBuffer, int latency, uint outTime)
Parameters
outputBufferfloat[]Output buffer to write audio data to.
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[], 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
outputBufferfloat[]Output buffer to write audio data to.
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.
GetLog(int)
Get the latest log messages from the SunVox engine.
string? GetLog(int length)
Parameters
lengthint
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
Calls sv_get_ticks_per_second().
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
Calls sv_update_input().
Exceptions
- SunVoxException
Thrown when the operation fails.