std1.0.0-beta-7 SafeC docs

std :: dsp::audio_buffer

Struct std::AudioBuffer

#include <std/dsp/audio_buffer.h> source

struct AudioBuffer {
    Fixed data[AUDIO_BUF_FRAMES * AUDIO_MAX_CHANNELS];
    unsigned long cap_frames;
    unsigned long channels;
    volatile unsigned long head;
    volatile unsigned long tail;
}

Fields

§unsigned long cap_framessource

capacity in frames

§unsigned long channelssource

number of channels (1=mono, 2=stereo, …)

§volatile unsigned long headsource

write head (frames)

§volatile unsigned long tailsource

read head (frames)

Methods

§unsigned long readable_frames() constsource · definition

Frames available to read.

§unsigned long writable_frames() constsource · definition

Frames available to write.

§unsigned long write_frames([]const Fixed src)source · definition

Write the frames in src (as many as fit). Returns frames written.

§unsigned long read_frames([]Fixed dst)source · definition

Read up to dst.len / channels frames into dst. Returns frames read.

§unsigned long peek_frames([]Fixed dst) constsource · definition

Like read_frames, without consuming.

§unsigned long mix_frames([]const Fixed src)source · definition

Mix (add) the frames in src into the next writable frames. Used for audio mixing; does not advance head. Returns frames mixed.

§void clear()source · definition

Clear (zero) all frames.

§int is_empty() constsource · definition
§int is_full() constsource · definition
§static struct AudioBuffer new(unsigned long channels)source · definition

An empty buffer of 'channels' channels (capacity = AUDIO_BUF_FRAMES frames), zeroed.