Close

Going Crazy With Sequence Blocks

A project log for OPL Studio - OPL2 / OPL3 MIDI Synthesizer

The ultimate dual OPL3 MIDI syntesizer with touch screen

maarten-janssenMaarten Janssen 06/02/2021 at 17:260 Comments

A lot of work has been done this week on the Sequence Composer module. The idea is that you can compose loops and simple songs from the drum and melody sequence that you create in the two sequencer modules. To do this you have a grid of 6 tracks where you can place the sequences represented by different color blocks (sequence blocks).

Without having covered the basics of a grid with sequence blocks that you can scroll through I started on the most difficult part for this module. I wanted to be able to drag and drop sequence blocks in my editor! Without thinking it through I started working on dragging a single block. This was already a difficult thing to do and while working on the code I though of more and more edge cases I'd need to cover, such as dragging multiple sequence blocks, making the editor scroll when I drag block over the edge, what happens when two block overlap. it was becoming a real nightmare and after 3 or 4 failed attempts I decided to park it for now and first get the 'easy' part over with.

The easy part would be a scrollable grid filled with sequence blocks that all have the same size. Later sequence blocks can have different lengths due to a sequence taking more bars to play because of its clock divider, but that's not important now. Keeping rendering efficiency into account was still important to do from the start, so I made the grid and sequence blocks in such a way that only the part that will actually change while scrolling is updated. This turned out to be a relatively simple UI task to implement.

The screenshot below shows the result of rendering random sequence blocks in the editor. Each sequence has an identifier D for drum and M for melodic followed by the sequence number. To make them easier to recognice each sequence can be given a unique color and pattern as well.

What is needed next is to link sequence blocks to a sequence. For this quite some refactoring was needed, especially for the drum sequences that were not stored as individual objects yet like the melody sequences. So this has been changed now. Both drum and melody sequences are now objects that inherrit from a common Sequence class. As a bonus this allows me to now play any sequence at any time. Exactly what I need for the editor.

This was quite a big effort and after testing that I didn't break anything it will now be time to link sequences and sequence blocks and make a start on an actually functioning editor!

Discussions