midi out

azs's icon

I'm helping a student with a patch to get serial data from arduino and format it for midi so he can use it in ableton live, like a regular midi controller. I'm very comfortable parsing serial data from arduino, but I don't know anything about midi or ableton. My student is hoping to use max to make a standalone app that can be used with the version of ableton that he owns, because he can't buy max for live at this point. We wrote an arduino sketch to print the values of 2 different potentiometers and I've attached a patch that successfully routes the 2 different potentiometers values to different number boxes.

Beyond that, I am out of my element. My student would like to get these values into ableton to use for whatever he wants (volume, pitch ect.) Currently, we can see that the messages are getting to ableton, because when he turns the potentiometer all the way (so the value is 1023) we see a little yellow indicator. But he is not able to connect this to anything. Any advise would be great.

maxpatch.maxpat
Max Patch
Wetterberg's icon

hi.

looks like you're on the right track there. You should know that midi continuous controller values are 7-bit only, so you should / 8 before getting to the midiformat.

If you then see a midi indicator more or less constantly in Live when turning the pot, then you're good to go.
The rest is a mapping issue in Ableton Live. Enter the midi mapping mode in Live to assign that value, as per the Live manual, or this quickstart guide: https://www.ableton.com/en/articles/getting-started-3-setting-your-midi-controller/

Wetterberg's icon

you could probably do some nifty bit-stuff to get 7 bit too, I just realized. Not my strongest suit, though.

hz37's icon

I would let the Arduino code do the scaling already. If you read a value between 0 and 1023 you can tell the Arduino code to scale it to a MIDI CC range:

int sensorValue = analogRead(A2);
char outputValue = map(sensorValue, 0, 1023, 0, 127);

You then put this 7 bit number onto the Serial output:

Serial.write(outputValue);

And maybe delay a bit for the ADC in the Arduino to settle down a bit:

delay(10);

Then you have the right data flow into Max already! That's a simple matter of instantiating a [serial] object and assigning the right port to it. Your number comes out the bottom outlet, but it needs to be formatted as a list in order to become a MIDI CC that Ableton Live can understand. I'd use [sprintf %d %d] for this, where the first number is the MIDI CC (a more or less arbitrary value between 0 and 127; you can find out on the internet which values are already in use). Because only the first inlet of [sprintf] causes output, you can trigger it [t b] whenever the [serial] objects outputs data. Then use a [midiformat] connected to a [midiout] to send the custom MIDI CC out the door. The third inlet of [midiformat] expects the MIDI CC list you've made. For the [midiout], double-click it and select "from Max 1". Then in Abeton Live's preferences, select "from Max 1" as a remote control object (see attachment). Now it's a simple matter of MIDI mapping in Ableton Live. Right click a control you'd like to automate and choose "Edit MIDI map". Because Max is already bombarding it with MIDI CC information, it'll automagically pick up on it.

Good luck and have fun!

Max Patch
Copy patch and select New From Clipboard in Max.

Attached a simple example.

Screen-Shot-2015-04-11-at-21.01.19.png
png
hz37's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Come to think of it, you could thin the data a bit by adding a [change] object just below the [serial] output.

azs's icon

I am already very familiar with arduino/max communication but not the max/ableton side of it. Your patch essentially does the same thing as ours, except we were using multiple inputs so I prepended 1 before one of the potentiometer values and 2 in front of the other before sending it to the midi format object. It looks like it should be 0, 1 instead. Anyway, using either patch and arduino sketch, my student does not seem to be able consistently get the data into ableton. With your patch, he selected 'from max 1' in the patch as well as in the channels in ableton and set 'from max 1' to 'on' and 'remote' in ableton preference, but no data is getting to ableton and no yellow indicator light is changing ableton. The potentiometer values are changing properly in max.