16 Step MIDI Drum Machine - Help ?

Guys, I'm working on a 16 Step MIDI Drum-Machine to run on Arduino Uno/Mega/...

I want to use its EEPROM to hold the patterns, so the user can use a Song-Link that plays patterns in order. But the problem is the size of each pattern, and I don't know how to optimize. I was wondering maybe if I could "compress" each pattern before storing, and "uncompress" on reading?

Here's the pattern per say.

unsigned int dmSteps[15];

Its just 14 Tracks + 1 Accent Track (last) - since this is a 16 bit number, each bit is a step On/Off.

I also need to decide how to store the patterns in the EEPROM and how to manage the Song-Mode. (shouldn't be too hard I got an Arduino Mega, which has plenty resources, but I want my first project to run on the Uno too.

Any hints would be mostly appreciated.

Thanks in advance.

Best Regards, WilliamK

But them I could just go ahead and use one of those...

http://10kohms.com/arduino-external-eeprom-24lc256

:-X

Wk

You want the pattern to be 15 channels and every bit is one beat? So all bit0's are beat 0; all bits 1's are beat 1 all bits 2's are beat 2 and so on until 16. It is sort of a matrix, so let me think....

Rotate the matrix 90 degrees so every unsigned int is one beat (or was that the idea in the first place?)

#define NRBEATS 48    // just as example
unsigned int dmSteps[NRBEATS];
...
for (int i=0; i< NRBEATS; i++)
{
  for (int ch = 0; ch < 15; ch++)
  {
    if (bitSet(dmSteps[i], ch)) 
    {
      // SendMIDIchannel ch a beat
    } else {
      // SendMIDIchannel ch a silence (or just delay)
    }
  }
}

This way you just read one int at the time and instead of copying them to an array you could fetch them runtime from EEPROM, one int at the time. Should be fast enough, but keep an eye on your timing...

#define NRBEATS 48    // just as example
...
for (int i=0; i< NRBEATS; i++)
{
  unsigned int x = EEPROM.Read(2*i);
  x << = 8;
  x += EEPROM.Read(2*i + 1);
  for (int ch = 0; ch < 15; ch++)
  {
    if (bitSet(x, ch)) 
    {
      // SendMIDIchannel ch a beat
    } else {
      // SendMIDIchannel ch a silence (or just delay)
    }
  }
}

You might use an unsigned long to go to 32 channels :slight_smile:

Thanks, but things are a bit different. :wink:

First, I changed the specs to 14 channels + 2 accent channels. So we have 16 x 16 - channels x step

Now, I have a buffer for the next pattern to load, so I don't load and play from the EEPROM, I just load and write once and its on the memory, as it takes only 32 bytes to store the whole pattern. :sunglasses:

I ordered the extra SparkFun chips as they are chip, but it would be fun to be able to compress a 32 byte pattern into something smaller, but I doubt I would go much lower, so extra EEPROM is a must indeed.

In any event, thanks anyway.

Wk

Thanks, but things are a bit different.

Could you share the code to show how you did it?

Sure, give me a bit more time, as its almost ready, just missing the extra EEPROM chip I ordered. :wink:

Wk