.-----.   .----.   .-----.  .-----.           .----.      .---.          .-----.  .-----.  
/ ,-.   \ /  ..  \ / ,-.   \/ ,-.   \  .-')   /  ..  \    / .  |    .-') / ,-.   \/  -.   \ 
'-'  |  |.  /  \  .'-'  |  |'-'  |  |_(  OO) .  /  \  .  / /|  |  _(  OO)'-'  |  |'-' _'  | 
   .'  / |  |  '  |   .'  /    .'  /(,------.|  |  '  | / / |  |_(,------.  .'  /    |_  <  
 .'  /__ '  \  /  ' .'  /__  .'  /__ '------''  \  /  '/  '-'    |'------'.'  /__ .-.  |  | 
|       | \  `'  / |       ||       |         \  `'  / `----|  |-'       |       |\ `-'   / 
`-------'  `---''  `-------'`-------'          `---''       `--'         `-------' `----''  

A good tool improves the way you work. A great tool improves the way you think. --Jeff Duntemann

Building a scale tool in Ableton and max

This is a tool to have Ableton only display notes in the midi editor in the key you choose using the max programming environment. (the newest version of ableton does this for you now.)

Humans create tools to help offload what the brain needs to know how to do, so that the brain can then focus on doing other things. Tools can allow people to do superhuman tasks that they wouldn't normally be able to do, thus progressing what humans can do forward.

This is a tool to make it easier to compose music if you don't have all the scale memorized by only showing you the notes in the current scale (thus freeing up your mind to do more creative things like composing music.)

Music theory for building major and minor scales.

To calculate the notes that are shown for a scale, you need to know the root note that you want to start at, and then what type of scale you want to show (major/minor). Every scale has it's own pattern on how many semitones you need to jump between notes, so for a whole jump, you move 2 notes forward, and for a half note jump you only move 1 note forward. This is pretty easy with midi notes, since you just add either 1 or 2 based on the pattern.

you can see how this is laid out in the code:

var scales = [
  [2,2,1,2,2,2,1],  // major
  [2,1,2,2,1,2,2]   // minor

Interfacing with the Ableton interface with Max

To get Max to update the midi note editor, you need to interface live through the Live Object Model (LOM).
The LOM allows you to control most of the parts of Ableton through the javascript (or the max gui if you so choose.)

A little of example of setting the first channel to mute using the LOM:

api = new LiveAPI("live_set tracks 0");

Before I create the notes of the scale, I need to first clear out any previous data that might have already been there:

api.call("remove_notes", "-0.25", 0, "0.25", 128);

This wipes out all notes from the time -0.25 to 0, so I can come back in and add the notes of the scale.

adding notes to the midi editor is done in multiple steps:

api.call("set_notes");  // start the note adding transaction
api.call("notes", noteCount);  // tell it how many notes you plan on adding
api.call("note", total, "-0.25", "0.25", 100.0, 0); // the note infomration to add (call this noteCount times)
api.call("done"); // tell the api you are done adding notes.

Now you should have the scale filled out on the piano roll, before 0 (so it can be hidden). Using the fold button will hide all the notes that aren't in the key you selected.

Using the Tool

To use the patch, pull an instrument over, add the effect, select your options, click the create scale button, and then go to the midi roll for that instrument and click the "fold" button to show the notes of your scale. If you change anything, you just need to click the fold button twice to get it to refresh.

You can get the patch and see the code here: https://github.com/analogpixel/maxShowPianoInKey


Where does all my free time in December go after I finish making and delivering holidy cards? It goes to the horrible coding challenge AOC. AOC is a devious little site, that draws you in with the promise of easy and fun programming challenges throughout the month of December, but once they know you are hooked and won't stop because your completionist brain NEEDS to finish it, that's when they flip the switch and start giving you problems you can no longer brute force, but have to stop and actually think about what your code is doing; monsters!

This doesn't stop me from trying to brute force every problem I see, and letting it run over night hoping that when I come back the next day, the solution will be sitting there waiting for me, but alas, this never works and I have to figure out what the problem is really doing and figure out the "correct" way to solve the problem.

This year I am using Jupter notebooks as the coding platform of choice, because a) you can mix code and documentation, b) you can embed visualizations, and c) you can test snippets of code easier.

All of my completed days can be found on Github.

👈 Prev Day - Home - Next Day 👉