Go Down

Topic: Translate MIDI notes to CC for Kaossilator Pro - Partially Working (Read 7051 times) previous topic - next topic

RaveTZ

I'm investigating the possibility to use the Arduino platform to convert standard midi notes to CC messages.  The Kaossilator Pro doesn't accept MIDI notes from a keyboard, but instead accepts CC messages for X/Y inputs to the touchpad.  There have been a couple software solutions to date, but neither are very good in practice.

The desired result is to use a keyboard to play notes from the Kaossilator Pro.  Notes for X axis, Mod wheel for Y.

Here is the MIDI TABLE info:  http://www.midisolutions.com/Kaossilator%20Pro%20Midi.doc

I've done some digging in the forum to try and figure this out and I was able to dig up something relevant from another post (I think) http://forum.arduino.cc/index.php?topic=195967.0.  I'm not sure it is though.  The sample code is here from Deseipel https://github.com/deseipel/Arduino/blob/master/KORGES1_Control

My guess would be a lookup table

  • input if this note

  • out send this data



I'm asking since I'm very new to the Arduino platform and I want to make sure the task is possible before going down the rabbit hole.  I once converted the MIDI shield to work with the MIDI mod for Gameboy with great success, but that code was pre-made.

Thanks in advance

deseipel

I'm not really familiar with that Kaosilator, but I can tell you that my code works for what I'm using it for.  Mapping  notes to CCs has been the easiest part of my project so far.  If you know the notes and the CC's, then it's a matter of coding. 

MattiasOfTheMetal

I can agree with Deseipel. If you have Max MSP, it may help with quickly prototyping the mapping you wish to do and quickly get the codes you want (I prototype everything midi through Max). JM2C
Food for thought.
Nom.

RaveTZ

I'm downloading the MAX MSP demo.  Is there a good code example for converting notes to CC?  If I have a sample to modify, I can rig something to work.  Most of my code skills are in the Unity 3D engine so I hope it won't be too difficult to understand.

MattiasOfTheMetal

I just whipped this up for you (attachment). Let me know if you have any questions.

Just open max and paste the code inside.

This code will let you play with sending midi notes as a controller value (via the keyboard at the right), and you can set the value with the number box.
The other stuff in the middle (the big cluster of stuff) will monitor what comes in, and you can send custom messages out from here.
Food for thought.
Nom.

RaveTZ

I'll check this out once I return to my station tomorrow.  I've never heard of MAX so I'm not 100% sure how this will apply to arduino, but I trust it will make more sense once I dive in.  You guys are great btw.

MattiasOfTheMetal

Max is just a visual scripting language, correct me if I'm wrong here, based off of C++ but not directly compatible.

You can use Max to communicate with Arduino, but code isn't compatible (that I know of) between the two. If there is an automatic way to convert max code for Arduino, then please let me know!

I personally use Max when I'm prototyping Midi stuff; yes, it may seem odd as it's seemingly incompatible code, but I design my whole system in Max to get the entire concept down before writing code for Arduino. It's much quicker for me to work with hardware by visually programming and not having to upload and wait a minute between changes in code, etc.

When I have my rough draft written out in Max, it's quite easy and quick for me to translate everything manually to Arduino, rather than only building it on the Arduino alone.
Food for thought.
Nom.

deseipel

doesn't that doc link supply the CC value?  I would think you have everything you need, aside from the actual code, no?

KosmoMishka

#8
Jan 10, 2014, 09:02 pm Last Edit: Jan 10, 2014, 11:36 pm by KosmoMishka Reason: 1
I think MIDI Library  (http://playground.arduino.cc/Main/MIDILibrary) can do it. Not sure how, I am digging it now too.

You may try this for notes. Similar for ModWheel
Code: [Select]
#include <MIDI.h>
void HandleNoteOn(byte channel, byte pitch, byte velocity)
{
   MIDI.sendControlChange (kaoospadCC, pitch, channel);
}
void setup()
{
   MIDI.begin(MIDI_CHANNEL_OMNI);    
   MIDI.setHandleNoteOn(HandleNoteOn);
}
void loop()
{
   MIDI.read();
}

RaveTZ

Soory for the late reply.  Churning thru all of this while I wait for my MIDI shield to arrive.

RaveTZ

I'm digging into this now, any chance for some commented notes on the code above?  I mainly work in Unity3D but this environment is very new to me.  I feel like a 1st grader all over again.


RaveTZ

Its starting to work!

I need help to detect when the note is released and map the mod wheel to the y axis.  But I can play 2 notes with this:

Code: [Select]
#include <MIDI.h>
#define LED 6
void HandleNoteOn(byte channel, byte pitch, byte velocity)
{
  MIDI.sendControlChange (92, 127, 1);
  digitalWrite(LED,HIGH);
  if (pitch == 60){
    MIDI.sendControlChange (12, 1, 1);
  }
  if (pitch == 61){
    MIDI.sendControlChange (12, 7, 1);
  }
  delay(10);
  digitalWrite(LED,LOW);
 
}
void setup()
{
    MIDI.begin(MIDI_CHANNEL_OMNI);   
    MIDI.setHandleNoteOn(HandleNoteOn);
    pinMode(LED, OUTPUT);
}
void loop()
{
    MIDI.read();
}

RaveTZ

I've got it to turn off notes by checking the velocity.  Only the MOD Wheel left.

RaveTZ

I can't seem to figure out how to get messages from CC 1 and send the same value on CC 13.

I think this is the last big step I need.

Code so far:

Code: [Select]
#include <MIDI.h>
#define LED 6
void HandleControlChange(byte channel, byte number, byte value)
{
  //set messages from CC 1 to CC 13...somehow
}

void HandleNoteOn(byte channel, byte pitch, byte velocity)
{
  MIDI.sendControlChange (92, 127, 1);
  digitalWrite(LED,HIGH);
  if (velocity == 0){
    MIDI.sendControlChange (92, 00, 1);
  }
  if (pitch == 60){
    MIDI.sendControlChange (12, 1, 1);
  }
  if (pitch == 61){
    MIDI.sendControlChange (12, 7, 1);
  }
  digitalWrite(LED,LOW);
 
}
void setup()
{
    MIDI.begin(MIDI_CHANNEL_OMNI);   
    MIDI.setHandleNoteOn(HandleNoteOn);
    MIDI.setHandleControlChange(HandleControlChange);
    pinMode(LED, OUTPUT);
}
void loop()
{
    MIDI.read();
}

KosmoMishka

#14
Jan 21, 2014, 01:02 pm Last Edit: Jan 21, 2014, 01:06 pm by KosmoMishka Reason: 1
Not sure what you mean. Something like this?
Code: [Select]
void HandleControlChange(channel, cc, value)
{
if (cc == 1) {
 MIDI.sendControlChange (13, value, channel);
}
}

Go Up