If you're insane and have way too much time on your hands, or if you just want to experiment. Be my guest!
This program makes music using math! Don’t worry if you don’t know much about music or programming – here’s how it works:
Sounds are just vibrations that travel through the air. In this program, we can create sounds by making numbers that move up and down, which is like creating those vibrations. This is done using something called a **wave**.
In this code, we use two types of waves:
freq
controls the pitch of the sound (how high or low it is). A higher number makes a higher sound, and a lower number makes a lower sound.freq
controls the pitch.tri(t, freq)
or sq(t, freq)
to change the sound. For example, change the freq
value to make the sound higher or lower.Each time you press "Play," the computer runs the code in the box. The code tells the computer how to generate sound based on math. By changing the numbers and formulas in the code, you’re changing the way the sound is made!