Template Classes for Digital Signal Analysis | CodeGuru

Template Classes for Digital Signal Analysis

Environment: VC6 SP4, VC.NET This article briefly describes a collection of template classes that can be used in digital signal analysis. This collection consists of four classes: Template class WFastHT—implements algorithm of Fast Haara’s Transformation (by Anatoly Beletsky). The template has two type parameters: T_in—type of input values (input signal) T_out—type of output values (spectrum) […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 2, 2003
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6 SP4, VC.NET

This article briefly describes a collection of template classes that can be used in digital signal analysis.

This collection consists of four classes:

  1. Template class WFastHT—implements algorithm of Fast Haara’s Transformation (by Anatoly Beletsky). The template has two type parameters:
    • T_in—type of input values (input signal)
    • T_out—type of output values (spectrum)

    Input signal has any type (int, double, complex<T>). Spectrum is double or complex.

  2. Template class WIFastHT—implements algorithm of Inverse Fast Haara’s Transformation.
  3. Template class WFastFT—implements algorithm of Fast Fourier Transformation (Tim Kientzle “A Programmer’s Guide To Sound” Copyright © 1998 Tim Kientzle).
  4. Template class WFastWT—implements algorithm of Fast Walsh’s Transformation in different bases:
    • HADOMARD—Walsh’s-Hadomar’s basis
    • PELEY—Peley’s basis
    • WALSH—”classical” basis
    • COOLEY—Cooley’s basis (discovered by Anatoly Beletsky in 1999)

    It uses a new type of operation: Grey’s “right-handed” inverse coding. The complete group of operations that forms the so-called “Grey’s algebra” consists of five operations:

    1. Binary inversion
    2. Grey’s “left-handed” coding operation
    3. Grey’s “left-handed” inverse coding operation
    4. Grey’s “right-handed” coding operation
    5. Grey’s “right-handed” inverse coding operation

For details, contact me.

Here is an example of the code’s usage:

#include <iostream>
using std::cout;
using std::cin;
#include “transform.h”
const int Val = 8;
const int fr = 7;
int main()
{
  try {
    WFastHT< double, double > haaras( Val );
    WIFastHT< double, double > ihaaras( Val );
    double data[Val] = { 1,2,3,4,4,3,2,1 };
    double *pD, *pS;
    haaras.setData( data );
    haaras.doTransform();
    pD = haaras.getSpectrum();
    cout << “Input signal: n”;
    for( int i = 0; i < Val; i++ ) {
      cout << data[ i ] << “n”;
    }
    cout << “nSpectrum: n”;
    for( i = 0; i < Val; i++ ) {
      cout << pD[ i ] << “n”;
    }
    ihaaras.setData( pD );
    ihaaras.doTransform();
    pS = ihaaras.getSpectrum();
    cout << “nInverse haara’s transformation: n”;
    for( i = 0; i < Val; i++ ) {
      cout << pS[ i ] << “n”;
    }
  }
  catch( TransError::badNValue ) {
    cout << “Bad N!n”;
  }
  catch( TransError::noData ) {
    cout << “No data available!n”;
  }
  catch( TransError::noSuchBasis ) {
  }
  return 1;
}

Downloads


Download demo project – 78 Kb


Download source – 4 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.