Go Down

Topic: MIDI messages for presets up/down?? (Read 2181 times) previous topic - next topic

bergmusic

Hi!
Ive searched the forum and internet for too many days without finding any answer...

Im making my own DIY midi foot-controller (using Teensy with Arduino software), and just want two buttons
(a lot like the TC Electronic G-minor) for changing presets up and down on my TC Electronic Nova System.

Ive managed to send ProgramChanges to select a specific preset, but nothing more...
Looking thru the manual of the G-minor it says Ctrl. 82 and 83, but I have not managed to send that specific
message to the Nova System. Im not sure how to write the code:
MIDI.send(CC, 83, 0, 1);    // ????
MIDI.send(CC, 83, 127, 1);    // ????

It only receives midi messages (blinks) and just sits there staring at me  :~

Sooooo...

What is the midi message I need to send to my Nova System to change preset up and down?
Is there any? Or is there a code combination to increase/decrease ProgramChange?

And to the programmers out there; how do I write it?
Whats the code?

Ive used too many hours searching around, all suggestions are sooo welcome  :)

-Berg

Grumpy_Mike

#1
Oct 07, 2011, 06:36 pm Last Edit: Oct 07, 2011, 08:16 pm by Grumpy_Mike Reason: 1
You send MIDI through the serial port so any messages you send look like serial print statements. This piece of code is a function to send CC messages:-
Code: [Select]
void controlSend(char data1, char data2) {   // where  data1 is the CC number and data2 is the value
 byte cmd = 0xB0 | byte(midiChannel);  // merge channel number
 Serial.print(cmd, BYTE);
 Serial.print(data1, BYTE);
 Serial.print(data2, BYTE);
}

You need to have set a global variable midiChannel which goes from 0 to 15. The MIDI interface gives the illusion it uses channels 1 to 16 but the number it actually sends is one less than the channel number.

If you are outputting code directly from your arduino then you need to set the right serial speed in the setup() function:-
    Serial.begin(31250);       // MIDI speed

leenux5030

I did it  few months back.

Simple one : https://sites.google.com/site/bharatbhushankonka/home/diy-midi-over-usb-using-arduino-uno

a bit more advanced : https://sites.google.com/site/bharatbhushankonka/home/usb-midi-footcontroler-2-0

bergmusic

Hi!

Thanks for the replies!
Unfortunately this doesnt work on my system...

I`ve contacted TCElectronics about the NovaSystem, and they told me that it can only respond to
programchanges, not controlchanges.

So I need to increase/decrease the program change numbers somehow...

This code makes my NovaSystem change from one preset to another when I push switch 1;

Code: [Select]
#include <MIDI.h>




void setup() {               
  MIDI.begin();
  MIDI.setInputChannel(1);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);



}


void loop()                     
{
  if (digitalRead(1) == HIGH) {
    //MIDI.sendControlChange(80, 127, 1);
   
  } else {
   


    MIDI.sendProgramChange(30, 1);
    delay(400);
    MIDI.sendProgramChange(35, 1);
    delay(400);
   

   
  }
  delay(250);
}


Is there a simple code that increases / decreases the programchange?
I havent been able to find any easy description on how to do this...

Im also very new on this, so please give me a heads up, I dont fully understand the "MIDI vs Serial" coding  :smiley-eek:

Grumpy_Mike

#4
Oct 18, 2011, 04:19 pm Last Edit: Oct 18, 2011, 04:58 pm by Grumpy_Mike Reason: 1
Try this, it is not tested or anything. Your example used pin 1, that is not a good idea as that interferes with the serial port, so use pin 2 for the up push button and pin 3 for the down. Just wire the buttons from the pin to ground.

Code: [Select]
#include <MIDI.h>

int progNo = 30;
int upLastTime, downLastTime, upNow, downNow;

void setup() {                
 MIDI.begin();
 MIDI.setInputChannel(1);
 pinMode(2, INPUT);
 pinMode(3, INPUT);
 digitalWrite(2, HIGH); // enable pull up
 digitalWrite(3, HIGH); // enable pull up
 upLastTime = digitalRead(2);
 downLastTime = digitalRead(3);
}



void loop()                    
{
 upNow = digitalRead(2);
 downNow = digitalRead(3);

 if (upNow == HIGH && upLastTime == LOW) {
    progNo++; // increment program change
    if(progNo > 127) progNo = 127; // stop it going too high
    MIDI.sendProgramChange(byte(progNo), 1);
    delay(20); // bit of debounce delay
 }
   
 if (downNow == HIGH && downLastTime == LOW) {
    progNo--; // decrement program change
    if(progNo < 0) progNo = 0; // stop it going too low
    MIDI.sendProgramChange(byte(progNo), 1);
    delay(20); // bit of debounce delay
 }

  upLastTime= upNow;
  downLastTime = downNow;
 delay(200);
}


EDIT - added missing semicolon

bergmusic

Wow!

Thanks for quick reply, and IT WORKS!  :)

Fantastic, this (easy) thing has been a pain...

For others out there, I needed to add a ; after upnow to make it load:

Code: [Select]
#include <MIDI.h>

int progNo = 30;
int upLastTime, downLastTime, upNow, downNow;

void setup() {               
  MIDI.begin();
  MIDI.setInputChannel(1);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  digitalWrite(2, HIGH); // enable pull up
  digitalWrite(3, HIGH); // enable pull up
  upLastTime = digitalRead(2);
  downLastTime = digitalRead(3);
}



void loop()                     
{
  upNow = digitalRead(2);
  downNow = digitalRead(3);

  if (upNow == HIGH && upLastTime == LOW) {
     progNo++; // increment program change
     if(progNo > 127) progNo = 127; // stop it going too high
     MIDI.sendProgramChange(byte(progNo), 1);
     delay(20); // bit of debounce delay
  }
   
  if (downNow == HIGH && downLastTime == LOW) {
     progNo--; // decrement program change
     if(progNo < 0) progNo = 0; // stop it going too low
     MIDI.sendProgramChange(byte(progNo), 1);
     delay(20); // bit of debounce delay
  }

   upLastTime = upNow;
   downLastTime = downNow;
  delay(200);
}


And THANKS again!  :)

Grumpy_Mike

Sorry about the missing ; as I didn't have the MIDI library I couldn't do a test compile. Glad it is working. Can you follow what it is doing?

Go Up