I approached this by generating a table with a specified frequency and length for a tone. I then assign the tone generated to one of two tones: Tone 1 and Tone 2. The two tones generated can then be combined.
I haven't followed or understood all of the discussion about appropriate ways to use (or not to use variables), but it would appear that the method that that I have used to assign the tone generated to "Tone 1" or "Tone 2" is not the preferred way. I'm happy to do this in a different way if someone will explain how to do this in the preferred manner.
BTW, I've been using this method since it was first demonstrated in Logo. However, if Snap! has new, better affordances, I'm happy to adopt them.
The playback rate of 12000 Hz was chosen for convenience. A 1000 Hz tone with 12 samples per cycle requires a playback rate of 12000 Hz. Once that value is arbitrarily chosen, a 100 Hz tone will have 120 samples per cycle. I wanted a result that sounds reasonably good and provides sufficient resolution in the graph.
I can create a list of tones. But then how do I use "Item Number of Tone List" to assign a frequency table to one of the two variables (Tone 1 or Tone 2)?
It is not that the list of lists does not meet my needs; it is just that I don't know how to use it to assign a list of numbers (i.e., the frequency table) to one of two variables. ... If someone could provide an example demonstrating how this is accomplished, I would do it that way.
P.S. I initialize the variable by setting to a list because an error is generated if I try to assign a list of numbers to a variable that is not a list. Once it is initialized the first time, it is redundant, so I could probably remove it.
I'm off by one level of abstraction. I would actually like the variable "Tone 1" (formerly containing the list [a b]) to be replaced with the list [f g]. However, Item 1 of Tone List is actually replaced with [f g], not the variable Tone List. (It seems to have done what I told it to do, not what I wanted it to do.) Is there a way to shift the pointer so that it is directed at Tone 1, and not Item 1 of Tone List?
Just delete the variables Tone 1 and Tone 2, and stop thinking in those terms! (If you want to display JOIN [Tone] TONE-NUMBER to the user, go for it.) The one variable TONE LIST should be the only repository of tones. You can write a selector
TONE %NUM
REPORT ITEM (NUM) OF (TONE LIST)
if you want.
I revised the tone generator and placed each waveform in a tone repository table as suggested. This worked well. I appreciate the suggestions and help.
This raised a question regarding documentation. When I used the variable name "Tone 1" for Tone 1 and "Tone 2" for Tone 2, the name of the variable provided guidance regarding the contents. When a table is used in place of individual variables, the contents of each item in the table are not obvious. I could add a header at the beginning of each line in the table, but then the code would become more convoluted. Any suggestions regarding the best way to indicate to a user that the first item in the table is "Tone 1", the second item is "Tone 2", etc.? (Thanks)
Our students (pre-service teachers with no prior coding experience) generally find lists to be intuitive. Lists of lists seem less intuitive. For someone with prior experience, it may be apparent that the first item is Tone 1, the second item is Tone 2, etc. That may not necessarily be the case for a novice.
Therefore we were considering the possibility of adding a header at the beginning of each item to make the contents more apparent.
The capability of hyperblocks to add two lists is fantastic! I have a colleague who is a math educator. He believes that it is useful for teachers to understand that, in his words, "A function can be thought of not only as a process, but also as an object that can be multiplied by another object."
Joe used to introduce the concept by asking students to multiply one function by another by hand; this could take most of a class period. Hyperblocks can do this in a single click ... and, in the case of tones, you can hear the result. (The illustration below involves addition, but Joe immediately used the same capability to multiply two tones, etc.)