summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXANTRONIX Development2022-02-06 22:08:08 -0500
committerXANTRONIX Development2022-02-06 22:08:08 -0500
commita5c70a6adfaac0088e992caed5db5e3df2744ee0 (patch)
treed2af038404e88ca69a3f7320808749b085bc99d9
parent33251842264db1e8c35d8eeedd7a571652348bcd (diff)
downloadxas-a5c70a6adfaac0088e992caed5db5e3df2744ee0.tar.gz
xas-a5c70a6adfaac0088e992caed5db5e3df2744ee0.tar.bz2
xas-a5c70a6adfaac0088e992caed5db5e3df2744ee0.zip
Aw fuck it
-rw-r--r--examples/say.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/examples/say.c b/examples/say.c
index 23b31a2..19dcb08 100644
--- a/examples/say.c
+++ b/examples/say.c
@@ -11,6 +11,7 @@
#include <xas/riff.h>
#include <xas/synth.h>
#include <xas/vox.h>
+#include <xas/bank.h>
#define SYNTH_STATUS_CLEAR 0
#define SYNTH_STATUS_ON (1 << 0)
@@ -70,13 +71,15 @@ int main(int argc, char **argv) {
xas_mixer *mixer;
- xas_audio_stream *input,
+ xas_bank *bank;
+ xas_vox *vox;
+
+ xas_audio_stream *voice,
+ *bank_stream,
*synth_l,
*synth_r,
*output;
- xas_vox *vox;
-
size_t sample_rate = 44100,
buffer_size = 735,
duration_frames = 3600,
@@ -94,6 +97,13 @@ int main(int argc, char **argv) {
goto error_vox_new;
}
+ if ((bank = xas_bank_new(XAS_AUDIO_PCM_16_BIT,
+ 44100,
+ 2646000,
+ 4)) == NULL) {
+ goto error_bank_new;
+ }
+
if ((output = xas_riff_new_file(argv[1],
XAS_AUDIO_STEREO,
XAS_AUDIO_PCM_16_BIT,
@@ -102,10 +112,14 @@ int main(int argc, char **argv) {
goto error_riff_new_file;
}
- if ((input = xas_vox_stream_new(vox)) == NULL) {
+ if ((voice = xas_vox_stream_new(vox)) == NULL) {
goto error_vox_stream_new;
}
+ if ((bank_stream = xas_bank_stream_new(bank)) == NULL) {
+ goto error_bank_stream_new;
+ }
+
if ((synth_l = xas_synth_new(XAS_AUDIO_PCM_16_BIT,
sample_rate,
buffer_size,
@@ -131,7 +145,7 @@ int main(int argc, char **argv) {
goto error_mixer_new;
}
- if (xas_mixer_input_add(mixer, input, 1.0, 0.0) == NULL) {
+ if (xas_mixer_input_add(mixer, bank_stream, 1.0, 0.0) == NULL) {
goto error_mixer_input_add;
}
@@ -143,14 +157,25 @@ int main(int argc, char **argv) {
goto error_mixer_input_add;
}
+ /*
+ * Time to fill the sample bank, meow!
+ */
xas_vox_say(vox, "I want to eat your soul. You don't understand. I really want to eat your soul.\n");
xas_vox_generate(vox);
+ if (xas_bank_record(bank, voice, 0, 247018) < 0) {
+ goto error_bank_record;
+ }
+
for (i=0; i<duration_frames; i++) {
void *buf;
ssize_t readlen;
+ if (i >= 300 && !xas_bank_active(bank)) {
+ xas_bank_play(bank, 0, 1.0);
+ }
+
if ((readlen = xas_audio_stream_read(mixer->output,
&buf,
buffer_size)) < 0) {
@@ -167,15 +192,18 @@ int main(int argc, char **argv) {
xas_mixer_destroy(mixer);
xas_audio_stream_destroy(synth_r);
xas_audio_stream_destroy(synth_l);
- xas_audio_stream_destroy(input);
+ xas_audio_stream_destroy(bank_stream);
+ xas_audio_stream_destroy(voice);
xas_audio_stream_destroy(output);
+ xas_bank_destroy(bank);
xas_vox_destroy(vox);
return EX_OK;
error_audio_stream_write:
error_audio_stream_read:
+error_bank_record:
error_mixer_input_add:
xas_mixer_destroy(mixer);
@@ -186,12 +214,18 @@ error_synth_new_r:
xas_audio_stream_destroy(synth_l);
error_synth_new_l:
- xas_audio_stream_destroy(input);
+ xas_audio_stream_destroy(bank_stream);
+
+error_bank_stream_new:
+ xas_audio_stream_destroy(voice);
error_vox_stream_new:
xas_audio_stream_destroy(output);
error_riff_new_file:
+ xas_bank_destroy(bank);
+
+error_bank_new:
xas_vox_destroy(vox);
error_vox_new: