From 33251842264db1e8c35d8eeedd7a571652348bcd Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 3 Feb 2022 21:55:39 -0500 Subject: don't forget to adjust gain on sample playback --- src/bank.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bank.c b/src/bank.c index 6070714..d38822f 100644 --- a/src/bank.c +++ b/src/bank.c @@ -98,7 +98,7 @@ error_audio_stream_read: } static ssize_t stream_fill(xas_bank *bank, - int16_t *samples, + int16_t *dest, size_t count, xas_audio_stream *stream) { size_t index_o = 0, @@ -109,12 +109,16 @@ static ssize_t stream_fill(xas_bank *bank, xas_bank_entry *entry = &((xas_bank_entry *)(bank + 1))[bank->entry]; + int16_t *src = (int16_t *)(entry + 1); + size_t remaining = entry->duration - bank->index, amount = remaining < left? remaining: left; - memcpy(ptr(stream, samples, index_o), - ptr(stream, entry + 1, bank->index), - amount * stream->channels * stream->sample_size); + size_t i; + + for (i=0; iforce * src[bank->index + i]; + } left -= amount; bank->index += amount; @@ -124,7 +128,7 @@ static ssize_t stream_fill(xas_bank *bank, xas_bank_stop(bank); } } else { - memset(ptr(stream, samples, index_o), + memset(ptr(stream, dest, index_o), '\0', left * stream->channels * stream->sample_size); -- cgit v1.2.3