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.

Author:
Barbara Ericson

Field Summary
 
Fields inherited from class SimpleSound
MAX_NEG, MAX_POS
 
Constructor Summary
Sound(int numSeconds)
          Constructor that takes the number of seconds that this sound will have
Sound(Sound copySound)
          Constructor that makes a copy of the passed sound
Sound(String fileName)
          Constructor that takes a file name
 
Method Summary
 Sound append(Sound appendSound)
          Return this sound appended with the input sound
 void delete(int start, int end)
          Delete from start to end in this sound
 void increaseVolume(double factor)
          Increase the volume of a sound
 void insertAfter(Sound inSound, int start)
          insert the input Sound after the nth sample (input integer).
 Sound mix(Sound mixIn, double ratio)
          Mix the input sound with this sound, with percent ratio of input.
 Sound portion(int start, int end)
          Return part of a sound
 Sound reverse()
          Method to reverse a sound.
 Sound scale(double factor)
          Scale up or down a sound by the given factor (1.0 returns the same, 2.0 doubles the length, and 0.5 halves the length)
 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, getDEBUG, 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, setFrame, setLeftSample, setRightSample, setSampleValue, setSampleValueAt, setSoundExplorer, write, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sound

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

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

Sound

public Sound(int numSeconds)
Constructor that takes the number of seconds that this sound will have

Parameters:
numSeconds - the number of seconds desired

Sound

public Sound(Sound copySound)
Constructor that makes a copy of the passed sound

Parameters:
copySound - the sound to copy
Method Detail

toString

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

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

increaseVolume

public void increaseVolume(double factor)
Increase the volume of a sound


reverse

public Sound reverse()
Method to reverse a sound.


append

public Sound append(Sound appendSound)
Return this sound appended with the input sound

Parameters:
appendSound - sound to append to this

mix

public Sound mix(Sound mixIn,
                 double ratio)
Mix the input sound with this sound, with percent ratio of input. Use mixIn sound up to length of this sound. Return mixed sound.

Parameters:
mixIn - sound to mix in
ratio - how much of input mixIn to mix in

scale

public Sound scale(double factor)
Scale up or down a sound by the given factor (1.0 returns the same, 2.0 doubles the length, and 0.5 halves the length)

Parameters:
factor - ratio to increase or decrease

insertAfter

public void insertAfter(Sound inSound,
                        int start)
insert the input Sound after the nth sample (input integer). Modifies the given sound

Parameters:
inSound - Sound to insert
start - index where to start inserting the new sound

delete

public void delete(int start,
                   int end)
Delete from start to end in this sound

Parameters:
start - where to start deletion
end - where to stop deletion

portion

public Sound portion(int start,
                     int end)
Return part of a sound

Parameters:
start - where to start returning
end - where to end returning