From 79d6c75a1324073488a2e34db36ce0afb203537c Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sun, 27 Feb 2022 23:20:12 -0500 Subject: Implement xas_object Changes: * Implement xas_object as a base "class" for all playback state objects; allow implementation of start() and stop() methods to control playback * Move code for setting gain, bank slot to a new method, xas_bank_player_select() * Remove code from xas_bank_player_start() setting gain, bank slot * Add xas_object header to each monaural playable object --- include/xas/bank.h | 11 ++++++++--- include/xas/object.h | 19 +++++++++++++++++++ include/xas/synth.h | 3 +++ include/xas/vox.h | 7 +++++-- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 include/xas/object.h (limited to 'include') diff --git a/include/xas/bank.h b/include/xas/bank.h index 33be492..cd1511e 100644 --- a/include/xas/bank.h +++ b/include/xas/bank.h @@ -3,6 +3,7 @@ #include +#include #include enum xas_bank_player_status { @@ -22,6 +23,8 @@ typedef struct _xas_bank { } xas_bank; typedef struct _xas_bank_player { + xas_object obj; + xas_bank *bank; enum xas_bank_player_status status; @@ -50,9 +53,11 @@ xas_bank_player *xas_bank_player_new(xas_bank *bank); void xas_bank_player_destroy(xas_bank_player *player); -int xas_bank_player_start(xas_bank_player *player, - size_t entry, - float gain); +int xas_bank_player_select(xas_bank_player *player, + size_t entry, + float gain); + +int xas_bank_player_start(xas_bank_player *player); int xas_bank_player_stop(xas_bank_player *player); diff --git a/include/xas/object.h b/include/xas/object.h new file mode 100644 index 0000000..b8b713b --- /dev/null +++ b/include/xas/object.h @@ -0,0 +1,19 @@ +#ifndef _XAS_OBJECT_H +#define _XAS_OBJECT_H + +typedef struct _xas_object xas_object; + +typedef int (*xas_object_start_callback)(xas_object *object); + +typedef int (*xas_object_stop_callback)(xas_object *object); + +struct _xas_object { + xas_object_start_callback start; + xas_object_stop_callback stop; +}; + +int xas_object_start(xas_object *object); + +int xas_object_stop(xas_object *object); + +#endif /* _XAS_OBJECT_H */ diff --git a/include/xas/synth.h b/include/xas/synth.h index 53f3343..61f50bc 100644 --- a/include/xas/synth.h +++ b/include/xas/synth.h @@ -4,6 +4,7 @@ #include #include +#include #include #define XAS_SYNTH_DEFAULT_FREQUENCY 2600 /* Hz */ @@ -25,6 +26,8 @@ typedef struct _xas_synth xas_synth; typedef int16_t (*xas_synth_sample_callback)(xas_synth *synth); struct _xas_synth { + xas_object obj; + enum xas_synth_type type; enum xas_synth_state state; diff --git a/include/xas/vox.h b/include/xas/vox.h index 5a1cacf..9d63bba 100644 --- a/include/xas/vox.h +++ b/include/xas/vox.h @@ -5,6 +5,7 @@ #include #include +#include #include #define XAS_VOX_SETTINGS_TMP_PATH "/tmp/xas-vox.XXXXXX" @@ -16,6 +17,8 @@ enum xas_vox_state { }; typedef struct _xas_vox { + xas_object obj; + xas_audio_format format; size_t buffer_size; @@ -66,12 +69,12 @@ int xas_vox_set_parameter_int(xas_vox *vox, const char *name, int value); +int xas_vox_generate(xas_vox *vox); + int xas_vox_stop(xas_vox *vox); int xas_vox_active(xas_vox *vox); -int xas_vox_generate(xas_vox *vox); - int xas_vox_vsayf(xas_vox *vox, const char *message, va_list args); int xas_vox_sayf(xas_vox *vox, const char *message, ...); -- cgit v1.2.3