Write a Guitar Hero program that uses a queue to simulate the creation of guitar notes. When a guitar string is plucked, it vibrates to generate sound. The sound starts from the note’s initial note pitch or frequency, then it undergoes a wave-like oscillation and gradually fades in volume over time.
The oscillation and fading of notes can be computed using an algorithm called Karplus-Strong. The algorithm represents sound as time slices called samples (44,100 samples per second, in this case). You can compute samples that sound similar to the vibrations of a real guitar as displacements from the guitar string’s original frequency. First create a queue of random displacements between −½ and ½. The length of the queue should be the sampling rate, 44100, divided by the note’s frequency. Then repeatedly remove the first queue element, average it with the next front element, slightly fade the volume by multiplying it by 0.996, then add the result back into the queue as shown in Figure.
Figure Karplus-Strong algorithm samples

This program requires support code to send output to your computer’s sound card. The code is provided on our web site at http://buildingjavaprograms.com/.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.