Go Down

Topic: MIDI cc problems with Midi Library, Hairless MIDI and Ableton Live (Read 5257 times) previous topic - next topic

rogervila

Hello,

I'm creating my own MIDI Controller using the Arduino MIDI library.
I succeed sending notes into Ableton Live, but I have some problems sending MIDI controls.
I want to trigger a loop with a button but there is lag and Ableton Live just starts to go crazy and I have to close it. Maybe should I use another CC number? or another Arduino input?
I selected cc 16 because it's for general purpose (i read it here: http://nickfever.com/402/production-tips-and-resources/midi-cc-list/)

Here is my code:
Code: [Select]
#include <MIDI.h>

//Starting MIDI
MIDI_CREATE_DEFAULT_INSTANCE();

//VARIABLES

//the Led will shine while the button is pressed
int led = 13;

//button1 sends note, button2 sends Control Change
int button1 = 2;
int button2 = 4;

//last button state counter
int lastB1State = 0;
int lastB2State = 0;

//curent button state counter
int currentB1State = 0;
int currentB2State = 0;

//Note 60 = C
int note = 60;

//Control 16 = general purpose
int cc = 16;

//Setup:
void setup(){
 
  //Start midi connection
  MIDI.begin();
 
  //Serial connection 115200 for Hairless MIDI
  Serial.begin(115200);
 
  //input button, output led
  pinMode(led, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
}

//Loop:
void loop(){
 
  //FIRST PART WORKING PERFECT
 
  //BUTTON1 = B1 = piano key
  currentB1State = digitalRead(button1);
 
  if( currentB1State == 1){
   
    if (lastB1State == 0) {
      MIDI.sendNoteOn(note,127,1);
      digitalWrite(led, HIGH);
    }
   
    lastB1State = 1;

  }else{
   
    if(currentB1State == 0){
     
      if (lastB1State == 1) {
        MIDI.sendNoteOff(note,0,1);
        digitalWrite(led, LOW);
      }
     
      lastB1State = 0;
    }
  }
 
  //HERE I HAVE PROBLEMS
 
  //BUTTON2 = B2 = CC
  currentB2State = digitalRead(button2);
 
  if( currentB2State == 1){
   
    if (lastB2State == 0) {
      MIDI.sendControlChange(cc,127,1); //HERE IS WHERE I WANT TO SEND THE CONTROL CHANGE
      digitalWrite(led, HIGH);
    }
   
    lastB2State = 1;

  }else{
   
    if(currentB2State == 0){
     
      if (lastB2State == 1) {
        MIDI.sendControlChange(cc,0,1);
        digitalWrite(led, LOW);
      }
     
      lastB2State = 0;
    }
  }
 
 
 
  //50ms space
  delay(50);
}


Thank you for your help

Grumpy_Mike

Try this:-

Code: [Select]
//BUTTON2 = B2 = CC
  currentB2State = digitalRead(button2);
 
  if( currentB2State == 1 && lastB2State == 0){
      MIDI.sendControlChange(cc,127,1);
      digitalWrite(led, HIGH);
  } 
  if (currentB2State == 0 && lastB2State == 1) {
        MIDI.sendControlChange(cc,0,1);
        digitalWrite(led, LOW);
      }
     
      lastB2State = currentB2State;


rogervila

Thank you very much, now it works with controls like stop tracks, solo, rec, etc... but when I trigger a loop it overflows.
Maybe there are some controls that are better than others? I don't really understand how Midi CC works in Ableton Live.

Grumpy_Mike

Quote
but when I trigger a loop it overflows

Not sure I know what you mean by that?

That code is just sending the value 0 or 127 to a controller. Some control inputs need a value between those two value, for example a volume control.

peppesicurella

exist some way to connect 3 push button to several pin able act like midi push button controller   ??

rogervila

I want to send Midi CC through a button in order to trigger loops in Ableton Live like in this video https://www.youtube.com/watch?v=gMgxLPcq-3o(1:33). Is like a binary state where the button is HIGH or LOW, and it doesn't need intermediate values, but I don't know which values I have to send, and why ableton overflows when it recieves Midi CC.

peppesicurella

rogervilla
could you post the pic of breadboard configuration for this project pls

Grumpy_Mike

Quote
and why ableton overflows when it recieves Midi CC.

How many CCs are you sending it?

Use a MIDI monitor to see the MIDI signals you are sending before you pump them into Ableton.

peppesicurella

hey rogevila
many thanks for you help that;s great and it work  amazing, could you please suggest or post just a code to interface 6 push button ?

peppesicurella

hey rogevila
instead of the configuration you 've maded i would like to have for example 5 button one in each different midi note to controll the drum rack notes
in ableton

Grumpy_Mike

Stop begging for code and get down to trying to learn to write your own.

We can help when you are stuck but you have to make an effort.

peppesicurella

roger i would like to make 5 different push button that send via midi different notes cause are all button are setted to c3

rogervila

SOLVED

The problem was the Ableton Live config. You have to disable the MIDI port output and disable the MIDI clock sync.

It's explained here.

https://www.ableton.com/en/articles/lives-midi-ports-explained/

This is a snapshot of my Ableton config now. I can send MIDI notes and use them like Midi CC so the same buttons can be used as a keyboard or a launchapad.

http://i.imgur.com/b6qYvT0.png


Thank you very much @Grumpy_Mike for your help!

peppesicurella

#13
Sep 10, 2014, 05:25 pm Last Edit: Sep 10, 2014, 05:30 pm by peppesicurella Reason: 1
Thanks for your last post @Roger i knew this midi configuration in ableton but was helpfull as well , i appreciate this, i just was asking for something that can explain me how to send different note than C3 in each channel out (pin) cause in the tutorial for the   MIDI library i couldn't find it .I'm just a beginner and i'm triyng to write down my own code....P.S. not for you @roger but i also write in other Posts here in the forum and i notice that  in this  in these  ''arduino FORUM'' the kindness is a rare stuff...
Kind regards
your project is cool and helpfull for thousand people who needs some way to configure arduino with ableton.. well done

Grumpy_Mike

Quote
the kindness is a rare stuff...

I think your cultural sensitivity is all wrong.
We are kind in that we give up our time to help you.
Get it into your head that we do not do it for you.

There are plenty of MIDI projects that I have written up to help.
Here are a few:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Shield.html
http://www.thebox.myzen.co.uk/Hardware/MIDI_Footsteps.html
http://www.thebox.myzen.co.uk/Hardware/Pendulum.html
http://www.thebox.myzen.co.uk/Hardware/RFID_Sequencer.html

All contain code that will help you learn. So stop trying to make out you are a victim and do a little to educate yourself, and if you get stuck then ask specific questions. Do not ask for some one to write code for you.

Go Up