[DEV] contunue toos

This commit is contained in:
Edouard DUPIN 2015-03-26 22:28:37 +01:00
parent fa6cc4fa5c
commit abce0fc900
6 changed files with 217 additions and 99 deletions

34
lutin_drain_test.py Normal file
View File

@ -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

View File

@ -11,11 +11,17 @@
#include <appl/Windows.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/Button.h>
#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<int32_t> 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<std::string> 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<drain::Equalizer> 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;
}
}

View File

@ -12,6 +12,7 @@
#include <ewol/widget/Windows.h>
#include <ewol/widget/Layer.h>
#include <ewol/widget/Composer.h>
#include <drain/Equalizer.h>
namespace appl {
class Windows : public ewol::widget::Windows {
@ -22,7 +23,19 @@ namespace appl {
DECLARE_FACTORY(Windows);
protected:
std::shared_ptr<ewol::widget::Composer> 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<std::pair<float,float> > m_data;
};
};

View File

@ -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<float>& _data) {
void appl::widget::DisplayFrequency::setValue(const std::vector<std::pair<float,float> >& _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<m_data.size(); ++iii) {
m_draw.lineTo(vec2((float)iii*stepX, origin + ratioY*m_data[iii]));
m_draw.lineTo(vec2(ratioX*(m_data[0].first - m_gainMin),
ratioY*(m_data[0].second - m_gainMin)));
}
}
void appl::widget::DisplayFrequency::periodicCall(const ewol::event::Time& _event) {
for (size_t iii=0; iii<std::max(m_data.size()/200.0f, 50.0f); ++iii) {
if (m_data.size() > 50) {
m_data.erase(m_data.begin());
}
m_data.push_back(etk::tool::frand(m_minVal, m_maxVal));
}
markToRedraw();
}

View File

@ -28,20 +28,22 @@ namespace appl {
//! @brief destructor
virtual ~DisplayFrequency();
private:
std::vector<float> m_data; //!< data that might be displayed
std::vector<std::pair<float,float> > m_data; //!< data that might be displayed
public:
void setValue(const std::vector<float>& _data);
void setValue(const std::vector<std::pair<float,float> >& _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);
};
}
}

View File

@ -1,64 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<sizer mode="hori" expand="true" fill="true" lock="true" max-size="20,100%">
<scroll gravity="top" expand="true" fill="true">
<sizer mode="vert" expand="false,true" fill="true" lock="true" max-size="100%" addmode="invert">
<!--
<sizer mode="hori">
<button name="save">
<label>Save</label>
</button>
<button name="load">
<label>Load</label>
</button>
</sizer>
-->
<label>Global parameter:</label>
<sizer mode="vert"expand="true" border="0.2%" addmode="invert">
<spacer min-size="5,5px"/>
<sizer mode="hori">
<label>SampleRate:</label>
<entry expand="true" name="sample-rate" regex="[0-9]*" value="48000"/>
<!--
<combo expand="true" name="sample-rate" select="48">
<item value="96">96000</item>
<item value="48">48000</item>
<item value="32">32000</item>
<item value="16">16000</item>
<item value="8">8000</item>
</combo>
-->
</sizer>
</sizer>
<label>Filter:</label>
<sizer mode="vert"expand="true" border="0.2%" addmode="invert">
<spacer min-size="5,5px"/>
<sizer mode="hori">
<label>type:</label>
<entry expand="true" name="type" value="HPF"/>
<!--
<combo expand="true" name="type" select="HPF">
<item value="HPF">High Pass Filter</item>
<item value="LPF">Low Pass Filter</item>
</combo>
-->
</sizer>
<sizer mode="hori">
<label>gain:</label>
<entry expand="true" name="gain" regex="-?[0-9]*" value="0"/>
</sizer>
<sizer mode="hori">
<label>frequency:</label>
<entry expand="true" name="frequency" regex="[0-9]*" value="1000"/>
</sizer>
<sizer mode="hori">
<label>Band width:</label>
<entry expand="true" name="band-width" regex="[0-9]*" value="100"/>
</sizer>
</sizer>
<button name="display">
<label>Display</label>
<sizer mode="vert" expand="false,true" fill="true" lock="true" max-size="100%" addmode="invert">
<!--
<sizer mode="hori">
<button name="save">
<label>Save</label>
</button>
<button name="load">
<label>Load</label>
</button>
</sizer>
</scroll>
-->
<label>Global parameter: .........</label>
<sizer mode="vert" expand="true,false" lock="true" border="0.2%" addmode="invert">
<spacer min-size="5,5px"/>
<sizer mode="hori">
<label>SampleRate:</label>
<entry expand="true" fill="true" name="sample-rate" regex="[0-9]*" value="48000"/>
<Spacer name="sample-rate-valid" min-size="10,10px" max-size="10,10px" color="green"/>
<!--
<combo expand="true" name="sample-rate" select="48">
<item value="96">96000</item>
<item value="48">48000</item>
<item value="32">32000</item>
<item value="16">16000</item>
<item value="8">8000</item>
</combo>
-->
</sizer>
</sizer>
<label>Filter:</label>
<sizer mode="vert" expand="true,false" lock="true" border="0.2%" addmode="invert">
<spacer min-size="5,5px"/>
<sizer mode="hori">
<label>type:</label>
<entry expand="true" fill="true" name="type" value="HPF"/>
<Spacer name="type-valid" min-size="10,10px" max-size="10,10px" color="green"/>
<!--
<combo expand="true" name="type" select="HPF">
<item value="HPF">High Pass Filter</item>
<item value="LPF">Low Pass Filter</item>
</combo>
-->
</sizer>
<sizer mode="hori">
<label>gain:</label>
<entry expand="true" fill="true" name="gain" regex="-?[0-9]*" value="0"/>
<Spacer name="gain-valid" min-size="10,10px" max-size="10,10px" color="green"/>
</sizer>
<sizer mode="hori">
<label>frequency:</label>
<entry expand="true" fill="true" name="frequency" regex="[0-9]*" value="1000"/>
<Spacer name="frequency-valid" min-size="10,10px" max-size="10,10px" color="green"/>
</sizer>
<sizer mode="hori">
<label>Band width:</label>
<entry expand="true" fill="true" name="band-width" regex="[0-9]*" value="100"/>
<Spacer name="band-width-valid" min-size="10,10px" max-size="10,10px" color="green"/>
</sizer>
</sizer>
<button name="display">
<label>Display</label>
</button>
<Spacer expand="true,true"/>
</sizer>
<DisplayFrequency name="displayer" fill="true" expand="true"/>
</sizer>