[DEV] add tools of the equalizer sizing

This commit is contained in:
Edouard DUPIN 2015-03-25 22:58:54 +01:00
parent 5dff6c1e8e
commit fa6cc4fa5c
10 changed files with 441 additions and 0 deletions

View File

@ -0,0 +1,39 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license APACHE-2 (see license file)
*/
#include <ewol/ewol.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Entry.h>
#undef __class__
#define __class__ "Windows"
appl::Windows::Windows() {
addObjectType("appl::Windows");
}
void appl::Windows::init() {
ewol::widget::Windows::init();
setTitle("Drain Equalizer Profiler");
m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:gui.xml");
if (m_gui != nullptr) {
setSubWidget(m_gui);
}
subBind(ewol::widget::Entry, "sample-rate", signalModify, shared_from_this(), &appl::Windows::onCallbackFrequency);
}
void appl::Windows::onCallbackFrequency(const std::string& _value) {
APPL_INFO("plop " << _value);
}

View File

@ -0,0 +1,30 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license APACHE-2 (see license file)
*/
#ifndef __APPL_WINDOWS_H__
#define __APPL_WINDOWS_H__
#include <ewol/widget/Windows.h>
#include <ewol/widget/Layer.h>
#include <ewol/widget/Composer.h>
namespace appl {
class Windows : public ewol::widget::Windows {
protected:
Windows();
void init();
public:
DECLARE_FACTORY(Windows);
protected:
std::shared_ptr<ewol::widget::Composer> m_gui;
void onCallbackFrequency(const std::string& _value);
};
};
#endif

View File

@ -0,0 +1,15 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license APACHE-2 (see license file)
*/
#include <appl/debug.h>
int32_t appl::getLogId() {
static int32_t g_val = etk::log::registerInstance("drain-equalizer");
return g_val;
}

View File

@ -0,0 +1,43 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license APACHE-2 (see license file)
*/
#ifndef __APPL_DEBUG_H__
#define __APPL_DEBUG_H__
#include <etk/log.h>
namespace appl {
int32_t getLogId();
};
#define APPL_BASE(info,data) TK_LOG_BASE(appl::getLogId(),info,data)
#define APPL_CRITICAL(data) APPL_BASE(1, data)
#define APPL_ERROR(data) APPL_BASE(2, data)
#define APPL_WARNING(data) APPL_BASE(3, data)
#ifdef DEBUG
#define APPL_INFO(data) APPL_BASE(4, data)
#define APPL_DEBUG(data) APPL_BASE(5, data)
#define APPL_VERBOSE(data) APPL_BASE(6, data)
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
#else
#define APPL_INFO(data) do { } while(false)
#define APPL_DEBUG(data) do { } while(false)
#define APPL_VERBOSE(data) do { } while(false)
#define APPL_TODO(data) do { } while(false)
#endif
#define APPL_ASSERT(cond,data) \
do { \
if (!(cond)) { \
APPL_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)
#endif

View File

@ -0,0 +1,60 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <etk/types.h>
#include <ewol/ewol.h>
#include <ewol/context/commandLine.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/object/Object.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
#include <appl/widget/DisplayFrequency.h>
class MainApplication : public ewol::context::Application {
public:
bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
// select internal data for font ...
_context.getFontDefault().setUseExternal(true);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
// add local widget list:
appl::widget::DisplayFrequency::createManagerWidget(_context.getWidgetManager());
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
}
void unInit(ewol::Context& _context) {
APPL_INFO("==> Un-Init APPL (START)");
// nothing to do ...
APPL_INFO("==> Un-Init APPL (END)");
}
};
/**
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
* @param std IO
* @return std IO
*/
int main(int _argc, const char *_argv[]) {
return ewol::run(new MainApplication(), _argc, _argv);
}

View File

@ -0,0 +1,14 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license APACHE-2 (see license file)
*/
#ifndef __APPL_MAIN_H__
#define __APPL_MAIN_H__
#endif

View File

@ -0,0 +1,93 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license APACHE-2 (see license file)
*/
#include <appl/widget/DisplayFrequency.h>
#include <appl/debug.h>
#include <etk/tool.h>
#undef __class__
#define __class__ "DisplayFrequency"
appl::widget::DisplayFrequency::DisplayFrequency() :
m_autoDisplay(false),
m_minVal(-1.0f),
m_maxVal(1.0f) {
addObjectType("appl::widget::DisplayFrequency");
}
void appl::widget::DisplayFrequency::init() {
ewol::Widget::init();
markToRedraw();
ToggleAuto();
}
appl::widget::DisplayFrequency::~DisplayFrequency() {
}
void appl::widget::DisplayFrequency::setValue(const std::vector<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::onDraw() {
m_draw.draw();
}
void appl::widget::DisplayFrequency::onRegenerateDisplay() {
//!< Check if we really need to redraw the display, if not needed, we redraw the previous data ...
if (needRedraw() == false) {
return;
}
// remove previous data
m_draw.clear();
// set background
m_draw.setColor(etk::color::black);
m_draw.setPos(vec2(0,0));
m_draw.rectangleWidth(m_size);
if (m_data.size() == 0) {
return;
}
// 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 baseX = 0;
for (size_t iii=1; iii<m_data.size(); ++iii) {
m_draw.lineTo(vec2((float)iii*stepX, origin + ratioY*m_data[iii]));
}
}
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

@ -0,0 +1,49 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license APACHE-2 (see license file)
*/
#ifndef __APPL_WIDGET_DISPLAY_FREQUENCY_H__
#define __APPL_WIDGET_DISPLAY_FREQUENCY_H__
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/Manager.h>
namespace appl {
namespace widget {
class DisplayFrequency : public ewol::Widget {
private:
ewol::compositing::Drawing m_draw; //!< drawing instance
protected:
//! @brief constructor
DisplayFrequency();
void init();
public:
DECLARE_WIDGET_FACTORY(DisplayFrequency, "DisplayFrequency");
//! @brief destructor
virtual ~DisplayFrequency();
private:
std::vector<float> m_data; //!< data that might be displayed
public:
void setValue(const std::vector<float>& _data);
private:
bool m_autoDisplay;
public:
void ToggleAuto();
private:
float m_minVal; //!< display minimum value
float m_maxVal; //!< display maximum value
public: // herited function
virtual void onDraw();
virtual void onRegenerateDisplay();
virtual void periodicCall(const ewol::event::Time& _event);
};
}
}
#endif

View File

@ -0,0 +1,64 @@
<?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>
</button>
</sizer>
</scroll>
<DisplayFrequency name="displayer" fill="true" expand="true"/>
</sizer>

View File

@ -0,0 +1,34 @@
#!/usr/bin/python
import lutinModule as module
import lutinTools as tools
# optionnal : Describe in the "lutin.py --help"
def get_desc():
return "drain_equalizer_profiling : basic test and profiling of equalizer work or not"
def create(target):
myModule = module.Module(__file__, 'drain_equalizer_profiling', 'BINARY')
# add the file to compile:
myModule.add_src_file([
'appl/main.cpp',
'appl/debug.cpp',
'appl/Windows.cpp',
'appl/widget/DisplayFrequency.cpp',
])
# add Library dependency name
myModule.add_module_depend(['ewol', 'drain'])
# add application C flags
myModule.compile_flags_CC([
"-DPROJECT_NAME=\"\\\""+myModule.name+"\\\"\""])
# Add current include Path
myModule.add_path(tools.get_current_path(__file__))
# copy internal datas
myModule.copy_folder("data/*")
# return the created module
return myModule