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(