public class SoundManager
extends java.lang.Object
Constructor and Description |
---|
SoundManager() |
Modifier and Type | Method and Description |
---|---|
int |
generateNote()
Generates a random piano note of seven possibilities
(C,D,E,F,G,A,B) and returns a corresponding integer.
|
void |
playBass()
Plays a bass drum sound once.
|
void |
playFile(java.lang.String filename)
Plays a a sound file located in the resource folder.
|
void |
playPianoNote(int index)
Used to play a piano note.
|
void |
playSnare()
Requires the existence of a file named "snare.wav" in the project resource folder.
|
void |
stopAllFiles()
Stops all the currently playing files.
|
void |
stopFile()
Stops the playing of the first file that was being played
for example: if user played file1 then file2 then file3.
|
void |
stopFile(java.lang.String filename)
Stops the playing of a specific file.
|
void |
wait(int milliseconds) |
void |
waitEighth()
(r) Used to add a time gap of an eighth of a second after playing a sound.
|
void |
waitHalf()
(r) Used to add a time gap of half a second after playing a sound.
|
void |
waitQuarter()
(r) Used to add a time gap of a quarter of a second after playing a sound.
|
void |
waitSecond()
(r) Used to add a time gap of 1 second after playing a sound.
|
public void stopAllFiles()
public void stopFile()
Stops the playing of the first file that was being played for example: if user played file1 then file2 then file3. If the user calls this method, file1 will be stopped. If the user calls the method again, then file2 will be stopped. If the user calls the method a third time, then file3 will be stopped.
public void stopFile(java.lang.String filename)
filename
- The name of the file to be stopped.public void playFile(java.lang.String filename)
filename
- The full name of a sound file located in the resource folder of the project.public void playSnare()
public void playBass()
public int generateNote()
Generates a random piano note of seven possibilities (C,D,E,F,G,A,B) and returns a corresponding integer.
public void waitSecond()
public void waitHalf()
public void waitQuarter()
public void waitEighth()
public void wait(int milliseconds)
public void playPianoNote(int index)
Used to play a piano note.
index
- note value between 1 and 7.
plays a C note if index = 1.
plays a D note if index = 2.
plays a E note if index = 3.
plays a F note if index = 4.
plays a G note if index = 5.
plays a A note if index = 6.
plays a B note if index = 7.