Zumi can play sounds to match her emotions! Sound can be measured in frequency and amplitude.
- Frequency is the number of pulses or vibrations per second, and is measured in hertz. The higher the frequency, the higher the pitch of the sound is.
- Amplitude is how loud or strong the sound is and is measured in decibels. The higher the amplitude, the louder the sound is.
Video: Sound: Wavelength, Frequency, and Amplitude
What does each emotion sound like? Is happy a low or high frequency? Is angry a low or high amplitude? How does this apply to Zumi?
You can use play_note()
to play various notes. The first parameter is the note you want to play (anywhere from C2 to B6). The second parameter is optional and denotes the amount of time you want the note to play in milliseconds. The default value is set to 500ms, but you can change that by adding a second parameter like this:
play note(Note.GS3, 400)
This plays the note G sharp below middle C for 400 milliseconds. Try the code below to hear a scale and then compose your own music!
from zumi.protocol import Note
zumi.play_note(Note.C4)
zumi.play_note(Note.D4)
zumi.play_note(Note.E4)
zumi.play_note(Note.F4)
zumi.play_note(Note.G4)
zumi.play_note(Note.A4)
zumi.play_note(Note.B4)
zumi.play_note(Note.C5)
Code your own sounds for happy, sad, angry, or excited. Try out different melodies until you find your favorites.