Feature Request: value object

Feb 13, 2007 at 9:15pm

Feature Request: value object

It would be great if value could receive a “refer” message to change the value it is referring to, similar to the way coll works.

For example, using [value #0_myValue] inside a subpatcher works as expected in the context of a larger patch that contains other #0_ objects.

But once you save it as an abstraction and use it in the same patch, it creates its own instance number, separate from that of the larger patch.

There are workarounds, but it would be nice if could behave like coll in such cases.

#30276
Feb 13, 2007 at 11:47pm

I’ll add to a feature request thats been on my mind.

variable support in expr.
expr $i1 + var(myVariable)* 2

also coll support.
expr $f1+$f2+coll(myColl,myEntry,myAtom)

basically expr should be like the right side of an assignment line of
code.

OR include the same type of thing after # characters

split 4 #var(myvariable)

#96369
Feb 14, 2007 at 12:47am

well, you could create an abstraction that contains a scripted value which is deleted, remade, rewired, when a refer message is sent to it.

I’d call it dynaValue.

#96370
Feb 14, 2007 at 12:57am

> well, you could create an abstraction that contains a scripted
> value which is deleted, remade, rewired, when a refer message is
> sent to it.

True.

But I would hesitate to use scripting to create internal objects within
essentially hidden subpatchers.

I simply don’t trust it.

#96371
Feb 14, 2007 at 12:59am

hrm, well try it out at least. better than waiting for someone to code the bugger. Outside of scripting I don’t see that there’s a way, albeit I haven’t read the value documentation in forever.

#96372
Feb 14, 2007 at 1:22am

> Outside of scripting I don’t see that there’s a way

Right now, I use #1 as the value name inside the abstraction (as
opposed to #0). Then I pass, as an arguement, #0_myvalue.

In the various instances, the #0 is converted into the instance number
in the arguement, which is then correct inside the abstraction itself.

As I said, it is a workaround, and it works fine, but I’m suggesting
some consistency between data objects.

#96373
Feb 14, 2007 at 9:42am

Quote: arne wrote on Wed, 14 February 2007 01:57
—————————————————-
> > well, you could create an abstraction that contains a scripted
> > value which is deleted, remade, rewired, when a refer message is
> > sent to it.

How about defining a global variable in javascript and binding another javascript to it. Like so:

——- save as ‘value.js’

autowatch = 1;
var name = null;
g = new Global(“jsvalue”);

function addValue(name, value)
{
if (g[name]) pst(“error: value already exists”);
else
{
g[name] = value;
this.name = name;
}
}

function refer(name)
{
this.name = name
if (g[name]) bang();
else pst(“error: value doesn’t exist”);
}

function bang()
{
if (name)
outlet(0, g["" + name]);
else
pst(“error: is not referring to a value”);
}

function pst(v)
{
post(v);
post();
}

function anything()
{
if (name)
{
var a = arrayfromargs(messagename,arguments);
g["" + name] = a;
}
else
pst(“error: is not referring to a value”);
}

——- save as anything:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 25 42 105 196617 addValue precious 42;
#P number 224 43 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 262 43 60 196617 the answer;
#P button 206 43 15 0;
#P message 354 43 75 196617 refer precious;
#P newex 206 99 32 196617 print;
#P message 354 60 59 196617 refer thing;
#P newex 206 79 58 196617 js value.js;
#P message 25 59 98 196617 addValue thing 1.62;
#P newex 25 79 58 196617 js value.js;
#P connect 2 0 4 0;
#P connect 3 0 2 0;
#P connect 5 0 2 0;
#P connect 6 0 2 0;
#P connect 7 0 2 0;
#P connect 8 0 2 0;
#P connect 1 0 0 0;
#P connect 9 0 0 0;
#P window clipboard copycount 10;

#96374
Feb 14, 2007 at 4:09pm

On Feb 14, 2007, at 1:42 AM, Mattijs Kneppers wrote:

> How about defining a global variable in javascript and binding
> another javascript to it. Like so:

Whoa.

I’ve tended to avoid learning and using javascript, since I seem to
remember reading on this list that there is a CPU hit in going from
Max to JS and back again.

Urban myth? Inconsequential difference?

What say you, oh javascript master?

#96375
Feb 14, 2007 at 4:33pm

depends on what CPU you have. I mean, with a core 2 duo or a woodcrest processor,… don’t even worry about it. Not that there was even so much as a chip off my old athlon 3000.

#96376
Feb 14, 2007 at 5:18pm

Ha!

Urban myth.

On Feb 14, 2007, at 4:09 PM, Arne Eigenfeldt wrote:

>
> On Feb 14, 2007, at 1:42 AM, Mattijs Kneppers wrote:
>
>> How about defining a global variable in javascript and binding
>> another javascript to it. Like so:
>
> Whoa.
>
> I’ve tended to avoid learning and using javascript, since I seem to
> remember reading on this list that there is a CPU hit in going from
> Max to JS and back again.
>
> Urban myth? Inconsequential difference?
>
> What say you, oh javascript master?

#96377
Feb 14, 2007 at 7:41pm

On 14-Feb-2007, at 18:18, evan.raskob [lists] wrote:
> Urban myth.

Offhand I’m not sure about JScript, but there is a measurable
performance hit in switching between Max and Java contexts. In many
situations the hit would qualify as inconsequential. But it is there
and as much of an urban myth as Bernhard Goetz.

————– http://www.bek.no/~pcastine/Litter/ ————-
Peter Castine +–> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de

#96378
Feb 15, 2007 at 9:22am

Quote: arne wrote on Wed, 14 February 2007 17:09
—————————————————-
>
> On Feb 14, 2007, at 1:42 AM, Mattijs Kneppers wrote:
>
> > How about defining a global variable in javascript and binding
> > another javascript to it. Like so:
>
> Whoa.
>
> I’ve tended to avoid learning and using javascript, since I seem to
> remember reading on this list that there is a CPU hit in going from
> Max to JS and back again.
>
> Urban myth? Inconsequential difference?
>
> What say you, oh javascript master?

Whoa, plz, not so much honor. All I do is studying the cycling documentation and this website http://javascript-reference.info/

My opinion about the speed issue: when I make something in js I always promise myself to do it in C as soon as I have the time. I never have the time, so I end up using js. I never researched the speed drawback but my patches do run on mac pro 4 x 2,7 ghz computers ;)

Mattijs

#96379
Feb 15, 2007 at 9:50am

I documented the speed issues at one point with Josh Goldbergs class
last year – no idea how correct this is, but it might be of interest.

Forgive the obnoxious comments – Half notes for the class, half
‘performance’ notes for myself when giving the overview.

On my Macbook Pro (and on my Powerbook G4), I get that JS is between
4.5 to 2 times slower depending what you are doing.

Note that, this is the most simplistic and non scientific test… ever.


On Feb 15, 2007, at 4:22 AM, Mattijs Kneppers wrote:

>
> Quote: arne wrote on Wed, 14 February 2007 17:09
> —————————————————-
>>
>> On Feb 14, 2007, at 1:42 AM, Mattijs Kneppers wrote:
>>
>>> How about defining a global variable in javascript and binding
>>> another javascript to it. Like so:
>>
>> Whoa.
>>
>> I’ve tended to avoid learning and using javascript, since I seem to
>> remember reading on this list that there is a CPU hit in going from
>> Max to JS and back again.
>>
>> Urban myth? Inconsequential difference?
>>
>> What say you, oh javascript master?
>
> Whoa, plz, not so much honor. All I do is studying the cycling
> documentation and this website http://javascript-reference.info/
>
> My opinion about the speed issue: when I make something in js I
> always promise myself to do it in C as soon as I have the time. I
> never have the time, so I end up using js. I never researched the
> speed drawback but my patches do run on mac pro 4 x 2,7 ghz
> computers ;)
>
> Mattijs
> –
> SmadSteck – http://www.smadsteck.nl
> Interactive audiovisual sampling soft- and hardware
>

v a d e //

http://www.vade.info
abstrakt.vade.info

#96380
Feb 15, 2007 at 9:54am

Hi vade,

That’s interesting. It looks like you attached something, but I can’t read it.

Mattijs

Quote: vade wrote on Thu, 15 February 2007 10:50
—————————————————-
> I documented the speed issues at one point with Josh Goldbergs class
> last year – no idea how correct this is, but it might be of interest.
>
> Forgive the obnoxious comments – Half notes for the class, half
> ‘performance’ notes for myself when giving the overview.
>
> On my Macbook Pro (and on my Powerbook G4), I get that JS is between
> 4.5 to 2 times slower depending what you are doing.
>
> Note that, this is the most simplistic and non scientific test… ever.
>
> 
> On Feb 15, 2007, at 4:22 AM, Mattijs Kneppers wrote:
>
> >
> > Quote: arne wrote on Wed, 14 February 2007 17:09
> > —————————————————-
> >>
> >> On Feb 14, 2007, at 1:42 AM, Mattijs Kneppers wrote:
> >>
> >>> How about defining a global variable in javascript and binding
> >>> another javascript to it. Like so:
> >>
> >> Whoa.
> >>
> >> I’ve tended to avoid learning and using javascript, since I seem to
> >> remember reading on this list that there is a CPU hit in going from
> >> Max to JS and back again.
> >>
> >> Urban myth? Inconsequential difference?
> >>
> >> What say you, oh javascript master?
> >
> > Whoa, plz, not so much honor. All I do is studying the cycling
> > documentation and this website http://javascript-reference.info/
> >
> > My opinion about the speed issue: when I make something in js I
> > always promise myself to do it in C as soon as I have the time. I
> > never have the time, so I end up using js. I never researched the
> > speed drawback but my patches do run on mac pro 4 x 2,7 ghz
> > computers ;)
> >
> > Mattijs
> > –
> > SmadSteck – http://www.smadsteck.nl
> > Interactive audiovisual sampling soft- and hardware
> >
>
> v a d e //
>
> http://www.vade.info
> abstrakt.vade.info
>
>
>
>
>
>
—————————————————-

#96381
Feb 15, 2007 at 9:55am

Arne Eigenfeldt wrote:
> As I said, it is a workaround, and it works fine, but I’m suggesting
> some consistency between data objects.

Its not a workaround, its the way to do it and tell value to what to
refer to, and if you need to change the reference you’d use pattr
instead of value… Has uncountable other advantages as well…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#96382
Feb 15, 2007 at 10:05am

And due to my idiocy, and not using the current index for uzi (for
some stupid reason I was using counter.. heh), I now have javascript
being on the order of 20 times slower with outputting ints, and 8
times slower when just iterating internally.

Not that one would ever use code like this, but it is interesting
none the less.

On Feb 15, 2007, at 4:50 AM, vade wrote:

> I documented the speed issues at one point with Josh Goldbergs
> class last year – no idea how correct this is, but it might be of
> interest.
>
> Forgive the obnoxious comments – Half notes for the class, half
> ‘performance’ notes for myself when giving the overview.
>
> On my Macbook Pro (and on my Powerbook G4), I get that JS is
> between 4.5 to 2 times slower depending what you are doing.
>
> Note that, this is the most simplistic and non scientific test…
> ever.
>
>
>
>
>
> On Feb 15, 2007, at 4:22 AM, Mattijs Kneppers wrote:
>
>>
>> Quote: arne wrote on Wed, 14 February 2007 17:09
>> —————————————————-
>>>
>>> On Feb 14, 2007, at 1:42 AM, Mattijs Kneppers wrote:
>>>
>>>> How about defining a global variable in javascript and binding
>>>> another javascript to it. Like so:
>>>
>>> Whoa.
>>>
>>> I’ve tended to avoid learning and using javascript, since I seem to
>>> remember reading on this list that there is a CPU hit in going from
>>> Max to JS and back again.
>>>
>>> Urban myth? Inconsequential difference?
>>>
>>> What say you, oh javascript master?
>>
>> Whoa, plz, not so much honor. All I do is studying the cycling
>> documentation and this website http://javascript-reference.info/
>>
>> My opinion about the speed issue: when I make something in js I
>> always promise myself to do it in C as soon as I have the time. I
>> never have the time, so I end up using js. I never researched the
>> speed drawback but my patches do run on mac pro 4 x 2,7 ghz
>> computers ;)
>>
>> Mattijs
>> –
>> SmadSteck – http://www.smadsteck.nl
>> Interactive audiovisual sampling soft- and hardware
>>
>
> v a d e //
>
> http://www.vade.info
> abstrakt.vade.info
>
>
>

v a d e //

http://www.vade.info
abstrakt.vade.info

#96383
Feb 15, 2007 at 10:15am

Try this?

#96384
Feb 15, 2007 at 10:29am

Quote: vade wrote on Thu, 15 February 2007 11:15
—————————————————-
>
>
> Try this?
>
>
>
>
>
—————————————————-

Uhh.. nothing. Do you see an attachment in your submitted post? I see nothing.

#96385
Feb 15, 2007 at 10:37am

I see one.

wes

On 2/15/07, Mattijs Kneppers wrote:
>
> Quote: vade wrote on Thu, 15 February 2007 11:15
> —————————————————-
> >
> >
> > Try this?
> >
> >
> >
> >
> >
> —————————————————-
>
> Uhh.. nothing. Do you see an attachment in your submitted post? I see nothing.
> –
> SmadSteck – http://www.smadsteck.nl
> Interactive audiovisual sampling soft- and hardware
>
>

#96386
Feb 15, 2007 at 11:41am

I’m sure that JKC has a more complete explanation, but as people have
said before this is mostly due to the spitting out ints part of the
patch. Any data passing thru the Max/js boundary via outlets or
inlets (same with Java) takes a decent-sized performance hit. If you
remove the “outlet” call in js, even without overdrive on I get a
value of ~3x slower than max (max=~55-60, js=~170). For the patch,
instead of using timer I used cpuclock, because timer depends on the
max scheduler apparently and I seem to get more consistent results
with cpuclock (can someone confirm this?)

So I would never output 1,000,000 numbers-per-bang using js.
Comparing it to uzi is like comparing the engines of a passenger
train and a Porsche. Each is only a piece of the puzzle. Instead, I
would compare the result of a computational for loop in max using uzi
vs. a computational for loop in js that only spit out the result at
the end.

But the patch does show the inlet/outlet penalty pretty well, so it’s
goo to show new users how NOT to use js. Here’s a slightly modified
version, comments appreciated. I might use this in a workshop.

http://lowfrequency.org/maxmspjitter/js-vs-max.zip

cheers
evan

On Feb 15, 2007, at 10:05 AM, vade wrote:

> And due to my idiocy, and not using the current index for uzi (for
> some stupid reason I was using counter.. heh), I now have
> javascript being on the order of 20 times slower with outputting
> ints, and 8 times slower when just iterating internally.
>
> Not that one would ever use code like this, but it is interesting
> none the less.
>
> On Feb 15, 2007, at 4:50 AM, vade wrote:
>
>> I documented the speed issues at one point with Josh Goldbergs
>> class last year – no idea how correct this is, but it might be of
>> interest.
>>
>> Forgive the obnoxious comments – Half notes for the class, half
>> ‘performance’ notes for myself when giving the overview.
>>
>> On my Macbook Pro (and on my Powerbook G4), I get that JS is
>> between 4.5 to 2 times slower depending what you are doing.
>>
>> Note that, this is the most simplistic and non scientific test…
>> ever.
>>
>>
>>
>>
>>
>> On Feb 15, 2007, at 4:22 AM, Mattijs Kneppers wrote:
>>
>>>
>>> Quote: arne wrote on Wed, 14 February 2007 17:09
>>> —————————————————-
>>>>
>>>> On Feb 14, 2007, at 1:42 AM, Mattijs Kneppers wrote:
>>>>
>>>>> How about defining a global variable in javascript and binding
>>>>> another javascript to it. Like so:
>>>>
>>>> Whoa.
>>>>
>>>> I’ve tended to avoid learning and using javascript, since I seem to
>>>> remember reading on this list that there is a CPU hit in going from
>>>> Max to JS and back again.
>>>>
>>>> Urban myth? Inconsequential difference?
>>>>
>>>> What say you, oh javascript master?
>>>
>>> Whoa, plz, not so much honor. All I do is studying the cycling
>>> documentation and this website http://javascript-reference.info/
>>>
>>> My opinion about the speed issue: when I make something in js I
>>> always promise myself to do it in C as soon as I have the time. I
>>> never have the time, so I end up using js. I never researched the
>>> speed drawback but my patches do run on mac pro 4 x 2,7 ghz
>>> computers ;)
>>>
>>> Mattijs
>>> –
>>> SmadSteck – http://www.smadsteck.nl
>>> Interactive audiovisual sampling soft- and hardware
>>>
>>
>> v a d e //
>>
>> http://www.vade.info
>> abstrakt.vade.info
>>
>>
>>
>
> v a d e //
>
> http://www.vade.info
> abstrakt.vade.info
>
>
>

#96387
Feb 15, 2007 at 12:03pm

#96388
Feb 15, 2007 at 2:28pm

#96389
Feb 15, 2007 at 3:48pm

#96390

You must be logged in to reply to this topic.