107static void*
setup(
struct bj_app* app,
void* init_data) {
118 data.function = BJ_AUDIO_PLAY_SINE;
129 .sample_rate = 44100,
150 static const double melody[] = {
151 261.63, 293.66, 329.63,
152 349.23, 392.00, 349.23,
153 329.63, 293.66, 261.63
155 enum { MELODY_LEN = 9 };
160 if (note >= MELODY_LEN) {
167 data.frequency = melody[note];
170static void teardown(
struct bj_app* app,
void* user_data) {
177int main(
int argc,
char* argv[]) {
178 (void)argc; (void)argv;
General-purpose definitions for Banjo API.
Application lifecycle: callback-driven setup, step, and teardown.
Basic audio library interface.
int main(int argc, char *argv[])
static void step(struct bj_app *app, struct bj_tick_info tick, void *user_data)
bj_audio_device * p_device
static void teardown(struct bj_app *app, void *user_data)
bj_audio_play_note_data data
static void * setup(struct bj_app *app, void *init_data)
int bj_run_app(bj_app_setup_fn setup, bj_app_step_fn step, bj_app_fixed_step_fn fixed_step, bj_app_teardown_fn teardown, void *init_data)
Drive the application lifecycle.
void bj_quit_app(struct bj_app *app, int exit_code)
Signal the given application to exit on the next iteration.
Timing snapshot handed to the step and fixed-step callbacks.
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.
void bj_close_audio_device(struct bj_audio_device *device)
Close an audio device and release all associated resources.
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.
Describe properties of an audio device.
struct bj_audio_device bj_audio_device
bj_bool bj_begin(int systems, struct bj_error **error)
Initialises the system.
void bj_end(void)
De-initialises the system.
double bj_run_time(void)
Gets the current time in seconds since Banjo initialisation.
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
Define parameters for generating simple waveforms.
Header file for system interactions.
Header file for time manipulation utilities.