[DEV] continue removing stl
This commit is contained in:
parent
0010fc3f19
commit
7c441c30ce
@ -20,8 +20,8 @@ namespace audio {
|
|||||||
int8_t m_nbChannel;
|
int8_t m_nbChannel;
|
||||||
float m_sampleRate;
|
float m_sampleRate;
|
||||||
enum audio::format m_format;
|
enum audio::format m_format;
|
||||||
std::vector<std::vector<float> > m_filter; //!< Current filter
|
etk::Vector<etk::Vector<float> > m_filter; //!< Current filter
|
||||||
std::vector<std::vector<float> > m_feedBack; //!< Feedback history
|
etk::Vector<etk::Vector<float> > m_feedBack; //!< Feedback history
|
||||||
float m_mu; //!< mu step size
|
float m_mu; //!< mu step size
|
||||||
public:
|
public:
|
||||||
LmsPrivate() :
|
LmsPrivate() :
|
||||||
@ -91,7 +91,7 @@ namespace audio {
|
|||||||
float feedback[processingSize];
|
float feedback[processingSize];
|
||||||
float microphone[processingSize];
|
float microphone[processingSize];
|
||||||
int32_t offset = bbb*processingSize;
|
int32_t offset = bbb*processingSize;
|
||||||
int32_t nbData = std::min(processingSize,
|
int32_t nbData = etk::min(processingSize,
|
||||||
_nbSample - offset);
|
_nbSample - offset);
|
||||||
for (size_t iii=0; iii<nbData; ++iii) {
|
for (size_t iii=0; iii<nbData; ++iii) {
|
||||||
microphone[iii] = float(_microphone[offset+iii])/32767.0f;
|
microphone[iii] = float(_microphone[offset+iii])/32767.0f;
|
||||||
@ -119,11 +119,11 @@ namespace audio {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float processValue(float* _feedback, float _microphone, std::vector<float>& _filter) {
|
float processValue(float* _feedback, float _microphone, etk::Vector<float>& _filter) {
|
||||||
// Error calculation.
|
// Error calculation.
|
||||||
float convolutionValue = audio::algo::river::convolution(_feedback, &_filter[0], _filter.size());
|
float convolutionValue = audio::algo::river::convolution(_feedback, &_filter[0], _filter.size());
|
||||||
float error = _microphone - convolutionValue;
|
float error = _microphone - convolutionValue;
|
||||||
float out = std::avg(-1.0f, error, 1.0f);
|
float out = etk::avg(-1.0f, error, 1.0f);
|
||||||
audio::algo::river::updateFilter(&_filter[0], _feedback, error*m_mu, _filter.size());
|
audio::algo::river::updateFilter(&_filter[0], _feedback, error*m_mu, _filter.size());
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -173,15 +173,15 @@ void audio::algo::river::Lms::init(int8_t _nbChannel, float _sampleRate, enum au
|
|||||||
m_private->init(_nbChannel, _sampleRate, _format);
|
m_private->init(_nbChannel, _sampleRate, _format);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::river::Lms::getSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::river::Lms::getSupportedFormat() {
|
||||||
std::vector<enum audio::format> out = getNativeSupportedFormat();
|
etk::Vector<enum audio::format> out = getNativeSupportedFormat();
|
||||||
out.push_back(audio::format_int16);
|
out.pushBack(audio::format_int16);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::river::Lms::getNativeSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::river::Lms::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,12 +93,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.
|
||||||
|
@ -20,8 +20,8 @@ namespace audio {
|
|||||||
int8_t m_nbChannel;
|
int8_t m_nbChannel;
|
||||||
float m_sampleRate;
|
float m_sampleRate;
|
||||||
enum audio::format m_format;
|
enum audio::format m_format;
|
||||||
std::vector<std::vector<float> > m_filter; //!< Current filter
|
etk::Vector<etk::Vector<float> > m_filter; //!< Current filter
|
||||||
std::vector<std::vector<float> > m_feedBack; //!< Feedback history
|
etk::Vector<etk::Vector<float> > m_feedBack; //!< Feedback history
|
||||||
float m_mu; //!< mu step size
|
float m_mu; //!< mu step size
|
||||||
public:
|
public:
|
||||||
NlmsPrivate() :
|
NlmsPrivate() :
|
||||||
@ -91,7 +91,7 @@ namespace audio {
|
|||||||
float feedback[processingSize];
|
float feedback[processingSize];
|
||||||
float microphone[processingSize];
|
float microphone[processingSize];
|
||||||
int32_t offset = bbb*processingSize;
|
int32_t offset = bbb*processingSize;
|
||||||
int32_t nbData = std::min(processingSize,
|
int32_t nbData = etk::min(processingSize,
|
||||||
_nbSample - offset);
|
_nbSample - offset);
|
||||||
for (size_t iii=0; iii<nbData; ++iii) {
|
for (size_t iii=0; iii<nbData; ++iii) {
|
||||||
microphone[iii] = float(_microphone[offset+iii])/32767.0f;
|
microphone[iii] = float(_microphone[offset+iii])/32767.0f;
|
||||||
@ -119,11 +119,11 @@ namespace audio {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float processValue(float* _feedback, float _microphone, std::vector<float>& _filter) {
|
float processValue(float* _feedback, float _microphone, etk::Vector<float>& _filter) {
|
||||||
// Error calculation.
|
// Error calculation.
|
||||||
float convolutionValue = audio::algo::river::convolution(_feedback, &_filter[0], _filter.size());
|
float convolutionValue = audio::algo::river::convolution(_feedback, &_filter[0], _filter.size());
|
||||||
float error = _microphone - convolutionValue;
|
float error = _microphone - convolutionValue;
|
||||||
float out = std::avg(-1.0f, error, 1.0f);
|
float out = etk::avg(-1.0f, error, 1.0f);
|
||||||
// calculate mu:
|
// calculate mu:
|
||||||
float mu = audio::algo::river::power(_feedback, _filter.size());
|
float mu = audio::algo::river::power(_feedback, _filter.size());
|
||||||
//mu = *_feedback * *_feedback;
|
//mu = *_feedback * *_feedback;
|
||||||
@ -184,15 +184,15 @@ void audio::algo::river::Nlms::init(int8_t _nbChannel, float _sampleRate, enum a
|
|||||||
m_private->init(_nbChannel, _sampleRate, _format);
|
m_private->init(_nbChannel, _sampleRate, _format);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::river::Nlms::getSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::river::Nlms::getSupportedFormat() {
|
||||||
std::vector<enum audio::format> out = getNativeSupportedFormat();
|
etk::Vector<enum audio::format> out = getNativeSupportedFormat();
|
||||||
out.push_back(audio::format_int16);
|
out.pushBack(audio::format_int16);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::river::Nlms::getNativeSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::river::Nlms::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,12 +93,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.
|
||||||
|
@ -146,14 +146,14 @@ void audio::algo::river::Supressor::init(int8_t _nbChannel, float _sampleRate, e
|
|||||||
m_private->init(_nbChannel, _sampleRate, _format);
|
m_private->init(_nbChannel, _sampleRate, _format);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::river::Supressor::getSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::river::Supressor::getSupportedFormat() {
|
||||||
std::vector<enum audio::format> out = getNativeSupportedFormat();
|
etk::Vector<enum audio::format> out = getNativeSupportedFormat();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<enum audio::format> audio::algo::river::Supressor::getNativeSupportedFormat() {
|
etk::Vector<enum audio::format> audio::algo::river::Supressor::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +44,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.
|
||||||
|
@ -37,8 +37,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++;
|
||||||
|
|
||||||
@ -64,15 +64,15 @@ 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);
|
||||||
ethread::setName("test thread");
|
ethread::setName("test thread");
|
||||||
std::string fbName = "";
|
etk::String fbName = "";
|
||||||
std::string micName = "";
|
etk::String micName = "";
|
||||||
int32_t filterSize = 0;
|
int32_t filterSize = 0;
|
||||||
float mu = 0.0f;
|
float mu = 0.0f;
|
||||||
bool nlms = false;
|
bool nlms = false;
|
||||||
bool perf = false;
|
bool perf = false;
|
||||||
int64_t sampleRate = 48000;
|
int64_t sampleRate = 48000;
|
||||||
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,"--fb=")) {
|
if (etk::start_with(data,"--fb=")) {
|
||||||
fbName = &data[5];
|
fbName = &data[5];
|
||||||
} else if (etk::start_with(data,"--mic=")) {
|
} else if (etk::start_with(data,"--mic=")) {
|
||||||
@ -114,14 +114,14 @@ int main(int _argc, const char** _argv) {
|
|||||||
Performance perfo;
|
Performance perfo;
|
||||||
|
|
||||||
TEST_INFO("Read FeedBack:");
|
TEST_INFO("Read FeedBack:");
|
||||||
std::vector<int16_t> fbData = etk::FSNodeReadAllDataType<int16_t>(fbName);
|
etk::Vector<int16_t> fbData = etk::FSNodeReadAllDataType<int16_t>(fbName);
|
||||||
TEST_INFO(" " << fbData.size() << " samples");
|
TEST_INFO(" " << fbData.size() << " samples");
|
||||||
TEST_INFO("Read Microphone:");
|
TEST_INFO("Read Microphone:");
|
||||||
std::vector<int16_t> micData = etk::FSNodeReadAllDataType<int16_t>(micName);
|
etk::Vector<int16_t> micData = etk::FSNodeReadAllDataType<int16_t>(micName);
|
||||||
TEST_INFO(" " << micData.size() << " samples");
|
TEST_INFO(" " << micData.size() << " samples");
|
||||||
// resize output :
|
// resize output :
|
||||||
std::vector<int16_t> output;
|
etk::Vector<int16_t> output;
|
||||||
output.resize(std::min(fbData.size(), micData.size()), 0);
|
output.resize(etk::min(fbData.size(), micData.size()), 0);
|
||||||
// process in chunk of 256 samples
|
// process in chunk of 256 samples
|
||||||
int32_t blockSize = 256;
|
int32_t blockSize = 256;
|
||||||
if (nlms == false) {
|
if (nlms == false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user