kwave  18.07.70
Kwave::WindowFunction Class Reference

#include <WindowFunction.h>

Collaboration diagram for Kwave::WindowFunction:
Collaboration graph

Classes

class  InitializedTypesMap
 

Public Member Functions

 WindowFunction (window_function_t type)
 
virtual ~WindowFunction ()
 
QVector< double > points (unsigned int len) const
 

Static Public Member Functions

static window_function_t findFromIndex (unsigned int index)
 
static window_function_t findFromName (const QString &name)
 
static unsigned int index (window_function_t type)
 
static const QString name (window_function_t type)
 
static QString description (window_function_t type, bool localized)
 
static unsigned int count ()
 

Private Attributes

window_function_t m_type
 

Static Private Attributes

static InitializedTypesMap m_types_map
 

Detailed Description

Handles window functions for signal processing. Also holds a static map of known window functions.

Definition at line 47 of file WindowFunction.h.

Constructor & Destructor Documentation

◆ WindowFunction()

Kwave::WindowFunction::WindowFunction ( Kwave::window_function_t  type)
explicit

Constructor

Parameters
typeinitial window function type.

Definition at line 49 of file WindowFunction.cpp.

50  :m_type(type)
51 {
52 }
window_function_t m_type

◆ ~WindowFunction()

Kwave::WindowFunction::~WindowFunction ( )
virtual

Destructor

Definition at line 55 of file WindowFunction.cpp.

56 {
57 }

Member Function Documentation

◆ count()

static unsigned int Kwave::WindowFunction::count ( )
inlinestatic

returns the number of available window functions

Definition at line 115 of file WindowFunction.h.

Referenced by Kwave::SonagramDialog::SonagramDialog().

115  {
116  return m_types_map.count();
117  }
static InitializedTypesMap m_types_map
unsigned int count() const
Definition: TypesMap.h:81
Here is the caller graph for this function:

◆ description()

static QString Kwave::WindowFunction::description ( window_function_t  type,
bool  localized 
)
inlinestatic

Returns the description of a window function.

Parameters
typethe type of the window function
localizedif true, the localized description will be returned instead of the non-localized one

Definition at line 108 of file WindowFunction.h.

Referenced by Kwave::SonagramDialog::SonagramDialog().

110  {
111  return m_types_map.description(type, localized);
112  }
static InitializedTypesMap m_types_map
QString description(IDX type, bool localized) const
Definition: TypesMap.h:128
Here is the caller graph for this function:

◆ findFromIndex()

static window_function_t Kwave::WindowFunction::findFromIndex ( unsigned int  index)
inlinestatic

Returns the window function id through it's numeric index. If the index is out of range, the return value will be "WINDOW_FUNC_NONE".

Parameters
indexnumeric index to be searched [0...count-1]

Definition at line 71 of file WindowFunction.h.

Referenced by Kwave::SonagramDialog::parameters().

71  {
73  }
static InitializedTypesMap m_types_map
static unsigned int index(window_function_t type)
IDX findFromData(const DATA &data) const
Definition: TypesMap.h:89
Here is the caller graph for this function:

◆ findFromName()

static window_function_t Kwave::WindowFunction::findFromName ( const QString &  name)
inlinestatic

Returns the window function id through it's name. If the name is unknown the return value will be "WINDOW_FUNC_NONE".

Parameters
namethe name to be searched

Definition at line 80 of file WindowFunction.h.

Referenced by Kwave::SonagramPlugin::interpreteParameters().

80  {
82  }
static InitializedTypesMap m_types_map
static const QString name(window_function_t type)
IDX findFromName(const QString &name) const
Definition: TypesMap.h:101
Here is the caller graph for this function:

◆ index()

static unsigned int Kwave::WindowFunction::index ( window_function_t  type)
inlinestatic

Returns the numeric index of a window function [0...count-1].

Parameters
typethe type of the window function

Definition at line 88 of file WindowFunction.h.

Referenced by Kwave::SonagramDialog::setWindowFunction().

89  {
90  return m_types_map.data(type);
91  }
static InitializedTypesMap m_types_map
DATA data(IDX type) const
Definition: TypesMap.h:110
Here is the caller graph for this function:

◆ name()

static const QString Kwave::WindowFunction::name ( window_function_t  type)
inlinestatic

Returns the name of a window function.

Parameters
typethe type of the window function

Definition at line 97 of file WindowFunction.h.

Referenced by Kwave::SonagramDialog::parameters().

98  {
99  return m_types_map.name(type);
100  }
static InitializedTypesMap m_types_map
QString name(IDX type) const
Definition: TypesMap.h:117
Here is the caller graph for this function:

◆ points()

QVector< double > Kwave::WindowFunction::points ( unsigned int  len) const

Returns the coefficients of a window function with the given number of points. This is similar to Kwave's Interpolation class.

Definition at line 60 of file WindowFunction.cpp.

References m_type, Kwave::toInt(), Kwave::WINDOW_FUNC_BLACKMAN, Kwave::WINDOW_FUNC_HAMMING, Kwave::WINDOW_FUNC_HANNING, Kwave::WINDOW_FUNC_NONE, and Kwave::WINDOW_FUNC_TRIANGULAR.

Referenced by Kwave::SonagramPlugin::makeAllValid().

61 {
62  QVector<double> out(len);
63  Q_ASSERT(out.count() == Kwave::toInt(len));
64  if (out.count() != Kwave::toInt(len)) {
65  out.resize(0);
66  return out;
67  }
68 
69  // Hanning, Hamming, Blackman window functions as proposed
70  // in Oppenheim, Schafer, p.241 ff
71  switch (m_type) {
72  case WINDOW_FUNC_NONE: //rectangular window
73  for (unsigned int i = 0; i < len; i++)
74  out[i] = 1;
75  break;
77  for (unsigned int i = 0; i < len; i++)
78  out[i] = 0.5 * (1 - cos(i * 2 * M_PI / (len - 1)));
79  break;
81  for (unsigned int i = 0; i < len; i++)
82  out[i] = 0.54-(0.46 * cos(static_cast<double>(i) * 2 * M_PI /
83  (len - 1)));
84  break;
86  for (unsigned int i = 0; i < len; i++)
87  out[i] = 0.42-(0.50 * cos(static_cast<double>(i) * 2 * M_PI /
88  (len - 1))) +
89  (0.08 * cos(static_cast<double>(i) * 4 * M_PI /
90  (len - 1)));
91  break;
93  for (unsigned int i = 0; i < len / 2; i++)
94  out[i] = static_cast<double>(i) / (len / 2 - 1);
95 
96  for (unsigned int i = len / 2; i < len; i++)
97  out[i] = 1 - (static_cast<double>(i) - len / 2) / (len / 2 - 1);
98  break;
99  }
100 
101  return out;
102 }
window_function_t m_type
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_type

window_function_t Kwave::WindowFunction::m_type
private

id of the window function

Definition at line 140 of file WindowFunction.h.

Referenced by points().

◆ m_types_map

Kwave::WindowFunction::InitializedTypesMap Kwave::WindowFunction::m_types_map
staticprivate

Static map of window function types.

Definition at line 143 of file WindowFunction.h.

Referenced by Kwave::WindowFunction::InitializedTypesMap::fill().


The documentation for this class was generated from the following files: