Question: Audio collage. Create a library to manipulate digital audio and use that library to create an audio collage. As in lecture, we will represent sound

Audio collage. Create a library to manipulate digital audio and use that library to create an audio collage. As in lecture, we will represent sound as an array of real numbers between 1 and +1, with 44,100 samples per second. You will write a library of functions to produce audio effects by manipulating such arrays.

  • Amplify. Create a new sound that contains the same samples as an existing sound, but with each sample multiplied by a constant . This increases the volume when >1 and decreases it when 0
  • Reverse. Create a new sound that contains the same samples as an existing sound, but in reverse order. This can lead to unexpected and entertaining results.
  • Merge/join. Create a new sound that combines two existing sounds by appending the second one after the first. If the two sounds have m and n samples, then the resulting sound has m + n samples. This enables you to play two sounds sequentially.
  • Mix/overlay. Create a new sound that combines two existing sounds by summing the values of the corresponding samples. If one sound is longer than the other, append 0s to the shorter sound before summing. This enables you to play two sounds simultaneously.
  • Change speed. Create a new sound that changes the duration of an existing sound via resampling. If the existing sound has n samples, then the new sound has n/ samples for some constant >0>0, with sample i of the new sound having the same amplitude as sample ii of the existing sound.

To do so, organize your program according to the following public API:

Audio collage. Create a library to manipulate digital audio and use that

Here is some more information about the required behavior:

  • The functions must not mutate the argument array(s).
  • You may assume that the array arguments are not null and that >0>0 in changeSpeed().
  • The main() method must create an audio collage and play it using StdAudio.play().
    • Do not use any command-line arguments.
    • The duration must be between 10 and 60 seconds (441,000 to 2,646,000 samples).
    • All samples sent to standard audio must be between 1 and +1.
    • It must use at least five different WAV files. Several WAV files are provided: beatbox.wav, buzzer.wav, chimes.wav, cow.wav, dialup.wav, exposure.wav, harp.wav, piano.wav, scratch.wav, silence.wav, and singer.wav. You may also supply or create your own.
    • Use StdAudio.read() to read a WAV file and extract its samples as an array of floating-point numbers between 1 and +1.
    • It must use all of the audio effects specified in the API (amplify, reverse, merge, mix, and change speed). Feel free to add additional audio effects (see the FAQ for some ideas).
    • Be creative!

public class AudioCollage { // Returns a new array that rescales a[] by a multiplicative factor of alpha. public static double[] amplify (double[] a, double alpha) // Returns a new array that is the reverse of a[]. public static double[] reverse (double[] a) // Returns a new array that is the concatenation of a[] and b[]. public static double[] merge (double[] a, double[] b) // Returns a new array that is the sum of a[] and b[], // padding the shorter arrays with trailing Os if necessary. public static double[] mix (double[] a, double[] b) // Returns a new array that changes the speed by the given factor. public static double[] changeSpeed (double[] a, double alpha) // Creates an audio collage and plays it on standard audio. // See below for the requirements. public static void main(String[] args) }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!