summaryrefslogtreecommitdiffstats
path: root/include/xas
diff options
context:
space:
mode:
authorXANTRONIX Development2022-02-27 23:20:12 -0500
committerXANTRONIX Development2022-02-27 23:20:12 -0500
commit79d6c75a1324073488a2e34db36ce0afb203537c (patch)
treeb93a05532a2f26cb29df48baf93b8eb4aa125436 /include/xas
parent445050f6ad1603bbd778f29be7b5503c2a455873 (diff)
downloadxas-79d6c75a1324073488a2e34db36ce0afb203537c.tar.gz
xas-79d6c75a1324073488a2e34db36ce0afb203537c.tar.bz2
xas-79d6c75a1324073488a2e34db36ce0afb203537c.zip
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
Diffstat (limited to 'include/xas')
-rw-r--r--include/xas/bank.h11
-rw-r--r--include/xas/object.h19
-rw-r--r--include/xas/synth.h3
-rw-r--r--include/xas/vox.h7
4 files changed, 35 insertions, 5 deletions
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 <sys/types.h>
+#include <xas/object.h>
#include <xas/audio.h>
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 <stdint.h>
#include <sys/types.h>
+#include <xas/object.h>
#include <xas/audio.h>
#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 <stdarg.h>
#include <sys/types.h>
+#include <xas/object.h>
#include <xas/audio.h>
#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, ...);