diff options
author | XANTRONIX Development | 2022-03-14 01:06:51 -0400 |
---|---|---|
committer | XANTRONIX Development | 2022-03-14 01:06:51 -0400 |
commit | b386b20a515e43674b3a233df6256e88fdf31563 (patch) | |
tree | 441a7c46ed01ed6ae040825feb559979bf3198e9 | |
parent | 50a89aff9d93192674ed712ffeb7a0eb7107a516 (diff) | |
download | xas-b386b20a515e43674b3a233df6256e88fdf31563.tar.gz xas-b386b20a515e43674b3a233df6256e88fdf31563.tar.bz2 xas-b386b20a515e43674b3a233df6256e88fdf31563.zip |
Implement xas_drone_sample_import()
Implement xas_drone_sample_import() to import a RIFF WAVE file
to a drone's sample bank
-rw-r--r-- | include/xas/drone.h | 5 | ||||
-rw-r--r-- | src/drone.c | 30 |
2 files changed, 35 insertions, 0 deletions
diff --git a/include/xas/drone.h b/include/xas/drone.h index 1af22be..1f329ae 100644 --- a/include/xas/drone.h +++ b/include/xas/drone.h @@ -62,6 +62,11 @@ ssize_t xas_drone_sample_record(xas_drone *drone, size_t sample_index, size_t sample_len); + +ssize_t xas_drone_sample_import(xas_drone *drone, + const char *file, + size_t sample_index); + int xas_drone_speech_import(xas_drone *drone, const char *voice, float speed, diff --git a/src/drone.c b/src/drone.c index 13610fa..188f546 100644 --- a/src/drone.c +++ b/src/drone.c @@ -1,7 +1,9 @@ #include <stdlib.h> #include <string.h> +#include <fcntl.h> #include <errno.h> +#include <xas/riff.h> #include <xas/vox.h> #include <xas/drone.h> @@ -73,6 +75,34 @@ error_invalid: return -1; } +ssize_t xas_drone_sample_import(xas_drone *drone, + const char *path, + size_t sample_index) { + ssize_t ret; + xas_audio_stream *source; + + if ((source = xas_riff_open_file(path, O_RDONLY)) == NULL) { + goto error_riff_open_file; + } + + if ((ret = xas_drone_sample_record(drone, + source, + sample_index, + drone->bank->entry_size)) < 0) { + goto error_sample_record; + } + + xas_audio_stream_destroy(source); + + return ret; + +error_sample_record: + xas_audio_stream_destroy(source); + +error_riff_open_file: + return -1; +} + int xas_drone_speech_import(xas_drone *drone, const char *voice, float speed, |