Forums > MaxMSP

create harmonic series with partial stretch / extract javascript from an html file?

Oct 22 2009 | 2:13 am


i’m looking for a way to do this in max:
does anybody know what the formula is (or where to find it)?

i need something that takes inputs for fundamental freq, nr of partials and partial stretch and returns a list of freqs.

it gave me an interesting side thought: would it be possible to extract the javascript bit from the html source code and implement that in max? i guess so, but i have no idea how to do that…


Oct 22 2009 | 7:42 am

Your browser probably allows you to see the source code.
For example with firefox : menu : view->page source
And you’ll see the js code.

Oct 22 2009 | 9:59 am

The [mtof] object does most of the work, then its just a matter of multiplying by the partial number. Here’s a patch to illustrate, half of it is just formatting for the [jit.cellblock] display.


— Pasted Max Patch, click to expand. —

Oct 22 2009 | 8:03 pm

@ ch : thanks, i know how to get the source code and i can clearly see the javascript bit, but i have no idea how to turn that into a max patch. i also assume some of the code would have to be omited or edited (???)

@ thereishopeforus : i can see how mtof could be involved but that still doesn’t give me the formula to create a natural harmonic series. mtof is based on midi notes, which represent a tempered scale. in a real harmonic series an octave is not exactly an octave anymore when you go up a few steps. nevertheless i’m curious about your patch, only i’m still on max 4.6 so i can’t open it. could you post a 4.6 friendly version?

Oct 22 2009 | 8:48 pm

thereishopeforus, very neat!

Oct 22 2009 | 10:56 pm

Here’s a screenshot, you should be able to piece the patch back together in max 4. The [coll] contains 0, C; 1, C#; etc up to 11, B; Hopefully you can make out that the first "bang" of the [trigger] object below the [vexpr] is going to all centre inlets of the [counter]s to reset them. If you have any questions feel free to ask.


Oct 24 2009 | 9:47 pm

very cool patch, thanks hope! nicely organized too, very clear.

@xaf: look to the js object. If you’re familiar with programming in something like Flash, this might be familiar too. In Flash you access all your objects by Instance Name, whereas in Max you don’t usually need to, but you can. If you give your objects Scripting Names (in the Inspector) then you can get/set properties through js, and also through scripting messages to [thispatcher]. It’s just that for most things, you use patch cords or send/receive. So you can do it in a bunch of ways. Try some of the js examples to get a feel for it. Then maybe you can grab the code from the website and mangle it to fit.

Then again, you can see that the Max objects in the example patch are doing something similar to the code, so there are lots of approaches. Sometimes a snippet of code is just the thing to make life easier or less messy, but you’ll find that you can accomplish most things with regular objects and cords too.

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

Forums > MaxMSP