Play a sequence of tones?


#1

Hi,

Brand-new to mBlock. Looking for an efficient way to play a series of tones.

In Scratch, I can play a continuously rising or falling tone by writing a loop that repeatedly changes the frequency. But in mBlock, each tone has a name (such as C4), and there doesn’t seem to be a “next tone” type of command.

If I want to play a series of rising or falling tones, do I really need to specify each one in a separate command?

Thanks.


#2

The names are associated with the frequency of each note (from mBot.s2e):

"B0":31,"C1":33,"D1":37,"E1":41,"F1":44,"G1":49,"A1":55,"B1":62,
"C2":65,"D2":73,"E2":82,"F2":87,"G2":98,"A2":110,"B2":123,
"C3":131,"D3":147,"E3":165,"F3":175,"G3":196,"A3":220,"B3":247,
"C4":262,"D4":294,"E4":330,"F4":349,"G4":392,"A4":440,"B4":494,
"C5":523,"D5":587,"E5":659,"F5":698,"G5":784,"A5":880,"B5":988,
"C6":1047,"D6":1175,"E6":1319,"F6":1397,"G6":1568,"A6":1760,"B6":1976,
"C7":2093,"D7":2349,"E7":2637,"F7":2794,"G7":3136,"A7":3520,"B7":3951,
"C8":4186,"D8":4699

To get the effect you are after, you will need to create a list and stuff the note names into it, then iterate over the list. Tragically, this approach may require more memory than is available on the mBot at least if you plan to use all of the notes.


#3

Thanks - not the answer I was hoping for, but probably the one I expected. I appreciate your taking the time to share that info with me!


#4

No worries, I ran up against a lot of those things when I wrote my eBook (link) on using mBlock and the mBot.