Self build Midi Controller

Self build Midi Controller

Hi Guys,

I’m about building a Midicontroller. I programmed my AVR to send Midinotes. But I’m still wondering how to programm the microcontroller to send a Midinote by pressing a button a send one if I release it, such as a Cue - Button.

What AVR/mcu are you using?

How many buttons do you want?

How are they connected (matrix/direct/through a shift register)?

Hi Necro. Iam using a Atmega8 but I’m planing to use a 32, because I want to use the A&H 4 way eq, and the Atmega32 has 8 ADC’s for my potentiometers.
I would love all the buttons that are used in tractor, connected to the controller. Also the rotary controlls.

But for the first time, it would be nice to use the 4 way eq.

MidiFighter use Atmel and it’s open source. The source code is also really well documented. That should be more than enough to keep yourself busy for few hours :wink:

I don’t know where to find it :disappointed:

Yep… the MF source is AMAZINGLY well commented… I’ve hacked it apart for one of my own projects that incorporates a custom MF layout… The only thing is that it uses quite a bit of bitmath (and’s/or’s/not’s/xor’s etc), so it can be a little tough to understand if you arent well versed in boolean logic :slight_smile:

You won’t be able to replicate all the buttons in traktor with only an atmega8 (or even a 32). As there aren’t enough inputs. There are many ways of multiplexing button inputs, shift registers (cd4021be) and matrices are the most common.

Feel free to post your ongoing questions, there’s plenty of hardcore mod’ers and hackers around here to help :slight_smile:

Here ya go!

Download the zip file, not the compiled hex file…

Hi Necro,

I’ve already simulated the play button via switch and the high eq via poti. I’ve problems with my cue button. I would like to use a 1 µC for the eq, one for the FX and so on…

I also get problems with the sourcecode: I don’t know C.

what do you mean? electrically there is no difference between a play or a cue button… they’re both just buttons..

The difference comes inside traktor (or whatever midi software you’re using)…

Could you post a schematic (even if crudely drawn)? What exactly is or is not happening?

My edit to your edit: You should be able to get away with a single mcu for the whole thing… I am running a 30+ controls off a single atmega328 (that includes midi thru for 2 other controllers)

When I hit the Play button, it toggles the value. When I hit the cue button, it toggles then value also. Cue stays highlighted until i press the button again.

inside traktor, change the ‘Interaction Mode’ to Hold, not toggle.

I tried, but it didn’t work. May be the midi note ist the wrong one, which i send via the Atmel. I’m sending Ch3 CC70.

Btw.: How do you use more than 8 Potis at the µC. It only contains 8 adcs.

You should be sending note-on and note-off midi messages for buttons, and CC’s for pots and faders..

Through the use of multiplexer ic’s! Do a search for CD4051 and its variants.

Let me sum up:

If i press the button (and holding it), I should send a 0x90 00 7F. And if I release the button, I should send a 0x80 00 7F?

I’m sorry asking such silly questions, but I am a beginner in terms of midi :disappointed:

I am not used to sending direct midi messages.. I am using a midi library which makes it simple: midi.sendNoteOn(channel, note, velocity); midi.sendControlChange(channel, CC, value); etc…

A small excerpt of my code is below:

void midiStreamNote(const uint8_t pitch, const bool onoff) {
#ifdef DEBUG
uint8_t command = ((onoff)? 0x90 : 0x80);
Serial.print("cmd:");Serial.print(command >> 4,HEX);   // command type 0..15
Serial.print(" ch:");Serial.print((MIDI_CHANNEL & 0x0f),DEC);  // channel 0..15
Serial.print(" note:");Serial.print(pitch & 0x7f,DEC);   // note 0..127
Serial.print(" vel:");Serial.println(MIDI_VELOCITY,HEX); // velocity 0..127
#else
if (onoff) {
midi.sendNoteOn(MIDI_CHANNEL, pitch & 0x7f, 0x7f);
} else {
midi.sendNoteOff(MIDI_CHANNEL, pitch & 0x7f, 0x7f);
}
#endif
}

void midiStreamCC(const uint8_t cc, const uint8_t val) {
#ifdef DEBUG
Serial.print("cmd:");Serial.print(cc,DEC);   // command type 0..15
Serial.print(" ch:");Serial.print(MIDI_CHANNEL,DEC);  // channel 0..15
Serial.print(" val:");Serial.print(val & 0x7f,DEC);   // note 0..127
Serial.print(" vel:");Serial.println(MIDI_VELOCITY,DEC); // velocity 0..127
#else
midi.sendControlChange(MIDI_CHANNEL, cc, val);
#endif
}

Midi Library: http://timothytwillman.com/itp_blog/?page_id=240

Hi,

i figuered it out. It works fine by pressing the button sending note on, releasing sends note off. C is a language i don’t understand, I write my software in Bascom, cause I grew up with Basic.

Thanks any way, you saved my day :wink:

Glad I could help :slight_smile:

I can certainly say that I’ve never heard of Bascom… but the thought of using a basic like language for avr programming is kind of neat… Please tell me they don’t have GOTO :wink:

Of course Bascom has GOTO, also Gosub, … :wink: All of the happy Basic stuff. Now I have to figure out, how can I mux the Potis.

With using basic? I have no clue… are you able to do your own serial comms? most multiplexers use spi or in some cases i2c.. The 4051 should work for you.. set its 3 input select pins to select which input to read, then read the analog value from a single analog input… Here’s the code I’m using… it is C, and it’s using plenty of bitmath to be warned :wink:

for(int i = 0; i < NUM_POTS; i++) {
PORTD = (NUM_POTS > 8 && i >= 8) ? (i % 8) << 2 : i << 2; // set pins 2, 3 and 4 to value between 0 (00000) and 7 (11100) to select the pot
if (i > 0 && (i % 8 == 0)) chipSelect++; // increase chip select index every 8 pots
potValues[i] = analogRead(potReadPins[chipSelect]);
if (abs(potValues[i] - prevPotValues[i]) > SMOOTHING) {
prevPotValues[i] = potValues[i];
midiStreamCC(i, map(potValues[i],5,1020,0,127));
}
}

OMG, C is so cryptic. I got special SPI and I2C commands in bascom, for e.g.:

SPI:
portb.7 = SCL
portb.6 = MISO
portb.5= MOSI
portb.4 = SS
spiout = 11010010
i2c:
I2cstart
I2cwbyte &H40
I2cwbyte &HAA
I2cstop

I will try it as soon as possible. I got to buy some more potis and the other stuff like a 4051. Thanks anyway.