igorski / MWEngine

Audio engine and DSP library for Android, written in C++ providing low latency performance within a musical context, while providing a Java/Kotlin API. Supports both OpenSL and AAudio.
MIT License
264 stars 45 forks source link

setTempo creates invalid boundaries if loop is not starting at buffer position 0 #51

Closed harthorst closed 6 years ago

harthorst commented 6 years ago

if a loop is running from start > 0 to end > start (set by setLoopRange()) and setTempo() is called I observed: 1) buffer positions of audio events are scaled according to ratio (oldTempo/newTempo) 2) min_buffer_position stays untouched (but should be scaled too?) 3) max_buffer_position is samples_per_bar amount_of_bars bout should be min_buffer_position + samples_per_bar amount_of_bars

Maybe I'm not using it correctly. But changing handleTempoUpdate() to: float ratio = tempo / aQueuedTempo; .... min_buffer_position = min_buffer_position ratio; max_buffer_position = ( min_buffer_position + samples_per_bar amount_of_bars ) - 1;

Helped me.

igorski commented 6 years ago

That's a great find, took your code and implemented it in https://github.com/igorski/MWEngine/pull/52

harthorst commented 6 years ago

Thanks. I forgot to mention that you have to scale the notification marker as well.