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
257 stars 45 forks source link

Issues with event.addToSequencer() while the sequencer is running #161

Open vustav opened 2 years ago

vustav commented 2 years ago

In my app I'm having a classic sequencer UI where clicking a cell adds or removes an event to be played at that position by calling event.addToSequencer(). I've noticed that clicking these too fast while the sequencer is running causes bugs. For instance if a step is on and I double click it (turn off then immediatelly turn it on again) it won't play. After playing around with a timer in the method that handles this it seems that a pause of around 1,4 seconds is required for this to work properly. I'm certain event.addToSequencer() is being called properly and this happens while the sequencer is running, paused it works as expected.

vustav commented 2 years ago

I've gotten around this by adding the events to the sequencer on creation and the never remove them, just enable/disable. Is this how it's supposed to be handled?

igorski commented 2 years ago

Hm, no that seems properly broken 🙈

I think what is going is that the events are not added to the currently running sub-sequence cache (explaining why your experiment with the timeout seemed to work). I'll have a look.

(If you are testing with (Base)SynthEvents, it may be possible that the bug you highlighted in issue #146 may be the culprit)

vustav commented 2 years ago

The problem is still there with the latest build.

igorski commented 1 year ago

Would you have some (pseudo) code relating to all operations you do with an event when you both add and remove them when clicking on the cell pads ? I can't quite reproduce and am wondering whether the sequence of things might be an issue (I'm curious whether you also set the event position prior/after addition to the sequencer or something related).

vustav commented 1 year ago

If the event is off when clicked, event.addToSequencer() is called, and the other way around. Logs show them to be called in the right order at the right time etc.