MUS 270D: Advanced Projects in Computer Music
Sound Synthesis for Computer Animation
The images, motion, and sounds of the animation below
were generated entirely by a computer. The images were computed at 60 Hz, the motion was computed at 240 Hz, and the
sounds were computed at 48,000 Hz. Each sound event consisted of a pure tone modified by an attack-decay-release (ASR)
volume envelope. From left to right in the animation, the spheres played frequencies of 220 Hz, 440 Hz, and 880 Hz. Following the main computation,
the audio and video were automatically combined using FFmpeg. The computation was performed using C++, and the
graphics were rendered using OpenGL. The main computation took the following general form:
for (int i = 0; i < 60; i++) {
// render images of falling spheres at 60 Hz
for (int j = 0; j < 4; j++) {
// update sphere motion at 60 \(\times\) 4 = 240 Hz
for (int k = 0; k < numberOfSpheres; k++) {
// advance position of each sphere using forward Euler method
// initialize new sound event if sphere collides with floor
for (int w = 0; w < 200; w++) {
// compute audio samples for each sound event at 60 \(\times\) 4 \(\times\) 200 = 48,000 Hz
}
}
}
}