[DEV] set theoric calculation.
This commit is contained in:
parent
20275009b3
commit
b1d5b8aeab
@ -169,3 +169,18 @@ void drain::Equalizer::configureBiQuad() {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::pair<float,float> > drain::Equalizer::calculateTheory() {
|
||||
std::vector<std::pair<float,float> > out;
|
||||
for (size_t iii=0; iii<m_biquads[0].size(); ++iii) {
|
||||
if (iii == 0) {
|
||||
out = m_biquads[0][iii].calculateTheory(getOutputFormat().getFrequency());
|
||||
} else {
|
||||
std::vector<std::pair<float,float> > tmp = m_biquads[0][iii].calculateTheory(getOutputFormat().getFrequency());
|
||||
for (size_t jjj=0; jjj< out.size(); ++jjj) {
|
||||
out[jjj].second += tmp[jjj].second;
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
@ -52,6 +52,9 @@ namespace drain {
|
||||
* @brief Configure biquad with the user spec.
|
||||
*/
|
||||
void configureBiQuad();
|
||||
public:
|
||||
// for debug & tools only
|
||||
std::vector<std::pair<float,float> > calculateTheory();
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -228,7 +228,7 @@ void appl::Windows::onCallbackStart16() {
|
||||
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
for (size_t iii=0; iii < len; iii++) {
|
||||
for (size_t iii=1; iii < len; iii++) {
|
||||
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
|
||||
// To reset filter
|
||||
bq.reset();
|
||||
@ -250,11 +250,11 @@ void appl::Windows::onCallbackStart16() {
|
||||
void* outputVoid = nullptr;
|
||||
size_t outputNbChunk = 0;
|
||||
std11::chrono::system_clock::time_point time;
|
||||
//RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_16.raw",&data[0],data.size());
|
||||
RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_16.raw",&data[0],data.size());
|
||||
bq.processInt16(&data[0], &data[0], data.size(), 1, 1);
|
||||
//RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_16.raw",&data[0],data.size());
|
||||
RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_16.raw",&data[0],data.size());
|
||||
int16_t value = 0;
|
||||
for (size_t iii=200; iii<data.size()-200; ++iii) {
|
||||
for (size_t iii=800; iii<data.size()-200; ++iii) {
|
||||
value = std::max(value, data[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(double(value)/32000.0);
|
||||
@ -272,7 +272,7 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
for (size_t iii=0; iii < len; iii++) {
|
||||
for (size_t iii=1; iii < len; iii++) {
|
||||
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
|
||||
// To reset filter
|
||||
bq.reset();
|
||||
@ -289,11 +289,11 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
m_phase -= 2*M_PI;
|
||||
}
|
||||
}
|
||||
//RIVER_SAVE_FILE_MACRO(float,"aaa_test_INPUT_F.raw",&data[0],data.size());
|
||||
RIVER_SAVE_FILE_MACRO(float,"aaa_test_INPUT_F.raw",&data[0],data.size());
|
||||
bq.processFloat(&data[0], &data[0], data.size(), 1, 1);
|
||||
//RIVER_SAVE_FILE_MACRO(float,"aaa_test_OUTPUT_F.raw",&data[0],data.size());
|
||||
float value = 0;
|
||||
for (size_t iii=200; iii<data.size()-200; ++iii) {
|
||||
RIVER_SAVE_FILE_MACRO(float,"aaa_test_OUTPUT_F.raw",&data[0],data.size());
|
||||
float value = 0.0f;
|
||||
for (size_t iii=800; iii<data.size()-200; ++iii) {
|
||||
value = std::max(value, data[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(double(value)/1.0);
|
||||
|
@ -18,11 +18,7 @@
|
||||
#define __class__ "Windows"
|
||||
|
||||
appl::Windows::Windows() :
|
||||
m_sampleRate(48000),
|
||||
m_type(drain::filterType::filterType_lowPass),
|
||||
m_cutFrequency(8000.0),
|
||||
m_gain(0.0),
|
||||
m_quality(0.707) {
|
||||
m_sampleRate(48000) {
|
||||
addObjectType("appl::Windows");
|
||||
m_listSampleRate.push_back(192000);
|
||||
m_listSampleRate.push_back(176400);
|
||||
@ -36,14 +32,7 @@ appl::Windows::Windows() :
|
||||
m_listSampleRate.push_back(11025);
|
||||
m_listSampleRate.push_back(8000);
|
||||
m_listSampleRate.push_back(4000);
|
||||
m_listType.push_back(drain::filterType_none);
|
||||
m_listType.push_back(drain::filterType_lowPass);
|
||||
m_listType.push_back(drain::filterType_highPass);
|
||||
m_listType.push_back(drain::filterType_bandPass);
|
||||
m_listType.push_back(drain::filterType_notch);
|
||||
m_listType.push_back(drain::filterType_peak);
|
||||
m_listType.push_back(drain::filterType_lowShelf);
|
||||
m_listType.push_back(drain::filterType_highShelf);
|
||||
m_listGain.resize(10, 0.0f);
|
||||
}
|
||||
|
||||
void appl::Windows::init() {
|
||||
@ -56,17 +45,17 @@ void appl::Windows::init() {
|
||||
}
|
||||
subBind(ewol::widget::Button, "sample-rate-low", signalPressed, shared_from_this(), &appl::Windows::onCallbackSampleRateLow);
|
||||
subBind(ewol::widget::Button, "sample-rate-up", signalPressed, shared_from_this(), &appl::Windows::onCallbackSampleRateUp);
|
||||
subBind(ewol::widget::Button, "type-low", signalPressed, shared_from_this(), &appl::Windows::onCallbackTypeLow);
|
||||
subBind(ewol::widget::Button, "type-up", signalPressed, shared_from_this(), &appl::Windows::onCallbackTypeUp);
|
||||
|
||||
subBind(ewol::widget::Entry, "gain", signalModify, shared_from_this(), &appl::Windows::onCallbackGain);
|
||||
subBind(ewol::widget::Slider, "gain-slider", signalChange, shared_from_this(), &appl::Windows::onCallbackGainSlider);
|
||||
|
||||
subBind(ewol::widget::Entry, "frequency", signalModify, shared_from_this(), &appl::Windows::onCallbackFrequency);
|
||||
subBind(ewol::widget::Slider, "frequency-slider", signalChange, shared_from_this(), &appl::Windows::onCallbackFrequencySlider);
|
||||
|
||||
subBind(ewol::widget::Entry, "quality", signalModify, shared_from_this(), &appl::Windows::onCallbackQuality);
|
||||
subBind(ewol::widget::Slider, "quality-slider", signalChange, shared_from_this(), &appl::Windows::onCallbackQualitySlider);
|
||||
subBind(ewol::widget::Slider, "gain-0", signalChange, shared_from_this(), &appl::Windows::onCallbackGain0);
|
||||
subBind(ewol::widget::Slider, "gain-1", signalChange, shared_from_this(), &appl::Windows::onCallbackGain1);
|
||||
subBind(ewol::widget::Slider, "gain-2", signalChange, shared_from_this(), &appl::Windows::onCallbackGain2);
|
||||
subBind(ewol::widget::Slider, "gain-3", signalChange, shared_from_this(), &appl::Windows::onCallbackGain3);
|
||||
subBind(ewol::widget::Slider, "gain-4", signalChange, shared_from_this(), &appl::Windows::onCallbackGain4);
|
||||
subBind(ewol::widget::Slider, "gain-5", signalChange, shared_from_this(), &appl::Windows::onCallbackGain5);
|
||||
subBind(ewol::widget::Slider, "gain-6", signalChange, shared_from_this(), &appl::Windows::onCallbackGain6);
|
||||
subBind(ewol::widget::Slider, "gain-7", signalChange, shared_from_this(), &appl::Windows::onCallbackGain7);
|
||||
subBind(ewol::widget::Slider, "gain-8", signalChange, shared_from_this(), &appl::Windows::onCallbackGain8);
|
||||
subBind(ewol::widget::Slider, "gain-9", signalChange, shared_from_this(), &appl::Windows::onCallbackGain9);
|
||||
|
||||
subBind(ewol::widget::Button, "display16", signalPressed, shared_from_this(), &appl::Windows::onCallbackStart16);
|
||||
subBind(ewol::widget::Button, "displayFloat", signalPressed, shared_from_this(), &appl::Windows::onCallbackStartFloat);
|
||||
@ -85,14 +74,12 @@ void appl::Windows::onCallbackSampleRateUp() {
|
||||
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));
|
||||
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));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@ -106,115 +93,75 @@ void appl::Windows::onCallbackSampleRateLow() {
|
||||
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));
|
||||
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));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackTypeUp() {
|
||||
for (int32_t iii=0; iii<m_listType.size(); ++iii) {
|
||||
if (m_type == m_listType[iii]) {
|
||||
iii++;
|
||||
if (iii<m_listType.size()) {
|
||||
m_type = m_listType[iii];
|
||||
} else {
|
||||
m_type = m_listType[0];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_type = m_listType[0];
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
void appl::Windows::onCallbackGain(const float& _value, int32_t _id) {
|
||||
m_listGain[_id] = _value;
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackTypeLow() {
|
||||
for (int32_t iii=0; iii<m_listType.size(); ++iii) {
|
||||
if (m_type == m_listType[iii]) {
|
||||
iii--;
|
||||
if (iii>=0) {
|
||||
m_type = m_listType[iii];
|
||||
} else {
|
||||
m_type = m_listType[m_listType.size()-1];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_type = m_listType[0];
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
|
||||
void appl::Windows::onCallbackGain(const std::string& _value) {
|
||||
m_gain = etk::string_to_float(_value);
|
||||
ewol::parameterSetOnObjectNamed("gain-slider", "value", etk::to_string(_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));
|
||||
APPL_INFO("Gain " << m_gain);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void appl::Windows::onCallbackQuality(const std::string& _value) {
|
||||
m_quality = etk::string_to_float(_value);
|
||||
ewol::parameterSetOnObjectNamed("quality-slider", "value", etk::to_string(_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));
|
||||
APPL_INFO("quality " << m_quality);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
|
||||
void appl::Windows::onCallbackFrequency(const std::string& _value) {
|
||||
m_cutFrequency = etk::string_to_float(_value);
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "value", etk::to_string(_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));
|
||||
APPL_INFO("cut frequency " << m_cutFrequency);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
#include <river/debug.h>
|
||||
|
||||
void appl::Windows::onCallbackStart() {
|
||||
APPL_INFO("start ");
|
||||
int32_t iii = 10;
|
||||
std11::shared_ptr<drain::Equalizer> appl::Windows::createEqualizer(enum audio::format _format) {
|
||||
std::vector<audio::channel> map;
|
||||
map.push_back(audio::channel_frontCenter);
|
||||
//drain::IOFormatInterface format(map, audio::format_int16, m_sampleRate);
|
||||
drain::IOFormatInterface format(map, audio::format_float, m_sampleRate);
|
||||
// create biquad
|
||||
drain::BiQuadFloat 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);
|
||||
drain::IOFormatInterface format(map, _format, m_sampleRate);
|
||||
// create equalizer
|
||||
std11::shared_ptr<drain::Equalizer> out = drain::Equalizer::create();
|
||||
// configure input
|
||||
out->setInputFormat(format);
|
||||
// configure output
|
||||
out->setOutputFormat(format);
|
||||
// create ejson:
|
||||
std::string conf;
|
||||
conf += "{\n";
|
||||
conf += " global: [\n";
|
||||
for (size_t iii=3; iii<m_listGain.size(); ++iii) {
|
||||
float cutFrequency = 49000;
|
||||
switch (iii) {
|
||||
case 0:cutFrequency = 31.25; break;
|
||||
case 1:cutFrequency = 62.5; break;
|
||||
case 2:cutFrequency = 125; break;
|
||||
case 3:cutFrequency = 250; break;
|
||||
case 4:cutFrequency = 500; break;
|
||||
|
||||
case 5:cutFrequency = 1000; break;
|
||||
case 6:cutFrequency = 2000; break;
|
||||
case 7:cutFrequency = 4000; break;
|
||||
case 8:cutFrequency = 8000; break;
|
||||
case 9:cutFrequency = 16000; break;
|
||||
}
|
||||
|
||||
if (iii != 0) {
|
||||
conf += " ,\n";
|
||||
}
|
||||
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 += " }\n";
|
||||
}
|
||||
conf += " ]\n";
|
||||
conf += "}\n";
|
||||
APPL_INFO("config : " << conf);
|
||||
// configure:
|
||||
out->setParameter("config", conf);
|
||||
return out;
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackStart() {
|
||||
APPL_INFO("start ");
|
||||
std11::shared_ptr<drain::Equalizer> eq = appl::Windows::createEqualizer();
|
||||
std::vector<std::pair<float,float> > theory = eq->calculateTheory();
|
||||
m_displayer->clear();
|
||||
m_displayer->setValue(theory);
|
||||
}
|
||||
@ -222,22 +169,18 @@ void appl::Windows::onCallbackStart() {
|
||||
|
||||
void appl::Windows::onCallbackStart16() {
|
||||
APPL_INFO("start ");
|
||||
// create biquad
|
||||
drain::BiQuadFloat bq;
|
||||
// configure parameter
|
||||
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
|
||||
std11::shared_ptr<drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_int16);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
for (size_t iii=0; iii < len; iii++) {
|
||||
std::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;
|
||||
// To reset filter
|
||||
bq.reset();
|
||||
eq->setParameter("reset", "");
|
||||
double m_phase = 0;
|
||||
double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq);
|
||||
float gain = 0;
|
||||
std::vector<int16_t> data;
|
||||
// create sinus
|
||||
data.resize(16000, 0);
|
||||
for (int32_t iii=0; iii<data.size(); iii++) {
|
||||
data[iii] = cos(m_phase) * 32000;
|
||||
m_phase += baseCycle;
|
||||
@ -250,12 +193,13 @@ void appl::Windows::onCallbackStart16() {
|
||||
void* outputVoid = nullptr;
|
||||
size_t outputNbChunk = 0;
|
||||
std11::chrono::system_clock::time_point time;
|
||||
//RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_16.raw",&data[0],data.size());
|
||||
bq.processInt16(&data[0], &data[0], data.size(), 1, 1);
|
||||
//RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_16.raw",&data[0],data.size());
|
||||
RIVER_SAVE_FILE_MACRO(int16_t, "aaa_test_INPUT.raw", &data[0], data.size());
|
||||
eq->process(time, &data[0], data.size(), outputVoid, outputNbChunk);
|
||||
output = static_cast<int16_t*>(outputVoid);
|
||||
RIVER_SAVE_FILE_MACRO(int16_t, "aaa_test_OUTPUT.raw", output, outputNbChunk);
|
||||
int16_t value = 0;
|
||||
for (size_t iii=200; iii<data.size()-200; ++iii) {
|
||||
value = std::max(value, data[iii]);
|
||||
for (size_t iii=800; iii<outputNbChunk-200; ++iii) {
|
||||
value = std::max(value, output[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(double(value)/32000.0);
|
||||
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
|
||||
@ -266,22 +210,18 @@ void appl::Windows::onCallbackStart16() {
|
||||
|
||||
void appl::Windows::onCallbackStartFloat() {
|
||||
APPL_INFO("start ");
|
||||
// create biquad
|
||||
drain::BiQuadFloat bq;
|
||||
// configure parameter
|
||||
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
|
||||
std11::shared_ptr<drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_float);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
for (size_t iii=0; iii < len; iii++) {
|
||||
std::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;
|
||||
// To reset filter
|
||||
bq.reset();
|
||||
eq->setParameter("reset", "");
|
||||
double m_phase = 0;
|
||||
double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq);
|
||||
float gain = 0;
|
||||
std::vector<float> data;
|
||||
// create sinus
|
||||
data.resize(16000, 0);
|
||||
for (int32_t iii=0; iii<data.size(); iii++) {
|
||||
data[iii] = cos(m_phase);
|
||||
m_phase += baseCycle;
|
||||
@ -289,12 +229,18 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
m_phase -= 2*M_PI;
|
||||
}
|
||||
}
|
||||
//RIVER_SAVE_FILE_MACRO(float,"aaa_test_INPUT_F.raw",&data[0],data.size());
|
||||
bq.processFloat(&data[0], &data[0], data.size(), 1, 1);
|
||||
//RIVER_SAVE_FILE_MACRO(float,"aaa_test_OUTPUT_F.raw",&data[0],data.size());
|
||||
// process
|
||||
float* output = nullptr;
|
||||
void* outputVoid = nullptr;
|
||||
size_t outputNbChunk = 0;
|
||||
std11::chrono::system_clock::time_point time;
|
||||
RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_F.raw",&data[0],data.size());
|
||||
eq->process(time, &data[0], data.size(), outputVoid, outputNbChunk);
|
||||
output = static_cast<float*>(outputVoid);
|
||||
RIVER_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_F.raw",output, outputNbChunk);
|
||||
float value = 0;
|
||||
for (size_t iii=200; iii<data.size()-200; ++iii) {
|
||||
value = std::max(value, data[iii]);
|
||||
for (size_t iii=800; iii<outputNbChunk-200; ++iii) {
|
||||
value = std::max(value, output[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(double(value)/1.0);
|
||||
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
|
||||
@ -302,4 +248,3 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
}
|
||||
m_displayer->setValue(pratic);
|
||||
}
|
||||
|
||||
|
@ -27,25 +27,46 @@ namespace appl {
|
||||
std::shared_ptr<appl::widget::DisplayFrequency> m_displayer;
|
||||
void onCallbackSampleRateLow();
|
||||
void onCallbackSampleRateUp();
|
||||
void onCallbackTypeUp();
|
||||
void onCallbackTypeLow();
|
||||
void onCallbackGain(const std::string& _value);
|
||||
void onCallbackGainSlider(const float& _value);
|
||||
void onCallbackFrequency(const std::string& _value);
|
||||
void onCallbackFrequencySlider(const float& _value);
|
||||
void onCallbackQuality(const std::string& _value);
|
||||
void onCallbackQualitySlider(const float& _value);
|
||||
void onCallbackGain0(const float& _value) {
|
||||
onCallbackGain(_value, 0);
|
||||
}
|
||||
void onCallbackGain1(const float& _value) {
|
||||
onCallbackGain(_value, 1);
|
||||
}
|
||||
void onCallbackGain2(const float& _value) {
|
||||
onCallbackGain(_value, 2);
|
||||
}
|
||||
void onCallbackGain3(const float& _value) {
|
||||
onCallbackGain(_value, 3);
|
||||
}
|
||||
void onCallbackGain4(const float& _value) {
|
||||
onCallbackGain(_value, 4);
|
||||
}
|
||||
void onCallbackGain5(const float& _value) {
|
||||
onCallbackGain(_value, 5);
|
||||
}
|
||||
void onCallbackGain6(const float& _value) {
|
||||
onCallbackGain(_value, 6);
|
||||
}
|
||||
void onCallbackGain7(const float& _value) {
|
||||
onCallbackGain(_value, 7);
|
||||
}
|
||||
void onCallbackGain8(const float& _value) {
|
||||
onCallbackGain(_value, 8);
|
||||
}
|
||||
void onCallbackGain9(const float& _value) {
|
||||
onCallbackGain(_value, 9);
|
||||
}
|
||||
void onCallbackGain(const float& _value, int32_t _id);
|
||||
void onCallbackStart();
|
||||
void onCallbackStart16();
|
||||
void onCallbackStartFloat();
|
||||
protected:
|
||||
int32_t m_sampleRate;
|
||||
std::vector<int32_t> m_listSampleRate;
|
||||
enum drain::filterType m_type;
|
||||
std::vector<enum drain::filterType> m_listType;
|
||||
float m_cutFrequency;
|
||||
float m_gain;
|
||||
float m_quality;
|
||||
|
||||
std::vector<float> m_listGain;
|
||||
std11::shared_ptr<drain::Equalizer> createEqualizer(enum audio::format _format = audio::format_float);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -92,6 +92,7 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
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);
|
||||
//APPL_INFO("plop " << m_data[kkk][iii].second);
|
||||
}
|
||||
if (displayLog == false) {
|
||||
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
|
||||
@ -105,12 +106,15 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
}
|
||||
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));
|
||||
APPL_INFO("plop " << m_data[kkk][iii].first << " " << std::log(m_data[kkk][iii].first));
|
||||
//APPL_INFO("plop " << m_data[kkk][iii].first << " " << std::log(m_data[kkk][iii].first));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO : limit unit at a unit value.
|
||||
|
||||
m_gainMin = int32_t(m_gainMin - 1);
|
||||
m_gainMax = int32_t(m_gainMax + 1);
|
||||
/*
|
||||
for (size_t iii=0; iii<m_data[0].size() && m_data[1].size(); ++iii) {
|
||||
APPL_INFO(" f=" << m_data[0][iii].first << " val=" << m_data[0][iii].second << " f=" << m_data[1][iii].first << " val=" << m_data[1][iii].second);
|
||||
@ -118,9 +122,14 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
*/
|
||||
// set all the line:
|
||||
m_draw.setThickness(1);
|
||||
//APPL_ERROR("---------------------------");
|
||||
m_draw.setColor(etk::color::red);
|
||||
|
||||
float ratioX = (m_size.x()-m_borderSize.x()*2.0) / (m_frequencyMax - m_frequencyMin);
|
||||
float ratioY = (m_size.y()-m_borderSize.y()*2.0) / (m_gainMax - m_gainMin);
|
||||
|
||||
m_draw.setPos(m_borderSize + vec2(0, ratioY*(- m_gainMin)));
|
||||
m_draw.lineTo(m_borderSize + vec2(ratioX*(m_frequencyMax - m_frequencyMin), ratioY*(- m_gainMin)));
|
||||
for (size_t kkk=0; kkk<m_data.size(); ++kkk) {
|
||||
//APPL_ERROR("kjhkjhkj " << kkk << " " << m_data.size());
|
||||
if (kkk == 0) {
|
||||
m_draw.setColor(etk::color::green);
|
||||
} else if (kkk == 0) {
|
||||
@ -129,8 +138,6 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
m_draw.setColor(etk::color::red);
|
||||
}
|
||||
|
||||
float ratioX = (m_size.x()-m_borderSize.x()*2.0) / (m_frequencyMax - m_frequencyMin);
|
||||
float ratioY = (m_size.y()-m_borderSize.y()*2.0) / (m_gainMax - m_gainMin);
|
||||
if (displayLog == false) {
|
||||
m_draw.setPos( m_borderSize
|
||||
+ vec2(ratioX*(m_data[kkk][0].first - m_frequencyMin),
|
||||
|
@ -29,40 +29,56 @@
|
||||
</sizer>
|
||||
<label>Filter:</label>
|
||||
<sizer mode="vert" expand="true,false" lock="true" border="0.2%" addmode="invert">
|
||||
<spacer min-size="5,5px"/>
|
||||
<label>type:</label>
|
||||
<sizer mode="hori">
|
||||
<button name="type-low">
|
||||
<label>---</label>
|
||||
</button>
|
||||
<label expand="true" fill="true" name="type">
|
||||
Low-pass
|
||||
</label>
|
||||
<button name="type-up">
|
||||
<label>+++</label>
|
||||
</button>
|
||||
<label>Band 0:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-0" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
|
||||
<sizer mode="hori">
|
||||
<label>gain:</label>
|
||||
<entry expand="true" fill="true" name="gain" regex="-?(\.|[0-9])*" value="0"/>
|
||||
<label>Band 1:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-slider" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<slider expand="true" name="gain-1" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
|
||||
<sizer mode="hori">
|
||||
<label>cut frequency:</label>
|
||||
<entry expand="true" fill="true" name="frequency" regex="[0-9]*" value="1000"/>
|
||||
<label>Band 2:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="frequency-slider" value="8000" min="1" max="24000" step="0.01"/>
|
||||
<slider expand="true" name="gain-2" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
|
||||
<sizer mode="hori">
|
||||
<label>Quality factor:</label>
|
||||
<entry expand="true" fill="true" name="quality" regex="[0-9]*" value="100"/>
|
||||
<label>Band 3:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="quality-slider" value="0.707" min="0.001" max="50" step="0.001"/>
|
||||
<slider expand="true" name="gain-3" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
<sizer mode="hori">
|
||||
<label>Band 4:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-4" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
<sizer mode="hori">
|
||||
<label>Band 5:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-5" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
<sizer mode="hori">
|
||||
<label>Band 6:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-6" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
<sizer mode="hori">
|
||||
<label>Band 7:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-7" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
<sizer mode="hori">
|
||||
<label>Band 8:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-8" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
<sizer mode="hori">
|
||||
<label>Band 9:</label>
|
||||
</sizer>
|
||||
<slider expand="true" name="gain-9" value="0" min="-30" max="+30" step="0.01"/>
|
||||
<spacer min-size="5,5px"/>
|
||||
</sizer>
|
||||
<button name="display16">
|
||||
<label>test int16_t</label>
|
||||
|
Loading…
x
Reference in New Issue
Block a user