Skip to content

Commit

Permalink
Merge pull request adafruit#9787 from relic-se/audiofilters_stopfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jepler authored Nov 5, 2024
2 parents 6cb7c82 + 0aab00d commit 3a0b97d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion shared-module/audiodelays/Echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t *
} else {
// For unsigned samples set to the middle which is "quiet"
if (MP_LIKELY(self->bits_per_sample == 16)) {
memset(word_buffer, 32768, length * (self->bits_per_sample / 8));
uint16_t *uword_buffer = (uint16_t *)word_buffer;
while (length--) {
*uword_buffer++ = 32768;
}
} else {
memset(hword_buffer, 128, length * (self->bits_per_sample / 8));
}
Expand Down
20 changes: 18 additions & 2 deletions shared-module/audiofilters/Filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,24 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o
}
}

// If we have a sample, filter it
if (self->sample != NULL) {
if (self->sample == NULL) {
if (self->samples_signed) {
memset(word_buffer, 0, length * (self->bits_per_sample / 8));
} else {
// For unsigned samples set to the middle which is "quiet"
if (MP_LIKELY(self->bits_per_sample == 16)) {
uint16_t *uword_buffer = (uint16_t *)word_buffer;
while (length--) {
*uword_buffer++ = 32768;
}
} else {
memset(hword_buffer, 128, length * (self->bits_per_sample / 8));
}
}

length = 0;
} else {
// we have a sample to play and filter
// Determine how many bytes we can process to our buffer, the less of the sample we have left and our buffer remaining
uint32_t n = MIN(self->sample_buffer_length, length);

Expand Down

0 comments on commit 3a0b97d

Please sign in to comment.