[DEV] continue removing stl

This commit is contained in:
Edouard DUPIN 2017-08-28 00:08:17 +02:00
parent 2bd207471f
commit 567bdd6a86
29 changed files with 317 additions and 317 deletions

View File

@ -59,16 +59,16 @@ void audio::drain::Algo::configurationChange() {
}
}
std::string audio::drain::Algo::getDotDesc() {
std::string out;
etk::String audio::drain::Algo::getDotDesc() {
etk::String out;
if (m_input.getFormat() != m_output.getFormat()) {
out += "\\nformat: " + etk::to_string(m_input.getFormat()) + "->" + etk::to_string(m_output.getFormat());
out += "\\nformat: " + etk::toString(m_input.getFormat()) + "->" + etk::to_string(m_output.getFormat());
}
if (m_input.getMap() != m_output.getMap()) {
out += "\\nmap: " + etk::to_string(m_input.getMap()) + "->" + etk::to_string(m_output.getMap());
out += "\\nmap: " + etk::toString(m_input.getMap()) + "->" + etk::to_string(m_output.getMap());
}
if (m_input.getFrequency() != m_output.getFrequency()) {
out += "\\nsamplerate: " + etk::to_string(m_input.getFrequency()) + "->" + etk::to_string(m_output.getFrequency());
out += "\\nsamplerate: " + etk::toString(m_input.getFrequency()) + "->" + etk::to_string(m_output.getFrequency());
}
return out;
}
@ -116,7 +116,7 @@ void audio::drain::Algo::setStatusFunction(algoStatusFunction _newFunction) {
m_statusFunction = _newFunction;
}
void audio::drain::Algo::generateStatus(const std::string& _status) {
void audio::drain::Algo::generateStatus(const etk::String& _status) {
if (m_statusFunction != nullptr) {
if (m_name.size() == 0) {
m_statusFunction(m_type, _status);

View File

@ -5,8 +5,8 @@
*/
#pragma once
#include <string>
#include <vector>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <cstdint>
#include <audio/format.hpp>
#include <audio/channel.hpp>
@ -27,28 +27,28 @@ namespace audio {
* @brief audio-algo library namespace
*/
namespace drain{
typedef std::function<void (const std::string& _origin, const std::string& _status)> algoStatusFunction;
typedef std::function<void (const etk::String& _origin, const etk::String& _status)> algoStatusFunction;
class Algo : public ememory::EnableSharedFromThis<Algo> {
private:
std::string m_name;
etk::String m_name;
public:
const std::string& getName() const {
const etk::String& getName() const {
return m_name;
}
void setName(const std::string& _name) {
void setName(const etk::String& _name) {
m_name = _name;
}
protected:
std::string m_type;
etk::String m_type;
public:
const std::string& getType() const {
const etk::String& getType() const {
return m_type;
}
void setType(const std::string& _type) {
void setType(const etk::String& _type) {
m_type = _type;
}
public:
virtual std::string getDotDesc();
virtual etk::String getDotDesc();
private:
bool m_temporary;
public:
@ -63,9 +63,9 @@ namespace audio {
public:
void setStatusFunction(algoStatusFunction _newFunction);
protected:
void generateStatus(const std::string& _status);
void generateStatus(const etk::String& _status);
protected:
std::vector<int8_t> m_outputData;
etk::Vector<int8_t> m_outputData;
int8_t m_formatSize; //!< sample size
/**
* @brief Constructor
@ -138,58 +138,58 @@ namespace audio {
// TODO : Manage the change of the timestamp ...
virtual size_t needInputData(size_t _output);
protected: // note when nothing ==> support all type
std::vector<audio::format> m_supportedFormat;
etk::Vector<audio::format> m_supportedFormat;
public:
virtual std::vector<audio::format> getFormatSupportedInput() {
virtual etk::Vector<audio::format> getFormatSupportedInput() {
if (m_output.getConfigured() == true) {
std::vector<audio::format> out;
out.push_back(m_output.getFormat());
etk::Vector<audio::format> out;
out.pushBack(m_output.getFormat());
return out;
}
return m_supportedFormat;
};
virtual std::vector<audio::format> getFormatSupportedOutput() {
virtual etk::Vector<audio::format> getFormatSupportedOutput() {
if (m_input.getConfigured() == true) {
std::vector<audio::format> out;
out.push_back(m_input.getFormat());
etk::Vector<audio::format> out;
out.pushBack(m_input.getFormat());
return out;
}
return m_supportedFormat;
};
protected: // note when nothing ==> support all type
std::vector<std::vector<audio::channel> > m_supportedMap;
etk::Vector<etk::Vector<audio::channel> > m_supportedMap;
public:
virtual std::vector<std::vector<audio::channel> > getMapSupportedInput() {
virtual etk::Vector<etk::Vector<audio::channel> > getMapSupportedInput() {
if (m_output.getConfigured() == true) {
std::vector<std::vector<audio::channel> > out;
out.push_back(m_output.getMap());
etk::Vector<etk::Vector<audio::channel> > out;
out.pushBack(m_output.getMap());
return out;
}
return m_supportedMap;
};
virtual std::vector<std::vector<audio::channel> > getMapSupportedOutput() {
virtual etk::Vector<etk::Vector<audio::channel> > getMapSupportedOutput() {
if (m_input.getConfigured() == true) {
std::vector<std::vector<audio::channel> > out;
out.push_back(m_input.getMap());
etk::Vector<etk::Vector<audio::channel> > out;
out.pushBack(m_input.getMap());
return out;
}
return m_supportedMap;
};
protected: // note when nothing ==> support all type
std::vector<float> m_supportedFrequency;
etk::Vector<float> m_supportedFrequency;
public:
virtual std::vector<float> getFrequencySupportedInput() {
virtual etk::Vector<float> getFrequencySupportedInput() {
if (m_output.getConfigured() == true) {
std::vector<float> out;
out.push_back(m_output.getFrequency());
etk::Vector<float> out;
out.pushBack(m_output.getFrequency());
return out;
}
return m_supportedFrequency;
};
virtual std::vector<float> getFrequencySupportedOutput() {
virtual etk::Vector<float> getFrequencySupportedOutput() {
if (m_input.getConfigured() == true) {
std::vector<float> out;
out.push_back(m_input.getFrequency());
etk::Vector<float> out;
out.pushBack(m_input.getFrequency());
return out;
}
return m_supportedFrequency;
@ -202,19 +202,19 @@ namespace audio {
* @return true set done
* @return false An error occured
*/
virtual bool setParameter(const std::string& _parameter, const std::string& _value) { return false; }
virtual bool setParameter(const etk::String& _parameter, const etk::String& _value) { return false; }
/**
* @brief Get a parameter value
* @param[in] _parameter Parameter name.
* @return The requested value.
*/
virtual std::string getParameter(const std::string& _parameter) const { return "[ERROR]"; }
virtual etk::String getParameter(const etk::String& _parameter) const { return "[ERROR]"; }
/**
* @brief Get a parameter value
* @param[in] _parameter Parameter name.
* @return The requested value.
*/
virtual std::string getParameterProperty(const std::string& _parameter) const { return "[ERROR]"; };
virtual etk::String getParameterProperty(const etk::String& _parameter) const { return "[ERROR]"; };
};
}
}

View File

@ -7,7 +7,7 @@
#include "AutoLogInOut.hpp"
#include "debug.hpp"
audio::drain::AutoLogInOut::AutoLogInOut(const std::string& _value) :
audio::drain::AutoLogInOut::AutoLogInOut(const etk::String& _value) :
m_value(_value) {
DRAIN_VERBOSE(" '" << m_value << "' [START]");
}

View File

@ -5,16 +5,16 @@
*/
#pragma once
#include <string>
#include <etk/String.hpp>
#include "debug.hpp"
namespace audio {
namespace drain{
class AutoLogInOut {
private:
std::string m_value;
etk::String m_value;
public:
AutoLogInOut(const std::string& _value);
AutoLogInOut(const etk::String& _value);
~AutoLogInOut();
};
}

View File

@ -196,7 +196,7 @@ size_t audio::drain::CircularBuffer::read(void* _data, size_t _nbChunk, const au
} else if (deltaTime.count() > 0) {
// Add empty sample in the output buffer ...
size_t nbSampleEmpty = m_frequency*deltaTime.count()/100000000;
nbSampleEmpty = std::min(nbSampleEmpty, _nbChunk);
nbSampleEmpty = etk::min(nbSampleEmpty, _nbChunk);
DRAIN_WARNING("add Empty sample in the output buffer " << nbSampleEmpty << " / " << _nbChunk);
memset(_data, 0, nbSampleEmpty * m_sizeChunk);
if (nbSampleEmpty == _nbChunk) {
@ -258,7 +258,7 @@ void audio::drain::CircularBuffer::setReadPosition(const audio::Time& _time) {
// check the time of the read :
audio::Duration deltaTime = _time - m_timeRead;
size_t nbSampleToRemove = int64_t(m_frequency)*int64_t(deltaTime.count())/1000000000LL;
nbSampleToRemove = std::min(nbSampleToRemove, m_size);
nbSampleToRemove = etk::min(nbSampleToRemove, m_size);
DRAIN_VERBOSE("Remove sample in the buffer " << nbSampleToRemove << " / " << m_size);
audio::Duration updateTime(0,(int64_t(nbSampleToRemove)*1000000000LL)/int64_t(m_frequency));
DRAIN_VERBOSE(" add time : " << updateTime.count() << "ns / " << deltaTime.count() << "ns");

View File

@ -6,7 +6,7 @@
#pragma once
#include <etk/types.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <chrono>
#include <audio/Time.hpp>
#include <audio/Duration.hpp>
@ -40,7 +40,7 @@ namespace audio {
*/
class CircularBuffer {
private:
std::vector<uint8_t> m_data; //!< data pointer
etk::Vector<uint8_t> m_data; //!< data pointer
void* m_write; //!< write pointer
void* m_read; //!< read pointer
audio::Time m_timeRead; //!< current read time

View File

@ -15,13 +15,13 @@ namespace audio {
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map)> playbackFunction;
const etk::Vector<audio::channel>& _map)> playbackFunction;
typedef std::function<void (const void* _data,
const audio::Time& _readTime,
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map)> recordFunction;
const etk::Vector<audio::channel>& _map)> recordFunction;
class EndPointCallback : public EndPoint {
private:
playbackFunction m_outputFunction;

View File

@ -94,7 +94,7 @@ bool audio::drain::EndPointWrite::process(audio::Time& _time,
m_bufferUnderFlowSize = 0;
DRAIN_VERBOSE("Write " << _outputNbChunk << " chunks");
// check if we have enought data:
int32_t nbChunkToCopy = std::min(_inputNbChunk, m_buffer.getSize());
int32_t nbChunkToCopy = etk::min(_inputNbChunk, m_buffer.getSize());
if (nbChunkToCopy != _inputNbChunk) {
generateStatus("EPW_UNDERFLOW");
}

View File

@ -16,7 +16,7 @@ namespace audio {
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map)> playbackFunctionWrite;
const etk::Vector<audio::channel>& _map)> playbackFunctionWrite;
class EndPointWrite : public EndPoint {
private:
audio::drain::CircularBuffer m_buffer;

View File

@ -18,8 +18,8 @@ audio::drain::Equalizer::Equalizer() {
void audio::drain::Equalizer::init() {
audio::drain::Algo::init();
audio::drain::Algo::m_type = "Equalizer";
m_supportedFormat.push_back(audio::format_int16);
m_supportedFormat.push_back(audio::format_int16);
m_supportedFormat.pushBack(audio::format_int16);
m_supportedFormat.pushBack(audio::format_int16);
configureBiQuad();
}
@ -52,7 +52,7 @@ bool audio::drain::Equalizer::process(audio::Time& _time,
return true;
}
bool audio::drain::Equalizer::setParameter(const std::string& _parameter, const std::string& _value) {
bool audio::drain::Equalizer::setParameter(const etk::String& _parameter, const etk::String& _value) {
//DRAIN_WARNING("set : " << _parameter << " " << _value);
if (_parameter == "config") {
m_config = ejson::Object(_value);
@ -64,17 +64,17 @@ bool audio::drain::Equalizer::setParameter(const std::string& _parameter, const
return false;
}
std::string audio::drain::Equalizer::getParameter(const std::string& _parameter) const {
etk::String audio::drain::Equalizer::getParameter(const etk::String& _parameter) const {
return "error";
}
std::string audio::drain::Equalizer::getParameterProperty(const std::string& _parameter) const {
etk::String audio::drain::Equalizer::getParameterProperty(const etk::String& _parameter) const {
return "error";
}
void audio::drain::Equalizer::addBiquad(int32_t _idBiquad, const ejson::Object& _object) {
// get type:
std::string typeString = _object["type"].toString().get("none");
etk::String typeString = _object["type"].toString().get("none");
if (typeString == "direct-value") {
double a0 = _object["a0"].toNumber().get(0.0);
double a1 = _object["a1"].toNumber().get(0.0);
@ -125,7 +125,7 @@ void audio::drain::Equalizer::configureBiQuad() {
return;
}
for (size_t iii=0; iii<getOutputFormat().getMap().size(); ++iii) {
std::string channelName = etk::to_string(getOutputFormat().getMap()[iii]);
etk::String channelName = etk::toString(getOutputFormat().getMap()[iii]);
const ejson::Array channelConfig = m_config[channelName].toArray();
if (channelConfig.exist() == false) {
// no config ... not a problem ...
@ -145,6 +145,6 @@ void audio::drain::Equalizer::configureBiQuad() {
return;
}
std::vector<std::pair<float,float> > audio::drain::Equalizer::calculateTheory() {
etk::Vector<etk::Pair<float,float> > audio::drain::Equalizer::calculateTheory() {
return m_algo.calculateTheory();
}

View File

@ -36,9 +36,9 @@ namespace audio {
protected:
ejson::Object m_config; // configuration of the equalizer.
public:
virtual bool setParameter(const std::string& _parameter, const std::string& _value);
virtual std::string getParameter(const std::string& _parameter) const;
virtual std::string getParameterProperty(const std::string& _parameter) const;
virtual bool setParameter(const etk::String& _parameter, const etk::String& _value);
virtual etk::String getParameter(const etk::String& _parameter) const;
virtual etk::String getParameterProperty(const etk::String& _parameter) const;
protected:
void addBiquad(int32_t _idBiquad, const ejson::Object& _object);
audio::algo::drain::Equalizer m_algo;
@ -48,7 +48,7 @@ namespace audio {
void configureBiQuad();
public:
// for debug & tools only
std::vector<std::pair<float,float> > calculateTheory();
etk::Vector<etk::Pair<float,float> > calculateTheory();
};
}
}

View File

@ -49,14 +49,14 @@ static void convert__int16_on_int32__to__int16(void* _input, void* _output, size
int32_t* in = static_cast<int32_t*>(_input);
int16_t* out = static_cast<int16_t*>(_output);
for (size_t iii=0; iii<_nbSample; ++iii) {
out[iii] = static_cast<int16_t>(std::min(std::max(INT16_MIN, in[iii]), INT16_MAX));
out[iii] = static_cast<int16_t>(etk::min(etk::max(INT16_MIN, in[iii]), INT16_MAX));
}
}
static void convert__int16_on_int32__to__int32(void* _input, void* _output, size_t _nbSample) {
int32_t* in = static_cast<int32_t*>(_input);
int32_t* out = static_cast<int32_t*>(_output);
for (size_t iii=0; iii<_nbSample; ++iii) {
int32_t value = std::min(std::max(INT16_MIN, in[iii]), INT16_MAX);
int32_t value = etk::min(etk::max(INT16_MIN, in[iii]), INT16_MAX);
out[iii] = value << 16;
}
}
@ -74,7 +74,7 @@ static void convert__int32__to__int16(void* _input, void* _output, size_t _nbSam
int16_t* out = static_cast<int16_t*>(_output);
for (size_t iii=0; iii<_nbSample; ++iii) {
int32_t value = in[iii] >> 16;
out[iii] = static_cast<int16_t>(std::min(std::max(INT16_MIN, value), INT16_MAX));
out[iii] = static_cast<int16_t>(etk::min(etk::max(INT16_MIN, value), INT16_MAX));
}
}
static void convert__int32__to__int16_on_int32(void* _input, void* _output, size_t _nbSample) {
@ -98,7 +98,7 @@ static void convert__float__to__int16(void* _input, void* _output, size_t _nbSam
int16_t* out = static_cast<int16_t*>(_output);
for (size_t iii=0; iii<_nbSample; ++iii) {
float value = in[iii] * static_cast<float>(INT16_MAX);
value = std::min(std::max(static_cast<float>(INT16_MIN), value), static_cast<float>(INT16_MAX));
value = etk::min(etk::max(static_cast<float>(INT16_MIN), value), static_cast<float>(INT16_MAX));
out[iii] = static_cast<int16_t>(value);
//DRAIN_DEBUG(iii << " in=" << in[iii] << " out=" << out[iii]);
}
@ -108,7 +108,7 @@ static void convert__float__to__int16_on_int32(void* _input, void* _output, size
int32_t* out = static_cast<int32_t*>(_output);
for (size_t iii=0; iii<_nbSample; ++iii) {
float value = in[iii] * static_cast<float>(INT16_MAX);
value = std::min(std::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
value = etk::min(etk::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
out[iii] = static_cast<int32_t>(value);
}
}
@ -117,7 +117,7 @@ static void convert__float__to__int32(void* _input, void* _output, size_t _nbSam
int32_t* out = static_cast<int32_t*>(_output);
for (size_t iii=0; iii<_nbSample; ++iii) {
float value = in[iii] * static_cast<float>(INT32_MAX);
value = std::min(std::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
value = etk::min(etk::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
out[iii] = static_cast<int32_t>(value);
}
}

View File

@ -7,7 +7,7 @@
#include "IOFormatInterface.hpp"
#include "debug.hpp"
std::ostream& audio::drain::operator <<(std::ostream& _os, const IOFormatInterface& _obj) {
etk::Stream& audio::drain::operator <<(etk::Stream& _os, const IOFormatInterface& _obj) {
_os << "{";
if (_obj.getConfigured() == false) {
_os << "Not configured";
@ -25,11 +25,11 @@ audio::drain::IOFormatInterface::IOFormatInterface() :
m_format(audio::format_unknow),
m_map(),
m_frequency(0) {
m_map.push_back(audio::channel_frontLeft);
m_map.push_back(audio::channel_frontRight);
m_map.pushBack(audio::channel_frontLeft);
m_map.pushBack(audio::channel_frontRight);
}
audio::drain::IOFormatInterface::IOFormatInterface(std::vector<enum audio::channel> _map, enum audio::format _format, float _frequency) :
audio::drain::IOFormatInterface::IOFormatInterface(etk::Vector<enum audio::channel> _map, enum audio::format _format, float _frequency) :
m_configured(true),
m_format(_format),
m_map(_map),
@ -37,7 +37,7 @@ audio::drain::IOFormatInterface::IOFormatInterface(std::vector<enum audio::chann
}
void audio::drain::IOFormatInterface::set(std::vector<enum audio::channel> _map, enum audio::format _format, float _frequency) {
void audio::drain::IOFormatInterface::set(etk::Vector<enum audio::channel> _map, enum audio::format _format, float _frequency) {
bool hasChange = false;
if (m_map != _map) {
m_map = _map;
@ -78,11 +78,11 @@ void audio::drain::IOFormatInterface::setFormat(enum audio::format _value) {
configurationChange();
}
const std::vector<enum audio::channel>& audio::drain::IOFormatInterface::getMap() const{
const etk::Vector<enum audio::channel>& audio::drain::IOFormatInterface::getMap() const{
return m_map;
}
void audio::drain::IOFormatInterface::setMap(const std::vector<enum audio::channel>& _value) {
void audio::drain::IOFormatInterface::setMap(const etk::Vector<enum audio::channel>& _value) {
if (m_map == _value) {
return;
}

View File

@ -5,8 +5,8 @@
*/
#pragma once
#include <string>
#include <vector>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <cstdint>
#include <audio/format.hpp>
#include <audio/channel.hpp>
@ -21,8 +21,8 @@ namespace audio {
class IOFormatInterface {
public:
IOFormatInterface();
IOFormatInterface(std::vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f);
void set(std::vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f);
IOFormatInterface(etk::Vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f);
void set(etk::Vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f);
protected:
bool m_configured;
public:
@ -42,18 +42,18 @@ namespace audio {
*/
void setFormat(enum audio::format _value);
protected:
std::vector<enum audio::channel> m_map; //!< input channel Map
etk::Vector<enum audio::channel> m_map; //!< input channel Map
public:
/**
* @brief Get the algo channel Map.
* @return the current channel Map.
*/
const std::vector<enum audio::channel>& getMap() const;
const etk::Vector<enum audio::channel>& getMap() const;
/**
* @brief Set the algo channel Map.
* @param[in] _value New channel Map.
*/
void setMap(const std::vector<enum audio::channel>& _value);
void setMap(const etk::Vector<enum audio::channel>& _value);
protected:
float m_frequency; //!< input Algo Format
public:
@ -83,7 +83,7 @@ namespace audio {
*/
void setCallback(const std::function<void()>& _functor);
};
std::ostream& operator <<(std::ostream& _os, const audio::drain::IOFormatInterface& _obj);
etk::Stream& operator <<(etk::Stream& _os, const audio::drain::IOFormatInterface& _obj);
}
}

View File

@ -4,8 +4,8 @@
* @license MPL v2.0 (see license file)
*/
#include <string>
#include <vector>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <cstdint>
#include <audio/format.hpp>
#include <audio/channel.hpp>
@ -69,7 +69,7 @@ bool audio::drain::Process::pull(audio::Time& _time,
}
}
// copy only data availlable :
int32_t minByTeSize = std::min(m_data.size(), _nbChunk*_chunkSize);
int32_t minByTeSize = etk::min(m_data.size(), _nbChunk*_chunkSize);
if (minByTeSize >= 0) {
memcpy(_data, &m_data[0], minByTeSize);
m_data.erase(m_data.begin(), m_data.begin()+minByTeSize);
@ -104,7 +104,7 @@ bool audio::drain::Process::process(audio::Time& _time,
void audio::drain::Process::pushBack(ememory::SharedPtr<audio::drain::Algo> _algo) {
removeAlgoDynamic();
_algo->setStatusFunction(std::bind(&audio::drain::Process::generateStatus, this, std::placeholders::_1, std::placeholders::_2));
m_listAlgo.push_back(_algo);
m_listAlgo.pushBack(_algo);
}
void audio::drain::Process::pushFront(ememory::SharedPtr<audio::drain::Algo> _algo) {
@ -113,8 +113,8 @@ void audio::drain::Process::pushFront(ememory::SharedPtr<audio::drain::Algo> _al
m_listAlgo.insert(m_listAlgo.begin(), _algo);
}
template<typename T> std::vector<T> getUnion(const std::vector<T>& _out, const std::vector<T>& _in) {
std::vector<T> out;
template<typename T> etk::Vector<T> getUnion(const etk::Vector<T>& _out, const std::vector<T>& _in) {
etk::Vector<T> out;
if (_out.size() == 0) {
// Last is ok for all format
// ==> set the limit with the next element
@ -126,7 +126,7 @@ template<typename T> std::vector<T> getUnion(const std::vector<T>& _out, const s
for (size_t ooo=0; ooo<_out.size(); ++ooo) {
for (size_t iii=0; iii<_in.size(); ++iii) {
if (_out[ooo] == _in[iii]) {
out.push_back(_out[ooo]);
out.pushBack(_out[ooo]);
}
}
}
@ -173,54 +173,54 @@ void audio::drain::Process::updateAlgo(size_t _position) {
)
) {
// step 1 : check frequency:
std::vector<float> freqOut;
std::vector<float> freqIn;
etk::Vector<float> freqOut;
etk::Vector<float> freqIn;
if (_position == 0) {
freqOut.push_back(m_inputConfig.getFrequency());
freqOut.pushBack(m_inputConfig.getFrequency());
} else {
freqOut = m_listAlgo[_position-1]->getFrequencySupportedOutput();
}
if (_position == m_listAlgo.size()) {
freqIn.push_back(m_outputConfig.getFrequency());
freqIn.pushBack(m_outputConfig.getFrequency());
} else {
freqIn = m_listAlgo[_position]->getFrequencySupportedInput();
}
std::vector<float> freq = getUnion<float>(freqOut, freqIn);
etk::Vector<float> freq = getUnion<float>(freqOut, freqIn);
DRAIN_VERBOSE(" freq out :" << freqOut);
DRAIN_VERBOSE(" freq in :" << freqIn);
DRAIN_VERBOSE(" freq union :" << freq);
// step 2 : Check map:
std::vector<std::vector<audio::channel> > mapOut;
std::vector<std::vector<audio::channel> > mapIn;
etk::Vector<etk::Vector<audio::channel> > mapOut;
etk::Vector<etk::Vector<audio::channel> > mapIn;
if (_position == 0) {
mapOut.push_back(m_inputConfig.getMap());
mapOut.pushBack(m_inputConfig.getMap());
} else {
mapOut = m_listAlgo[_position-1]->getMapSupportedOutput();
}
if (_position == m_listAlgo.size()) {
mapIn.push_back(m_outputConfig.getMap());
mapIn.pushBack(m_outputConfig.getMap());
} else {
mapIn = m_listAlgo[_position]->getMapSupportedInput();
}
std::vector<std::vector<audio::channel> > map = getUnion<std::vector<audio::channel> >(mapOut, mapIn);
etk::Vector<etk::Vector<audio::channel> > map = getUnion<std::vector<audio::channel> >(mapOut, mapIn);
DRAIN_VERBOSE(" map out :" << mapOut);
DRAIN_VERBOSE(" map in :" << mapIn);
DRAIN_VERBOSE(" map union :" << map);
// step 3 : Check Format:
std::vector<audio::format> formatOut;
std::vector<audio::format> formatIn;
etk::Vector<audio::format> formatOut;
etk::Vector<audio::format> formatIn;
if (_position == 0) {
formatOut.push_back(m_inputConfig.getFormat());
formatOut.pushBack(m_inputConfig.getFormat());
} else {
formatOut = m_listAlgo[_position-1]->getFormatSupportedOutput();
}
if (_position == m_listAlgo.size()) {
formatIn.push_back(m_outputConfig.getFormat());
formatIn.pushBack(m_outputConfig.getFormat());
} else {
formatIn = m_listAlgo[_position]->getFormatSupportedInput();
}
std::vector<audio::format> format = getUnion<audio::format>(formatOut, formatIn);
etk::Vector<audio::format> format = getUnion<audio::format>(formatOut, formatIn);
DRAIN_VERBOSE(" format out :" << formatOut);
DRAIN_VERBOSE(" format in :" << formatIn);
DRAIN_VERBOSE(" format union :" << format);
@ -439,7 +439,7 @@ bool audio::drain::Process::processIn(void* _inData,
return false;
}
static void link(etk::FSNode& _node, const std::string& _first, const std::string& _op, const std::string& _second, bool _isLink=true) {
static void link(etk::FSNode& _node, const etk::String& _first, const etk::String& _op, const std::string& _second, bool _isLink=true) {
if (_op == "->") {
if (_isLink) {
_node << " " << _first << " -> " << _second << ";\n";
@ -459,8 +459,8 @@ static void link(etk::FSNode& _node, const std::string& _first, const std::strin
void audio::drain::Process::generateDot(etk::FSNode& _node,
int32_t _offset,
int32_t _basicID,
std::string& _nameIn,
std::string& _nameOut,
etk::String& _nameIn,
etk::String& _nameOut,
bool _reserseGraph) {
_node << " subgraph clusterNode_" << _basicID << "_process {\n";
_node << " label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n";
@ -470,14 +470,14 @@ void audio::drain::Process::generateDot(etk::FSNode& _node,
// ----------------------
// -- STEP 1 --
// ----------------------
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
_node << " " << _nameIn << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
<< "\\n freq=" << getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
// ----------------------
// -- STEP 2 --
// ----------------------
std::string connectString = _nameIn;
etk::String connectString = _nameIn;
_node << " node [shape=box];\n";
// ----------------------
// -- STEP 3 --
@ -486,12 +486,12 @@ void audio::drain::Process::generateDot(etk::FSNode& _node,
if (m_listAlgo[iii] == nullptr) {
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
@ -506,10 +506,10 @@ void audio::drain::Process::generateDot(etk::FSNode& _node,
// ----------------------
// -- STEP 5 --
// ----------------------
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
_node << " " << _nameOut << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
<< "\\n freq=" << getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
// ----------------------
// -- STEP 6 --
// ----------------------
@ -518,14 +518,14 @@ void audio::drain::Process::generateDot(etk::FSNode& _node,
// ----------------------
// -- STEP 1 --
// ----------------------
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
_node << " " << _nameIn << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
<< "\\n freq=" << getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
// ----------------------
// -- STEP 2 --
// ----------------------
std::string connectString = _nameIn;
etk::String connectString = _nameIn;
_node << " node [shape=box];\n";
// ----------------------
// -- STEP 3 --
@ -535,12 +535,12 @@ void audio::drain::Process::generateDot(etk::FSNode& _node,
if (m_listAlgo[iii] == nullptr) {
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
@ -557,10 +557,10 @@ void audio::drain::Process::generateDot(etk::FSNode& _node,
// ----------------------
// -- STEP 5 --
// ----------------------
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
_node << " " << _nameOut << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
<< "\\n freq=" << getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
// ----------------------
// -- STEP 6 --
// ----------------------
@ -569,35 +569,35 @@ void audio::drain::Process::generateDot(etk::FSNode& _node,
_node << " }\n";
}
void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph) {
void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offset, int32_t _basicID, etk::String& _nameIn, etk::String& _nameOut, bool _reserseGraph) {
_node << " subgraph clusterNode_" << _basicID << "_process {\n";
_node << " label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n";
_node << " node [shape=ellipse];\n";
if (_reserseGraph == true) {
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
_node << " " << _nameIn << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
<< "\\n freq=" << getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
} else {
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
_node << " " << _nameIn << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
<< "\\n freq=" << getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
}
std::string connectString = _nameIn;
etk::String connectString = _nameIn;
_node << " node [shape=box];\n";
if (_reserseGraph == false) {
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
if (m_listAlgo[iii] == nullptr) {
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
@ -611,12 +611,12 @@ void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offs
if (m_listAlgo[iii] == nullptr) {
continue;
}
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::to_string(iii);
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
if (m_listAlgo[iii]->getName() != "") {
_node << "\\nname='" << m_listAlgo[iii]->getName() << "'";
}
std::string tmpDesc = m_listAlgo[iii]->getDotDesc();
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
if (tmpDesc.size() != 0) {
_node << tmpDesc;
}
@ -627,15 +627,15 @@ void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offs
}
_node << " node [shape=ellipse];\n";
if (_reserseGraph == true) {
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
_node << " " << _nameOut << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
<< "\\n freq=" << getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
} else {
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
_node << " " << _nameOut << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
<< "\\n freq=" << getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
}
if (_reserseGraph == false) {
link(_node, connectString, "->", _nameOut);
@ -646,7 +646,7 @@ void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offs
}
void audio::drain::Process::generateStatus(const std::string& _origin, const std::string& _status) {
void audio::drain::Process::generateStatus(const etk::String& _origin, const etk::String& _status) {
if (m_statusFunction != nullptr) {
m_statusFunction(_origin, _status);
}

View File

@ -5,8 +5,8 @@
*/
#pragma once
#include <string>
#include <vector>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <cstdint>
#include <audio/format.hpp>
#include <audio/channel.hpp>
@ -17,10 +17,10 @@
namespace audio {
namespace drain{
typedef std::function<void (const std::string& _origin, const std::string& _status)> statusFunction;
typedef std::function<void (const etk::String& _origin, const etk::String& _status)> statusFunction;
class Process {
protected:
std::vector<int8_t> m_data; //!< temporary overlap output buffer (change size of the output data)
etk::Vector<int8_t> m_data; //!< temporary overlap output buffer (change size of the output data)
public:
Process();
virtual ~Process();
@ -94,7 +94,7 @@ namespace audio {
m_outputConfig = _interface;
}
protected:
std::vector<ememory::SharedPtr<drain::Algo> > m_listAlgo;
etk::Vector<ememory::SharedPtr<drain::Algo> > m_listAlgo;
public:
void pushBack(ememory::SharedPtr<drain::Algo> _algo);
void pushFront(ememory::SharedPtr<drain::Algo> _algo);
@ -105,17 +105,17 @@ namespace audio {
size_t size() {
return m_listAlgo.size();
}
std::vector<ememory::SharedPtr<drain::Algo> >::iterator begin() {
etk::Vector<ememory::SharedPtr<drain::Algo> >::iterator begin() {
return m_listAlgo.begin();
}
std::vector<ememory::SharedPtr<drain::Algo> >::iterator end() {
etk::Vector<ememory::SharedPtr<drain::Algo> >::iterator end() {
return m_listAlgo.end();
}
ememory::SharedPtr<drain::Algo> operator[](int32_t _id) {
return m_listAlgo[_id];
}
template<typename T> ememory::SharedPtr<T> get(const std::string& _name) {
template<typename T> ememory::SharedPtr<T> get(const etk::String& _name) {
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
if (m_listAlgo[iii] == nullptr) {
continue;
@ -126,7 +126,7 @@ namespace audio {
}
return ememory::SharedPtr<T>();
}
template<typename T> ememory::SharedPtr<const T> get(const std::string& _name) const {
template<typename T> ememory::SharedPtr<const T> get(const etk::String& _name) const {
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
if (m_listAlgo[iii] == nullptr) {
continue;
@ -168,7 +168,7 @@ namespace audio {
private:
statusFunction m_statusFunction;
public:
void generateStatus(const std::string& _origin, const std::string& _status);
void generateStatus(const etk::String& _origin, const etk::String& _status);
void setStatusFunction(statusFunction _newFunction);
private:
bool m_isConfigured;
@ -179,9 +179,9 @@ namespace audio {
void displayAlgo();
void updateAlgo(size_t _position);
public:
void generateDot(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph);
void generateDot(etk::FSNode& _node, int32_t _offset, int32_t _basicID, etk::String& _nameIn, etk::String& _nameOut, bool _reserseGraph);
// TODO : Remove this one when we find a good way to do it ...
void generateDotProcess(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph);
void generateDotProcess(etk::FSNode& _node, int32_t _offset, int32_t _basicID, etk::String& _nameIn, etk::String& _nameOut, bool _reserseGraph);
};
}
}

View File

@ -20,7 +20,7 @@ audio::drain::Resampler::Resampler() :
void audio::drain::Resampler::init() {
audio::drain::Algo::init();
m_type = "Resampler";
m_supportedFormat.push_back(audio::format_int16);
m_supportedFormat.pushBack(audio::format_int16);
m_residualTimeInResampler = audio::Duration(0);
}

View File

@ -18,8 +18,8 @@ audio::drain::Volume::Volume() :
void audio::drain::Volume::init() {
audio::drain::Algo::init();
m_type = "Volume";
m_supportedFormat.push_back(audio::format_int16);
m_supportedFormat.push_back(audio::format_int16_on_int32);
m_supportedFormat.pushBack(audio::format_int16);
m_supportedFormat.pushBack(audio::format_int16_on_int32);
}
ememory::SharedPtr<audio::drain::Volume> audio::drain::Volume::create() {
@ -37,7 +37,7 @@ static int32_t neareastsss(float _val) {
while (_val > float(1<<out)) {
out++;
}
return std::min(16,out);
return etk::min(16,out);
}
@ -294,32 +294,32 @@ void audio::drain::Volume::volumeChange() {
}
std::vector<audio::format> audio::drain::Volume::getFormatSupportedInput() {
std::vector<audio::format> tmp;
etk::Vector<audio::format> audio::drain::Volume::getFormatSupportedInput() {
etk::Vector<audio::format> tmp;
if (m_output.getFormat() == audio::format_float) {
tmp.push_back(audio::format_float);
tmp.pushBack(audio::format_float);
}
if ( m_output.getFormat() == audio::format_int16
|| m_output.getFormat() == audio::format_int16_on_int32
|| m_output.getFormat() == audio::format_int32) {
tmp.push_back(audio::format_int16);
tmp.push_back(audio::format_int16_on_int32);
tmp.push_back(audio::format_int32);
tmp.pushBack(audio::format_int16);
tmp.pushBack(audio::format_int16_on_int32);
tmp.pushBack(audio::format_int32);
}
return tmp;
};
std::vector<audio::format> audio::drain::Volume::getFormatSupportedOutput() {
std::vector<audio::format> tmp;
etk::Vector<audio::format> audio::drain::Volume::getFormatSupportedOutput() {
etk::Vector<audio::format> tmp;
if (m_input.getFormat() == audio::format_float) {
tmp.push_back(audio::format_float);
tmp.pushBack(audio::format_float);
}
if ( m_input.getFormat() == audio::format_int16
|| m_input.getFormat() == audio::format_int16_on_int32
|| m_input.getFormat() == audio::format_int32) {
tmp.push_back(audio::format_int16);
tmp.push_back(audio::format_int16_on_int32);
tmp.push_back(audio::format_int32);
tmp.pushBack(audio::format_int16);
tmp.pushBack(audio::format_int16_on_int32);
tmp.pushBack(audio::format_int32);
}
return tmp;
};
@ -371,11 +371,11 @@ void audio::drain::Volume::addVolumeStage(const ememory::SharedPtr<audio::drain:
return;
}
}
m_volumeList.push_back(_volume);
m_volumeList.pushBack(_volume);
volumeChange();
}
bool audio::drain::Volume::setParameter(const std::string& _parameter, const std::string& _value) {
bool audio::drain::Volume::setParameter(const etk::String& _parameter, const etk::String& _value) {
if (_parameter == "FLOW") {
// set Volume ...
for (auto &it : m_volumeList) {
@ -403,7 +403,7 @@ bool audio::drain::Volume::setParameter(const std::string& _parameter, const std
return false;
}
std::string audio::drain::Volume::getParameter(const std::string& _parameter) const {
etk::String audio::drain::Volume::getParameter(const etk::String& _parameter) const {
if (_parameter == "FLOW") {
// set Volume ...
for (auto &it : m_volumeList) {
@ -411,7 +411,7 @@ std::string audio::drain::Volume::getParameter(const std::string& _parameter) co
continue;
}
if (it->getName() == "FLOW") {
return etk::to_string(it->getVolume()) + "dB";
return etk::toString(it->getVolume()) + "dB";
}
}
}
@ -419,7 +419,7 @@ std::string audio::drain::Volume::getParameter(const std::string& _parameter) co
return "[ERROR]";
}
std::string audio::drain::Volume::getParameterProperty(const std::string& _parameter) const {
etk::String audio::drain::Volume::getParameterProperty(const etk::String& _parameter) const {
if (_parameter == "FLOW") {
// set Volume ...
for (auto &it : m_volumeList) {
@ -435,13 +435,13 @@ std::string audio::drain::Volume::getParameterProperty(const std::string& _param
return "[ERROR]";
}
std::string audio::drain::Volume::getDotDesc() {
std::string out = audio::drain::Algo::getDotDesc();
etk::String audio::drain::Volume::getDotDesc() {
etk::String out = audio::drain::Algo::getDotDesc();
for (auto &it : m_volumeList) {
if (it == nullptr) {
continue;
}
out += "\\n" + it->getName() + "=" + etk::to_string(it->getVolume()) + "dB";
out += "\\n" + it->getName() + "=" + etk::toString(it->getVolume()) + "dB";
if (it->getMute() == true) {
out += " MUTE";
}

View File

@ -16,16 +16,16 @@ namespace audio {
// data structure.
class VolumeElement {
public:
VolumeElement(const std::string& _name="ERROR-VOLUME-NAME", float _volumedB=0.0f) :
VolumeElement(const etk::String& _name="ERROR-VOLUME-NAME", float _volumedB=0.0f) :
m_name(_name),
m_volumedB(_volumedB),
m_mute(false) {
}
private:
std::string m_name;
etk::String m_name;
public:
std::string getName() const {
etk::String getName() const {
return m_name;
}
private:
@ -54,7 +54,7 @@ namespace audio {
// TODO: Manage set volume
class Volume : public audio::drain::Algo {
private:
std::vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList;
etk::Vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList;
// for float input :
float m_volumeAppli;
// for integer input :
@ -83,17 +83,17 @@ namespace audio {
void*& _output,
size_t& _outputNbChunk);
public:
virtual std::vector<audio::format> getFormatSupportedInput();
virtual std::vector<audio::format> getFormatSupportedOutput();
virtual etk::Vector<audio::format> getFormatSupportedInput();
virtual etk::Vector<audio::format> getFormatSupportedOutput();
public:
virtual void addVolumeStage(const ememory::SharedPtr<drain::VolumeElement>& _volume);
virtual bool setParameter(const std::string& _parameter, const std::string& _value);
virtual std::string getParameter(const std::string& _parameter) const;
virtual std::string getParameterProperty(const std::string& _parameter) const;
virtual bool setParameter(const etk::String& _parameter, const etk::String& _value);
virtual etk::String getParameter(const etk::String& _parameter) const;
virtual etk::String getParameterProperty(const etk::String& _parameter) const;
public:
void volumeChange();
public:
virtual std::string getDotDesc();
virtual etk::String getDotDesc();
};
}
}

View File

@ -5,7 +5,7 @@
*/
#pragma once
#include <string>
#include <etk/String.hpp>
#include <audio/format.hpp>
#include <audio/drain/channel.hpp>
#include <chrono>
@ -25,18 +25,18 @@ namespace audio {
* @param[in] _name Name of the Algorithm.
* @return Instanciate algorithm
*/
drain::Algo* createAlgo(const std::string& _name);
drain::Algo* createAlgo(const etk::String& _name);
/**
* @brief Add a Factory Algorithm in the internal List (static for all instance)
* @param[in] _name Name of the Algorithm.
* @param[in] _functor Function of the factory
*/
void addAlgoFactory(const std::string& _name, std::function<drain::Algo*(void)> _functor);
void addAlgoFactory(const etk::String& _name, std::function<drain::Algo*(void)> _functor);
/**
* @brief Remove a Factory Algorithm in the internal List (static for all instance)
* @param[in] _name Name of the Algorithm.
*/
void RmAlgoFactory(const std::string& _name);
void RmAlgoFactory(const etk::String& _name);
}
}

View File

@ -14,7 +14,7 @@ int main(int _argc, const char** _argv) {
// the only one init for etk:
etk::init(_argc, _argv);
for (int32_t iii=0; iii<_argc ; ++iii) {
std::string data = _argv[iii];
etk::String data = _argv[iii];
if ( data == "-h"
|| data == "--help") {
TEST_INFO("Help : ");

View File

@ -40,26 +40,26 @@ appl::Windows::Windows() :
m_gain(0.0),
m_quality(0.707) {
addObjectType("appl::Windows");
m_listSampleRate.push_back(192000);
m_listSampleRate.push_back(176400);
m_listSampleRate.push_back(96000);
m_listSampleRate.push_back(88200);
m_listSampleRate.push_back(48000);
m_listSampleRate.push_back(44100);
m_listSampleRate.push_back(32000);
m_listSampleRate.push_back(22050);
m_listSampleRate.push_back(16000);
m_listSampleRate.push_back(11025);
m_listSampleRate.push_back(8000);
m_listSampleRate.push_back(4000);
m_listType.push_back(audio::algo::drain::biQuadType_none);
m_listType.push_back(audio::algo::drain::biQuadType_lowPass);
m_listType.push_back(audio::algo::drain::biQuadType_highPass);
m_listType.push_back(audio::algo::drain::biQuadType_bandPass);
m_listType.push_back(audio::algo::drain::biQuadType_notch);
m_listType.push_back(audio::algo::drain::biQuadType_peak);
m_listType.push_back(audio::algo::drain::biQuadType_lowShelf);
m_listType.push_back(audio::algo::drain::biQuadType_highShelf);
m_listSampleRate.pushBack(192000);
m_listSampleRate.pushBack(176400);
m_listSampleRate.pushBack(96000);
m_listSampleRate.pushBack(88200);
m_listSampleRate.pushBack(48000);
m_listSampleRate.pushBack(44100);
m_listSampleRate.pushBack(32000);
m_listSampleRate.pushBack(22050);
m_listSampleRate.pushBack(16000);
m_listSampleRate.pushBack(11025);
m_listSampleRate.pushBack(8000);
m_listSampleRate.pushBack(4000);
m_listType.pushBack(audio::algo::drain::biQuadType_none);
m_listType.pushBack(audio::algo::drain::biQuadType_lowPass);
m_listType.pushBack(audio::algo::drain::biQuadType_highPass);
m_listType.pushBack(audio::algo::drain::biQuadType_bandPass);
m_listType.pushBack(audio::algo::drain::biQuadType_notch);
m_listType.pushBack(audio::algo::drain::biQuadType_peak);
m_listType.pushBack(audio::algo::drain::biQuadType_lowShelf);
m_listType.pushBack(audio::algo::drain::biQuadType_highShelf);
}
void appl::Windows::init() {
@ -100,15 +100,15 @@ void appl::Windows::onCallbackSampleRateUp() {
} else {
m_sampleRate = m_listSampleRate[0];
}
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
onCallbackStart();
return;
}
}
m_sampleRate = m_listSampleRate[0];
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
onCallbackStart();
}
@ -121,15 +121,15 @@ void appl::Windows::onCallbackSampleRateLow() {
} else {
m_sampleRate = m_listSampleRate[m_listSampleRate.size()-1];
}
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
onCallbackStart();
return;
}
}
m_sampleRate = m_listSampleRate[0];
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
onCallbackStart();
}
@ -142,13 +142,13 @@ void appl::Windows::onCallbackTypeUp() {
} else {
m_type = m_listType[0];
}
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
onCallbackStart();
return;
}
}
m_type = m_listType[0];
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
onCallbackStart();
}
@ -161,58 +161,58 @@ void appl::Windows::onCallbackTypeLow() {
} else {
m_type = m_listType[m_listType.size()-1];
}
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
onCallbackStart();
return;
}
}
m_type = m_listType[0];
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
onCallbackStart();
}
void appl::Windows::onCallbackGain(const std::string& _value) {
void appl::Windows::onCallbackGain(const etk::String& _value) {
m_gain = etk::string_to_float(_value);
ewol::parameterSetOnObjectNamed("gain-slider", "value", etk::to_string(_value));
ewol::parameterSetOnObjectNamed("gain-slider", "value", etk::toString(_value));
APPL_INFO("Gain " << m_gain);
onCallbackStart();
}
void appl::Windows::onCallbackGainSlider(const float& _value) {
m_gain = _value;
ewol::parameterSetOnObjectNamed("gain", "value", etk::to_string(_value));
ewol::parameterSetOnObjectNamed("gain", "value", etk::toString(_value));
APPL_INFO("Gain " << m_gain);
onCallbackStart();
}
void appl::Windows::onCallbackQuality(const std::string& _value) {
void appl::Windows::onCallbackQuality(const etk::String& _value) {
m_quality = etk::string_to_float(_value);
ewol::parameterSetOnObjectNamed("quality-slider", "value", etk::to_string(_value));
ewol::parameterSetOnObjectNamed("quality-slider", "value", etk::toString(_value));
APPL_INFO("quality " << m_quality);
onCallbackStart();
}
void appl::Windows::onCallbackQualitySlider(const float& _value) {
m_quality = _value;
ewol::parameterSetOnObjectNamed("quality", "value", etk::to_string(_value));
ewol::parameterSetOnObjectNamed("quality", "value", etk::toString(_value));
APPL_INFO("quality " << m_quality);
onCallbackStart();
}
void appl::Windows::onCallbackFrequency(const std::string& _value) {
void appl::Windows::onCallbackFrequency(const etk::String& _value) {
m_cutFrequency = etk::string_to_float(_value);
ewol::parameterSetOnObjectNamed("frequency-slider", "value", etk::to_string(_value));
ewol::parameterSetOnObjectNamed("frequency-slider", "value", etk::toString(_value));
APPL_INFO("cut frequency " << m_cutFrequency);
onCallbackStart();
}
void appl::Windows::onCallbackFrequencySlider(const float& _value) {
m_cutFrequency = _value;
ewol::parameterSetOnObjectNamed("frequency", "value", etk::to_string(_value));
ewol::parameterSetOnObjectNamed("frequency", "value", etk::toString(_value));
APPL_INFO("cut frequency " << m_cutFrequency);
onCallbackStart();
}
@ -225,15 +225,15 @@ void appl::Windows::onCallbackFrequencySlider(const float& _value) {
void appl::Windows::onCallbackStart() {
APPL_INFO("start ");
int32_t iii = 10;
std::vector<audio::channel> map;
map.push_back(audio::channel_frontCenter);
etk::Vector<audio::channel> map;
map.pushBack(audio::channel_frontCenter);
// audio::drain::IOFormatInterface format(map, audio::format_int16, m_sampleRate);
// audio::drain::IOFormatInterface format(map, audio::format_float, m_sampleRate);
// create biquad
audio::algo::drain::BiQuad<audio::float_t> bq;
// configure parameter
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
std::vector<std::pair<float,float> > theory = bq.calculateTheory(m_sampleRate);
etk::Vector<etk::Pair<float,float> > theory = bq.calculateTheory(m_sampleRate);
m_displayer->clear();
m_displayer->setValue(theory);
}
@ -245,7 +245,7 @@ void appl::Windows::onCallbackStart16() {
audio::algo::drain::BiQuad<audio::int16_16_t> bq;
// configure parameter
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
std::vector<std::pair<float,float> > pratic;
etk::Vector<etk::Pair<float,float> > pratic;
size_t len = 512;
for (size_t iii=1; iii < len; iii++) {
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
@ -254,7 +254,7 @@ void appl::Windows::onCallbackStart16() {
double m_phase = 0;
double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq);
float gain = 0;
std::vector<audio::int16_16_t> data;
etk::Vector<audio::int16_16_t> data;
// create sinus
data.resize(16000, 0);
for (int32_t iii=0; iii<data.size(); iii++) {
@ -273,11 +273,11 @@ void appl::Windows::onCallbackStart16() {
APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_16.raw",&data[0],data.size());
audio::int16_16_t value = 0;
for (size_t iii=800; iii<data.size()-200; ++iii) {
value = std::max(value, data[iii]);
value = etk::max(value, data[iii]);
}
gain = 20.0 * std::log10(value.getDouble()/32000.0);
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
}
m_displayer->setValue(pratic);
}
@ -288,7 +288,7 @@ void appl::Windows::onCallbackStartFloat() {
audio::algo::drain::BiQuad<audio::float_t> bq;
// configure parameter
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
std::vector<std::pair<float,float> > pratic;
etk::Vector<etk::Pair<float,float> > pratic;
size_t len = 512;
for (size_t iii=1; iii < len; iii++) {
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
@ -297,7 +297,7 @@ void appl::Windows::onCallbackStartFloat() {
double m_phase = 0;
double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq);
float gain = 0;
std::vector<audio::float_t> data;
etk::Vector<audio::float_t> data;
// create sinus
data.resize(16000, 0);
for (int32_t iii=0; iii<data.size(); iii++) {
@ -312,11 +312,11 @@ void appl::Windows::onCallbackStartFloat() {
APPL_SAVE_FILE_MACRO(float,"aaa_test_OUTPUT_F.raw",&data[0],data.size());
audio::float_t value = 0.0f;
for (size_t iii=800; iii<data.size()-200; ++iii) {
value = std::max(value, data[iii]);
value = etk::max(value, data[iii]);
}
gain = 20.0 * std::log10(value.getDouble()/1.0);
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
}
m_displayer->setValue(pratic);
}

View File

@ -25,20 +25,20 @@ namespace appl {
void onCallbackSampleRateUp();
void onCallbackTypeUp();
void onCallbackTypeLow();
void onCallbackGain(const std::string& _value);
void onCallbackGain(const etk::String& _value);
void onCallbackGainSlider(const float& _value);
void onCallbackFrequency(const std::string& _value);
void onCallbackFrequency(const etk::String& _value);
void onCallbackFrequencySlider(const float& _value);
void onCallbackQuality(const std::string& _value);
void onCallbackQuality(const etk::String& _value);
void onCallbackQualitySlider(const float& _value);
void onCallbackStart();
void onCallbackStart16();
void onCallbackStartFloat();
protected:
int32_t m_sampleRate;
std::vector<int32_t> m_listSampleRate;
etk::Vector<int32_t> m_listSampleRate;
enum audio::algo::drain::biQuadType m_type;
std::vector<enum audio::algo::drain::biQuadType> m_listType;
etk::Vector<enum audio::algo::drain::biQuadType> m_listType;
float m_cutFrequency;
float m_gain;
float m_quality;

View File

@ -28,8 +28,8 @@ appl::widget::DisplayFrequency::~DisplayFrequency() {
}
void appl::widget::DisplayFrequency::setValue(const std::vector<std::pair<float,float> >& _data) {
m_data.push_back(_data);
void appl::widget::DisplayFrequency::setValue(const etk::Vector<etk::Pair<float,float> >& _data) {
m_data.pushBack(_data);
markToRedraw();
}
@ -84,21 +84,21 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
for (size_t kkk=0; kkk<m_data.size(); kkk++) {
for (size_t iii=0; iii<m_data[kkk].size(); ++iii) {
if (std::abs(m_data[kkk][iii].second) != std::numeric_limits<float>::infinity()) {
m_gainMax = std::max(m_gainMax, m_data[kkk][iii].second);
m_gainMin = std::min(m_gainMin, m_data[kkk][iii].second);
m_gainMax = etk::max(m_gainMax, m_data[kkk][iii].second);
m_gainMin = etk::min(m_gainMin, m_data[kkk][iii].second);
}
if (displayLog == false) {
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
m_frequencyMax = std::max(m_frequencyMax, m_data[kkk][iii].first);
m_frequencyMin = std::min(m_frequencyMin, m_data[kkk][iii].first);
m_frequencyMax = etk::max(m_frequencyMax, m_data[kkk][iii].first);
m_frequencyMin = etk::min(m_frequencyMin, m_data[kkk][iii].first);
}
} else {
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
if (m_data[kkk][iii].first == 0) {
continue;
}
m_frequencyMax = std::max(m_frequencyMax, std::log(m_data[kkk][iii].first));
m_frequencyMin = std::min(m_frequencyMin, std::log(m_data[kkk][iii].first));
m_frequencyMax = etk::max(m_frequencyMax, std::log(m_data[kkk][iii].first));
m_frequencyMin = etk::min(m_frequencyMin, std::log(m_data[kkk][iii].first));
APPL_INFO("plop " << m_data[kkk][iii].first << " " << std::log(m_data[kkk][iii].first));
}
}
@ -148,22 +148,22 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
}
}
m_text.setDefaultColorFg(etk::color::green);
std::string textToDisplay = etk::to_string(m_frequencyMin) + " Hz";
etk::String textToDisplay = etk::toString(m_frequencyMin) + " Hz";
vec3 size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y()));
m_text.print(textToDisplay);
textToDisplay = etk::to_string(m_frequencyMax) + " Hz";
textToDisplay = etk::toString(m_frequencyMax) + " Hz";
size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y()));
m_text.print(textToDisplay);
textToDisplay = etk::to_string(m_gainMin) + " dB";
textToDisplay = etk::toString(m_gainMin) + " dB";
size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()));
m_text.print(textToDisplay);
textToDisplay = etk::to_string(m_gainMax) + " dB";
textToDisplay = etk::toString(m_gainMax) + " dB";
size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y()));
m_text.print(textToDisplay);

View File

@ -25,12 +25,12 @@ namespace appl {
//! @brief destructor
virtual ~DisplayFrequency();
private:
std::vector<std::vector<std::pair<float,float> > > m_data; //!< data that might be displayed
etk::Vector<etk::Vector<etk::Pair<float,float> > > m_data; //!< data that might be displayed
public:
void clear() {
m_data.clear();
}
void setValue(const std::vector<std::pair<float,float> >& _data);
void setValue(const etk::Vector<etk::Pair<float,float> >& _data);
private:
float m_gainMin; //!< display minimum gain value
float m_gainMax; //!< display maximum gain value

View File

@ -34,18 +34,18 @@
appl::Windows::Windows() :
m_sampleRate(48000) {
addObjectType("appl::Windows");
m_listSampleRate.push_back(192000);
m_listSampleRate.push_back(176400);
m_listSampleRate.push_back(96000);
m_listSampleRate.push_back(88200);
m_listSampleRate.push_back(48000);
m_listSampleRate.push_back(44100);
m_listSampleRate.push_back(32000);
m_listSampleRate.push_back(22050);
m_listSampleRate.push_back(16000);
m_listSampleRate.push_back(11025);
m_listSampleRate.push_back(8000);
m_listSampleRate.push_back(4000);
m_listSampleRate.pushBack(192000);
m_listSampleRate.pushBack(176400);
m_listSampleRate.pushBack(96000);
m_listSampleRate.pushBack(88200);
m_listSampleRate.pushBack(48000);
m_listSampleRate.pushBack(44100);
m_listSampleRate.pushBack(32000);
m_listSampleRate.pushBack(22050);
m_listSampleRate.pushBack(16000);
m_listSampleRate.pushBack(11025);
m_listSampleRate.pushBack(8000);
m_listSampleRate.pushBack(4000);
m_listGain.resize(10, 0.0f);
}
@ -87,13 +87,13 @@ void appl::Windows::onCallbackSampleRateUp() {
} else {
m_sampleRate = m_listSampleRate[0];
}
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
onCallbackStart();
return;
}
}
m_sampleRate = m_listSampleRate[0];
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
onCallbackStart();
}
@ -106,13 +106,13 @@ void appl::Windows::onCallbackSampleRateLow() {
} else {
m_sampleRate = m_listSampleRate[m_listSampleRate.size()-1];
}
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
onCallbackStart();
return;
}
}
m_sampleRate = m_listSampleRate[0];
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
onCallbackStart();
}
@ -122,8 +122,8 @@ void appl::Windows::onCallbackGain(const float& _value, int32_t _id) {
}
ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum audio::format _format) {
std::vector<audio::channel> map;
map.push_back(audio::channel_frontCenter);
etk::Vector<audio::channel> map;
map.pushBack(audio::channel_frontCenter);
audio::drain::IOFormatInterface format(map, _format, m_sampleRate);
// create equalizer
ememory::SharedPtr<audio::drain::Equalizer> out = audio::drain::Equalizer::create();
@ -132,7 +132,7 @@ ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum
// configure output
out->setOutputFormat(format);
// create ejson:
std::string conf;
etk::String conf;
conf += "{\n";
conf += " global: [\n";
for (size_t iii=3; iii<m_listGain.size(); ++iii) {
@ -157,8 +157,8 @@ ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum
conf += " {\n";
conf += " type:'peak',\n";
conf += " quality:2,\n";
conf += " cut-frequency:" + etk::to_string(cutFrequency) + ",\n";
conf += " gain:" + etk::to_string(m_listGain[iii]) + "\n";
conf += " cut-frequency:" + etk::toString(cutFrequency) + ",\n";
conf += " gain:" + etk::toString(m_listGain[iii]) + "\n";
conf += " }\n";
}
conf += " ]\n";
@ -172,7 +172,7 @@ ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum
void appl::Windows::onCallbackStart() {
APPL_INFO("start ");
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer();
std::vector<std::pair<float,float> > theory = eq->calculateTheory();
etk::Vector<etk::Pair<float,float> > theory = eq->calculateTheory();
m_displayer->clear();
m_displayer->setValue(theory);
}
@ -181,9 +181,9 @@ void appl::Windows::onCallbackStart() {
void appl::Windows::onCallbackStart16() {
APPL_INFO("start ");
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_int16);
std::vector<std::pair<float,float> > pratic;
etk::Vector<etk::Pair<float,float> > pratic;
size_t len = 512;
std::vector<int16_t> data;
etk::Vector<int16_t> data;
data.resize(16000, 0);
for (size_t iii=1; iii < len; iii++) {
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
@ -210,11 +210,11 @@ void appl::Windows::onCallbackStart16() {
APPL_SAVE_FILE_MACRO(int16_t, "aaa_test_OUTPUT.raw", output, outputNbChunk);
int16_t value = 0;
for (size_t iii=800; iii<outputNbChunk-200; ++iii) {
value = std::max(value, output[iii]);
value = etk::max(value, output[iii]);
}
gain = 20.0 * std::log10(double(value)/32000.0);
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
}
m_displayer->setValue(pratic);
}
@ -222,9 +222,9 @@ void appl::Windows::onCallbackStart16() {
void appl::Windows::onCallbackStartFloat() {
APPL_INFO("start ");
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_float);
std::vector<std::pair<float,float> > pratic;
etk::Vector<etk::Pair<float,float> > pratic;
size_t len = 512;
std::vector<float> data;
etk::Vector<float> data;
data.resize(16000, 0);
for (size_t iii=1; iii < len; iii++) {
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
@ -251,11 +251,11 @@ void appl::Windows::onCallbackStartFloat() {
APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_F.raw",output, outputNbChunk);
float value = 0;
for (size_t iii=800; iii<outputNbChunk-200; ++iii) {
value = std::max(value, output[iii]);
value = etk::max(value, output[iii]);
}
gain = 20.0 * std::log10(double(value)/1.0);
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
}
m_displayer->setValue(pratic);
}

View File

@ -59,9 +59,9 @@ namespace appl {
void onCallbackStartFloat();
protected:
int32_t m_sampleRate;
std::vector<int32_t> m_listSampleRate;
etk::Vector<int32_t> m_listSampleRate;
std::vector<float> m_listGain;
etk::Vector<float> m_listGain;
ememory::SharedPtr<audio::drain::Equalizer> createEqualizer(enum audio::format _format = audio::format_float);
};
}

View File

@ -28,8 +28,8 @@ appl::widget::DisplayFrequency::~DisplayFrequency() {
}
void appl::widget::DisplayFrequency::setValue(const std::vector<std::pair<float,float> >& _data) {
m_data.push_back(_data);
void appl::widget::DisplayFrequency::setValue(const etk::Vector<etk::Pair<float,float> >& _data) {
m_data.pushBack(_data);
markToRedraw();
}
@ -84,22 +84,22 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
for (size_t kkk=0; kkk<m_data.size(); kkk++) {
for (size_t iii=0; iii<m_data[kkk].size(); ++iii) {
if (std::abs(m_data[kkk][iii].second) != std::numeric_limits<float>::infinity()) {
m_gainMax = std::max(m_gainMax, m_data[kkk][iii].second);
m_gainMin = std::min(m_gainMin, m_data[kkk][iii].second);
m_gainMax = etk::max(m_gainMax, m_data[kkk][iii].second);
m_gainMin = etk::min(m_gainMin, m_data[kkk][iii].second);
//APPL_INFO("plop " << m_data[kkk][iii].second);
}
if (displayLog == false) {
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
m_frequencyMax = std::max(m_frequencyMax, m_data[kkk][iii].first);
m_frequencyMin = std::min(m_frequencyMin, m_data[kkk][iii].first);
m_frequencyMax = etk::max(m_frequencyMax, m_data[kkk][iii].first);
m_frequencyMin = etk::min(m_frequencyMin, m_data[kkk][iii].first);
}
} else {
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
if (m_data[kkk][iii].first == 0) {
continue;
}
m_frequencyMax = std::max(m_frequencyMax, std::log(m_data[kkk][iii].first));
m_frequencyMin = std::min(m_frequencyMin, std::log(m_data[kkk][iii].first));
m_frequencyMax = etk::max(m_frequencyMax, std::log(m_data[kkk][iii].first));
m_frequencyMin = etk::min(m_frequencyMin, std::log(m_data[kkk][iii].first));
//APPL_INFO("plop " << m_data[kkk][iii].first << " " << std::log(m_data[kkk][iii].first));
}
}
@ -155,22 +155,22 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
}
}
m_text.setDefaultColorFg(etk::color::green);
std::string textToDisplay = etk::to_string(m_frequencyMin) + " Hz";
etk::String textToDisplay = etk::toString(m_frequencyMin) + " Hz";
vec3 size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y()));
m_text.print(textToDisplay);
textToDisplay = etk::to_string(m_frequencyMax) + " Hz";
textToDisplay = etk::toString(m_frequencyMax) + " Hz";
size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y()));
m_text.print(textToDisplay);
textToDisplay = etk::to_string(m_gainMin) + " dB";
textToDisplay = etk::toString(m_gainMin) + " dB";
size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()));
m_text.print(textToDisplay);
textToDisplay = etk::to_string(m_gainMax) + " dB";
textToDisplay = etk::toString(m_gainMax) + " dB";
size = m_text.calculateSize(textToDisplay);
m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y()));
m_text.print(textToDisplay);

View File

@ -25,12 +25,12 @@ namespace appl {
//! @brief destructor
virtual ~DisplayFrequency();
private:
std::vector<std::vector<std::pair<float,float> > > m_data; //!< data that might be displayed
etk::Vector<etk::Vector<etk::Pair<float,float> > > m_data; //!< data that might be displayed
public:
void clear() {
m_data.clear();
}
void setValue(const std::vector<std::pair<float,float> >& _data);
void setValue(const etk::Vector<etk::Pair<float,float> >& _data);
private:
float m_gainMin; //!< display minimum gain value
float m_gainMax; //!< display maximum gain value