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

Oct 22, 2009 at 2:13am

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

hi,

i’m looking for a way to do this in max:
http://www.michaelnorris.info/harmcalclist.html
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…

thnx,
xaf

#45996
Oct 22, 2009 at 7:42am

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.

#165725
Oct 22, 2009 at 9:59am

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.

lh

– Pasted Max Patch, click to expand. –
#165726
Oct 22, 2009 at 8:03pm

@ 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?

#165727
Oct 22, 2009 at 8:48pm

thereishopeforus, very neat!

#165728
Oct 22, 2009 at 10:56pm

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.

lh

#165729
Oct 24, 2009 at 9:47pm

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.

#165730

You must be logged in to reply to this topic.