Self build Midi Controller

Home :: Reviews of DJ equipment :: Self build Midi ControllerReply
Self build Midi Controller
Posted on: 27.03.2011 by Thea Speigle
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.
Louisa Oberc
27.03.2011
Originally Posted by DANrulz81
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.
You should be sending note-on and note-off midi messages for buttons, and CC's for pots and faders..

Originally Posted by DANrulz81
Btw.: How do you use more than 8 Potis at the
Thea Speigle
27.03.2011
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
Shay Wyche
28.03.2011
Originally Posted by ToOntown
WWWWWWWWWWHHHHHHHHHOOOOOOOOOOOOOOOOOOOOSSSSSSSSSSS SHHHHHHHHHHHHHHHHHH

(that's the sound of this thread flying over my head)
So far above my head, I couldn't hear the rumble from it's sonic boom.
Louisa Oberc
27.03.2011
Originally Posted by DANrulz81
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.
You should be sending note-on and note-off midi messages for buttons, and CC's for pots and faders..

Originally Posted by DANrulz81
Btw.: How do you use more than 8 Potis at the
Thea Speigle
27.03.2011
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
Louisa Oberc
30.03.2011
Yep, I have my transport controller rigged with two beat lights and 11 leds to show the crossfader position (i'm not currently using it because the end of my midi chain doesn't have midi-in..

I've also done some work with these, things like using them as vu's or more recently pulsing beat lights using PWM...
Thea Speigle
30.03.2011
O.k. Thanks. I just have to buy an encoder and figure it out myself. Just one question: Do you use midi out to your controller to set for e.g. a LED, when play ist pressed?
Louisa Oberc
28.03.2011
Yep, I have two in my current controller, though one has been removed so I can beta test these: http://www.djranking s.com/community /showthread.php?t=25088

They're fairly simple to work with...

Again, this is C, not bascom... but the idea is the same...

Code:
byte read_two_encoders() {
  int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  static uint8_t old_AB1, old_AB2 = 0;
  byte rtn = 0;

  old_AB1 <<= 2; //remember previous state
  old_AB1 |= (ENC_PORT & 0b11); //add current state
  old_AB2 <<= 2; //remember previous state
  old_AB2 |= (ENC_PORT & 0b1100) >> 2; //add current state
  rtn |= (enc_states[(old_AB1 & 0b1111)]) & 0b11;
  return rtn | ((enc_states[(old_AB2 & 0b1111)]) & 0b11) << 2;
}
Shay Wyche
28.03.2011
Originally Posted by ToOntown
WWWWWWWWWWHHHHHHHHHOOOOOOOOOOOOOOOOOOOOSSSSSSSSSSS SHHHHHHHHHHHHHHHHHH

(that's the sound of this thread flying over my head)
So far above my head, I couldn't hear the rumble from it's sonic boom.
Thea Speigle
28.03.2011
Btw.: Did you ever used a rotary encoder for midi controlling?
Shonda Soulier
28.03.2011
WWWWWWWWWWHHHHHHHHHOOOOOOOOOOOOOOOOOOOOSSSSSSSSSSS SHHHHHHHHHHHHHHHHHH

(that's the sound of this thread flying over my head)
Louisa Oberc
28.03.2011
Heh, the 'cryptic' nature of that code is mostly due to the direct port manipulation... it's faster and more efficient than using digitalWrite(). and based on your code example, its actually exactly the same... I'm using the shortform of an if statement to safe some lines... it would normally look somthing similar to PORTD = 0b11101010, etc...
Thea Speigle
28.03.2011
OMG, C is so cryptic. I got special SPI and I2C commands in bascom, for e.g.:
Code:
SPI:
portb.7 = SCL
portb.6 = MISO
portb.5= MOSI
portb.4 = SS
spiout = 11010010
Code:
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.
Louisa Oberc
27.03.2011
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

Code:
 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));
    }
  }
Thea Speigle
27.03.2011
Of course Bascom has GOTO, also Gosub, ... All of the happy Basic stuff. Now I have to figure out, how can I mux the Potis.
Louisa Oberc
27.03.2011
Glad I could help

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
Thea Speigle
27.03.2011
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
Louisa Oberc
27.03.2011
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:

Code:
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
Thea Speigle
27.03.2011
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
Louisa Oberc
27.03.2011
Originally Posted by DANrulz81
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.
You should be sending note-on and note-off midi messages for buttons, and CC's for pots and faders..

Originally Posted by DANrulz81
Btw.: How do you use more than 8 Potis at the
Thea Speigle
27.03.2011
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
Louisa Oberc
27.03.2011
inside traktor, change the 'Interaction Mode' to Hold, not toggle.
Thea Speigle
27.03.2011
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.
Louisa Oberc
27.03.2011
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)
Thea Speigle
27.03.2011
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
Louisa Oberc
27.03.2011
Originally Posted by DANrulz81
I don't know where to find it
Here ya go!

http://sourceforge.net/projects/midi...hter-20110204/

Download the zip file, not the compiled hex file...
Louisa Oberc
27.03.2011
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

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
Thea Speigle
27.03.2011
I don't know where to find it
Lisa Lochotzki
27.03.2011
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
Thea Speigle
27.03.2011
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.
Louisa Oberc
27.03.2011
What AVR/mcu are you using?

How many buttons do you want?

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

<< Back to Reviews of DJ equipment Reply

Copyright 2012-2023
DJRANKINGS.ORG n.g.o.
Chuo-ku, Osaka, Japan

Created by Ajaxel CMS

Terms & Privacy