Forums > MaxMSP

Counting until two numbers match

December 9, 2011 | 8:29 pm

Hi all!

I’m working on a Rhythm generator which works using two inputed numbers.

Two numbers are multiplied by themselves to create two lists of essentially, times tables. e.g:

3, 6, 9, 12, 15 etc
5, 10, 15, 20 etc

With any combination of numbers eventually two numbers will match. In the example above the number is 15. But the two lists vary in lengths

I want to enter two numbers and count up until the matching number is found.

Any help would be grand!!


(Using MAX/MSP 5 on Windows 7)

December 9, 2011 | 9:29 pm

I’m unclear about what you’re trying to do here. Are you trying to find something like the lowest common denominator between the two numbers?

You use the word count, but where does counting come in?

December 9, 2011 | 10:15 pm

Hi Chris,

Yes, I am trying to find the lowest common denominator!
(apologies for my poor knowledge of maths!!)

In the patch, the user "counts" by pressing the green button, this adds the numbers to the coll list.

If I could work out the lowest common denominator of the two numbers then I could use a counting object to bang the green button until the lowest common denominator appears in either list.

Does that make sense? I’m not very good at penning my thoughts!

December 9, 2011 | 11:14 pm

just use [==] ? that would do it. You can match the numbers to each other, or check whether either one equals the LCM, assuming you have a way to easily determine that…checking whether the numbers "reduce" with each other (technically, do they share any prime factors and if so, don’t count them twice) will take a bit of fiddling with [%] and [/]. If you don’t have that many psosible combinations, you can just hard-code the LCM’s manually by figuring them out beforehand.

If you want more than two numbers, try [match]

Sounds like some interesting polyrhyms are on the way…math and music? yes indeed…!

December 10, 2011 | 7:23 am


I made an external that will give you the LCM of two arbitrary integers called [sadam.lcm], which might help you with this. It is included in my library (see ).

Hope this helps,

December 12, 2011 | 12:12 pm

Thanks for everyones input!

Viewing 6 posts - 1 through 6 (of 6 total)

Forums > MaxMSP