JS String to Max Message

Oct 18, 2007 at 1:53am

JS String to Max Message

Is the attached stuff really the best way to do this? I tried sending
out max messages to an automatic 0 videoplane from js but max
obviously wasn’t having it. However, I was also surprised to find
that inserting a fromsymbol didn’t solve it. I had to rig it up this
way. Help is greatly appreciated. If this is the best way, just let
me know.

Thanks,
Keith

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 128 34 48 196617 loadbang;
#P newex 128 56 40 196617 uzi 5;
#P newex 125 102 59 196617 prepend vp;
#N coll vp_info 1;
#T flags 1 0;
#T 1 1 0.6 0.07 0.6 -0.3 0 -0.32 1 4.67 0.4 tex2;
#T 2 2 0.6 0.07 0.6 -0.3 0 -0.32 1 4.67 0.5 tex3;
#T 3 3 0.6 0.04 1.2 0.6 0 -0.55 1 5.4 0.9 tex2;
#T 4 4 0.6 0.04 1.2 0.6 0 -0.55 1 5.4 0.5 tex3;
#T 5 5 1.8 0.03 1.7 0.3 0 -0.55 1 5.4 0.5 tex3;
#P newobj 125 80 72 196617 coll vp_info 1;
#P toggle 23 83 15 0;
#P newex 23 104 90 196617 qmetro 33.333328;
#N vpatcher 974 471 1355 765;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 242 126 20 196617 t b;
#P newex 218 107 82 196617 prepend texture;
#P message 194 168 84 196617 color 1. 1. 1. $1;
#P message 170 149 81 196617 tex_scale_y $1;
#P message 146 128 81 196617 tex_scale_x $1;
#P message 124 108 85 196617 tex_offset_y $1;
#P message 96 168 85 196617 tex_offset_x $1;
#P message 73 149 84 196617 position $1 $2 0;
#P message 50 109 72 196617 scale $1 $2 1;
#P newex 50 50 64 196617 fromsymbol;
#P window linecount 2;
#P newex 50 75 224 196617 route scale position tex_offset_x
tex_offset_y tex_scale_x tex_scale_y color texture bang;
#P inlet 50 30 15 0;
#P outlet 50 238 15 0;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 0 0;
#P connect 5 0 0 0;
#P connect 9 0 0 0;
#P connect 10 0 0 0;
#P connect 11 0 0 0;
#P connect 12 0 0 0;
#P connect 6 0 0 0;
#P connect 7 0 0 0;
#P connect 8 0 0 0;
#P connect 2 1 5 0;
#P connect 2 2 6 0;
#P connect 2 3 7 0;
#P connect 2 4 8 0;
#P connect 2 5 9 0;
#P connect 2 6 10 0;
#P connect 2 7 11 0;
#P connect 2 8 12 0;
#P pop;
#P newobj 23 149 84 196617 p sort_and_bang;
#P newex 23 127 150 196617 js kvm.videoplane_control.js 5;
#P window linecount 2;
#P newex 23 173 378 196617 jit.gl.videoplane wonk @blend_enable 1
@scale 1.333 1. 0. @depth_enable 0 @lighting_enable 1 @color 1 1 1 1
@automatic 0 @texture tex2 @blend_mode 6 1;
#P connect 4 0 3 0;
#P fasten 6 0 1 0 130 123 28 123;
#P connect 3 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P connect 7 2 5 0;
#P connect 5 0 6 0;
#P connect 8 0 7 0;

———save as kvm.videoplane_control.js

inlets = 1;
outlets = 1;

var videoplane = new Array(jsarguments[1]);
for (i=0;i< =jsarguments[1];i++)
{
videoplane[i] = new Array(7);
}

function bang( ){
for (i = 1; i < = jsarguments[1]; i++){
outlet(0, “scale ” + videoplane[i][0] + ” ” + videoplane[i][1]);
outlet(0, “position ” + videoplane[i][2] + ” ” + videoplane[i][3]);
outlet(0, “tex_offset_x ” + videoplane[i][4]);
outlet(0, “tex_offset_y ” + videoplane[i][5]);
outlet(0, “tex_scale_x ” + videoplane[i][6]);
outlet(0, “tex_scale_y ” + videoplane[i][7]);
outlet(0, “color” + ” ” + videoplane[i][8]);
outlet(0, “texture ” + videoplane[i][9]);
outlet(0, “bang”);
}
}

function vp(number, scale_x, scale_y, loc_x, loc_y, tex_offset_x,
tex_offset_y, tex_scale_x, tex_scale_y, alpha, texture){
videoplane[number][0] = scale_x;
videoplane[number][1] = scale_y;
videoplane[number][2] = loc_x;
videoplane[number][3] = loc_y;
videoplane[number][4] = tex_offset_x;
videoplane[number][5] = tex_offset_y;
videoplane[number][6] = tex_scale_x;
videoplane[number][7] = tex_scale_y;
videoplane[number][8] = alpha;
videoplane[number][9] = texture;
}

#34223
Oct 18, 2007 at 2:42am

On 18 oct. 07, at 10:53, keith manlove wrote:

> outlet(0, “scale ” + videoplane[i][0] + ” ” + videoplane[i][1]);

You need to send an array or separate the elements with a coma
because outlet() can do that:

outlet(0, “scale”, videoplane[i][0], videoplane[i][1]);

When you use “+” with string in JavaScript it just concatenate the
strings to make an unique one.

HTH,
ej

#115123
Oct 18, 2007 at 3:04am

Thanks EJ; that does help; I’m not getting error messages anymore, but
the videoplane still isn’t responding. I really feel like I’m missing
something obvious.

Keith

On 10/17/07, Emmanuel Jourdan wrote:
> On 18 oct. 07, at 10:53, keith manlove wrote:
>
> > outlet(0, “scale ” + videoplane[i][0] + ” ” + videoplane[i][1]);
>
> You need to send an array or separate the elements with a coma
> because outlet() can do that:
>
> outlet(0, “scale”, videoplane[i][0], videoplane[i][1]);
>
> When you use “+” with string in JavaScript it just concatenate the
> strings to make an unique one.
>
> HTH,
> ej
>
>
>

#115124
Oct 18, 2007 at 3:12am

On 18 oct. 07, at 12:04, keith manlove wrote:

> Thanks EJ; that does help; I’m not getting error messages anymore, but
> the videoplane still isn’t responding. I really feel like I’m missing
> something obvious

Could you post a little bit more of the patch because actually it’s
missing the textures, the render, etc.

ej

#115125
Oct 18, 2007 at 3:21am

Nevermind. I was doing some dumb stuff with the positioning. Thanks
again for your help.

Keith

On 10/17/07, Emmanuel Jourdan wrote:
> On 18 oct. 07, at 12:04, keith manlove wrote:
>
> > Thanks EJ; that does help; I’m not getting error messages anymore, but
> > the videoplane still isn’t responding. I really feel like I’m missing
> > something obvious
>
> Could you post a little bit more of the patch because actually it’s
> missing the textures, the render, etc.
>
> ej
>
>

#115126

You must be logged in to reply to this topic.