Native Sequencer Progress
It suddenly occured to me that there has not been a blog post in a long time. Work is still going on with the native C++ rewrite of the sequencer engine. As mentioned in the previous post I have been reimplementing the code for playhead movement. This is not as easy as it might seem, and is actually one of the more complex parts of Sputter.
The implementation in the current version actually works quite well, but on the inside it is all spaghetti code.

So I decided to reimplement it, since integrating it with the new sequencer code would be hard (it was after all spaghetti code).
Audio is generated in chunks (called buffers). These can range from quite small, like 64 samples, up to quite large like 2048 samples. When each of these are processed there has been progress in the audio timeline.
A simple solution could be to just report the number of “chunks” to the UI thread as they are processed. The issue with this is if the buffers are quite large, like 2048, their timespan are equal to several videoframes. In other words, a buffer of 2048 takes 42ms to process, and a video frame typically takes 16ms. With the simplest solution the play head would appear choppy, so some interpolation is needed while the next buffer is processed.
Another challenge is to determine when and what events are occuring during the audio processing. Examples of these are tempo changes, pattern positions changes or lengths of groups changing during playback. For example, when the length of a group is increased, the group progress ratio has to be immediately updated to reflect that. I found a solution to that, but then some issue occured when adding a new group to the sequence:
As you can see, when adding another group the group progress indicator gets messed up when in the second position.
As of now playhead movement is probably 90% implemented and the most complex issues are solved. Hopefully the rest of the integration with the new sequencer code will be more straightforward and a matter of “filling in the blanks”.
I will try to keep you all posted here in a more frequent manner going forward, so watch out for further updates!