Hello all,
I’m writing a bunch of MIDIdefs to have a small midi controller transform arrays on the fly.
i bet my approach is pretty cumbersome but i wanted to start small
one of the things i want to do is to be able to store an array for later recall. for which i thought i could use the same logic as this:
~a = [1, 2, 3]; // original array
~ab = ~a; // make a copy, new name
~ab; // test, same contents as ~a
~a = [1, 2, 3, 100, 800] // change ~a
~ab // still keeps old contents. success.
However, when i try with the MIDIdefs something goes wrong as the copy array, called ~bbb, does not seem to hold the values, as if they were being updated or something.
Here are 3 MIDIdefs: first one modifies the current array which serves as the note sequence, and the other 2 are supposed to do the storing and recalling of the array.
(
MIDIdef.cc(\cc5, {arg key, ccNum;
~position = rrand(0, ~nnn.size-1); ~da_one = ~nnn.at(~position); ~nnn.put(~position, (40..80).choose); Pdefn(\notes, Pseq(~nnn, inf));
~nnn.postln;
}, 5).permanent_(true);
);
(
MIDIdef.cc(\cc6, {arg key, ccNum;
~bbb = ~nnn; // saves current state of ~nnn by copying to a new array called ~bbb
“SAVED!”.postln;
~bbb.postln;
}, 6).permanent_(true);
);
(
MIDIdef.cc(\cc7, {arg key, ccNum;
Pdefn(\notes, Pseq(~bbb, inf)); // go back!
“revert!”.postln;
~bbb.postln;
}, 7).permanent_(true);
);
What am i missing?
Many thanks!