Forums > MaxMSP

adding graphics to max/msp

March 29, 2012 | 6:47 pm

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


March 29, 2012 | 11:04 pm

Try looking at the nodes object.

Marc P.


March 30, 2012 | 12:06 pm

[lcd] seems perfect for this


March 30, 2012 | 12:53 pm

Probably not the best approach, whacky though:

– Pasted Max Patch, click to expand. –

March 30, 2012 | 12:55 pm

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


March 30, 2012 | 4:46 pm

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


March 31, 2012 | 11:48 am

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. –

March 31, 2012 | 3:52 pm

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!)


March 31, 2012 | 6:42 pm

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

thanks,
j


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