mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
added delta() and decibel() to utils
This commit is contained in:
parent
6769872b39
commit
f3c22ed3cc
2 changed files with 14 additions and 0 deletions
|
|
@ -57,6 +57,8 @@ Some everyday helpers:
|
|||
* [lerp function](https://en.wikipedia.org/wiki/Linear_interpolation)
|
||||
* [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) of the [normal distribution](https://en.wikipedia.org/wiki/Normal_distribution)
|
||||
* [sinc function](https://en.wikipedia.org/wiki/Sinc_function)
|
||||
* [delta function](https://en.wikipedia.org/wiki/Dirac_delta_function)
|
||||
* [decibel function](https://en.wikipedia.org/wiki/Decibel)
|
||||
|
||||
### [resampler.hh](resampler.hh)
|
||||
|
||||
|
|
|
|||
12
utils.hh
12
utils.hh
|
|
@ -35,6 +35,18 @@ TYPE sinc(TYPE x)
|
|||
return TYPE(0) == x ? TYPE(1) : std::sin(Const<TYPE>::Pi() * x) / (Const<TYPE>::Pi() * x);
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
TYPE delta(TYPE x)
|
||||
{
|
||||
return TYPE(0) == x ? TYPE(1) : TYPE(0);
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
TYPE decibel(TYPE v)
|
||||
{
|
||||
return TYPE(10) * std::log10(v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue