adding graphics to max/msp

Mar 29, 2012 at 6:47pm

adding graphics to max/msp

Hi,

I would like to get circles to represent the volume of an audio file (as you turn up the gain the circle radius increases). Is there a way to link max with some simple 2D graphics- and if so any recommendations please?

j

#62658
Mar 29, 2012 at 11:04pm

Try looking at the nodes object.

Marc P.

#226315
Mar 30, 2012 at 12:06pm

[lcd] seems perfect for this

#226316
Mar 30, 2012 at 12:53pm

Probably not the best approach, whacky though:

– Pasted Max Patch, click to expand. –
#226317
Mar 30, 2012 at 12:55pm

That’s a the bastard child of a few open patches by the way, I thought it demonstrated the concept.

#226318
Mar 30, 2012 at 4:46pm

JSUI is what you want. (this is what it’s designed for…)

#226319
Mar 31, 2012 at 11:48am

Thanks Peter for JSUI tip- looks perfect.

Quick question; can a jsui patch have 2 objects? i.e. can it have simple 2d dial functionality and 2d vector control combined, and if so do i need to edit the java code? I’m trying to combine the attached 2 objects;

– Pasted Max Patch, click to expand. –
#226320
Mar 31, 2012 at 3:52pm

You do need to edit the javascript code. Do you want dial functionality, or did you want the radius to scale as you shift-drag, say? (this is pretty trivial to do)

The variable you’re interested in is vradius. You also need to know how the mouse has changed relative to its previous position so create a global variable called prev_w. (below)

var prev_w = [];

You’ll need to tweak the onclick and ondrag methods.

For onclick, you should store the value of w into prev_w (so it’s not blank, and also so if we click to jump we won’t have a crazy scaling factor)

Ondrag needs to be slightly changed. This call doesn’t have a shift parameter, but you can find the relevant looking one in the jsui dial’s source code. It looks like this:

function ondrag(x,y,but,cmd,shift,capslock,option,ctrl) { // note the presence of shift, which is what we need

w = sketch.screentoworld(x,y);
// w[0] = x pos, w[1] = y pos

// Now find the distance between the two points
var distx = w[0]-prev_w[0];
var disty = w[1]-prev_w[1];

var distance = Math.sqrt(distx*distx + disty*disty); // Pythagorean distance
if (distx<0) {
vradius -= distance;
} else {
vardius += distance;
}

// At the end of this function, you should store w into prev_w:
prev_w = w;

This is my best guess at it (haven’t tried this yet!)

#226321
Mar 31, 2012 at 6:42pm

Thanks- could I just get some clarification on this? should I make the modifications to the dial or the vector control javascript?

thanks,
j

#226322

You must be logged in to reply to this topic.