Noob: Storing & recalling "synthesizer patches"

You should post the part of your code where you declare ~midiFighter_encoders and ~init_sound.

I had to make a few assumptions about what types of objects these were, and I assumed they’d be Events or IdentityDictionaries. With either, I was able to make your example work as you expected it to:

~midiFighter_encoders = [(), (), (), ()]
~midiFighter_encoders[0].put(\parameter, \freq)
~midiFighter_encoders[0].at(\parameter); // returns freq
~init_sound = ()
~init_sound.put(\freq, 50)
~init_sound.at( \freq ); // returns 50

~init_sound.at( ~midiFighter_encoders[0].at(\parameter) ); // returns 50!!

Perhaps you entered ~midiFighter_encoders[0].put(\parameter, "freq") instead? In which case it makes sense that you received nil.

The big difference between symbols and strings is the difference between “equality” and “identity”. Two symbols with the exact same set of characters are both equal and identical to one another, two strings are equal, but not identical:

\test == \test // test equivalence: returns true
\test === \test // test identity: returns true
"test" == "test" // test equivalence: returns true
"test" === "test" // test identity: returns false

There was a good thread on this recently: Arrays by Reference (?) The put method

I often use the class message to verify things when I get unexpected behavior.

Eg, evaluating ~midiFighter_encoders[0].at(\parameter).class returns Symbol in the post window for me. Yours likely returns something different.

1 Like