From b386b20a515e43674b3a233df6256e88fdf31563 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 14 Mar 2022 01:06:51 -0400 Subject: Implement xas_drone_sample_import() Implement xas_drone_sample_import() to import a RIFF WAVE file to a drone's sample bank --- src/drone.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') 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 #include +#include #include +#include #include #include @@ -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, -- cgit v1.2.3