summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXANTRONIX Development2022-03-01 09:45:48 -0500
committerXANTRONIX Development2022-03-01 09:47:11 -0500
commit297dd2f36cfc5d4f53ee7a6528e0064d913f8b75 (patch)
treee065d6c1bd1f63915bbbbd3d047c938b487ead1d /src
parent2096356f1d4fb95cd1273018bcbff13c88487f8d (diff)
downloadxas-297dd2f36cfc5d4f53ee7a6528e0064d913f8b75.tar.gz
xas-297dd2f36cfc5d4f53ee7a6528e0064d913f8b75.tar.bz2
xas-297dd2f36cfc5d4f53ee7a6528e0064d913f8b75.zip
Make wrappers for adding new spatial scene objects
Diffstat (limited to 'src')
-rw-r--r--src/spatial.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/spatial.c b/src/spatial.c
index 9631603..7688f07 100644
--- a/src/spatial.c
+++ b/src/spatial.c
@@ -5,6 +5,7 @@
#include <errno.h>
#include <xas/object.h>
+#include <xas/vox.h>
#include <xas/spatial.h>
static inline float dist(xas_spatial_coord a, xas_spatial_coord b) {
@@ -426,6 +427,118 @@ error_invalid_source:
return NULL;
}
+xas_spatial_object *xas_spatial_scene_add_synth(xas_spatial_scene *scene,
+ xas_spatial_coord point,
+ enum xas_synth_type type) {
+ xas_spatial_object *obj;
+ xas_synth *synth;
+ xas_audio_stream *stream;
+
+ if ((synth = xas_synth_new(scene->format,
+ scene->buffer->size,
+ type)) == NULL) {
+ goto error_synth_new;
+ }
+
+ if ((stream = xas_synth_stream_new(synth)) == NULL) {
+ goto error_synth_stream_new;
+ }
+
+ if ((obj = xas_spatial_scene_add_object(scene,
+ point,
+ stream,
+ synth)) == NULL) {
+ goto error_scene_add_object;
+ }
+
+ obj->flags |= XAS_SPATIAL_OBJECT_MANAGED;
+
+ return obj;
+
+error_scene_add_object:
+ xas_audio_stream_destroy(stream);
+
+error_synth_stream_new:
+ xas_synth_destroy(synth);
+
+error_synth_new:
+ return NULL;
+}
+
+xas_spatial_object *xas_spatial_scene_add_bank_player(xas_spatial_scene *scene,
+ xas_spatial_coord point,
+ xas_bank *bank) {
+ xas_spatial_object *obj;
+ xas_bank_player *player;
+ xas_audio_stream *stream;
+
+ if ((player = xas_bank_player_new(bank)) == NULL) {
+ goto error_bank_player_new;
+ }
+
+ if ((stream = xas_bank_player_stream_new(player)) == NULL) {
+ goto error_bank_player_stream_new;
+ }
+
+ if ((obj = xas_spatial_scene_add_object(scene,
+ point,
+ stream,
+ player)) == NULL) {
+ goto error_scene_add_object;
+ }
+
+ obj->flags |= XAS_SPATIAL_OBJECT_MANAGED;
+
+ return obj;
+
+error_scene_add_object:
+ xas_audio_stream_destroy(stream);
+
+error_bank_player_stream_new:
+ xas_bank_player_destroy(player);
+
+error_bank_player_new:
+ return NULL;
+}
+
+xas_spatial_object *xas_spatial_scene_add_vox(xas_spatial_scene *scene,
+ xas_spatial_coord point,
+ const char *text2wave_path) {
+ xas_spatial_object *obj;
+ xas_vox *vox;
+ xas_audio_stream *stream;
+
+ if ((vox = xas_vox_new(scene->format,
+ scene->buffer->size,
+ text2wave_path)) == NULL) {
+ goto error_vox_new;
+ }
+
+ if ((stream = xas_vox_stream_new(vox)) == NULL) {
+ goto error_vox_stream_new;
+ }
+
+ if ((obj = xas_spatial_scene_add_object(scene,
+ point,
+ stream,
+ vox)) == NULL) {
+ goto error_scene_add_object;
+ }
+
+ obj->flags |= XAS_SPATIAL_OBJECT_MANAGED;
+
+ return obj;
+
+error_scene_add_object:
+ xas_audio_stream_destroy(stream);
+
+error_vox_stream_new:
+ xas_vox_destroy(vox);
+
+error_vox_new:
+ return NULL;
+}
+
void xas_spatial_scene_position_object(xas_spatial_scene *scene,
xas_spatial_object *object,
xas_spatial_coord point) {