Counting until two numbers match
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)
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?
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!
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…!
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 http://www.sadam.hu/software ).
Hope this helps,
Thanks for everyones input!