SciLib.SP
Class Sound

java.lang.Object
  extended by SciLib.SP.Sound
Direct Known Subclasses:
Audio, Wave

public class Sound
extends java.lang.Object

This class contains some useful methods to handle Sound file.


Field Summary
protected  vector audioData
           
protected  sun.audio.AudioDataStream audioDataStream
           
protected  byteVector byteSignal
           
protected  int sampleRate
           
 
Constructor Summary
Sound()
          Make an empty Sound object
Sound(byte[] s)
          Make an Sound object from a signal array s
Sound(byteVector s)
          Make an Sound object from a signal vector s
Sound(double[] s)
          Make an Sound object from a signal array s
Sound(vector s)
          Make an Sound object from a signal vector s
 
Method Summary
 double duration()
          compute the duration
 vector getAudioData()
          get the whole audio Data
 vector getAudioData(int n)
          get n point audio Data from the beginning
 vector getAudioData(int i, int j)
          get audio Data from index i to index j
 byteVector getByteData()
          get audio Data
 int getSampleRate()
          get sample rate
 double max()
          compute the maximum signal
 double min()
          compute the minimum signal
 void normalize()
          normalize the audio signal
 void play()
          Plays the audio data synchronously, i.e. it blocks the thread it is being called from.
 int size()
          get the size of the audio signal
 void stop()
          Stop playing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

byteSignal

protected byteVector byteSignal

sampleRate

protected int sampleRate

audioData

protected vector audioData

audioDataStream

protected sun.audio.AudioDataStream audioDataStream
Constructor Detail

Sound

public Sound()
Make an empty Sound object


Sound

public Sound(byteVector s)
Make an Sound object from a signal vector s

Parameters:
s - A vector that contains the audio signal

Sound

public Sound(byte[] s)
Make an Sound object from a signal array s

Parameters:
s - An array that contains the audio signal

Sound

public Sound(double[] s)
Make an Sound object from a signal array s

Parameters:
s - An array that contains the audio signal

Sound

public Sound(vector s)
Make an Sound object from a signal vector s

Parameters:
s - A vector that contains the audio signal
Method Detail

getByteData

public byteVector getByteData()
get audio Data

Returns:
A byteVector

getAudioData

public vector getAudioData(int i,
                           int j)
get audio Data from index i to index j

Parameters:
i - the start index
j - the stop index
Returns:
A vector

getAudioData

public vector getAudioData(int n)
get n point audio Data from the beginning

Parameters:
n - the number of data points
Returns:
A vector

getAudioData

public vector getAudioData()
get the whole audio Data

Returns:
A vector

getSampleRate

public int getSampleRate()
get sample rate

Returns:
An integer value

size

public int size()
get the size of the audio signal

Returns:
An integer value

duration

public double duration()
compute the duration

Returns:
A double value

min

public double min()
compute the minimum signal

Returns:
A double value

max

public double max()
compute the maximum signal

Returns:
A double value

normalize

public void normalize()
normalize the audio signal


play

public void play()
Plays the audio data synchronously, i.e. it blocks the thread it is being called from.


stop

public void stop()
Stop playing