I added some new stuff in the sequencer.

I sold the doepfer midi/cv for others projets, it was rarely used and the midi_seq having midi in its tittle could do the job as well. it is just about messing around in the firmware to allow this new feature to exist.

The DAC is now 12bit resolution (MCP4822). A bit better ( I needed the 8bit dac for other purposes anyway)

I also found out that I rarely use that sequencer. It is still too much of a regular sequencer and a bit of a pain to set up with all those wires.(I don’t have a proper space for my modular/music thing). Besides, other modular nerds would certainly agree that it’s better to have everything in the case. So, I’m curently in the process of adding some other, more weird, fonctions to it.

I was reading a website about the transposition of nature to coding (The nature of code) and I had an idea.

I put a new clocking sequencing. The random clocking. Inspired a bit by the idea of random walk, although I’ve only kept the basic idea and haven’t read much about the process.

Basically, the fonction increments a Linear Feedback shift register (yes again, sorry if you read this blog quite often and start to be annoyed by that thing being mentioned almost all the time, but the fact is, this concept is fascinating !) and decides upon the last bit if the index (into the sequence) move up or down. The length of register is settable from 3 to 16 (or even 32 if you wish so but it might take a bit of time to move all those bits around. For those low 8bit uC, the data bus is only 8bit wide)

I’ll show what I used to allow the modification of the register. Could be useful to someone else.

this is the proper incrementing fonction. This idea is to keep the tap number into array that a fonction modifies for a particular bit_length.

uint8_t incr_lfsr0(void)
    if( lfsr0_length == L_4BIT   ||
        lfsr0_length == L_5BIT   || 
        lfsr0_length == L_6BIT   ||   
        lfsr0_length == L_7BIT   ||   
        lfsr0_length == L_9BIT   ||   
        lfsr0_length == L_10BIT  ||    
        lfsr0_length == L_11BIT  ||     
        lfsr0_length == L_15BIT)  
            xor_bit = ((lfsr0 >> 0) ^ (lfsr0 >> lfsr0_taps[0])) & 1;
            lfsr0  =  (lfsr0 >> 1) | (xor_bit << lfsr0_taps[3]); 
        xor_bit = ((lfsr0 >> 0) ^ (lfsr0 >> lfsr0_taps[0]) ^ (lfsr0 >> lfsr0_taps[1]) ^ (lfsr0 >> lfsr0_taps[2])) & 1;   
        lfsr0  =  (lfsr0 >> 1) | (xor_bit << lfsr0_taps[3]);  
            return lfsr0 & 1; 
void newlfsr_config(uint8_t val)
/* it seems that this all crap can be substitued with pointers/dereference which makes the code and the program more compact and elegant. Of course, you need
some additional pointer variables. 

        case 0:
        lfsr0_length = L_4BIT;
        lfsr0_taps[3] = 3;
        lfsr0_taps[0] = 1;
        case 1:
        lfsr0_length = L_5BIT;
        lfsr0_taps[3] = 4; 
        lfsr0_taps[0] = 2;
        case 2:
        lfsr0_length = L_6BIT;
        lfsr0_taps[3] = 5; 
        lfsr0_taps[0] = 1;
        case 3:
        lfsr0_length = L_7BIT;
        lfsr0_taps[3] = 6;
        lfsr0_taps[0] = 1; 

maybe not the prettiest way to do it, but it works.

void walking_direction(void)
uint8_t a = incr_lfsr0();
if(a)     seq_out_index++;
else     seq_out_index--;
if(seq_out_index == 255) seq_out_index = 0; //oveflow?
if(seq_out_index >= max_steps) seq_out_index = max_steps;

It turns out that it works nicely and create interesting patterns. Having different bit length give nice variations too. One could even imagine a gate input to change the bit_length of the LFSR and add even more “live” variations. 
The idea of the random walk could be expand even further. Imagine an array containing note data organised according to musical scales (pentatonic, major, minor ect…) where the random walker (texas ranger) would randomly walk in and output the note he is on. Could be nice.

the driver code for the MCP4822:

void send_to_DAC(uint8_t chan, uint16_t data)
PORT_SPI &=~(1<<SS_PIN); //Chip select pin
uint8_t first_byte = (chan << 7) | (1 << 4) | (data>>8);
uint8_t second_byte = data & 0x00ff;
PORT_SPI |= (1<<SS_PIN);


Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s