63#define BJ_AUDIO_FORMAT_WIDTH(x) ((x) & (0xFFu))
71#define BJ_AUDIO_FORMAT_FLOAT(x) ((x) & (1u<<8))
79#define BJ_AUDIO_FORMAT_INT(x) (!((x) & (1u<<8)))
87#define BJ_AUDIO_FORMAT_BIG_ENDIAN(x) ((x) & (1u<<12))
95#define BJ_AUDIO_FORMAT_SIGNED(x) ((x) & (1u<<15))
132 uint64_t base_sample_index
156 void* callback_user_data,
281 uint64_t base_sample_index
General-purpose definitions for Banjo API.
Recoverable error handling.
int16_t amplitude
Maximum amplitude of the output samples.
Definition audio.h:107
enum bj_audio_format format
Sampling format.
Definition audio.h:106
unsigned int sample_rate
Number of samples per second (Hz).
Definition audio.h:109
unsigned int channels
Number of channels (currently always 1).
Definition audio.h:108
void bj_play_audio_note(void *buffer, unsigned frames, const struct bj_audio_properties *audio, void *user_data, uint64_t base_sample_index)
Generate a basic waveform tone using a built-in callback.
bj_bool bj_audio_playing(const struct bj_audio_device *device)
Query whether the device is currently playing audio.
bj_audio_format
Audio sample format descriptor.
Definition audio.h:51
void bj_reset_audio_device(struct bj_audio_device *device)
Reset the playback stream sample index to 0.
void bj_pause_audio_device(struct bj_audio_device *device)
Pause audio playback.
void bj_close_audio_device(struct bj_audio_device *device)
Close an audio device and release all associated resources.
void bj_stop_audio_device(struct bj_audio_device *device)
Stop playback and reset the sample stream.
void(* bj_audio_callback_fn)(void *buffer, unsigned frames, const struct bj_audio_properties *audio, void *user_data, uint64_t base_sample_index)
Define a callback for generating audio samples.
Definition audio.h:127
struct bj_audio_device * bj_open_audio_device(const struct bj_audio_properties *properties, bj_audio_callback_fn callback, void *callback_user_data, struct bj_error **error)
Open the default audio device for playback.
void bj_play_audio_device(struct bj_audio_device *device)
Resume audio playback.
@ BJ_AUDIO_FORMAT_F32
32-bit IEEE-754 float PCM.
Definition audio.h:54
@ BJ_AUDIO_FORMAT_UNKNOWN
Unknown/unspecified format.
Definition audio.h:52
@ BJ_AUDIO_FORMAT_INT16
16-bit signed integer PCM.
Definition audio.h:53
Describe properties of an audio device.
Definition audio.h:105
#define BANJO_EXPORT
Definition api.h:155
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:249
struct bj_audio_device bj_audio_device
Definition api.h:328
Error structure.
Definition error.h:131
Define parameters for generating simple waveforms.
Definition audio.h:251
enum bj_audio_play_note_data::@240042340022345302376151237345105167321121277363 function
Type of waveform to generate.
@ BJ_AUDIO_PLAY_SINE
Generate a sine wave.
Definition audio.h:253
@ BJ_AUDIO_PLAY_SQUARE
Generate a square wave.
Definition audio.h:254
@ BJ_AUDIO_PLAY_TRIANGLE
Generate a triangle wave.
Definition audio.h:255
@ BJ_AUDIO_PLAY_SAWTOOTH
Generate a sawtooth wave.
Definition audio.h:256
double frequency
Frequency of the waveform (Hz).
Definition audio.h:258
double phase
Internal phase accumulator.
Definition audio.h:259