Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
audio.h File Reference

Basic audio library interface.

#include <banjo/error.h>
#include <banjo/api.h>
Include dependency graph for audio.h:

Go to the source code of this file.

Data Structures

struct  bj_audio_properties_t
 Describe properties of an audio device. More...
 
struct  bj_audio_play_note_data_t
 Define parameters for generating simple waveforms. More...
 
struct  bj_audio_layer_t
 Represent an audio backend (ALSA, MME, etc). More...
 
struct  bj_audio_layer_create_info
 Declare a backend and its constructor function. More...
 

Macros

#define BJ_AUDIO_FORMAT_WIDTH(x)
 
#define BJ_AUDIO_FORMAT_FLOAT(x)
 
#define BJ_AUDIO_FORMAT_INT(x)
 
#define BJ_AUDIO_FORMAT_BIG_ENDIAN(x)
 
#define BJ_AUDIO_FORMAT_SIGNED(x)
 

Typedefs

typedef struct bj_audio_device_t bj_audio_device
 Opaque handle to an audio device instance.
 
typedef enum bj_audio_format_t bj_audio_format
 Describes how and audio device encodes sound samples.
 
typedef struct bj_audio_properties_t bj_audio_properties
 Describe properties of an audio device.
 
typedef 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.
 
typedef struct bj_audio_play_note_data_t bj_audio_play_note_data
 Define parameters for generating simple waveforms.
 
typedef struct bj_audio_layer_t bj_audio_layer
 Represent an audio backend (ALSA, MME, etc).
 

Enumerations

enum  bj_audio_format_t { BJ_AUDIO_FORMAT_UNKNOWN = 0x0000 , BJ_AUDIO_FORMAT_INT16 = 0x8010 , BJ_AUDIO_FORMAT_F32 = 0x8120 }
 Describes how and audio device encodes sound samples. More...
 

Functions

bj_audio_devicebj_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.
 
void bj_close_audio_device (bj_audio_device *p_device)
 Close an audio device and release all associated resources.
 
void bj_audio_device_play (bj_audio_device *p_device)
 Resume audio playback.
 
void bj_audio_device_pause (bj_audio_device *p_device)
 Pause audio playback.
 
void bj_audio_device_reset (bj_audio_device *p_device)
 Reset the playback stream sample index to 0.
 
void bj_audio_device_stop (bj_audio_device *p_device)
 Stop playback and reset the sample stream.
 
bj_bool bj_audio_device_is_playing (const bj_audio_device *p_device)
 Query whether the device is currently playing audio.
 
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.