In order to capture the elements in sounds to produce drawing, we’ve found a library named Minim built in Processing that could be used for audio acquisition, including playing a media file as well as audio input. The library uses a buffer to store the values from left, right and mix channel. The get(i) function can access the values, which represents the amplitude/volume ranging from -1 to 1 and the fft.getBand(i) function returns frequency. These are the values we use to define the color for drawing and how the pen would move.
A sample is a measurement of the amplitude of the audio source at a particular moment in time. Amplitude defines a range of values, but can also be thought of as representing volume. This Processing code is a visualisation of the changing amplitude and the waveform is drawn by connecting neighbor values with a line. But as is printed in the console, the original amplitude data being read are small values between -1 and 1, we need to scaled up the values, multiplied them by 50 in order to display more significant changes, or the waveform will look like a straight line.
The minim library can also map the amplitude in stereo signal. in.left.get() or in.right.get() maps the amplitude of left or righeside in a stereo signal, while in.mix.get() maps the average amplitude between the left and right sides in a stereo signal and we are using the captured data from this function to represent the volume of audio input from users. The frequency spectrum is drawn as a series of vertical lines, multiplied by 4 to see the lines better.
In this code the console read the frequency values, according to which we define the low, middle and high frequency and each of them has a corresponding color. Blue to represent a value from low frequencies (40-300Hz), Red from middle frequencies (301-1500Hz) and Green from high (1501-10000Hz).