In Western music, we represent the "notes" in music with letters from A through G. Those notes correspond to specific tone frequencies - in fact, the same frequencies that we've been using with the buzzer. You could recreate your favorite songs using just the appropriate frequencies, but the Maker Toolkit includes a buzzer.note()
command that looks up the appropriate values for you.
Frequency | Note It Maps To |
---|---|
261 | C4 |
277 | C#4 |
293 | D4 |
311 | D#4 |
329 | E4 |
349 | F4 |
369 | F#4 |
392 | G4 |
415 | G#4 |
440 | A4 |
466 | A#4 |
493 | B4 |
523 | C5 |
The chart to the right shows one set of notes starting with C4, also known as "middle" C, and each of the notes' corresponding frequency.
buzzer.note()
simplifies this. Instead of passing it a frequency to play, like buzzer.frequency
, you just give it the note that you want to be played. This can include sharp notes as well, so long as you include the "#" after the note.
The buzzer can play each note on one of eight octaves. When passing any note into the buzzer.note()
method, you'll include the octave you want that note to be at too. "C4", for example, if you want to play the middle C note, "C1" if you want the lowest possible C note, and "C8" if you want the highest possible C note. If you don't specify this, then the notes will automatically play at the 4th octave.
For the best possible sound, you should stay in octave 4. Anything lower than the 4th or higher than 6th octaves tend to sound distorted on the buzzer.
Found a bug in the documentation? Let us know at documentation@code.org