Raw Data and the Sound Spectrum
With the arrival of digital sound, a new art form quickly followed: the visualization of sound.
Note
A sound waveform is the shape of the graph representing the amplitude of a sound over time. The amplitude is the distance of a point on the waveform from the equilibrium line, also called the time-domain. The peak is the highest point in a waveform.
You can read a digital signal to represent sound in real time using amplitude values.
Note
Making Pictures of Music is a project run by mathematics and music academics that analyses and visualizes music pieces. It uses Unsquare Dance, a complex multi-instrumental piece created by Dave Brubeck. For more information, go to http://www.uwec.edu/walkerjs/PicturesOfMusic/MultiInstrumental%20Complex%20Rhythm.htm.
In AIR, you can draw a sound waveform using the computeSpectrum
method
of the SoundMixer
class. This method
takes a snapshot of the current sound wave and stores the data in a
ByteArray
:
SoundMixer.computeSpectrum(bytes, false, 0);
The method takes three parameters. The first is the container
ByteArray
. The second optional
parameter is FFTMode
(the fast
Fourier transform); false
, the
default, returns a waveform, and true
returns a frequency spectrum. The third optional parameter is the
stretch factor; 0 is the default and represents 44.1 kHz. Resampling at
a lower rate results in a smoother waveform and a less detailed
frequency. Figure 11-1
shows the drawing generated from this data.
Figure 11-1. A waveform (top) ...
Get Developing Android Applications with Adobe AIR now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.