This chapter is intended to highlight the difference between forever loops and repeat blocks in make-code. Eventually, you might find yourself in a situation where one loop is better than the other. In this demonstration, you will see how one cat make both make-code blocks do, essentially, the same thing.
The first program simply plays a “Middle C” tone for 2 beats at the start and that is it. It is a very simple program, but there is more going on behind the blocks. Like I showed in my last chapter, the blocks, beats, and tones only mean something to the CPX because the programmers of make-code previously defined these functions and variables.
The second program plays a set of tones separated by pauses in a forever loop. The first tone is a middle C for 2 beats, then a high B for 2 beats, and finally a low C for 4 beats. Once the third tone is done playing it starts with the first one again. This explores how make code uses forever loops and also how order matters.
The third program aims to do the same as the second program. At the start it plays the same 3 tones and then repeats them so many times that it approximates the forever loop. This explores the different kinds of loops and how they contrast and compare to each other.