comirva.audio.util
Class CentSpectrum

java.lang.Object
  extended by comirva.audio.util.CentSpectrum

public class CentSpectrum
extends Object


Field Summary
protected  double baseFreq
           
protected  int blockWidth
           
protected  int centHop
           
protected  int centStart
           
protected  int hopSize
           
protected  int linearFilters
           
protected  FFT magnitudeFFT
           
protected  int normalizationWidth
           
protected  float sampleRate
           
protected  int windowSize
           
 
Constructor Summary
CentSpectrum(float sampleRate)
          Creates a Sone object with default window size of 256 for the given sample rate.
CentSpectrum(int windowSize, int hopSize, float sampleRate, int centStart, int centHop, int linearFilters, int normalizationWidth)
          Creates a Sone object with given window size and sample rate.
 
Method Summary
 int getHopSize()
          Returns the number of samples skipped between two windows.
 int[] getUpperBoundsCent()
           
 int getWindowSize()
          Returns the number of samples skipped between two windows.
(package private)  float hz2cent(float hz)
           
(package private)  double[][] normalize(double[][] centSpectrum, int normalizationWidth)
           
 Vector<double[]> process(AudioPreProcessor in)
          Performs the transformation of the input data to Sone.
 double[][] process(double[] input)
          Performs the transformation of the input data to Sone.
 double[] processWindow(double[] window, int start)
          Transforms one window of samples to Sone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

windowSize

protected int windowSize

hopSize

protected int hopSize

sampleRate

protected float sampleRate

baseFreq

protected double baseFreq

magnitudeFFT

protected FFT magnitudeFFT

centStart

protected int centStart

centHop

protected int centHop

normalizationWidth

protected int normalizationWidth

blockWidth

protected int blockWidth

linearFilters

protected int linearFilters
Constructor Detail

CentSpectrum

public CentSpectrum(float sampleRate)
             throws IllegalArgumentException
Creates a Sone object with default window size of 256 for the given sample rate.

Parameters:
sampleRate - float samples per second, must be greater than zero; none integer values get rounded
Throws:
IllegalArgumentException - raised if method contract is violated

CentSpectrum

public CentSpectrum(int windowSize,
                    int hopSize,
                    float sampleRate,
                    int centStart,
                    int centHop,
                    int linearFilters,
                    int normalizationWidth)
             throws IllegalArgumentException
Creates a Sone object with given window size and sample rate. The overleap of the windows is fixed at 50 percent. The window size must be 2^n and at least 32. The sample rate must be at least 1.

Parameters:
windowSize - int size of a window
sampleRate - float samples per second, must be greater than zero; not whole-numbered values get rounded
Throws:
IllegalArgumentException - raised if method contract is violated
Method Detail

getUpperBoundsCent

public int[] getUpperBoundsCent()

getHopSize

public int getHopSize()
Returns the number of samples skipped between two windows. Since the overleap of 50 percent is fixed, the hop size is half the window size.

Returns:
int hop size

getWindowSize

public int getWindowSize()
Returns the number of samples skipped between two windows. Since the overleap of 50 percent is fixed, the hop size is half the window size.

Returns:
int hop size

process

public Vector<double[]> process(AudioPreProcessor in)
                         throws IllegalArgumentException,
                                IOException
Performs the transformation of the input data to Sone. This is done by splitting the given data into windows and processing each of these windows with processWindow().

Parameters:
in - AudioPreProcessor input data is a complete Audio stream, must have the same sample rate like this sone object, must not be a null value
Returns:
Vector this vector contains a double array of Sone value for each window
Throws:
IOException - if there are any problems regarding the inputstream
IllegalArgumentException - raised if mehtod contract is violated

process

public double[][] process(double[] input)
                   throws IllegalArgumentException,
                          IOException
Performs the transformation of the input data to Sone. This is done by splitting the given data into windows and processing each of these windows with processWindow().

Parameters:
input - double[] input data is an array of samples, must be a multiple of the hop size, must not be a null value
Returns:
double[][] an array of arrays contains a double array of Sone value for each window
Throws:
IOException - if there are any problems regarding the inputstream
IllegalArgumentException - raised if mehtod contract is violated

processWindow

public double[] processWindow(double[] window,
                              int start)
                       throws IllegalArgumentException
Transforms one window of samples to Sone. The following steps are performed:

(1) normalized power fft with hanning window function

(2) compute influence of the outer ear by emphasizing some frequencies (model by Terhardt[3])

(3) convertion to bark scale to reduce the data to the critical bands of human hearing[4].

(4) calculate the influence of spectral masking effekts, since the human hear needs some regeneration time and can't perceive similar short delayed tones[2]. Also conversion to db is done in this step

(5) Finally the db values are converted to loudness values (Sone, a psychoacoustic scale). This loudness scale better represent the human perception of loudness than the db scale does[5].

Parameters:
window - double[] data to be converted, must contain enough data for one window
start - int start index of the window data
Returns:
double[] the window representation in Sone
Throws:
IllegalArgumentException - raised if mehtod contract is violated

normalize

double[][] normalize(double[][] centSpectrum,
                     int normalizationWidth)

hz2cent

float hz2cent(float hz)