By pressing certain keys within the StdDraw window, the user can tell the program to generate tones of a given pitch.
The difference between this program and the
PlayThatTune program provided by the book authors is that this one implements an the Karplus-Strong Algorithm.
This algorithm allows the tones to have a "decay" or fading effect, producing more realistic sounding tones.
The Karplus-Strong Algorithm played an important role in the initial development of digital insturments. While most digital insturments that are designed to replicate real sounds now use samples (short recordings of the real insturment), this algorithm still plays an important role in the various genres of electronic music.Shown here is how the keys on the computer keyboard correspond to those on a piano in this program:
An important difference to note is that in contrast to
PlayThatTune, this program uses modified white noise, rather than a pure sine wave. This creates a more realistic sounding tone.
Given more time, there are a few things in this program that could be improved:
StdDraw, one could implement a virtual keyboard that the user could click on to play notes, and maybe even react to the keyboard presses corresponding the virtual keys on the screen.
|27 Feb 2017||Reduced the download files to just two options: the binary as a java archive or the source. I decided there was really no point in having JARs with the source code in them anyways.|
|27 Feb 2017||I have corrected the problem with the guitar sounding too harsh, and now have achieved a much more realistic sound. The issue was a problem in my implementaiton of the Karplus-Strong algorithm, my code was removing the first and second samples from the buffer when calculating the new sample to add, when really only one should be removed and the second just read without removing. The fix was in the tic() method in GuitarString.java.|
|19 Oct 2015||Initial Release|
|GuitarHero.jar||Executable JAR file with compiled class files only.|
|GuitarHero.tar.gz||Java source code of GuitarHero|
To execute GuitarHero, you will also need to have
stdlib.jar available in your classpath. You can download it from the textbook publisher's site: http://introcs.cs.princeton.edu/java/stdlib/stdlib.jar
Copyright © 2015 -2017 Joseph Tortorello. Contents of this webpage are all rights reserved. Linked source code is under the license distributed with the code contained in LICENSE.txt. Contact Me