framed
Class Melfilter

java.lang.Object
  extended by framed.Melfilter
All Implemented Interfaces:
FrameSource

public class Melfilter
extends java.lang.Object
implements FrameSource

Triangular mel-filter with log application in the end (if desired). Note that the bandwidth is fixed(*), thus the number of filters can be controlled using the overlap parameter.
(*) as suggested by Florian Hoenig

Author:
sikoried

Field Summary
static double DEFAULT_FO
          Default filter overlap
static double DEFAULT_FW
          Default filter width in mel
static double DEFAULT_LB
          Default lower boundary frequency (Hz) of mel filter bank
static double DEFAULT_UB
          Default upper boundary frequency (Hz) of mel filter bank
static double EPSILON
          Epsilon constant for logarithm
 
Constructor Summary
Melfilter(FrameSource source, int sampleRate)
          Create the default mel filter bank (bandwidth = 226.79982mel)
Melfilter(FrameSource source, int sampleRate, boolean logMel)
          Create the default mel filter bank (bandwidth = 226.79982mel) and apply the logarithm in the end.
 
Method Summary
static Melfilter create(FrameSource source, int sampleRate, java.lang.String parameterString)
          Create a Melfilter object using the given parameter string and connect it to the source.
 double getActualFilterOverlap()
          Though a certain overlap is requested at initialization, the actual overlap might be slightly different to exactly match start and end freqs.
 int getFrameSize()
          The frame size is the size of the filter bank!
static void main(java.lang.String[] args)
           
 java.lang.String printFilterBank()
          get a String representation of the filter bank format 3 lines per filter (gnuplot ready):
filterNum 0 startFreq
filterNum 1 centerFreq
filterNum 0 endFreq
 boolean read(double[] buf)
          Extract the next frame from the the source stream using a window function
 java.lang.String toString()
          Return a String representation of the FrameSource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FO

public static double DEFAULT_FO
Default filter overlap


DEFAULT_FW

public static double DEFAULT_FW
Default filter width in mel


DEFAULT_LB

public static double DEFAULT_LB
Default lower boundary frequency (Hz) of mel filter bank


DEFAULT_UB

public static double DEFAULT_UB
Default upper boundary frequency (Hz) of mel filter bank


EPSILON

public static double EPSILON
Epsilon constant for logarithm

Constructor Detail

Melfilter

public Melfilter(FrameSource source,
                 int sampleRate)
Create the default mel filter bank (bandwidth = 226.79982mel)

Parameters:
source - FrameSource to read from
sampleRate - sample rate of the original signal in Hz

Melfilter

public Melfilter(FrameSource source,
                 int sampleRate,
                 boolean logMel)
Create the default mel filter bank (bandwidth = 226.79982mel) and apply the logarithm in the end.

Parameters:
source - FrameSource to read from
sampleRate - sample rate of the original signal in Hz
logMel - if true, log is applied to all values in the end
Method Detail

create

public static Melfilter create(FrameSource source,
                               int sampleRate,
                               java.lang.String parameterString)
                        throws MalformedParameterStringException
Create a Melfilter object using the given parameter string and connect it to the source. Default parameter String: "188,6071,226.79982,0.5". If you wish to keep the default value for any of the fields, put a value below 0.

Parameters:
source -
sampleRate -
parameterString - "start-hz,end-hz,width-mel,val"; val < 1: min-overlap, val > 1: min-num filters
Returns:
Throws:
MalformedParameterStringException

getActualFilterOverlap

public double getActualFilterOverlap()
Though a certain overlap is requested at initialization, the actual overlap might be slightly different to exactly match start and end freqs.

Returns:
actual overlap factor

getFrameSize

public int getFrameSize()
The frame size is the size of the filter bank!

Specified by:
getFrameSize in interface FrameSource

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

printFilterBank

public java.lang.String printFilterBank()
get a String representation of the filter bank format 3 lines per filter (gnuplot ready):
filterNum 0 startFreq
filterNum 1 centerFreq
filterNum 0 endFreq

Returns:
String representation of the filter bank

read

public boolean read(double[] buf)
             throws java.io.IOException
Description copied from interface: FrameSource
Extract the next frame from the the source stream using a window function

Specified by:
read in interface FrameSource
Parameters:
buf - buffer to save the frame; implementing objects may depend on a constant dimensionduring subsequent calls
Returns:
true on success, false if the stream terminated before the window was filled
Throws:
java.io.IOException

toString

public java.lang.String toString()
Description copied from interface: FrameSource
Return a String representation of the FrameSource

Specified by:
toString in interface FrameSource
Overrides:
toString in class java.lang.Object