MIDI cc problems with Midi Library, Hairless MIDI and Ableton Live


hello,

i'm creating own midi controller using arduino midi library.
i succeed sending notes ableton live, have problems sending midi controls.
i want trigger loop button there lag , ableton live starts go crazy , have close it. maybe should use cc number? or arduino input?
i selected cc 16 because it's general purpose (i read here: http://nickfever.com/402/production-tips-and-resources/midi-cc-list/)

here code:
code: [select]
#include <midi.h>

//starting midi
midi_create_default_instance();

//variables

//the led shine while button 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 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 have problems
 
  //button2 = b2 = cc
  currentb2state = digitalread(button2);
 
  if( currentb2state == 1){
   
    if (lastb2state == 0) {
      midi.sendcontrolchange(cc,127,1); //here want send 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 help

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;



Arduino Forum > Using Arduino > Audio > MIDI cc problems with Midi Library, Hairless MIDI and Ableton Live


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support