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
Try looking at the nodes object.
Marc P.
[lcd] seems perfect for this
Probably not the best approach, whacky though:
That's a the bastard child of a few open patches by the way, I thought it demonstrated the concept.
JSUI is what you want. (this is what it's designed for...)
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;
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
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!)
Thanks- could I just get some clarification on this? should I make the modifications to the dial or the vector control javascript?
thanks,
j