33 BJ_AUDIO_FORMAT_UNKNOWN = 0x0000,
39#define BJ_AUDIO_FORMAT_WIDTH(x) ((x) & (0xFFu))
40#define BJ_AUDIO_FORMAT_FLOAT(x) ((x) & (1u<<8))
41#define BJ_AUDIO_FORMAT_INT(x) (!((x) & (1u<<8)))
42#define BJ_AUDIO_FORMAT_BIG_ENDIAN(x) ((x) & (1u<<12))
43#define BJ_AUDIO_FORMAT_SIGNED(x) ((x) & (1u<<15))
80 uint64_t base_sample_index
110 void* p_callback_user_data,
237 uint64_t base_sample_index
292 struct bj_audio_layer_data_t*
data;
General-purpose definitions for Banjo API.
Recoverable error handling.
const char * name
Name of the backend (e.g., "alsa", "mme").
Definition audio.h:304
void(* close_device)(struct bj_audio_layer_t *self, bj_audio_device *device)
Close an audio device managed by this backend.
Definition audio.h:265
bj_audio_format format
Sampling format.
Definition audio.h:54
unsigned int sample_rate
Number of samples per second (Hz).
Definition audio.h:57
int16_t amplitude
Maximum amplitude of the output samples.
Definition audio.h:55
struct bj_audio_layer_data_t * data
Backend-specific data pointer.
Definition audio.h:292
void(* end)(struct bj_audio_layer_t *self, bj_error **p_error)
Shutdown and clean up the backend.
Definition audio.h:255
unsigned int channels
Number of channels (currently always 1).
Definition audio.h:56
bj_audio_format_t
Describes how and audio device encodes sound samples.
Definition audio.h:32
bj_audio_device * bj_open_audio_device(const bj_audio_properties *p_properties, bj_audio_callback_t p_callback, void *p_callback_user_data, bj_error **p_error)
Open the default audio device for playback.
struct bj_audio_properties_t bj_audio_properties
Describe properties of an audio device.
void(* bj_audio_callback_t)(void *buffer, unsigned frames, const bj_audio_properties *audio, void *user_data, uint64_t base_sample_index)
Define a callback for generating audio samples.
Definition audio.h:75
struct bj_audio_device_t bj_audio_device
Opaque handle to an audio device instance.
Definition audio.h:24
struct bj_audio_layer_t bj_audio_layer
Represent an audio backend (ALSA, MME, etc).
void bj_audio_device_stop(bj_audio_device *p_device)
Stop playback and reset the sample stream.
enum bj_audio_format_t bj_audio_format
Describes how and audio device encodes sound samples.
void bj_audio_device_reset(bj_audio_device *p_device)
Reset the playback stream sample index to 0.
void bj_audio_play_note(void *buffer, unsigned frames, const bj_audio_properties *audio, void *user_data, uint64_t base_sample_index)
Generate a basic waveform tone using a built-in callback.
void bj_audio_device_play(bj_audio_device *p_device)
Resume audio playback.
struct bj_audio_play_note_data_t bj_audio_play_note_data
Define parameters for generating simple waveforms.
void bj_audio_device_pause(bj_audio_device *p_device)
Pause audio playback.
void bj_close_audio_device(bj_audio_device *p_device)
Close an audio device and release all associated resources.
bj_bool bj_audio_device_is_playing(const bj_audio_device *p_device)
Query whether the device is currently playing audio.
@ BJ_AUDIO_FORMAT_F32
!< 16-bit signed integer
Definition audio.h:35
@ BJ_AUDIO_FORMAT_INT16
!< Unknown
Definition audio.h:34
Declare a backend and its constructor function.
Definition audio.h:303
Represent an audio backend (ALSA, MME, etc).
Definition audio.h:246
Describe properties of an audio device.
Definition audio.h:53
uint32_t bj_bool
Boolean type used throughout the BJ codebase.
Definition api.h:143
Error structure.
Definition error.h:131
Define parameters for generating simple waveforms.
Definition audio.h:206
enum bj_audio_play_note_data_t::@240042340022345302376151237345105167321121277363 function
Type of waveform to generate.
@ BJ_AUDIO_PLAY_TRIANGLE
Generate a triangle wave.
Definition audio.h:210
@ BJ_AUDIO_PLAY_SQUARE
Generate a square wave.
Definition audio.h:209
@ BJ_AUDIO_PLAY_SINE
Generate a sine wave.
Definition audio.h:208
@ BJ_AUDIO_PLAY_SAWTOOTH
Generate a sawtooth wave.
Definition audio.h:211
double frequency
Frequency of the waveform (Hz).
Definition audio.h:213
double phase
Internal phase accumulator.
Definition audio.h:214