diff --git a/lutin_drain_test.py b/lutin_drain_test.py new file mode 100644 index 0000000..c7a0d9f --- /dev/null +++ b/lutin_drain_test.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +import lutinModule as module +import lutinTools as tools +import lutinDebug as debug + +def get_desc(): + return "drain_test : single audio flow test" + + +def create(target): + myModule = module.Module(__file__, 'drain_test', 'BINARY') + + myModule.add_src_file([ + 'test/main.cpp', + 'test/debug.cpp', + 'test/updateFlow.cpp', + 'test/resampling.cpp', + 'test/format.cpp', + 'test/channelOrder.cpp', + 'test/equalizer.cpp' + ]) + + myModule.add_module_depend(['drain', 'gtest', 'etk']) + + return myModule + + + + + + + + + diff --git a/tools/drainEqualizerProfiling/appl/Windows.cpp b/tools/drainEqualizerProfiling/appl/Windows.cpp index c81e330..3b85dc0 100644 --- a/tools/drainEqualizerProfiling/appl/Windows.cpp +++ b/tools/drainEqualizerProfiling/appl/Windows.cpp @@ -11,11 +11,17 @@ #include #include #include +#include #undef __class__ #define __class__ "Windows" -appl::Windows::Windows() { +appl::Windows::Windows() : + m_sampleRate(48000), + m_type(drain::filterType::filterType_LPF), + m_cutFrequency(2000), + m_gain(2), + m_bandWidth(200) { addObjectType("appl::Windows"); } @@ -27,13 +33,79 @@ void appl::Windows::init() { if (m_gui != nullptr) { setSubWidget(m_gui); } - - subBind(ewol::widget::Entry, "sample-rate", signalModify, shared_from_this(), &appl::Windows::onCallbackFrequency); - - + subBind(ewol::widget::Entry, "sample-rate", signalModify, shared_from_this(), &appl::Windows::onCallbackSampleRate); + subBind(ewol::widget::Entry, "type", signalModify, shared_from_this(), &appl::Windows::onCallbackType); + subBind(ewol::widget::Entry, "gain", signalModify, shared_from_this(), &appl::Windows::onCallbackGain); + subBind(ewol::widget::Entry, "frequency", signalModify, shared_from_this(), &appl::Windows::onCallbackFrequency); + subBind(ewol::widget::Entry, "band-width", signalModify, shared_from_this(), &appl::Windows::onCallbackBandWidth); + subBind(ewol::widget::Button, "display", signalPressed, shared_from_this(), &appl::Windows::onCallbackStart); +} + +void appl::Windows::onCallbackSampleRate(const std::string& _value) { + APPL_INFO("SampleRate " << _value); + std::vector list; + list.push_back(96000); + list.push_back(48000); + list.push_back(44100); + list.push_back(32000); + list.push_back(22050); + list.push_back(16000); + list.push_back(8000); + if (etk::isIn(etk::string_to_int32_t(_value), list) == true) { + ewol::parameterSetOnObjectNamed("sample-rate-valid", "color", "green"); + } else { + ewol::parameterSetOnObjectNamed("sample-rate-valid", "color", "red"); + } +} + +void appl::Windows::onCallbackType(const std::string& _value) { + APPL_INFO("Type " << _value); + std::vector list; + list.push_back("HPF"); + list.push_back("LPF"); + if (etk::isIn(etk::string_to_int32_t(_value), list) == true) { + ewol::parameterSetOnObjectNamed("type-valid", "color", "green"); + } else { + ewol::parameterSetOnObjectNamed("type-valid", "color", "red"); + } +} + +void appl::Windows::onCallbackGain(const std::string& _value) { + APPL_INFO("Gain " << _value); } void appl::Windows::onCallbackFrequency(const std::string& _value) { - APPL_INFO("plop " << _value); + APPL_INFO("Frequency " << _value); } +void appl::Windows::onCallbackBandWidth(const std::string& _value) { + APPL_INFO("BandWidth " << _value); +} + +void appl::Windows::onCallbackStart() { + APPL_INFO("start "); + m_data.clear(); + int32_t iii = 200; + while (iii < m_sampleRate/2) { + APPl_INFO("TEST : " << iii); + // create equalizer + std11::shared_ptr eq = drain::Equalizer::create(); + // configure parameter + eq->setParameter("type", "LPF"); + eq->setParameter("gain", etk::to_string(m_gain)); + eq->setParameter("frequency", etk::to_string(m_cutFrequency)); + eq->setParameter("band-width", etk::to_string(m_bandWidth)); + // configure input + + // configure outpur + + // create sinus + + // process + + iii += 200; + } + +} + + diff --git a/tools/drainEqualizerProfiling/appl/Windows.h b/tools/drainEqualizerProfiling/appl/Windows.h index 9f32836..3acc8a4 100644 --- a/tools/drainEqualizerProfiling/appl/Windows.h +++ b/tools/drainEqualizerProfiling/appl/Windows.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace appl { class Windows : public ewol::widget::Windows { @@ -22,7 +23,19 @@ namespace appl { DECLARE_FACTORY(Windows); protected: std::shared_ptr m_gui; + void onCallbackSampleRate(const std::string& _value); + void onCallbackType(const std::string& _value); + void onCallbackGain(const std::string& _value); void onCallbackFrequency(const std::string& _value); + void onCallbackBandWidth(const std::string& _value); + void onCallbackStart(); + protected: + int32_t m_sampleRate; + enum drain::filterType m_type; + float m_cutFrequency; + float m_gain; + float m_bandWidth; + std::vector > m_data; }; }; diff --git a/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.cpp b/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.cpp index dfe8743..1143ce7 100644 --- a/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.cpp +++ b/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.cpp @@ -15,16 +15,16 @@ appl::widget::DisplayFrequency::DisplayFrequency() : - m_autoDisplay(false), - m_minVal(-1.0f), - m_maxVal(1.0f) { + m_gainMin(0.0f), + m_gainMax(1.0f), + m_frequencyMin(0.0f), + m_frequencyMax(24000.0f) { addObjectType("appl::widget::DisplayFrequency"); } void appl::widget::DisplayFrequency::init() { ewol::Widget::init(); markToRedraw(); - ToggleAuto(); } @@ -33,19 +33,21 @@ appl::widget::DisplayFrequency::~DisplayFrequency() { } -void appl::widget::DisplayFrequency::setValue(const std::vector& _data) { +void appl::widget::DisplayFrequency::setValue(const std::vector >& _data) { m_data = _data; markToRedraw(); } -void appl::widget::DisplayFrequency::ToggleAuto() { - if (m_autoDisplay == false) { - periodicCallEnable(); - m_autoDisplay = true; - } else { - periodicCallDisable(); - m_autoDisplay = false; - } +void appl::widget::DisplayFrequency::setGainRange(float _min, float _max) { + m_gainMin = _min; + m_gainMax = _max; + markToRedraw(); +} + +void appl::widget::DisplayFrequency::setFrequencyRange(float _min, float _max) { + m_frequencyMin = _min; + m_frequencyMax = _max; + markToRedraw(); } void appl::widget::DisplayFrequency::onDraw() { @@ -71,23 +73,14 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() { // set all the line: m_draw.setColor(etk::color::white); m_draw.setThickness(1); - float origin = m_size.y()*0.5f; - float ratioY = m_size.y() / (m_maxVal - m_minVal); - float stepX = m_size.x() / (float)m_data.size(); - m_draw.setPos(vec2(0, origin + ratioY*m_data[0])); + float ratioX = m_size.x() / (m_frequencyMax - m_frequencyMin); + float ratioY = m_size.y() / (m_gainMax - m_gainMin); + m_draw.setPos(vec2(ratioX*(m_data[0].first - m_gainMin), + ratioY*(m_data[0].second - m_gainMin))); float baseX = 0; for (size_t iii=1; iii 50) { - m_data.erase(m_data.begin()); - } - m_data.push_back(etk::tool::frand(m_minVal, m_maxVal)); - } - markToRedraw(); -} diff --git a/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.h b/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.h index e1a3304..6c27a62 100644 --- a/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.h +++ b/tools/drainEqualizerProfiling/appl/widget/DisplayFrequency.h @@ -28,20 +28,22 @@ namespace appl { //! @brief destructor virtual ~DisplayFrequency(); private: - std::vector m_data; //!< data that might be displayed + std::vector > m_data; //!< data that might be displayed public: - void setValue(const std::vector& _data); + void setValue(const std::vector >& _data); private: - bool m_autoDisplay; + float m_gainMin; //!< display minimum gain value + float m_gainMax; //!< display maximum gain value public: - void ToggleAuto(); + void setGainRange(float _min, float _max); private: - float m_minVal; //!< display minimum value - float m_maxVal; //!< display maximum value + float m_frequencyMin; //!< display minimum gain value + float m_frequencyMax; //!< display maximum gain value + public: + void setFrequencyRange(float _min, float _max); public: // herited function virtual void onDraw(); virtual void onRegenerateDisplay(); - virtual void periodicCall(const ewol::event::Time& _event); }; } } diff --git a/tools/drainEqualizerProfiling/data/gui.xml b/tools/drainEqualizerProfiling/data/gui.xml index 1025398..00cb884 100644 --- a/tools/drainEqualizerProfiling/data/gui.xml +++ b/tools/drainEqualizerProfiling/data/gui.xml @@ -1,64 +1,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +