Write a Guitar Hero program that uses a queue to simulate the creation of guitar notes. When

Question:

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, 44,100, 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 14.3.

time t .2 .4 .5 .3 -.2 .4 .3 .0 -.1|-.3 .996 X 2 (2 +.4) time t+1 .2 .4 .5 .3 -.2.4 .3 .0 -.1-.3 .2988 the Karplus-Strong update

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/.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: