[DEV] update new ETK
This commit is contained in:
parent
0a7a5e98ce
commit
39e1afcf47
@ -8,7 +8,10 @@
|
|||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <audio/algo/drain/BiQuadType.hpp>
|
#include <audio/algo/drain/BiQuadType.hpp>
|
||||||
#include <cmath>
|
#include <etk/Pair.hpp>
|
||||||
|
extern "C" {
|
||||||
|
#include <math.h>
|
||||||
|
}
|
||||||
#ifndef M_LN10
|
#ifndef M_LN10
|
||||||
#define M_LN10 2.30258509299404568402
|
#define M_LN10 2.30258509299404568402
|
||||||
#endif
|
#endif
|
||||||
@ -63,7 +66,7 @@ namespace audio {
|
|||||||
_qualityFactor = 0.01;
|
_qualityFactor = 0.01;
|
||||||
}
|
}
|
||||||
double norm;
|
double norm;
|
||||||
double V = std::pow(10.0, etk::abs(_gain) / 20.0);
|
double V = etk::pow(10.0, etk::abs(_gain) / 20.0);
|
||||||
double K = etk::tan(M_PI * _frequencyCut / _sampleRate);
|
double K = etk::tan(M_PI * _frequencyCut / _sampleRate);
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case biQuadType_none:
|
case biQuadType_none:
|
||||||
@ -125,35 +128,35 @@ namespace audio {
|
|||||||
case biQuadType_lowShelf:
|
case biQuadType_lowShelf:
|
||||||
if (_gain >= 0) {
|
if (_gain >= 0) {
|
||||||
norm = 1.0 / (1.0 + M_SQRT2 * K + K * K);
|
norm = 1.0 / (1.0 + M_SQRT2 * K + K * K);
|
||||||
m_a[0] = (1.0 + std::sqrt(2.0*V) * K + V * K * K) * norm;
|
m_a[0] = (1.0 + etk::sqrt(2.0*V) * K + V * K * K) * norm;
|
||||||
m_a[1] = 2.0 * (V * K * K - 1.0) * norm;
|
m_a[1] = 2.0 * (V * K * K - 1.0) * norm;
|
||||||
m_a[2] = (1.0 - std::sqrt(2.0*V) * K + V * K * K) * norm;
|
m_a[2] = (1.0 - etk::sqrt(2.0*V) * K + V * K * K) * norm;
|
||||||
m_b[0] = 2.0 * (K * K - 1.0) * norm;
|
m_b[0] = 2.0 * (K * K - 1.0) * norm;
|
||||||
m_b[1] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
m_b[1] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
||||||
} else {
|
} else {
|
||||||
norm = 1.0 / (1.0 + std::sqrt(2.0*V) * K + V * K * K);
|
norm = 1.0 / (1.0 + etk::sqrt(2.0*V) * K + V * K * K);
|
||||||
m_a[0] = (1.0 + M_SQRT2 * K + K * K) * norm;
|
m_a[0] = (1.0 + M_SQRT2 * K + K * K) * norm;
|
||||||
m_a[1] = 2.0 * (K * K - 1.0) * norm;
|
m_a[1] = 2.0 * (K * K - 1.0) * norm;
|
||||||
m_a[2] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
m_a[2] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
||||||
m_b[0] = 2.0 * (V * K * K - 1.0) * norm;
|
m_b[0] = 2.0 * (V * K * K - 1.0) * norm;
|
||||||
m_b[1] = (1.0 - std::sqrt(2.0*V) * K + V * K * K) * norm;
|
m_b[1] = (1.0 - etk::sqrt(2.0*V) * K + V * K * K) * norm;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case biQuadType_highShelf:
|
case biQuadType_highShelf:
|
||||||
if (_gain >= 0) {
|
if (_gain >= 0) {
|
||||||
norm = 1.0 / (1.0 + M_SQRT2 * K + K * K);
|
norm = 1.0 / (1.0 + M_SQRT2 * K + K * K);
|
||||||
m_a[0] = (V + std::sqrt(2.0*V) * K + K * K) * norm;
|
m_a[0] = (V + etk::sqrt(2.0*V) * K + K * K) * norm;
|
||||||
m_a[1] = 2.0 * (K * K - V) * norm;
|
m_a[1] = 2.0 * (K * K - V) * norm;
|
||||||
m_a[2] = (V - std::sqrt(2.0*V) * K + K * K) * norm;
|
m_a[2] = (V - etk::sqrt(2.0*V) * K + K * K) * norm;
|
||||||
m_b[0] = 2.0 * (K * K - 1.0) * norm;
|
m_b[0] = 2.0 * (K * K - 1.0) * norm;
|
||||||
m_b[1] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
m_b[1] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
||||||
} else {
|
} else {
|
||||||
norm = 1.0 / (V + std::sqrt(2.0*V) * K + K * K);
|
norm = 1.0 / (V + etk::sqrt(2.0*V) * K + K * K);
|
||||||
m_a[0] = (1.0 + M_SQRT2 * K + K * K) * norm;
|
m_a[0] = (1.0 + M_SQRT2 * K + K * K) * norm;
|
||||||
m_a[1] = 2.0 * (K * K - 1.0) * norm;
|
m_a[1] = 2.0 * (K * K - 1.0) * norm;
|
||||||
m_a[2] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
m_a[2] = (1.0 - M_SQRT2 * K + K * K) * norm;
|
||||||
m_b[0] = 2.0 * (K * K - V) * norm;
|
m_b[0] = 2.0 * (K * K - V) * norm;
|
||||||
m_b[1] = (V - std::sqrt(2.0*V) * K + K * K) * norm;
|
m_b[1] = (V - etk::sqrt(2.0*V) * K + K * K) * norm;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -261,14 +264,14 @@ namespace audio {
|
|||||||
w = iii / (len - 1.0) * M_PI;
|
w = iii / (len - 1.0) * M_PI;
|
||||||
} else {
|
} else {
|
||||||
// 0.001 to 1, times pi, log scale
|
// 0.001 to 1, times pi, log scale
|
||||||
w = std::exp(std::log(1.0 / 0.001) * iii / (len - 1.0)) * 0.001 * M_PI;
|
w = etk::exp(etk::log(1.0 / 0.001) * iii / (len - 1.0)) * 0.001 * M_PI;
|
||||||
}
|
}
|
||||||
double freq = iii / (len - 1.0) * _sampleRate / 2.0;
|
double freq = iii / (len - 1.0) * _sampleRate / 2.0;
|
||||||
double phi = std::pow(etk::sin(w/2.0), 2.0);
|
double phi = etk::pow(etk::sin(w/2.0), 2.0);
|
||||||
double y = std::log( std::pow((m_a[0]+m_a[1]+m_a[2]).getDouble(), 2.0)
|
double y = etk::log( etk::pow((m_a[0]+m_a[1]+m_a[2]).getDouble(), 2.0)
|
||||||
- 4.0*((m_a[0]*m_a[1]).getDouble() + 4.0*(m_a[0]*m_a[2]).getDouble() + (m_a[1]*m_a[2]).getDouble())*phi
|
- 4.0*((m_a[0]*m_a[1]).getDouble() + 4.0*(m_a[0]*m_a[2]).getDouble() + (m_a[1]*m_a[2]).getDouble())*phi
|
||||||
+ 16.0*(m_a[0]*m_a[2]).getDouble()*phi*phi)
|
+ 16.0*(m_a[0]*m_a[2]).getDouble()*phi*phi)
|
||||||
- std::log( std::pow(1.0+(m_b[0]+m_b[1]).getDouble(), 2.0)
|
- etk::log( etk::pow(1.0+(m_b[0]+m_b[1]).getDouble(), 2.0)
|
||||||
- 4.0*((m_b[0]).getDouble() + 4.0*(m_b[1]).getDouble() + (m_b[0]*m_b[1]).getDouble())*phi
|
- 4.0*((m_b[0]).getDouble() + 4.0*(m_b[1]).getDouble() + (m_b[0]*m_b[1]).getDouble())*phi
|
||||||
+ 16.0*m_b[1].getDouble()*phi*phi);
|
+ 16.0*m_b[1].getDouble()*phi*phi);
|
||||||
y = y * 10.0 / M_LN10;
|
y = y * 10.0 / M_LN10;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <etk/Vector.hpp>
|
#include <etk/Vector.hpp>
|
||||||
#include <audio/format.hpp>
|
#include <audio/format.hpp>
|
||||||
#include <audio/algo/drain/BiQuadType.hpp>
|
#include <audio/algo/drain/BiQuadType.hpp>
|
||||||
|
#include <etk/Pair.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace algo {
|
namespace algo {
|
||||||
|
@ -8,18 +8,18 @@
|
|||||||
#include <etk/etk.hpp>
|
#include <etk/etk.hpp>
|
||||||
#include <audio/algo/drain/Equalizer.hpp>
|
#include <audio/algo/drain/Equalizer.hpp>
|
||||||
#include <etk/os/FSNode.hpp>
|
#include <etk/os/FSNode.hpp>
|
||||||
#include <chrono>
|
#include <echrono/echrono.hpp>
|
||||||
#include <ethread/Thread.hpp>
|
#include <ethread/Thread.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Performance {
|
class Performance {
|
||||||
private:
|
private:
|
||||||
std::chrono::steady_clock::time_point m_timeStart;
|
echrono::Steady m_timeStart;
|
||||||
std::chrono::steady_clock::time_point m_timeStop;
|
echrono::Steady m_timeStop;
|
||||||
std::chrono::nanoseconds m_totalTimeProcessing;
|
echrono::nanoseconds m_totalTimeProcessing;
|
||||||
std::chrono::nanoseconds m_minProcessing;
|
echrono::nanoseconds m_minProcessing;
|
||||||
std::chrono::nanoseconds m_maxProcessing;
|
echrono::nanoseconds m_maxProcessing;
|
||||||
int32_t m_totalIteration;
|
int32_t m_totalIteration;
|
||||||
public:
|
public:
|
||||||
Performance() :
|
Performance() :
|
||||||
@ -30,11 +30,11 @@ class Performance {
|
|||||||
|
|
||||||
}
|
}
|
||||||
void tic() {
|
void tic() {
|
||||||
m_timeStart = std::chrono::steady_clock::now();
|
m_timeStart = echrono::Steady::now();
|
||||||
}
|
}
|
||||||
void toc() {
|
void toc() {
|
||||||
m_timeStop = std::chrono::steady_clock::now();
|
m_timeStop = echrono::Steady::now();
|
||||||
std::chrono::nanoseconds time = m_timeStop - m_timeStart;
|
echrono::nanoseconds time = m_timeStop - m_timeStart;
|
||||||
m_minProcessing = etk::min(m_minProcessing, time);
|
m_minProcessing = etk::min(m_minProcessing, time);
|
||||||
m_maxProcessing = etk::max(m_maxProcessing, time);
|
m_maxProcessing = etk::max(m_maxProcessing, time);
|
||||||
m_totalTimeProcessing += time;
|
m_totalTimeProcessing += time;
|
||||||
@ -42,13 +42,13 @@ class Performance {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::nanoseconds getTotalTimeProcessing() {
|
echrono::nanoseconds getTotalTimeProcessing() {
|
||||||
return m_totalTimeProcessing;
|
return m_totalTimeProcessing;
|
||||||
}
|
}
|
||||||
std::chrono::nanoseconds getMinProcessing() {
|
echrono::nanoseconds getMinProcessing() {
|
||||||
return m_minProcessing;
|
return m_minProcessing;
|
||||||
}
|
}
|
||||||
std::chrono::nanoseconds getMaxProcessing() {
|
echrono::nanoseconds getMaxProcessing() {
|
||||||
return m_maxProcessing;
|
return m_maxProcessing;
|
||||||
}
|
}
|
||||||
int32_t getTotalIteration() {
|
int32_t getTotalIteration() {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include <cstdio>
|
|
||||||
#include <cmath>
|
extern "C" {
|
||||||
#include <cstdint>
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
}
|
||||||
// http://www.labbookpages.co.uk/audio/beamforming/delaySum.html
|
// http://www.labbookpages.co.uk/audio/beamforming/delaySum.html
|
||||||
// Number of angle points to calculate
|
// Number of angle points to calculate
|
||||||
#define ANGLE_RESOLUTION 100000
|
#define ANGLE_RESOLUTION 100000
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <cstdio>
|
extern "C" {
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdint>
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
}
|
||||||
// http://www.labbookpages.co.uk/audio/beamforming/delaySum.html
|
// http://www.labbookpages.co.uk/audio/beamforming/delaySum.html
|
||||||
|
|
||||||
// Number of freq points to calculate
|
// Number of freq points to calculate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user