From 52f09d772858d13cb5e030fb757f623ad93c418e Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 13 Dec 2024 12:59:33 +0100 Subject: [PATCH] sust: rename buffer --- sust.c | 9 ++++++++- sust.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sust.c b/sust.c index c836b2a..d684930 100644 --- a/sust.c +++ b/sust.c @@ -11,7 +11,7 @@ void sust_init( struct sust * sust ) { sust->start_idx = 0; sust->idx = 0; - sust->buf_len = 12800; + sust->buf_len = 51200; sust->record_buf = malloc( sizeof(float) * sust->buf_len ); sust->play_buf = malloc( sizeof(float) * sust->buf_len ); } @@ -30,6 +30,13 @@ float softcos( float x ) { return sin( x * (3.141 / 2.0) ); } +void sust_resize( struct sust * sust, size_t new_len ) { + sust->buf_len = new_len; + sust->play_buf = realloc( sust->play_buf, sizeof(float) * new_len ); + sust->record_buf = realloc( sust->record_buf, sizeof(float) * new_len ); + sust->idx %= new_len; +} + void sust_swap( struct sust * sust ) { diff --git a/sust.h b/sust.h index 23c6f67..92bece8 100644 --- a/sust.h +++ b/sust.h @@ -21,6 +21,7 @@ struct sust { void sust_init( struct sust * sust ); +void sust_resize( struct sust * sust, size_t new_len ); void sust_swap( struct sust * sust ); void sust_process(