Real-time analysis of sound lets us create audio-reactive visuals. It is an important part of any video synthesizer. Here, we consider the simplest case of analysis—getting the level of sound and using it to control a parameter of our project.
We consider two ways of getting a sound: by playing an audio file and by capturing a sound from the sound card's input.
openFrameworks has a powerful class for audio file playback, called
ofSoundPlayer. It loads an audio file of various formats, including MP3, WAV, and AIFF, plays it, and controls its basic parameters, such as volume, pan, and speed.
Let's use this class to play an audio file by performing the following ...