64#define BJ_AUDIO_FORMAT_WIDTH(x) ((x) & (0xFFu))
72#define BJ_AUDIO_FORMAT_FLOAT(x) ((x) & (1u<<8))
80#define BJ_AUDIO_FORMAT_INT(x) (!((x) & (1u<<8)))
88#define BJ_AUDIO_FORMAT_BIG_ENDIAN(x) ((x) & (1u<<12))
96#define BJ_AUDIO_FORMAT_SIGNED(x) ((x) & (1u<<15))
133 uint64_t base_sample_index
157 void* p_callback_user_data,
282 uint64_t base_sample_index
336 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:348
void(* close_device)(struct bj_audio_layer_t *self, bj_audio_device *device)
Close an audio device managed by this backend.
Definition audio.h:309
bj_audio_format format
Sampling format.
Definition audio.h:107
unsigned int sample_rate
Number of samples per second (Hz).
Definition audio.h:110
int16_t amplitude
Maximum amplitude of the output samples.
Definition audio.h:108
struct bj_audio_layer_data_t * data
Backend-specific data pointer.
Definition audio.h:336
void(* end)(struct bj_audio_layer_t *self, bj_error **p_error)
Shutdown and clean up the backend.
Definition audio.h:299
unsigned int channels
Number of channels (currently always 1).
Definition audio.h:109
bj_audio_format_t
Audio sample format descriptor.
Definition audio.h:52
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.
bj_bool bj_audio_playing(const bj_audio_device *p_device)
Query whether the device is currently playing audio.
void bj_play_audio_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_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:128
struct bj_audio_device_t bj_audio_device
Opaque handle to an audio device instance.
Definition audio.h:38
struct bj_audio_layer_t bj_audio_layer
Represent an audio backend (ALSA, MME, etc).
enum bj_audio_format_t bj_audio_format
Audio sample format descriptor.
void bj_play_audio_device(bj_audio_device *p_device)
Resume audio playback.
void bj_pause_audio_device(bj_audio_device *p_device)
Pause audio playback.
void bj_stop_audio_device(bj_audio_device *p_device)
Stop playback and reset the sample stream.
struct bj_audio_play_note_data_t bj_audio_play_note_data
Define parameters for generating simple waveforms.
void bj_reset_audio_device(bj_audio_device *p_device)
Reset the playback stream sample index to 0.
void bj_close_audio_device(bj_audio_device *p_device)
Close an audio device and release all associated resources.
@ BJ_AUDIO_FORMAT_F32
32-bit IEEE-754 float PCM.
Definition audio.h:55
@ BJ_AUDIO_FORMAT_UNKNOWN
Unknown/unspecified format.
Definition audio.h:53
@ BJ_AUDIO_FORMAT_INT16
16-bit signed integer PCM.
Definition audio.h:54
Declare a backend and its constructor function.
Definition audio.h:347
Represent an audio backend (ALSA, MME, etc).
Definition audio.h:290
Describe properties of an audio device.
Definition audio.h:106
#define BANJO_EXPORT
Definition api.h:139
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:276
Error structure.
Definition error.h:131
Define parameters for generating simple waveforms.
Definition audio.h:252
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:256
@ BJ_AUDIO_PLAY_SQUARE
Generate a square wave.
Definition audio.h:255
@ BJ_AUDIO_PLAY_SINE
Generate a sine wave.
Definition audio.h:254
@ BJ_AUDIO_PLAY_SAWTOOTH
Generate a sawtooth wave.
Definition audio.h:257
double frequency
Frequency of the waveform (Hz).
Definition audio.h:259
double phase
Internal phase accumulator.
Definition audio.h:260