soundio.api

Undocumented in source.

Members

Enums

SoundIoBackend
enum SoundIoBackend
SoundIoChannelId
enum SoundIoChannelId

Specifies where a channel is physically located.

SoundIoChannelLayoutId
enum SoundIoChannelLayoutId

Built-in channel layouts for convenience.

SoundIoDeviceAim
enum SoundIoDeviceAim

Whether a device is an input device or output device

SoundIoError
enum SoundIoError

See also ::soundio_strerror

SoundIoFormat
enum SoundIoFormat

For your convenience, Native Endian and Foreign Endian constants are defined which point to the respective SoundIoFormat values.

Functions

soundio_backend_count
int soundio_backend_count(SoundIo* soundio)

Returns the number of available backends.

soundio_backend_name
const(char)* soundio_backend_name(SoundIoBackend backend)

Get a string representation of a #SoundIoBackend

soundio_best_matching_channel_layout
const(SoundIoChannelLayout)* soundio_best_matching_channel_layout(const(SoundIoChannelLayout)* preferred_layouts, int preferred_layout_count, const(SoundIoChannelLayout)* available_layouts, int available_layout_count)

Iterates over preferred_layouts. Returns the first channel layout in preferred_layouts which matches one of the channel layouts in available_layouts. Returns NULL if none matches.

soundio_channel_layout_builtin_count
int soundio_channel_layout_builtin_count()

Returns the number of builtin channel layouts.

soundio_channel_layout_detect_builtin
bool soundio_channel_layout_detect_builtin(SoundIoChannelLayout* layout)

Populates the name field of layout if it matches a builtin one. returns whether it found a match

soundio_channel_layout_equal
bool soundio_channel_layout_equal(const(SoundIoChannelLayout)* a, const(SoundIoChannelLayout)* b)

Returns whether the channel count field and each channel id matches in the supplied channel layouts.

soundio_channel_layout_find_channel
int soundio_channel_layout_find_channel(const(SoundIoChannelLayout)* layout, SoundIoChannelId channel)

Return the index of channel in layout, or -1 if not found.

soundio_channel_layout_get_builtin
const(SoundIoChannelLayout)* soundio_channel_layout_get_builtin(int index)

Returns a builtin channel layout. 0 <= index < ::soundio_channel_layout_builtin_count

soundio_channel_layout_get_default
const(SoundIoChannelLayout)* soundio_channel_layout_get_default(int channel_count)

Get the default builtin channel layout for the given number of channels.

soundio_connect
int soundio_connect(SoundIo* soundio)

Tries ::soundio_connect_backend on all available backends in order. Possible errors: * #SoundIoErrorInvalid - already connected * #SoundIoErrorNoMem * #SoundIoErrorSystemResources * #SoundIoErrorNoSuchClient - when JACK returns JackNoSuchClient See also ::soundio_disconnect

soundio_connect_backend
int soundio_connect_backend(SoundIo* soundio, SoundIoBackend backend)

Instead of calling ::soundio_connect you may call this function to try a specific backend. Possible errors: * #SoundIoErrorInvalid - already connected or invalid backend parameter * #SoundIoErrorNoMem * #SoundIoErrorBackendUnavailable - backend was not compiled in * #SoundIoErrorSystemResources * #SoundIoErrorNoSuchClient - when JACK returns JackNoSuchClient * #SoundIoErrorInitAudioBackend - requested backend is not active * #SoundIoErrorBackendDisconnected - backend disconnected while connecting See also ::soundio_disconnect

soundio_create
SoundIo* soundio_create()

Create a SoundIo context. You may create multiple instances of this to connect to multiple backends. Sets all fields to defaults. Returns NULL if and only if memory could not be allocated. See also ::soundio_destroy

soundio_default_input_device_index
int soundio_default_input_device_index(SoundIo* soundio)

returns the index of the default input device returns -1 if there are no devices or if you never called ::soundio_flush_events.

soundio_default_output_device_index
int soundio_default_output_device_index(SoundIo* soundio)

returns the index of the default output device returns -1 if there are no devices or if you never called ::soundio_flush_events.

soundio_destroy
void soundio_destroy(SoundIo* soundio)

Create a SoundIo context. You may create multiple instances of this to connect to multiple backends. Sets all fields to defaults. Returns NULL if and only if memory could not be allocated. See also ::soundio_destroy

soundio_device_equal
bool soundio_device_equal(const(SoundIoDevice)* a, const(SoundIoDevice)* b)

Return true if and only if the devices have the same SoundIoDevice::id, SoundIoDevice::is_raw, and SoundIoDevice::aim are the same.

soundio_device_nearest_sample_rate
int soundio_device_nearest_sample_rate(SoundIoDevice* device, int sample_rate)

Convenience function. Returns the available sample rate nearest to sample_rate, rounding up.

soundio_device_ref
void soundio_device_ref(SoundIoDevice* device)

Add 1 to the reference count of device.

soundio_device_sort_channel_layouts
void soundio_device_sort_channel_layouts(SoundIoDevice* device)

Sorts channel layouts by channel count, descending.

soundio_device_supports_format
bool soundio_device_supports_format(SoundIoDevice* device, SoundIoFormat format)

Convenience function. Returns whether format is included in the device's supported formats.

soundio_device_supports_layout
bool soundio_device_supports_layout(SoundIoDevice* device, const(SoundIoChannelLayout)* layout)

Convenience function. Returns whether layout is included in the device's supported channel layouts.

soundio_device_supports_sample_rate
bool soundio_device_supports_sample_rate(SoundIoDevice* device, int sample_rate)

Convenience function. Returns whether sample_rate is included in the device's supported sample rates.

soundio_device_unref
void soundio_device_unref(SoundIoDevice* device)

Remove 1 to the reference count of device. Clean up if it was the last reference.

soundio_disconnect
void soundio_disconnect(SoundIo* soundio)

Instead of calling ::soundio_connect you may call this function to try a specific backend. Possible errors: * #SoundIoErrorInvalid - already connected or invalid backend parameter * #SoundIoErrorNoMem * #SoundIoErrorBackendUnavailable - backend was not compiled in * #SoundIoErrorSystemResources * #SoundIoErrorNoSuchClient - when JACK returns JackNoSuchClient * #SoundIoErrorInitAudioBackend - requested backend is not active * #SoundIoErrorBackendDisconnected - backend disconnected while connecting See also ::soundio_disconnect

soundio_flush_events
void soundio_flush_events(SoundIo* soundio)

Atomically update information for all connected devices. Note that calling this function merely flips a pointer; the actual work of collecting device information is done elsewhere. It is performant to call this function many times per second.

soundio_force_device_scan
void soundio_force_device_scan(SoundIo* soundio)

If necessary you can manually trigger a device rescan. Normally you will not ever have to call this function, as libsoundio listens to system events for device changes and responds to them by rescanning devices and preparing the new device information for you to be atomically replaced when you call ::soundio_flush_events. However you might run into cases where you want to force trigger a device rescan, for example if an ALSA device has a SoundIoDevice::probe_error.

soundio_format_string
const(char)* soundio_format_string(SoundIoFormat format)

Returns string representation of format.

soundio_get_backend
SoundIoBackend soundio_get_backend(SoundIo* soundio, int index)

get the available backend at the specified index (0 <= index < ::soundio_backend_count)

soundio_get_bytes_per_frame
int soundio_get_bytes_per_frame(SoundIoFormat format, int channel_count)

A frame is one sample per channel.

soundio_get_bytes_per_sample
int soundio_get_bytes_per_sample(SoundIoFormat format)

Returns -1 on invalid format.

soundio_get_bytes_per_second
int soundio_get_bytes_per_second(SoundIoFormat format, int channel_count, int sample_rate)

Sample rate is the number of frames per second.

soundio_get_channel_name
const(char)* soundio_get_channel_name(SoundIoChannelId id)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
soundio_get_input_device
SoundIoDevice* soundio_get_input_device(SoundIo* soundio, int index)

Always returns a device. Call ::soundio_device_unref when done. index must be 0 <= index < ::soundio_input_device_count Returns NULL if you never called ::soundio_flush_events or if you provide invalid parameter values.

soundio_get_output_device
SoundIoDevice* soundio_get_output_device(SoundIo* soundio, int index)

Always returns a device. Call ::soundio_device_unref when done. index must be 0 <= index < ::soundio_output_device_count Returns NULL if you never called ::soundio_flush_events or if you provide invalid parameter values.

soundio_have_backend
bool soundio_have_backend(SoundIoBackend backend)

Returns whether libsoundio was compiled with backend.

soundio_input_device_count
int soundio_input_device_count(SoundIo* soundio)

When you call ::soundio_flush_events, a snapshot of all device state is saved and these functions merely access the snapshot data. When you want to check for new devices, call ::soundio_flush_events. Or you can call ::soundio_wait_events to block until devices change. If an error occurs scanning devices in a background thread, SoundIo::on_backend_disconnect is called with the error code. Get the number of input devices. Returns -1 if you never called ::soundio_flush_events.

soundio_instream_begin_read
int soundio_instream_begin_read(SoundIoInStream* instream, SoundIoChannelArea** areas, int* frame_count)

Call this function when you are ready to begin reading from the device buffer. * instream - (in) The input stream you want to read from. * areas - (out) The memory addresses you can read data from. It is OK to modify the pointers if that helps you iterate. There might be a "hole" in the buffer. To indicate this, areas will be NULL and frame_count tells how big the hole is in frames. * frame_count - (in/out) - Provide the number of frames you want to read; returns the number of frames you can actually read. The returned value will always be less than or equal to the provided value. If the provided value is less than frame_count_min from SoundIoInStream::read_callback this function returns with #SoundIoErrorInvalid. It is your responsibility to call this function no more and no fewer than the correct number of times according to the frame_count_min and frame_count_max criteria from SoundIoInStream::read_callback. You must call this function only from the SoundIoInStream::read_callback thread context. After calling this function, read data from areas and then use ::soundio_instream_end_read` to actually remove the data from the buffer and move the read index forward. ::soundio_instream_end_read should not be called if the buffer is empty (frame_count == 0), but it should be called if there is a hole.

soundio_instream_create
SoundIoInStream* soundio_instream_create(SoundIoDevice* device)

Allocates memory and sets defaults. Next you should fill out the struct fields and then call ::soundio_instream_open. Sets all fields to defaults. Returns NULL if and only if memory could not be allocated. See also ::soundio_instream_destroy

soundio_instream_destroy
void soundio_instream_destroy(SoundIoInStream* instream)

You may not call this function from SoundIoInStream::read_callback.

soundio_instream_end_read
int soundio_instream_end_read(SoundIoInStream* instream)

This will drop all of the frames from when you called ::soundio_instream_begin_read. You must call this function only from the SoundIoInStream::read_callback thread context. You must call this function only after a successful call to ::soundio_instream_begin_read.

soundio_instream_get_latency
int soundio_instream_get_latency(SoundIoInStream* instream, double* out_latency)

Obtain the number of seconds that the next frame of sound being captured will take to arrive in the buffer, plus the amount of time that is represented in the buffer. This includes both software and hardware latency.

soundio_instream_open
int soundio_instream_open(SoundIoInStream* instream)

After you call this function, SoundIoInStream::software_latency is set to the correct value. The next thing to do is call ::soundio_instream_start. If this function returns an error, the instream is in an invalid state and you must call ::soundio_instream_destroy on it.

soundio_instream_pause
int soundio_instream_pause(SoundIoInStream* instream, bool pause)

If the underyling device supports pausing, this pauses the stream and prevents SoundIoInStream::read_callback from being called. Otherwise this returns #SoundIoErrorIncompatibleDevice. This function may be called from any thread. Pausing when already paused or unpausing when already unpaused has no effect and always returns #SoundIoErrorNone.

soundio_instream_start
int soundio_instream_start(SoundIoInStream* instream)

After you call this function, SoundIoInStream::read_callback will be called.

soundio_output_device_count
int soundio_output_device_count(SoundIo* soundio)

Get the number of output devices. Returns -1 if you never called ::soundio_flush_events.

soundio_outstream_begin_write
int soundio_outstream_begin_write(SoundIoOutStream* outstream, SoundIoChannelArea** areas, int* frame_count)

Call this function when you are ready to begin writing to the device buffer. * outstream - (in) The output stream you want to write to. * areas - (out) The memory addresses you can write data to, one per channel. It is OK to modify the pointers if that helps you iterate. * frame_count - (in/out) Provide the number of frames you want to write. Returned will be the number of frames you can actually write, which is also the number of frames that will be written when you call ::soundio_outstream_end_write. The value returned will always be less than or equal to the value provided. It is your responsibility to call this function exactly as many times as necessary to meet the frame_count_min and frame_count_max criteria from SoundIoOutStream::write_callback. You must call this function only from the SoundIoOutStream::write_callback thread context. After calling this function, write data to areas and then call ::soundio_outstream_end_write. If this function returns an error, do not call ::soundio_outstream_end_write.

soundio_outstream_clear_buffer
int soundio_outstream_clear_buffer(SoundIoOutStream* outstream)

Clears the output stream buffer. This function can be called from any thread. This function can be called regardless of whether the outstream is paused or not. Some backends do not support clearing the buffer. On these backends this function will return SoundIoErrorIncompatibleBackend. Some devices do not support clearing the buffer. On these devices this function might return SoundIoErrorIncompatibleDevice. Possible errors:

soundio_outstream_create
SoundIoOutStream* soundio_outstream_create(SoundIoDevice* device)

Allocates memory and sets defaults. Next you should fill out the struct fields and then call ::soundio_outstream_open. Sets all fields to defaults. Returns NULL if and only if memory could not be allocated. See also ::soundio_outstream_destroy

soundio_outstream_destroy
void soundio_outstream_destroy(SoundIoOutStream* outstream)

You may not call this function from the SoundIoOutStream::write_callback thread context.

soundio_outstream_end_write
int soundio_outstream_end_write(SoundIoOutStream* outstream)

Commits the write that you began with ::soundio_outstream_begin_write. You must call this function only from the SoundIoOutStream::write_callback thread context.

soundio_outstream_get_latency
int soundio_outstream_get_latency(SoundIoOutStream* outstream, double* out_latency)

Obtain the total number of seconds that the next frame written after the last frame written with ::soundio_outstream_end_write will take to become audible. This includes both software and hardware latency. In other words, if you call this function directly after calling ::soundio_outstream_end_write, this gives you the number of seconds that the next frame written will take to become audible.

soundio_outstream_open
int soundio_outstream_open(SoundIoOutStream* outstream)

After you call this function, SoundIoOutStream::software_latency is set to the correct value.

soundio_outstream_pause
int soundio_outstream_pause(SoundIoOutStream* outstream, bool pause)

If the underlying backend and device support pausing, this pauses the stream. SoundIoOutStream::write_callback may be called a few more times if the buffer is not full. Pausing might put the hardware into a low power state which is ideal if your software is silent for some time. This function may be called from any thread context, including SoundIoOutStream::write_callback. Pausing when already paused or unpausing when already unpaused has no effect and returns #SoundIoErrorNone.

soundio_outstream_set_volume
int soundio_outstream_set_volume(SoundIoOutStream* outstream, double volume)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
soundio_outstream_start
int soundio_outstream_start(SoundIoOutStream* outstream)

After you call this function, SoundIoOutStream::write_callback will be called.

soundio_parse_channel_id
SoundIoChannelId soundio_parse_channel_id(const(char)* str, int str_len)

Given UTF-8 encoded text which is the name of a channel such as "Front Left", "FL", or "front-left", return the corresponding SoundIoChannelId. Returns SoundIoChannelIdInvalid for no match.

soundio_ring_buffer_advance_read_ptr
void soundio_ring_buffer_advance_read_ptr(SoundIoRingBuffer* ring_buffer, int count)

count in bytes.

soundio_ring_buffer_advance_write_ptr
void soundio_ring_buffer_advance_write_ptr(SoundIoRingBuffer* ring_buffer, int count)

count in bytes.

soundio_ring_buffer_capacity
int soundio_ring_buffer_capacity(SoundIoRingBuffer* ring_buffer)

When you create a ring buffer, capacity might be more than the requested capacity for alignment purposes. This function returns the actual capacity.

soundio_ring_buffer_clear
void soundio_ring_buffer_clear(SoundIoRingBuffer* ring_buffer)

Must be called by the writer.

soundio_ring_buffer_create
SoundIoRingBuffer* soundio_ring_buffer_create(SoundIo* soundio, int requested_capacity)
soundio_ring_buffer_destroy
void soundio_ring_buffer_destroy(SoundIoRingBuffer* ring_buffer)

A ring buffer is a single-reader single-writer lock-free fixed-size queue. libsoundio ring buffers use memory mapping techniques to enable a contiguous buffer when reading or writing across the boundary of the ring buffer's capacity. requested_capacity in bytes. Returns NULL if and only if memory could not be allocated. Use ::soundio_ring_buffer_capacity to get the actual capacity, which might be greater for alignment purposes. See also ::soundio_ring_buffer_destroy

soundio_ring_buffer_fill_count
int soundio_ring_buffer_fill_count(SoundIoRingBuffer* ring_buffer)
soundio_ring_buffer_free_count
int soundio_ring_buffer_free_count(SoundIoRingBuffer* ring_buffer)
soundio_ring_buffer_read_ptr
char* soundio_ring_buffer_read_ptr(SoundIoRingBuffer* ring_buffer)

Do not read more than capacity.

soundio_ring_buffer_write_ptr
char* soundio_ring_buffer_write_ptr(SoundIoRingBuffer* ring_buffer)

Do not write more than capacity.

soundio_sort_channel_layouts
void soundio_sort_channel_layouts(SoundIoChannelLayout* layouts, int layout_count)

Sorts by channel count, descending.

soundio_strerror
const(char)* soundio_strerror(int error)

Get a string representation of a #SoundIoError

soundio_version_major
int soundio_version_major()

See also ::soundio_version_string, ::soundio_version_minor, ::soundio_version_patch

soundio_version_minor
int soundio_version_minor()

See also ::soundio_version_major, ::soundio_version_string, ::soundio_version_patch

soundio_version_patch
int soundio_version_patch()

See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_string

soundio_version_string
const(char)* soundio_version_string()

See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_patch

soundio_wait_events
void soundio_wait_events(SoundIo* soundio)

This function calls ::soundio_flush_events then blocks until another event is ready or you call ::soundio_wakeup. Be ready for spurious wakeups.

soundio_wakeup
void soundio_wakeup(SoundIo* soundio)

Makes ::soundio_wait_events stop blocking.

Manifest constants

SOUNDIO_MAX_CHANNELS
enum SOUNDIO_MAX_CHANNELS;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
SoundIoBackendAlsa
enum SoundIoBackendAlsa;
SoundIoBackendCoreAudio
enum SoundIoBackendCoreAudio;
SoundIoBackendDummy
enum SoundIoBackendDummy;
SoundIoBackendJack
enum SoundIoBackendJack;
SoundIoBackendNone
enum SoundIoBackendNone;
SoundIoBackendPulseAudio
enum SoundIoBackendPulseAudio;
SoundIoBackendWasapi
enum SoundIoBackendWasapi;
SoundIoDeviceAimInput
enum SoundIoDeviceAimInput;
SoundIoDeviceAimOutput
enum SoundIoDeviceAimOutput;

Whether a device is an input device or output device

SoundIoErrorBackendDisconnected
enum SoundIoErrorBackendDisconnected;
SoundIoErrorBackendUnavailable
enum SoundIoErrorBackendUnavailable;
SoundIoErrorEncodingString
enum SoundIoErrorEncodingString;
SoundIoErrorIncompatibleBackend
enum SoundIoErrorIncompatibleBackend;
SoundIoErrorIncompatibleDevice
enum SoundIoErrorIncompatibleDevice;
SoundIoErrorInitAudioBackend
enum SoundIoErrorInitAudioBackend;
SoundIoErrorInterrupted
enum SoundIoErrorInterrupted;
SoundIoErrorInvalid
enum SoundIoErrorInvalid;
SoundIoErrorNoMem
enum SoundIoErrorNoMem;
SoundIoErrorNoSuchClient
enum SoundIoErrorNoSuchClient;
SoundIoErrorNoSuchDevice
enum SoundIoErrorNoSuchDevice;
SoundIoErrorNone
enum SoundIoErrorNone;
SoundIoErrorOpeningDevice
enum SoundIoErrorOpeningDevice;
SoundIoErrorStreaming
enum SoundIoErrorStreaming;
SoundIoErrorSystemResources
enum SoundIoErrorSystemResources;
SoundIoErrorUnderflow
enum SoundIoErrorUnderflow;

See also ::soundio_strerror

SoundIoFormatFloat32BE
enum SoundIoFormatFloat32BE;
SoundIoFormatFloat32FE
enum SoundIoFormatFloat32FE;
SoundIoFormatFloat32LE
enum SoundIoFormatFloat32LE;
SoundIoFormatFloat32NE
enum SoundIoFormatFloat32NE;
SoundIoFormatFloat64BE
enum SoundIoFormatFloat64BE;
SoundIoFormatFloat64FE
enum SoundIoFormatFloat64FE;
SoundIoFormatFloat64LE
enum SoundIoFormatFloat64LE;
SoundIoFormatFloat64NE
enum SoundIoFormatFloat64NE;
SoundIoFormatInvalid
enum SoundIoFormatInvalid;
SoundIoFormatS16BE
enum SoundIoFormatS16BE;
SoundIoFormatS16FE
enum SoundIoFormatS16FE;
SoundIoFormatS16LE
enum SoundIoFormatS16LE;
SoundIoFormatS16NE
enum SoundIoFormatS16NE;
SoundIoFormatS24BE
enum SoundIoFormatS24BE;
SoundIoFormatS24FE
enum SoundIoFormatS24FE;
SoundIoFormatS24LE
enum SoundIoFormatS24LE;
SoundIoFormatS24NE
enum SoundIoFormatS24NE;
SoundIoFormatS32BE
enum SoundIoFormatS32BE;
SoundIoFormatS32FE
enum SoundIoFormatS32FE;
SoundIoFormatS32LE
enum SoundIoFormatS32LE;
SoundIoFormatS32NE
enum SoundIoFormatS32NE;
SoundIoFormatS8
enum SoundIoFormatS8;
SoundIoFormatU16BE
enum SoundIoFormatU16BE;
SoundIoFormatU16FE
enum SoundIoFormatU16FE;
SoundIoFormatU16LE
enum SoundIoFormatU16LE;
SoundIoFormatU16NE
enum SoundIoFormatU16NE;
SoundIoFormatU24BE
enum SoundIoFormatU24BE;
SoundIoFormatU24FE
enum SoundIoFormatU24FE;
SoundIoFormatU24LE
enum SoundIoFormatU24LE;
SoundIoFormatU24NE
enum SoundIoFormatU24NE;
SoundIoFormatU32BE
enum SoundIoFormatU32BE;
SoundIoFormatU32FE
enum SoundIoFormatU32FE;
SoundIoFormatU32LE
enum SoundIoFormatU32LE;
SoundIoFormatU32NE
enum SoundIoFormatU32NE;
SoundIoFormatU8
enum SoundIoFormatU8;

For your convenience, Native Endian and Foreign Endian constants are defined which point to the respective SoundIoFormat values.

Structs

SoundIo
struct SoundIo

The size of this struct is not part of the API or ABI.

SoundIoChannelArea
struct SoundIoChannelArea

The size of this struct is OK to use.

SoundIoChannelLayout
struct SoundIoChannelLayout

The size of this struct is OK to use.

SoundIoDevice
struct SoundIoDevice

The size of this struct is not part of the API or ABI.

SoundIoInStream
struct SoundIoInStream

The size of this struct is not part of the API or ABI.

SoundIoOutStream
struct SoundIoOutStream

The size of this struct is not part of the API or ABI.

SoundIoRingBuffer
struct SoundIoRingBuffer
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
SoundIoSampleRateRange
struct SoundIoSampleRateRange

The size of this struct is OK to use.

Meta