Class Sound

java.lang.Object
  extended by SimpleSound
      extended by Sound

public class Sound
extends SimpleSound

Class that represents a sound. This class is used by the students to extend the capabilities of SimpleSound.
Copyright Georgia Institute of Technology 2004


Field Summary
 
Fields inherited from class SimpleSound
_SoundIndexOffset, MAX_NEG, MAX_POS, SAMPLE_RATE
 
Constructor Summary
Sound(int numSamples)
          Constructor that takes the number of samples in the sound
Sound(int numSamples, int sampleRate)
          Constructor that takes the number of samples that this sound will have and the sample rate
Sound(Sound copySound)
          Constructor that takes a sound to copy
Sound(java.lang.String fileName)
          Constructor that takes a file name
 
Method Summary
 void copySoundInto(Sound dest, int startIndex)
          Method to copy as much of this sound as will fit into another sound.
 Sound cropSound(int startIndex, int numSamples)
          Mehtod to crop out a portion of this sound and return it as a new sound
 java.lang.String toString()
          Method to return the string representation of this sound
 
Methods inherited from class SimpleSound
asArray, blockingPlay, blockingPlayAtRateDur, blockingPlayAtRateInRange, blockingPlayOld, convert, explore, getAudioFileFormat, getBuffer, getChannels, getFileName, getFrame, getLeftSample, getLength, getLengthInBytes, getLengthInFrames, getNumSamples, getPlaybacks, getRightSample, getSample, getSamples, getSampleValue, getSampleValueAt, getSamplingRate, getSoundExplorer, isStereo, loadFromFile, makeAIS, play, playAtRateDur, playAtRateInRange, playAtRateInRange, playNote, printError, printError, removePlayback, setAudioFileFormat, setBuffer, setBuffer, setFrame, setLeftSample, setRightSample, setSampleValue, setSampleValueAt, setSoundExplorer, stopPlaying, write, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sound

public Sound(java.lang.String fileName)
Constructor that takes a file name

Parameters:
fileName - the name of the file to read the sound from

Sound

public Sound(int numSamples)
Constructor that takes the number of samples in the sound

Parameters:
numSamples - the number of samples desired

Sound

public Sound(int numSamples,
             int sampleRate)
Constructor that takes the number of samples that this sound will have and the sample rate

Parameters:
numSamples - the number of samples desired
sampleRate - the number of samples per second

Sound

public Sound(Sound copySound)
Constructor that takes a sound to copy

Parameters:
copySound - the Sound to copy
Method Detail

toString

public java.lang.String toString()
Method to return the string representation of this sound

Overrides:
toString in class SimpleSound
Returns:
a string with information about this sound

copySoundInto

public void copySoundInto(Sound dest,
                          int startIndex)
                   throws SoundException
Method to copy as much of this sound as will fit into another sound.

Parameters:
dest - the sound which gets copied into
startIndex - the starting index for copying
Throws:
SoundException

cropSound

public Sound cropSound(int startIndex,
                       int numSamples)
                throws SoundException
Mehtod to crop out a portion of this sound and return it as a new sound

Parameters:
startIndex - the index at which to start cropping
numSamples - the number of samples to crop out
Returns:
the new sound derived from this sound by cropping
Throws:
SoundException