|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSimpleSound
Sound
public class Sound
Class that represents a sound. This class is used by the students to extend the capabilities of SimpleSound. Sounds are immutable (they don't change). Each method that modifies a sound returns a copy of the original sound. Copyright Georgia Institute of Technology 2004
Constructor Summary | |
---|---|
Sound(int numSeconds)
Constructor that takes the number of seconds that this sound will have |
|
Sound(Sound copySound)
Constructor that takes a sound to copy |
|
Sound(java.lang.String fileName)
Constructor that takes a file name |
Method Summary | |
---|---|
void |
add(Sound source)
Method to add the passed sound to this sound |
static Sound |
blendSounds()
Method to overlap or blend two sounds. |
void |
changeFreq(double factor)
Method to change the frequency of a sound by the passed factor |
void |
changeFreq1(double factor)
Method to change the frequency of a sound by the passed factor |
void |
changeVolume(double factor)
Method to change the volume (amplitude) of the sound by multiplying the current values in the sound by the passed factor. |
Sound |
clip(int start,
int end)
Method to create a new sound by copying just part of the current sound to a new sound |
static Sound |
createSineWave(int freq,
int maxAmplitude)
Method to create a one second sine wave sound with the given frequency and maximum amplitude |
static Sound |
createSquareWave(int freq,
int maxAmplitude)
Method to generate a 1 second sound with square waves with the passed frequency and maximum amplitude. |
static Sound |
createTriangleWave(int freq,
int maxAmplitude)
Method to create a one second triangle wave sound with the given frequency and maximum amplitude |
void |
decreaseVolume()
Method to halve the volume (amplitude) of the sound. |
void |
decreaseVolume2()
Method to halve the volume (amplitude) of the sound. |
void |
doNothing()
Method to go through each sound sample and set the sample value to the original value. |
void |
doubleFreq()
Method to double the frequency of a sound by taking every second sample. |
void |
echo(int delay)
Method to add an echo to a sound |
void |
echo(int delay,
int numEchos)
Method to create multiple echos |
void |
forceToExtremes()
Method to set all the sample values to the maximum positive value it they were positive (including 0) and the minimum negative value if they were negative. |
void |
halveFreq()
Method to halve the frequency of a sound by taking each sample twice. |
void |
increaseHalfDecreaseHalf()
Method to increase the first half of the sound (double it) and then decrease the second half (half it). |
void |
increaseVolume()
Method to double the volume (amplitude) of the sound |
void |
mirrorFrontToBack()
Method to mirror a sound front to back |
void |
normalize()
Method to normalize (make as loud as possible) a sound. |
static Sound |
pickAndPlay()
Method to pick a sound file, create the sound object, play the sound object, and return the sound object |
void |
play5Freq()
Method to play a sound 5 times and each time increase the frequency. |
static Sound |
playNamed(java.lang.String fileName)
Method to create a sound object from the given file name and play the sound. |
static Sound |
playSpecificSound()
Method to play a specific sound. |
void |
reverse()
Method to reverse the current sound. |
static Sound |
reverse(java.lang.String file)
Method to reverse the sound with the passed file name |
static Sound |
splice()
Method to splice two sounds together with some silence between them |
void |
splice(Sound source,
int sourceStart,
int sourceStop,
int targetStart)
Method to copy part of the passed sound into this sound at the given start index |
static Sound |
splicePreamble()
Method to splice "United" into "We the people of the United States" by adding it after the "the" |
static Sound |
spliceSimpler()
Method to splice "United" into "We the people of the United States" by adding it after the "the" |
java.lang.String |
toString()
Method to return the string representation of this sound |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Sound(java.lang.String fileName)
fileName
- the name of the file to read the sound frompublic Sound(int numSeconds)
numSeconds
- the number of seconds desiredpublic Sound(Sound copySound)
Method Detail |
---|
public java.lang.String toString()
toString
in class SimpleSound
public static Sound pickAndPlay()
public static Sound playSpecificSound()
public static Sound playNamed(java.lang.String fileName)
public void doNothing()
public void increaseVolume()
public void decreaseVolume()
public void decreaseVolume2()
public void changeVolume(double factor)
factor
- the factor to multiply bypublic void normalize()
public void forceToExtremes()
public void increaseHalfDecreaseHalf()
public Sound clip(int start, int end)
start
- the index to start the copy at (inclusive)end
- the index to stop the copy at (inclusive)
public static Sound splice()
public static Sound splicePreamble()
public static Sound spliceSimpler()
public void splice(Sound source, int sourceStart, int sourceStop, int targetStart)
source
- the source sound to copy fromsourceStart
- the starting index to copy from in the sourcesourceStop
- the ending index (the copy won't include this)targetStart
- the index to start copying intopublic static Sound reverse(java.lang.String file)
file
- the name of the file
public void reverse()
public void mirrorFrontToBack()
public static Sound blendSounds()
public void echo(int delay)
delay
- the number of samples before the echo startspublic void echo(int delay, int numEchos)
delay
- the number of samples before the echo startsnumEchos
- the number of echos desiredpublic void doubleFreq()
public void halveFreq()
public void changeFreq1(double factor)
factor
- the amount to increment the source index by. A number
greater than 1 will increase the frequency and make the sound higher
while a number less than one will decrease the frequency and make
the sound lower.public void changeFreq(double factor)
factor
- the amount to increment the source index by. A number
greater than 1 will increase the frequency and make the sound higher
while a number less than one will decrease the frequency and make
the sound lower.public void play5Freq()
public static Sound createSineWave(int freq, int maxAmplitude)
freq
- the desired frequencymaxAmplitude
- the maximum amplitude
public void add(Sound source)
source
- the sound to combine with this onepublic static Sound createSquareWave(int freq, int maxAmplitude)
freq
- the desired frequencymaxAmplitude
- the maximum amplitude
public static Sound createTriangleWave(int freq, int maxAmplitude)
freq
- the desired frequencymaxAmplitude
- the maximum amplitude
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |