So here is some weird behavior: When I create a list inside a loop whose elements are Play functions, with arguments that depend on the counter, it is as if the counter is being stored symbolically, so all the list elements - not just the last one - change with each iteration. THis only happens with Play. If I do the same thing with Plot, for example, it works as expected. Here is an example, though I have also tried creating the list using Append and AppendTo, I have assigned the outputs, etc. list1 has every part the same, and all equal to the result with the current value of i. list2 has each part equal to what it was when it was first created (so the first with the results evaluated with i=1, the second with i=2, etc.). Why? How do I fix Play?
list1 = {0, 0, 0};
list2 = list1;
Do[
list1[[i]] = Play[Cos[150*i*2*Pi*t], {t, 0, 0.5}];
list2[[i]] = Plot[Cos[i*2*Pi*t], {t, 0, 0.5}];
Print[list1, list2],
{i, 3}
]
Show[list1]
Show[list2]
list1
list2
Sound
? $\endgroup$