Max patching quicktip: Remapping data


I recently needed to do some remapping of integers in a Max patch I was working on, and found myself solving the problem in a very ugly way at first:

How not to remap numbers in Cycling'74 Max

How not to do remapping of integers

The object was simple: To remap incoming number x into resulting number y. In a more traditional programming language I would have opted for a simple array to solve this problem. Then I found out about the coll object, which can be used for storing and retrieving information in various ways. It’s basically like an array + hashmap rolled into one. Say hello to the revised solution, using the coll object:

A revised solution for remapping numbers in Cycling'74 Max

The revised solution

The contents of the coll object (Cycling'74 Max)

…and the contents of the coll object

And remember to check the “save with patcher” option when using the coll object in this way, otherwise the data you have put in will be wiped when you reload the patch.

When programming in Max, a lot of the times when I’m stuck or find myself solving problems in convoluted ways, the cause is most often insufficient knowledge about the Max object library (which is quite extensive). I’ll be posting up some quick tidbits like this from time to time in the hope that it will save you some extra work. In the meantime; happy patching, as they say in Max circles.