Module sokol.audio stdlib

sokol.audio
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
1
Imported by:
0
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Imported by

This section is empty.

Aliases

This section is empty.

Constants

This section is empty.

Sum types

This section is empty.

Functions

#fn buffer_frames

fn buffer_frames() int

buffer_frames - return the actual backend buffer size in number of frames

#fn channels

fn channels() int

channels - return the actual number of channels

#fn expect

fn expect() int

expect - get current number of frames to fill packet queue; use in combination with audio.push

#fn fclamp

inline
fn fclamp(x f32, flo f32, fhi f32) f32

fclamp - helper function to 'clamp' a number to a certain range

Example:

realsample := audio.fclamp(sample, -1.0, 1.0)

#fn is_valid

fn is_valid() bool

is_valid - true after setup if audio backend was successfully initialized

#fn max

fn max(x int, y int) int

max - helper function to return the larger of two numbers

NOTE: math.max returns f32 values, this returns int values

Example:

larger := audio.max(1, 5) // larger == 5

#fn min

fn min(x int, y int) int

min - helper function to return the smaller of two numbers

NOTE: math.min returns f32 values, this returns int values

Example:

smaller := audio.min(1, 5) // smaller == 1

#fn push

fn push(frames &f32, num_frames int) int

push - push sample frames from main thread, returns number of frames actually pushed

#fn query

fn query() C.saudio_desc

query - return a copy of the original saudio_desc struct

#fn sample_rate

fn sample_rate() int

sample_rate - return the actual sample rate

#fn setup

fn setup(desc &C.saudio_desc)

setup - setup sokol-audio

#fn shutdown

fn shutdown()

shutdown - shutdown sokol-audio

#fn suspended

fn suspended() bool

suspended returns true if audio context is currently suspended (only in WebAudio backend, all other backends return false)

#fn user_data

fn user_data() voidptr

userdata - return the saudio_desc.user_data pointer

Structs

#struct C.saudio_allocator

typedef
pub struct C.saudio_allocator {
pub mut:
	alloc     memory.FnAllocatorAlloc
	free      memory.FnAllocatorFree
	user_data voidptr
}

#struct C.saudio_logger

typedef
pub struct C.saudio_logger {
pub mut:
	log_cb    memory.FnLogCb
	user_data voidptr
}

#struct C.saudio_desc

typedef
pub struct C.saudio_desc {
	sample_rate        int
	num_channels       int
	buffer_frames      int
	packet_frames      int
	num_packets        int
	stream_cb          FNStreamingCB
	stream_userdata_cb FnStreamingCBWithUserData
pub mut:
	user_data voidptr
	allocator C.saudio_allocator
	logger    C.saudio_logger
}

only one of stream_cb or stream_userdata_cb should be used

default values (internal to sokol C library):

variable default note
sample_rate 44100 higher sample rates take more memory but are higher quality
num_channels 1 for stereo sound, this should be 2
buffer_frames 2048 buffer size in frames, larger is more latency, smaller means higher CPU
packet_frames 128 push model only, number of frames that will be pushed in each packet
num_packets 64 for push model only, number of packets in the backend ringbuffer

Interfaces

This section is empty.

Enums

This section is empty.