SYNTHINGS is a digital synthesizer development platform that I've been building.

Pattern editor (part 4)

jason | 09 January, 2011 22:32

I've combined two days into one, since the first day there wasn't a lot to show for it - I spent most of it refactoring where playing of notes was to be performed in preparation for the tune playroutine.

This meant that the pattern editor didn't get a lot of work done on it, except you could scroll through the pattern and it would play the notes that was in the pattern. Also, I planned what the effects are - based on Desktop Tracker.

The second day was when it started to take a bit more shape.

The first thing I did was get the pattern compression code working: the pattern editor uses an uncompressed format for ease of data manipulation (each line consumes 10 bytes of data). When compressed, each line will take between 0 and 11 bytes of data depending on what the line is doing (I am aware that 11 is more than 10!).

When the pattern is compressed, it is then put into the allocated chunks when you want to store/save the pattern.

When that had been written, I wrote the decompressor - that takes the compressed data and expands it into the more manageable format. This did take a couple of iterations for the compressor/decompressor to work. I think I could get it slightly more compressed, but the code complexity goes up a bit.

I also decided that I wanted to have the RS232 port emulate the user interface - so I don't actually need to touch the device itself. It also allows me to define other operations as well (such as deletion of the current field data directly from the keyboard, rather than having to go through the menu). Scrolling up and down can also be performed without having to select the line as the current editing field.

I may make a device to send these via MIDI (and merge from a MIDI keyboard at the same time).

Then, it was a case of "filling in the blanks" for the menu, and also the current status display. I've not taken screenshots until the end though.

So, here's what the editor looks like:

Pattern editor 4

The bottom of the screen shows the current status. From left to right:

  1. Step mode (if on, pressing a MIDI key automatically scrolls down to the next line)
  2. Sample mode (if on, pressing a MIDI key automatically sets the sample to the current sample)
  3. The current sample

The current sample can be "--" - in which case, it will leave the sample as the previously one played.

The menu has changed too:

Pattern editor 4

I did move the "End edit" option to the top. If you select "Insert row", you get an additional menu:

Pattern editor 4

Likewise, if you select "Delete row", then it'll ask you if you want to decrease the size.

Selecting the "Set sample mode" turns the sample mode on/off. Here it is turned off:

Pattern editor 4

And with step mode:

Pattern editor 4

The last three menu options allow you to select a MIDI note which will perform a scroll up, scroll down or clear the current events. Since SythTracker has a 63-note range, if you have more keys than that, you can select some that will not be playable in SythTracker to perform these functions. I've got a 25-key, a 61-key and an 88-key MIDI keyboard. Currently, I'm only using the 25-key one for testing.

Pattern editor 4 Pattern editor 4

Clearing the current field has a special context if you've currently got the line selected - this clears the entire row. Otherwise, it'll clear the currently selected field (if you have one of the effects fields selected, then both of the relevant effects fields are cleared).

Selecting a sample uses the same dialog as before - except you've got an option to select none:

Pattern editor 4

And this looks like:

Pattern editor 4

The colours are the same as the sample selection dialog, so the none one will be in blue, a sample which has data is in orange, and a sample which has no data is in grey.

I've almost reached the 100K size for the ROM:

Program Memory  [Origin = 0x200, Length = 0x2aa00]

section                    address   length (PC units)   length (bytes) (dec)
-------                    -------   -----------------   --------------------
.text                        0x200              0x136e          0x1d25  (7461)
.const                      0x156e              0x2664          0x3996  (14742)
.text                       0x3bd2              0xb89c         0x114ea  (70890)
.dinit                      0xf46e               0x232           0x34b  (843)
.text                       0xf6a0               0xc32          0x124b  (4683)
.isr                       0x102d2                 0x2             0x3  (3)

                     Total program memory used (bytes):        0x1813e  (98622) 37%

Data Memory  [Origin = 0x800, Length = 0x7800]

section                    address      alignment gaps    total length  (dec)
-------                    -------      --------------    -------------------
.nbss                        0x800                   0           0x9ea  (2538)
.ndata                      0x11ea                   0             0x2  (2)
_035f4ee04d299d91           0x11ec                   0           0x200  (512)
_035f70704d299d91           0x13ec                   0           0x200  (512)
.nbss                       0x15ec                   0           0x314  (788)
.ndata                      0x1900                   0            0x86  (134)
.nbss                       0x1986                   0            0x9e  (158)
.ndata                      0x1a24                   0            0x1c  (28)
.nbss                       0x1a40                   0            0x18  (24)
.ndata                      0x1a58                   0            0x12  (18)
.nbss                       0x1a6a                   0            0x1c  (28)
.ndata                      0x1a86                   0             0x8  (8)
.nbss                       0x1a8e                   0            0x1a  (26)
.ndata                      0x1aa8                   0             0x2  (2)
.nbss                       0x1aaa                   0             0x4  (4)
.ndata                      0x1aae                   0             0x4  (4)
.nbss                       0x1ab2                   0             0x2  (2)
.ndata                      0x1ab4                   0             0x2  (2)
.data                       0x1ab6                   0           0x106  (262)
.dconst                     0x1bbc                   0             0x8  (8)
.data                       0x1bc4                   0             0xa  (10)
.bss                        0x1bce                   0             0x4  (4)
.data                       0x1bd2                   0             0x2  (2)
.heap                       0x1bd4                   0          0x2000  (8192)

                        Total data memory used (bytes):         0x33d4  (13268) 43%

Dynamic Memory Usage

region                     address                      maximum length  (dec)
------                     -------                      ---------------------
heap                        0x1bd4                              0x2000  (8192)
stack                       0x3bd4                              0x442c  (17452)

                        Maximum dynamic memory (bytes):         0x642c  (25644)

Tomorrow, there'll be a little bit of finishing for the pattern editor (the colour editor needs to be done, and I need to make it so when you change the pattern length, it's reflected in the pattern below it).

Powered by LifeType - Design by BalearWeb and Jason Tribbeck
Copyright © 2010 | | Jason Tribbeck
All trademarks are the property of their respective owners