[DEV] continue removing stl
This commit is contained in:
parent
0e031fc91d
commit
8d75111d97
@ -182,13 +182,13 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Get direct Coefficients
|
* @brief Get direct Coefficients
|
||||||
*/
|
*/
|
||||||
std::vector<TYPE> getCoef() {
|
etk::Vector<TYPE> getCoef() {
|
||||||
std::vector<TYPE> out;
|
etk::Vector<TYPE> out;
|
||||||
out.push_back(m_a[0]);
|
out.pushBack(m_a[0]);
|
||||||
out.push_back(m_a[1]);
|
out.pushBack(m_a[1]);
|
||||||
out.push_back(m_a[2]);
|
out.pushBack(m_a[2]);
|
||||||
out.push_back(m_b[0]);
|
out.pushBack(m_b[0]);
|
||||||
out.push_back(m_b[1]);
|
out.pushBack(m_b[1]);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -249,8 +249,8 @@ namespace audio {
|
|||||||
* @param[in] _sampleRate input qample rate
|
* @param[in] _sampleRate input qample rate
|
||||||
* @retrun list of frequency/power in dB
|
* @retrun list of frequency/power in dB
|
||||||
*/
|
*/
|
||||||
std::vector<std::pair<float,float> > calculateTheory(double _sampleRate){
|
etk::Vector<etk::Pair<float,float> > calculateTheory(double _sampleRate){
|
||||||
std::vector<std::pair<float,float> > out;
|
etk::Vector<etk::Pair<float,float> > out;
|
||||||
double norm;
|
double norm;
|
||||||
bool buildLinear = true;
|
bool buildLinear = true;
|
||||||
size_t len = 512;
|
size_t len = 512;
|
||||||
@ -276,7 +276,7 @@ namespace audio {
|
|||||||
y = -200.0;
|
y = -200.0;
|
||||||
}
|
}
|
||||||
//APPL_DEBUG("theory = " << freq << " power=" << y);
|
//APPL_DEBUG("theory = " << freq << " power=" << y);
|
||||||
out.push_back(std::make_pair<float,float>(freq, y));
|
out.pushBack(etk::makePair<float,float>(freq, y));
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ static int32_t listValuesSize = sizeof(listValues)/sizeof(char*);
|
|||||||
|
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
template<> std::string to_string<enum audio::algo::drain::biQuadType>(const enum audio::algo::drain::biQuadType& _variable) {
|
template<> etk::String toString<enum audio::algo::drain::biQuadType>(const enum audio::algo::drain::biQuadType& _variable) {
|
||||||
return listValues[_variable];
|
return listValues[_variable];
|
||||||
}
|
}
|
||||||
template <> bool from_string<enum audio::algo::drain::biQuadType>(enum audio::algo::drain::biQuadType& _variableRet, const std::string& _value) {
|
template <> bool from_string<enum audio::algo::drain::biQuadType>(enum audio::algo::drain::biQuadType& _variableRet, const etk::String& _value) {
|
||||||
for (int32_t iii=0; iii<listValuesSize; ++iii) {
|
for (int32_t iii=0; iii<listValuesSize; ++iii) {
|
||||||
if (_value == listValues[iii]) {
|
if (_value == listValues[iii]) {
|
||||||
_variableRet = static_cast<enum audio::algo::drain::biQuadType>(iii);
|
_variableRet = static_cast<enum audio::algo::drain::biQuadType>(iii);
|
||||||
|
@ -74,11 +74,11 @@ namespace audio {
|
|||||||
virtual bool addBiquad(int32_t _idChannel, audio::algo::drain::biQuadType _type, double _frequencyCut, double _qualityFactor, double _gain) = 0;
|
virtual bool addBiquad(int32_t _idChannel, audio::algo::drain::biQuadType _type, double _frequencyCut, double _qualityFactor, double _gain) = 0;
|
||||||
public:
|
public:
|
||||||
// for debug & tools only
|
// for debug & tools only
|
||||||
virtual std::vector<std::pair<float,float> > calculateTheory() = 0;
|
virtual etk::Vector<etk::Pair<float,float> > calculateTheory() = 0;
|
||||||
};
|
};
|
||||||
template<typename TYPE> class EqualizerPrivateType : public audio::algo::drain::EqualizerPrivate {
|
template<typename TYPE> class EqualizerPrivateType : public audio::algo::drain::EqualizerPrivate {
|
||||||
protected:
|
protected:
|
||||||
std::vector<std::vector<audio::algo::drain::BiQuad<TYPE> > > m_biquads;
|
etk::Vector<etk::Vector<audio::algo::drain::BiQuad<TYPE> > > m_biquads;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -122,7 +122,7 @@ namespace audio {
|
|||||||
bq.setBiquadCoef(_a0, _a1, _a2, _b0, _b1);
|
bq.setBiquadCoef(_a0, _a1, _a2, _b0, _b1);
|
||||||
// add this bequad for every Channel:
|
// add this bequad for every Channel:
|
||||||
for (size_t iii=0; iii<m_biquads.size(); ++iii) {
|
for (size_t iii=0; iii<m_biquads.size(); ++iii) {
|
||||||
m_biquads[iii].push_back(bq);
|
m_biquads[iii].pushBack(bq);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ namespace audio {
|
|||||||
bq.setBiquad(_type, _frequencyCut, _qualityFactor, _gain, m_sampleRate);
|
bq.setBiquad(_type, _frequencyCut, _qualityFactor, _gain, m_sampleRate);
|
||||||
// add this bequad for every Channel:
|
// add this bequad for every Channel:
|
||||||
for (size_t iii=0; iii<m_biquads.size(); ++iii) {
|
for (size_t iii=0; iii<m_biquads.size(); ++iii) {
|
||||||
m_biquads[iii].push_back(bq);
|
m_biquads[iii].pushBack(bq);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ namespace audio {
|
|||||||
audio::algo::drain::BiQuad<TYPE> bq;
|
audio::algo::drain::BiQuad<TYPE> bq;
|
||||||
bq.setBiquadCoef(_a0, _a1, _a2, _b0, _b1);
|
bq.setBiquadCoef(_a0, _a1, _a2, _b0, _b1);
|
||||||
if (_idChannel<m_biquads.size()) {
|
if (_idChannel<m_biquads.size()) {
|
||||||
m_biquads[_idChannel].push_back(bq);
|
m_biquads[_idChannel].pushBack(bq);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -147,17 +147,17 @@ namespace audio {
|
|||||||
audio::algo::drain::BiQuad<TYPE> bq;
|
audio::algo::drain::BiQuad<TYPE> bq;
|
||||||
bq.setBiquad(_type, _frequencyCut, _qualityFactor, _gain, m_sampleRate);
|
bq.setBiquad(_type, _frequencyCut, _qualityFactor, _gain, m_sampleRate);
|
||||||
if (_idChannel<m_biquads.size()) {
|
if (_idChannel<m_biquads.size()) {
|
||||||
m_biquads[_idChannel].push_back(bq);
|
m_biquads[_idChannel].pushBack(bq);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual std::vector<std::pair<float,float> > calculateTheory() {
|
virtual etk::Vector<etk::Pair<float,float> > calculateTheory() {
|
||||||
std::vector<std::pair<float,float> > out;
|
etk::Vector<etk::Pair<float,float> > out;
|
||||||
for (size_t iii=0; iii<m_biquads[0].size(); ++iii) {
|
for (size_t iii=0; iii<m_biquads[0].size(); ++iii) {
|
||||||
if (iii == 0) {
|
if (iii == 0) {
|
||||||
out = m_biquads[0][iii].calculateTheory(m_sampleRate);
|
out = m_biquads[0][iii].calculateTheory(m_sampleRate);
|
||||||
} else {
|
} else {
|
||||||
std::vector<std::pair<float,float> > tmp = m_biquads[0][iii].calculateTheory(m_sampleRate);
|
etk::Vector<etk::Pair<float,float> > tmp = m_biquads[0][iii].calculateTheory(m_sampleRate);
|
||||||
for (size_t jjj=0; jjj< out.size(); ++jjj) {
|
for (size_t jjj=0; jjj< out.size(); ++jjj) {
|
||||||
out[jjj].second += tmp[jjj].second;
|
out[jjj].second += tmp[jjj].second;
|
||||||
}
|
}
|
||||||
@ -293,15 +293,15 @@ void audio::algo::drain::Equalizer::reset() {
|
|||||||
m_private->reset();
|
m_private->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::drain::Equalizer::getSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::drain::Equalizer::getSupportedFormat() {
|
||||||
std::vector<enum audio::format> out = audio::algo::drain::Equalizer::getNativeSupportedFormat();
|
etk::Vector<enum audio::format> out = audio::algo::drain::Equalizer::getNativeSupportedFormat();
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::drain::Equalizer::getNativeSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::drain::Equalizer::getNativeSupportedFormat() {
|
||||||
std::vector<enum audio::format> out;
|
etk::Vector<enum audio::format> out;
|
||||||
out.push_back(audio::format_float);
|
out.pushBack(audio::format_float);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,10 +343,10 @@ bool audio::algo::drain::Equalizer::addBiquad(int32_t _idChannel, audio::algo::d
|
|||||||
return m_private->addBiquad(_idChannel, _type, _frequencyCut, _qualityFactor, _gain);
|
return m_private->addBiquad(_idChannel, _type, _frequencyCut, _qualityFactor, _gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<float,float> > audio::algo::drain::Equalizer::calculateTheory() {
|
etk::Vector<etk::Pair<float,float> > audio::algo::drain::Equalizer::calculateTheory() {
|
||||||
if (m_private == nullptr) {
|
if (m_private == nullptr) {
|
||||||
AA_DRAIN_ERROR("Equalizer does not init ...");
|
AA_DRAIN_ERROR("Equalizer does not init ...");
|
||||||
return std::vector<std::pair<float,float> >();
|
return etk::Vector<etk::Pair<float,float> >();
|
||||||
}
|
}
|
||||||
return m_private->calculateTheory();
|
return m_private->calculateTheory();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
#include <vector>
|
#include <etk/Vector.hpp>
|
||||||
#include <audio/format.hpp>
|
#include <audio/format.hpp>
|
||||||
#include <audio/algo/drain/BiQuadType.hpp>
|
#include <audio/algo/drain/BiQuadType.hpp>
|
||||||
|
|
||||||
@ -41,12 +41,12 @@ namespace audio {
|
|||||||
* @brief Get list of format suported in input.
|
* @brief Get list of format suported in input.
|
||||||
* @return list of supported format
|
* @return list of supported format
|
||||||
*/
|
*/
|
||||||
virtual std::vector<enum audio::format> getSupportedFormat();
|
virtual etk::Vector<enum audio::format> getSupportedFormat();
|
||||||
/**
|
/**
|
||||||
* @brief Get list of algorithm format suported. No format convertion.
|
* @brief Get list of algorithm format suported. No format convertion.
|
||||||
* @return list of supported format
|
* @return list of supported format
|
||||||
*/
|
*/
|
||||||
virtual std::vector<enum audio::format> getNativeSupportedFormat();
|
virtual etk::Vector<enum audio::format> getNativeSupportedFormat();
|
||||||
/**
|
/**
|
||||||
* @brief Main input algo process.
|
* @brief Main input algo process.
|
||||||
* @param[in,out] _output Output data.
|
* @param[in,out] _output Output data.
|
||||||
@ -72,7 +72,7 @@ namespace audio {
|
|||||||
bool addBiquad(int32_t _idChannel, audio::algo::drain::biQuadType _type, double _frequencyCut, double _qualityFactor, double _gain);
|
bool addBiquad(int32_t _idChannel, audio::algo::drain::biQuadType _type, double _frequencyCut, double _qualityFactor, double _gain);
|
||||||
public:
|
public:
|
||||||
// for debug & tools only
|
// for debug & tools only
|
||||||
std::vector<std::pair<float,float> > calculateTheory();
|
etk::Vector<etk::Pair<float,float> > calculateTheory();
|
||||||
protected:
|
protected:
|
||||||
ememory::SharedPtr<EqualizerPrivate> m_private; //!< private data (abstract the type of the data flow).
|
ememory::SharedPtr<EqualizerPrivate> m_private; //!< private data (abstract the type of the data flow).
|
||||||
};
|
};
|
||||||
|
@ -35,8 +35,8 @@ class Performance {
|
|||||||
void toc() {
|
void toc() {
|
||||||
m_timeStop = std::chrono::steady_clock::now();
|
m_timeStop = std::chrono::steady_clock::now();
|
||||||
std::chrono::nanoseconds time = m_timeStop - m_timeStart;
|
std::chrono::nanoseconds time = m_timeStop - m_timeStart;
|
||||||
m_minProcessing = std::min(m_minProcessing, time);
|
m_minProcessing = etk::min(m_minProcessing, time);
|
||||||
m_maxProcessing = std::max(m_maxProcessing, time);
|
m_maxProcessing = etk::max(m_maxProcessing, time);
|
||||||
m_totalTimeProcessing += time;
|
m_totalTimeProcessing += time;
|
||||||
m_totalIteration++;
|
m_totalIteration++;
|
||||||
|
|
||||||
@ -58,9 +58,9 @@ class Performance {
|
|||||||
};
|
};
|
||||||
|
|
||||||
float performanceEqualizerType(audio::format _type) {
|
float performanceEqualizerType(audio::format _type) {
|
||||||
std::vector<float> input;
|
etk::Vector<float> input;
|
||||||
input.resize(1024, 0);
|
input.resize(1024, 0);
|
||||||
std::vector<float> output;
|
etk::Vector<float> output;
|
||||||
output.resize(input.size()*10, 0);
|
output.resize(input.size()*10, 0);
|
||||||
double sampleRate = 48000;
|
double sampleRate = 48000;
|
||||||
{
|
{
|
||||||
@ -116,17 +116,17 @@ void performanceEqualizer() {
|
|||||||
int main(int _argc, const char** _argv) {
|
int main(int _argc, const char** _argv) {
|
||||||
// the only one init for etk:
|
// the only one init for etk:
|
||||||
etk::init(_argc, _argv);
|
etk::init(_argc, _argv);
|
||||||
std::string inputName = "";
|
etk::String inputName = "";
|
||||||
std::string outputName = "output.raw";
|
etk::String outputName = "output.raw";
|
||||||
bool performance = false;
|
bool performance = false;
|
||||||
bool perf = false;
|
bool perf = false;
|
||||||
int64_t sampleRateIn = 48000;
|
int64_t sampleRateIn = 48000;
|
||||||
int64_t sampleRateOut = 48000;
|
int64_t sampleRateOut = 48000;
|
||||||
int32_t nbChan = 1;
|
int32_t nbChan = 1;
|
||||||
int32_t quality = 4;
|
int32_t quality = 4;
|
||||||
std::string test = "";
|
etk::String test = "";
|
||||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||||
std::string data = _argv[iii];
|
etk::String data = _argv[iii];
|
||||||
if (etk::start_with(data,"--in=")) {
|
if (etk::start_with(data,"--in=")) {
|
||||||
inputName = &data[5];
|
inputName = &data[5];
|
||||||
} else if (etk::start_with(data,"--out=")) {
|
} else if (etk::start_with(data,"--out=")) {
|
||||||
@ -178,10 +178,10 @@ int main(int _argc, const char** _argv) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
TEST_INFO("Read input:");
|
TEST_INFO("Read input:");
|
||||||
std::vector<int16_t> inputData = etk::FSNodeReadAllDataType<int16_t>(inputName);
|
etk::Vector<int16_t> inputData = etk::FSNodeReadAllDataType<int16_t>(inputName);
|
||||||
TEST_INFO(" " << inputData.size() << " samples");
|
TEST_INFO(" " << inputData.size() << " samples");
|
||||||
// resize output :
|
// resize output :
|
||||||
std::vector<int16_t> output;
|
etk::Vector<int16_t> output;
|
||||||
output.resize(inputData.size()*sampleRateOut/sampleRateIn+5000, 0);
|
output.resize(inputData.size()*sampleRateOut/sampleRateIn+5000, 0);
|
||||||
// process in chunk of 256 samples
|
// process in chunk of 256 samples
|
||||||
int32_t blockSize = 256*nbChan;
|
int32_t blockSize = 256*nbChan;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user