[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Env.levels problem - unexpected post window output



Hi Dominik,

do

~tempenv = ~wenv.copy

if you want to have two different arrays.

The way you did it, both variables point to the same object.

Cheers,
eddi




--
https://soundcloud.com/all-n4tural
https://alln4tural.bandcamp.com


On 28/12/2019, 13:32 vdom.kunz@xxxxxxxxxxxxxx wrote:
Dear All,

I am stuck with the following pretty simple problem...

(
~wenv = Env(levels: Array.fill(3, {arg j; j}), times: Array.fill(2, {arg
j; 1/2;}), curve: \lin);
("~wenv before:" + ~wenv.levels).postln;

~tempenv = ~wenv;
~tempenv.levels = ~tempenv.levels*2; // update

("~wenv after:" + ~wenv.levels).postln;
("temp:" + ~tempenv.levels).postln;
)

where the console output is...

~wenv before: [ 0, 1, 2 ]
~wenv after: [ 0, 2, 4 ]
temp: [ 0, 2, 4 ]
-> temp: [ 0, 2, 4 ]

I expected the following:

~wenv after:[ 0, 1, 2 ], or in other words ~wenv not to be modified.

I take it, it is me again having an issue with the concept of classes, no?

Many thanks in advance

Dominik



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________ sc-users mailing list info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx archive: https://listarc.bham.ac.uk/marchives/sc-users/ search: https://listarc.bham.ac.uk/lists/sc-users/search/