[DEV] update new lutin 0.8.0

This commit is contained in:
Edouard DUPIN 2015-10-14 21:21:03 +02:00
parent 0e208e9b27
commit 3bbf3500a2
5 changed files with 73 additions and 93 deletions

View File

@ -3,17 +3,34 @@ import lutin.module as module
import lutin.tools as tools import lutin.tools as tools
import lutin.debug as debug import lutin.debug as debug
def get_type():
return "BINARY"
def get_sub_type():
return "TEST"
def get_desc(): def get_desc():
return "test for River ALGO" return "test for River ALGO"
def get_licence():
return "APACHE-2"
def create(target): def get_compagny_type():
my_module = module.Module(__file__, 'audio-algo-river-test', 'BINARY') return "com"
def get_compagny_name():
return "atria-soft"
def get_maintainer():
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
def create(target, module_name):
my_module = module.Module(__file__, module_name, get_type())
my_module.add_src_file([ my_module.add_src_file([
'test/main.cpp', 'test/main.cpp'
'test/debug.cpp'
]) ])
my_module.add_module_depend(['audio-algo-river']) my_module.add_module_depend(['audio-algo-river', 'test-debug'])
return my_module return my_module

View File

@ -3,12 +3,30 @@ import lutin.module as module
import lutin.tools as tools import lutin.tools as tools
import lutin.debug as debug import lutin.debug as debug
def get_type():
return "LIBRARY"
def get_desc(): def get_desc():
return "river algos" return "river algos"
def get_licence():
return "APACHE-2"
def create(target): def get_compagny_type():
my_module = module.Module(__file__, 'audio-algo-river', 'LIBRARY') return "com"
def get_compagny_name():
return "atria-soft"
def get_maintainer():
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
def get_version():
return [0,0,0]
def create(target, module_name):
my_module = module.Module(__file__, module_name, get_type())
my_module.add_src_file([ my_module.add_src_file([
'audio/algo/river/debug.cpp', 'audio/algo/river/debug.cpp',
'audio/algo/river/convolution.cpp', 'audio/algo/river/convolution.cpp',
@ -28,7 +46,6 @@ def create(target):
]) ])
my_module.add_module_depend(['etk', 'audio']) my_module.add_module_depend(['etk', 'audio'])
my_module.add_path(tools.get_current_path(__file__)) my_module.add_path(tools.get_current_path(__file__))
# return module
return my_module return my_module

View File

@ -1,13 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
int32_t appl::getLogId() {
static int32_t g_val = etk::log::registerInstance("test-LMS");
return g_val;
}

View File

@ -1,41 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (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_PRINT(data) APPL_BASE(-1, 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)
#define APPL_INFO(data) APPL_BASE(4, data)
#ifdef DEBUG
#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_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

@ -4,7 +4,7 @@
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#include <test/debug.h> #include <test-debug/debug.h>
#include <etk/etk.h> #include <etk/etk.h>
#include <audio/algo/river/Lms.h> #include <audio/algo/river/Lms.h>
#include <audio/algo/river/Nlms.h> #include <audio/algo/river/Nlms.h>
@ -95,41 +95,41 @@ int main(int _argc, const char** _argv) {
sampleRate = etk::string_to_int32_t(data); sampleRate = etk::string_to_int32_t(data);
} else if ( data == "-h" } else if ( data == "-h"
|| data == "--help") { || data == "--help") {
APPL_PRINT("Help : "); TEST_PRINT("Help : ");
APPL_PRINT(" ./xxx --fb=file.raw --mic=file.raw"); TEST_PRINT(" ./xxx --fb=file.raw --mic=file.raw");
APPL_PRINT(" --fb=YYY.raw Feedback file"); TEST_PRINT(" --fb=YYY.raw Feedback file");
APPL_PRINT(" --mic=XXX.raw Microphone file"); TEST_PRINT(" --mic=XXX.raw Microphone file");
APPL_PRINT(" --filter-size=xxx Size of the filter"); TEST_PRINT(" --filter-size=xxx Size of the filter");
APPL_PRINT(" --mu=0.xx Mu value -1.0< mu < -1.0"); TEST_PRINT(" --mu=0.xx Mu value -1.0< mu < -1.0");
APPL_PRINT(" --nlms NLMS version"); TEST_PRINT(" --nlms NLMS version");
APPL_PRINT(" --perf Enable performence test (little slower but real performence test)"); TEST_PRINT(" --perf Enable performence test (little slower but real performence test)");
APPL_PRINT(" --sample-rate=XXXX Signal sample rate (default 48000)"); TEST_PRINT(" --sample-rate=XXXX Signal sample rate (default 48000)");
exit(0); exit(0);
} }
} }
if ( fbName == "" if ( fbName == ""
|| micName == "") { || micName == "") {
APPL_ERROR("Can not Process missing parameters..."); TEST_ERROR("Can not Process missing parameters...");
exit(-1); exit(-1);
} }
Performance perfo; Performance perfo;
APPL_INFO("Read FeedBack:"); TEST_INFO("Read FeedBack:");
std::vector<int16_t> fbData = etk::FSNodeReadAllDataType<int16_t>(fbName); std::vector<int16_t> fbData = etk::FSNodeReadAllDataType<int16_t>(fbName);
APPL_INFO(" " << fbData.size() << " samples"); TEST_INFO(" " << fbData.size() << " samples");
APPL_INFO("Read Microphone:"); TEST_INFO("Read Microphone:");
std::vector<int16_t> micData = etk::FSNodeReadAllDataType<int16_t>(micName); std::vector<int16_t> micData = etk::FSNodeReadAllDataType<int16_t>(micName);
APPL_INFO(" " << micData.size() << " samples"); TEST_INFO(" " << micData.size() << " samples");
// resize output : // resize output :
std::vector<int16_t> output; std::vector<int16_t> output;
output.resize(std::min(fbData.size(), micData.size()), 0); output.resize(std::min(fbData.size(), micData.size()), 0);
// process in chunk of 256 samples // process in chunk of 256 samples
int32_t blockSize = 256; int32_t blockSize = 256;
if (nlms == false) { if (nlms == false) {
APPL_PRINT("***********************"); TEST_PRINT("***********************");
APPL_PRINT("** LMS **"); TEST_PRINT("** LMS **");
APPL_PRINT("***********************"); TEST_PRINT("***********************");
audio::algo::river::Lms algo; audio::algo::river::Lms algo;
algo.init(1, sampleRate, audio::format_float); algo.init(1, sampleRate, audio::format_float);
if (filterSize != 0) { if (filterSize != 0) {
@ -142,9 +142,9 @@ int main(int _argc, const char** _argv) {
for (int32_t iii=0; iii<output.size()/blockSize; ++iii) { for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
if (lastPourcent != 100*iii / (output.size()/blockSize)) { if (lastPourcent != 100*iii / (output.size()/blockSize)) {
lastPourcent = 100*iii / (output.size()/blockSize); lastPourcent = 100*iii / (output.size()/blockSize);
APPL_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100"); TEST_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
} else { } else {
APPL_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize); TEST_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
} }
perfo.tic(); perfo.tic();
algo.process(&output[iii*blockSize], &fbData[iii*blockSize], &micData[iii*blockSize], blockSize); algo.process(&output[iii*blockSize], &fbData[iii*blockSize], &micData[iii*blockSize], blockSize);
@ -154,9 +154,9 @@ int main(int _argc, const char** _argv) {
} }
} }
} else { } else {
APPL_PRINT("***********************"); TEST_PRINT("***********************");
APPL_PRINT("** NLMS (power) **"); TEST_PRINT("** NLMS (power) **");
APPL_PRINT("***********************"); TEST_PRINT("***********************");
audio::algo::river::Nlms algo; audio::algo::river::Nlms algo;
algo.init(1, sampleRate, audio::format_float); algo.init(1, sampleRate, audio::format_float);
if (filterSize != 0) { if (filterSize != 0) {
@ -166,9 +166,9 @@ int main(int _argc, const char** _argv) {
for (int32_t iii=0; iii<output.size()/blockSize; ++iii) { for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
if (lastPourcent != 100*iii / (output.size()/blockSize)) { if (lastPourcent != 100*iii / (output.size()/blockSize)) {
lastPourcent = 100*iii / (output.size()/blockSize); lastPourcent = 100*iii / (output.size()/blockSize);
APPL_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100"); TEST_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
} else { } else {
APPL_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize); TEST_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
} }
perfo.tic(); perfo.tic();
algo.process(&output[iii*blockSize], &fbData[iii*blockSize], &micData[iii*blockSize], blockSize); algo.process(&output[iii*blockSize], &fbData[iii*blockSize], &micData[iii*blockSize], blockSize);
@ -178,18 +178,18 @@ int main(int _argc, const char** _argv) {
} }
} }
} }
APPL_PRINT("Process done"); TEST_PRINT("Process done");
if (perf == true) { if (perf == true) {
APPL_PRINT("Performance Result: "); TEST_PRINT("Performance Result: ");
APPL_INFO(" blockSize=" << blockSize << " sample"); TEST_INFO(" blockSize=" << blockSize << " sample");
APPL_INFO(" min < avg < max =" << perfo.getMinProcessing().count() << "ns < " TEST_INFO(" min < avg < max =" << perfo.getMinProcessing().count() << "ns < "
<< perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << "ns < " << perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << "ns < "
<< perfo.getMaxProcessing().count() << "ns "); << perfo.getMaxProcessing().count() << "ns ");
float avg = (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRate)/double(blockSize))/1000000000.0)*100.0; float avg = (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRate)/double(blockSize))/1000000000.0)*100.0;
APPL_INFO(" min < avg < max= " << (float((perfo.getMinProcessing().count()*sampleRate)/double(blockSize))/1000000000.0)*100.0 << "% < " TEST_INFO(" min < avg < max= " << (float((perfo.getMinProcessing().count()*sampleRate)/double(blockSize))/1000000000.0)*100.0 << "% < "
<< avg << "% < " << avg << "% < "
<< (float((perfo.getMaxProcessing().count()*sampleRate)/double(blockSize))/1000000000.0)*100.0 << "%"); << (float((perfo.getMaxProcessing().count()*sampleRate)/double(blockSize))/1000000000.0)*100.0 << "%");
APPL_PRINT("float : " << sampleRate << " : " << avg << "%"); TEST_PRINT("float : " << sampleRate << " : " << avg << "%");
} }
etk::FSNodeWriteAllDataType<int16_t>("output.raw", output); etk::FSNodeWriteAllDataType<int16_t>("output.raw", output);
} }