If you're insane and have way too much time on your hands, or if you just want to experiment. Be my guest!
0.5
How This Works (for Complete Beginners)
This program makes music using math! Don’t worry if you don’t know much about music or programming – here’s how it works:
How Sounds are Made
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:
Triangle Wave (smooth sound)
Square Wave (sharp, robotic sound)
What Do the Functions Do?
tri(t, freq): This makes a **triangle wave**, which creates a smooth sound. The 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.
sq(t, freq): This makes a **square wave**, which is a more robotic, sharp sound. Again, freq controls the pitch.
melp(t): This function creates a slight change in the sound over time, which keeps it from being too boring.
plikif(t, leftpan): This is the main function that puts everything together. It mixes different types of waves and moves the sound between the left and right speakers.
Try It Yourself!
Change the numbers inside tri(t, freq) or sq(t, freq) to change the sound. For example, change the freq value to make the sound higher or lower.
Press the "Play" button to hear how your changes affect the sound.
Use the volume control slider to adjust the sound volume.
What’s Happening?
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!