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

Pattern editor (part 3)

jason | 07 January, 2011 23:40

Today was a bit more work on the pattern editor, but also on the rotary encoder (again!). I started by adding a pop-up menu if you had pressed the rotary encoder when you hadn't highlighted the line position, and I found that I needed to redraw the back of the lines, as I hadn't done that before.

However, I found that this new rotary encoder had a large amount of bounce in it when you pressed it. Large enough for my 763Hz filter to occasionally pick up two switch presses. So I needed to add in a digital filter into it to eliminate bounce.

Luckily, one of the Verilog designs I had tried to fix the rotary encoder (before I reverted it back to my own design) had an example of a fairly simple digital filter, and while it wasn't exactly what I needed, it did form the basis. It's actually fairly obvious.

reg [3:0] filtered_key;
always @(posedge clk)
  filtered_key = {filtered_key[2:0], key};
wire filtered_value;
assign filtered_value = (filtered_key == 4'b1111);

This means that the signal filtered_value will only be a 1 if the previous 4 values were 1. I added this to the 763Hz counter, and that solved the bounce.

And then it was back to the pattern editor.

After adding the code in to display the pattern values, I added in the code to allow the rotary encoder to set the values. This is what it looks like when you've changed all four effects, have put a note and a sample in, and the brought up the menu:

Pattern editor 3

The menu may change later on, but you'll be able to enable the automatic stepping if you press a MIDI key down, whether the sample value is stored or not (if it isn't, the previous sample is used), a MIDI key which is used to scroll up and down (so you don't need to use the rotary encoder all the time) - although I may look at some of the control codes. Maybe even the pitch bend wheel could be used for this...

And I decided that this menu should appear even if you had the line number as the currently selected field - which is why there's an "End edit" menu option. This might be moved to the top.

The "Clear field" option will be used to clear the current note, or disable the effect that's in place. (Note than an effect of 00, and data byte 00 is a null effect).

The last linker output for today was:

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

section                    address   length (PC units)   length (bytes) (dec)
-------                    -------   -----------------   --------------------
.text                        0x200              0x1200          0x1b00  (6912)
.const                      0x1400              0x2522          0x37b3  (14259)
.text                       0x3922              0xa5c8          0xf8ac  (63660)
.dinit                      0xdeea               0x1d2           0x2bb  (699)
.text                       0xe0bc               0xccc          0x1332  (4914)
.isr                        0xed88                 0x2             0x3  (3)

                     Total program memory used (bytes):        0x1614f  (90447) 34%

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

section                    address      alignment gaps    total length  (dec)
-------                    -------      --------------    -------------------
.nbss                        0x800                   0           0x9ea  (2538)
.ndata                      0x11ea                   0             0x2  (2)
_03604ee04d23a5fe           0x11ec                   0           0x200  (512)
_036070704d23a5fe           0x13ec                   0           0x200  (512)
.nbss                       0x15ec                   0           0x190  (400)
.ndata                      0x177c                   0            0x86  (134)
.nbss                       0x1802                   0            0xb6  (182)
.ndata                      0x18b8                   0            0x2a  (42)
.nbss                       0x18e2                   0             0xe  (14)
.ndata                      0x18f0                   0             0x8  (8)
.nbss                       0x18f8                   0            0x1a  (26)
.ndata                      0x1912                   0             0x2  (2)
.nbss                       0x1914                   0             0x4  (4)
.ndata                      0x1918                   0             0x4  (4)
.data                       0x191c                   0            0xbc  (188)
.dconst                     0x19d8                   0             0x8  (8)
.data                       0x19e0                   0             0x6  (6)
.bss                        0x19e6                   0             0x4  (4)
.data                       0x19ea                   0             0x2  (2)
.heap                       0x19ec                   0          0x2000  (8192)

                        Total data memory used (bytes):         0x31ec  (12780) 41%

Dynamic Memory Usage

region                     address                      maximum length  (dec)
------                     -------                      ---------------------
heap                        0x19ec                              0x2000  (8192)
stack                       0x39ec                              0x4614  (17940)

                        Maximum dynamic memory (bytes):         0x6614  (26132)
Powered by LifeType - Design by BalearWeb and Jason Tribbeck
Copyright © 2010 | | Jason Tribbeck
All trademarks are the property of their respective owners