summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXANTRONIX Development2022-02-03 21:55:39 -0500
committerXANTRONIX Development2022-02-03 21:55:39 -0500
commit33251842264db1e8c35d8eeedd7a571652348bcd (patch)
treed92ed853e3072dc2f508a6cba511662089a48a6e /src
parente342eb1c2e0c75183491e36f14e36bc44faa60d0 (diff)
downloadxas-33251842264db1e8c35d8eeedd7a571652348bcd.tar.gz
xas-33251842264db1e8c35d8eeedd7a571652348bcd.tar.bz2
xas-33251842264db1e8c35d8eeedd7a571652348bcd.zip
don't forget to adjust gain on sample playback
Diffstat (limited to 'src')
-rw-r--r--src/bank.c14
1 files changed, 9 insertions, 5 deletions
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; i<amount; i++) {
+ dest[index_o + i] = bank->force * 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);