<?php $isip_window_title = "ISIP Homepage"; ?>
<?php include("/data/isip/www/templates/documentation/header/header.html"); ?>
<?php include("/data/isip/www/templates/documentation/body/bar.html"); ?>

<!--#set var="isip_page_title" value="ALGORITHMS" -->
<!--#include virtual="/hse/ies/templates/documentation/body/title.html" -->

<b>Library Name:</b> lib_algo.a

<br><br>
<b>Introduction:</b>

<br><br>

<ul>
  The Algorithm classes are used to implement most basic digital signal
  processing (DSP) functions in speech recognition. This library contains
  a collection of classes that are used as building blocks for creating
  many industry-standard front end algorithms - the portion of a
  speech recognition system that converts the audio signal to a feature
  stream. These classes have also been designed to support many types
  of basic DSP research and education.

  <br><br>

  Every class is designed to support multiple algorithms and
  implementations. The underlying mathematical operations in these
  classes can be accessed by selecting the appropriate algorithm
  and implementation, and then invoking the compute method:

  <ul>
    <pre>boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);</pre>
  </ul>

  The interface is essentially a vector input/vector output interface
  at this basic level.

  <br><br>

  The Algorithm classes have been designed to support a graphical
  user interface (GUI) tool,

  <a href="../../util/speech/isip_transform_builder/index.html">
  isip_transform_builder</a>,

  that allows algorithms to be implemented by simply drawing a flow chart
  using the building blocks provided in this library. All classes
  conform to a basic application programming interface (API)
  which is described in the class named

  <a href="./AlgorithmBase/index.html">AlgorithmBase</a>

  under the section titled

  <a href="./AlgorithmBase/index.html#specific">class-specific methods</a>.

  At the core of this interface is a method named <b>apply</b>:

  <ul>
    <pre>boolean apply(Vector<AlgorithmData>& output, const Vector< CircularBuffer<AlgorithmData> >& input);</pre>
  </ul>

  which produces output on a frame-by-frame basis.
  AlgorithmData is a container class that hides the details of the
  input data type from the programmer.

  <br><br>
  
  Each documentation page for an Algorithm class contains a table
  defining all algorithms and implementations supported for that class.
  For example, consider the table for the

  <a href="./Correlation/index.html">Correlation class</a>.

  In the description section of this class, you will see the following
  table:

  <br><br>

  <center>
  <img src="./Correlation/index_table_00.jpg">
  </center>

  <br>

  The first two columns in this table define what specific algorithm
  you will select. For example, to select a factored implementation
  of the autocorrelation algorithm, you would place the following lines
  in your code:

  <br><br>
  
  <ul>
    <pre>
    Correlation autoc;
    autoc.setAlgorithm(Correlation::AUTO);
    autoc.setImplementation(Correlation::UNFACTORED);</pre>
  </ul>
  
  The equations governing this particular choice are given in the column
  titled "Equation", and the parameters available for this choice
  are given in the column titled "Parameters".

  <br><br>

  The third column in this table, titled "Mode", provides control over
  whether the algorithm uses only data within the current frame, referred
  to as "FRAME_INTERNAL", or whether the algorithm uses data from previous
  and future frames, referred to as "CROSS_FRAME". Some classes, such
  as the Statistics class, support accumulation of results across
  many frames using a mode called "ACCUMULATE".

  <br><br>

  For some algorithms, such as correlation, the type of data
  also determines what specific algorithm should be used.
  The fourth and fifth columns in this table provide control over
  the data types. For example, the autocorrelation algorithm
  can operate on sampled data ("SIGNAL") and linear prediction
  coefficients ("REFLECTION" and "PREDICTION"). Users can specify
  the input data type using the <i>setMode</i> method:
  
  <br><br>
  
  <ul>
    <pre>
    Autocorrelation autoc;
    autoc.setMode(Autocorrelation::REFLECTION);</pre>
  </ul>

  The output data type is set automatically in the class based on the
  input data type, and the algorithm and implementation settings.  Two
  special values for this data type specification are "GENERIC", which
  means the algorithm will take any data as input, and "PROPAGATE",
  which directs the class set the output the data type to the same
  thing as the input data type.

  <br><br>

  This functionality, though a bit cumbersome to a typical user,
  is required to allow tools such as
  
  <a href="../../util/speech/isip_transform_builder/index.html">
  isip_transform_builder</a>

  to transparently process data. Most classes have default settings
  that allow them to be used without too much setup or initialization.
</ul>

<br>

<b>Example:</b>

<ul>
  To demonstrate the use of a compute method, let's begin with a simple

  <a href="../../doc/examples/class/algo/algo_example_01/">example</a>:

  <pre>
01  // isip include files
02  //
03  #include &lt;Energy.h&gt;
04  
05  // main program starts here:
06  //  this example demonstrates the use of a compute method
07  //
08  int main(int argc, const char** argv) {
09  
10    // declare an Energy object
11    //
12    Energy energy;
13  
14    // declare the input and output vectors
15    //
16    VectorFloat input(L"1, 2, 1, 3, 4, 2, 3, 1");
17    VectorFloat output;
18    
19    // set the algorithm implementation
20    //     
21    energy.setAlgorithm(Energy::SUM);
22    energy.setImplementation(Energy::IDENTITY);
23    
24    // compute the energy
25    //
26    energy.compute(output, input);
27  
28    // output the input and output to the console
29    //
30    input.debug(L"input signal:");
31    output.debug(L"energy:");
32    
33    // exit gracefully
34    //
35    Integral::exit();
36  }
</pre>
</ul>

<b>Explanation:</b>

<ul>
  In the above example, the declaration on line 12 creates a <a
  href="./Energy/index.html">Energy</a> object. On lines 16 and 17 we
  create input signal and output energy as a VectorFloat object. Next,
  on lines 21 and 22, we set the algorithm and implementation of the
  Energy object as SUM and IDENTITY, respectively. After setting the
  algorithm and implementation, we compute the energy of the input
  signal on line 26.

  <br><br>
  
  Finally, lines 30 and 31 demonstrates how to send input signal and
  output to the terminal using debug method. The output for this code
  is the following:
  
  <br><br>
  
  <pre>
&lt;VectorFloat::input signal:&gt; length_d = 8
&lt;VectorFloat::input signal:&gt; capacity_d = 8
&lt;VectorFloat::input signal:&gt; v_d = 1, 2, 1, 3, 4, 2, 3, 1
&lt;VectorFloat::energy:&gt; length_d = 1
&lt;VectorFloat::energy:&gt; capacity_d = 1
&lt;VectorFloat::energy:&gt; v_d = 45
</pre>
</ul>

<br>

<ul>
  The Algorithm classes that are currently available include:

  <br><br>

  <center>
  <table border=5>
  
  <tr>
  <td> <a href="./Algorithm/index.html">Algorithm</a> </td>
  <td> <a href="./AlgorithmBase/index.html">AlgorithmBase</a> </td>
  <td> <a href="./AlgorithmContainer/index.html">AlgorithmContainer</a> </td>
  <td> <a href="./AlgorithmUndefined/index.html">AlgorithmUndefined</a> </td>
  </tr>

  <tr>
  <td> <a href="./Calculus/index.html">Calculus</a> </td>
  <td> <a href="./Cepstrum/index.html">Cepstrum</a> </td>
  <td> <a href="./CoefficientLabel/index.html">CoefficientLabel</a> </td>
  <td> <a href="./Connection/index.html">Connection</a> </td>
  </tr>

  <tr>
  <td> <a href="./Constant/index.html">Constant</a> </td>
  <td> <a href="./Correlation/index.html">Correlation</a> </td>
  <td> <a href="./Covariance/index.html">Covariance</a> </td>
  <td> <a href="./DisplayData/index.html">DisplayData</a> </td>
  </tr>

  <tr>
  <td> <a href="./Energy/index.html">Energy</a> </td>
  <td> <a href="./Filter/index.html">Filter</a> </td>
  <td> <a href="./FilterBank/index.html">FilterBank</a> </td>
  <td> <a href="./FourierTransform/index.html">FourierTransform</a> </td>
  </tr>

  <tr>
  <td> <a href="./Generator/index.html">Generator</a> </td>
  <td> <a href="./KalmanFilter/index.html">KalmanFilter</a> </td>
  <td> <a href="./LogAreaRatio/index.html">LogAreaRatio</a> </td>
  <td> <a href="./Mask/index.html">Mask</a> </td>
  </tr>

  <tr>
  <td> <a href="./Math/index.html">Math</a> </td>
  <td> <a href="./Output/index.html">Output</a> </td>
  <td> <a href="./Prediction/index.html">Prediction</a> </td>
  <td> <a href="./Reflection/index.html">Reflection</a> </td>
  </tr>

  <tr>
  <td> <a href="./Spectrum/index.html">Spectrum</a> </td>
  <td> <a href="./Statistics/index.html">Statistics</a> </td>
  <td> <a href="./Window/index.html">Window</a> </td>
  <td> &nbsp; </td>
  </tr>

  </table>
  </center>

  <br>

  The next level in the ISIP class hierarchy is

  <a href="../sp/index.html">signal processing</a>

  which provides classes that produce feature streams from
  information sources such as speech signals.
  The software corresponding to the examples
  demonstrated in this document can be found in our

  <a href="../../doc/examples/">documentation directory</a>

  under

  <a href="../../doc/examples/class/sp/">class/sp/</a>.
</ul>


<!--#include virtual="/hse/ies/templates/documentation/footer/footer.html" -->
