Forums > Gen

Gen Param and initialization?


Jan 23 2017 | 2:16 pm

Hi, a question around genExpr "Param" object and initialization – see the attached patcher.

When opening the patch you will get the message "gen~ * invalid attribute testy" – which I don’t expect.

You will also note that the genexpr Param object ‘testy’ is not initialized with the gen~ attribute value of 1000, as set in the gen~ object with "@testy 1001".

However when you change the @testy attribute on the gen~ object, the value is reflected correctly.

Also if you press the "testy" message, it is reflected correctly.

So it seems only to fail during initialization – what am I doing wrong?

"version" : "Version 7.3.1 (340a77a) (32-bit mac)",
"platform" : "mac",
"arch" : "x86",
"osversion" : "Mac OS X Version 10.12.2 x86_64",

Thanks!

/Gert

Attachments:
  1. gen_param.maxpat
Jan 25 2017 | 7:37 am

My description was a bit clumsy. In short: I have a patch with an gen~ object that should be initialized through the use of attributes, like this:

gen~ @testy 1001

Inside the gen~ object there is a codebox declaring "Param testy(100);" in the first line.

I would expect that when opening the patch containing the gen~ object, that it would just be initialized with the value ‘1001’. This is exactly what happens while I’m in edit mode – I can modify the value of @testy as I want and the change is reflected in the gen~ output.

However when I open the patch for the first time, instead i see "gen~ * invalid attribute testy" in the max window. Also the value of @testy is not reflected in the gen~ output then.

So I’m not sure if this is a bug or by design – but to me the behavior is unexpected. Otherwise there is some initialization order logic that I can’t come up with a good way of adressing.

Can anyone cast some light on this behavior? Thanks :)

Jan 25 2017 | 9:10 am

You don’t declare the attribute in the gen~ object’s argument. If you want to declare params in arguments, I think it works in gen~ subpatches, and not in the top-level gen~ object. But I haven’t tried it. I do know, if you declare a Param in a codebox, these days you don’t need to declare it outside the codebox for it to alias with the external environment, unless the codebox is in a gen~ subpatch.

Jan 25 2017 | 2:14 pm

Thanks Ernest

I think you would use setparam when communicating to a subpatcher, but I guess that’s a bit different scenario than this.

I just puzzles me that after opening the patch, changing the @testy value directly on the gen~ object does propagate to the codebox. So it seems that it is actually designed for that, but that the initialization order somehow is wrong. How to fix that though I don’t know.

Any other ideas?

/Gert

Jan 26 2017 | 6:08 am

Thank you for the information. As I say, you dont need both declarations. I wont have anything further to say to you..

Jan 26 2017 | 7:55 am

np, thanks Ernest.

Hope someone else in this forum can shed light on this behavior.

/Gert

Jan 26 2017 | 3:03 pm

Hi there,

[gen~ @testy 1001] should work in the next update.

Graham

Jan 26 2017 | 11:24 pm

Awesome!! Thanks Graham.

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

Forums > Gen