[DEV] add usb microphone recorder (need add 20 db)
This commit is contained in:
parent
366a8d56c6
commit
0bd4847d2b
Binary file not shown.
@ -11,10 +11,11 @@
|
|||||||
#include <ewol/widget/Button.hpp>
|
#include <ewol/widget/Button.hpp>
|
||||||
#include <appl/widget/DataViewer.hpp>
|
#include <appl/widget/DataViewer.hpp>
|
||||||
#include <etk/tool.hpp>
|
#include <etk/tool.hpp>
|
||||||
|
#include <appl/wordList_FR.hpp>
|
||||||
|
|
||||||
appl::Windows::Windows() :
|
appl::Windows::Windows() :
|
||||||
propertyCount(this, "count",
|
propertyCount(this, "count",
|
||||||
5,
|
1,
|
||||||
"Number of time we restart a record"),
|
"Number of time we restart a record"),
|
||||||
m_composer(null) {
|
m_composer(null) {
|
||||||
addObjectType("appl::Windows");
|
addObjectType("appl::Windows");
|
||||||
@ -96,7 +97,13 @@ void appl::Windows::next() {
|
|||||||
m_listPos++;
|
m_listPos++;
|
||||||
if (m_listPos >= m_list.size()) {
|
if (m_listPos >= m_list.size()) {
|
||||||
m_listPos = 0;
|
m_listPos = 0;
|
||||||
return;
|
m_list.clear();
|
||||||
|
while (m_list.size() == 0) {
|
||||||
|
int32_t id = appl::wordList::getRandWord_FR();
|
||||||
|
if (appl::wordList::getWord_FR(id).size() > 5 ) {
|
||||||
|
m_list.pushBack(appl::wordList::getWord_FR(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
configureNewText(m_list[m_listPos]);
|
configureNewText(m_list[m_listPos]);
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,12 @@ namespace appl {
|
|||||||
etk::String m_textToSay;
|
etk::String m_textToSay;
|
||||||
etk::Vector<etk::String> m_list = {
|
etk::Vector<etk::String> m_list = {
|
||||||
"",
|
"",
|
||||||
//"bonjour", "ordinateur", "démarre", "arrête", "joue",
|
"bonjour", /*"ordinateur", "démarre", "arrête", "joue",
|
||||||
//"suivant", "suivante", "précédent", "précédente", "heure", "jour", "moi", "année",
|
"suivant", "suivante", "précédent", "précédente", "heure", "jour", "moi", "année",
|
||||||
|
"oui", "non", "ne", "pas", "est",
|
||||||
"maître", "esclave",
|
"maître", "esclave",
|
||||||
"quelle", "quel", "comment", "pourquoi",
|
"quelle", "quel", "comment", "pourquoi",
|
||||||
"zoo", "wagon", "téléphone", "télévision", "appel", "film", "musique", "vidéo", "annimation", "enfant", "adulte"};
|
"zoo", "wagon", "téléphone", "télévision", "appel", "film", "musique", "vidéo", "annimation", "enfant", "adulte"*/};
|
||||||
int32_t m_listPos = 0;
|
int32_t m_listPos = 0;
|
||||||
int32_t m_count = 0;
|
int32_t m_count = 0;
|
||||||
void configureNewText(const etk::String& _text);
|
void configureNewText(const etk::String& _text);
|
||||||
|
@ -29,6 +29,17 @@ static const etk::String configurationRiver =
|
|||||||
" channel-map:['front-left', 'front-right'],\n"
|
" channel-map:['front-left', 'front-right'],\n"
|
||||||
" type:'auto',\n"
|
" type:'auto',\n"
|
||||||
" nb-chunk:1024\n"
|
" nb-chunk:1024\n"
|
||||||
|
" },\n"
|
||||||
|
" microphone_USB:{\n"
|
||||||
|
" io:'input',\n"
|
||||||
|
" map-on:{\n"
|
||||||
|
" interface:'alsa',\n"
|
||||||
|
" name:'hw:1,0',\n"
|
||||||
|
" },\n"
|
||||||
|
" frequency:48000,\n"
|
||||||
|
" channel-map:['front-center'],\n"
|
||||||
|
" type:'int16',\n"
|
||||||
|
" nb-chunk:1024\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
@ -47,26 +47,28 @@ void appl::widget::DataViewer::onDataReceived(const void* _data,
|
|||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const etk::Vector<audio::channel>& _map) {
|
const etk::Vector<audio::channel>& _map) {
|
||||||
ethread::RecursiveLock lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
if (_format != audio::format_float) {
|
if (_format != audio::format_int16) {
|
||||||
APPL_ERROR("call wrong type ... (need int16_t)");
|
APPL_ERROR("call wrong type ... (need int16_t)");
|
||||||
}
|
}
|
||||||
// get the curent power of the signal.
|
// get the curent power of the signal.
|
||||||
const float* data = static_cast<const float*>(_data);
|
const int16_t* data = static_cast<const int16_t*>(_data);
|
||||||
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
|
||||||
m_data.pushBack(data[iii]);
|
float tmpData = double(data[iii])*0.00003051757;
|
||||||
|
m_data.pushBack(tmpData);
|
||||||
|
m_data16.pushBack(data[iii]);
|
||||||
if (m_startAnalyse == false) {
|
if (m_startAnalyse == false) {
|
||||||
m_detectStartPosition = m_data.size();
|
m_detectStartPosition = m_data.size();
|
||||||
m_detectStopPosition = m_data.size() + 1;
|
m_detectStopPosition = m_data.size() + 1;
|
||||||
if (data[iii] > startThresholdLevel) {
|
if (tmpData > startThresholdLevel) {
|
||||||
m_startAnalyse = true;
|
m_startAnalyse = true;
|
||||||
m_time = echrono::Clock::now();
|
m_time = echrono::Clock::now();
|
||||||
m_silenceCount = 0;
|
m_silenceCount = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (data[iii] > stopThresholdLevel) {
|
if (tmpData > stopThresholdLevel) {
|
||||||
m_silenceCount = 0;
|
m_silenceCount = 0;
|
||||||
m_detectStopPosition = m_data.size();
|
m_detectStopPosition = m_data.size();
|
||||||
m_detectMax = etk::max(m_detectMax, etk::abs(data[iii]));
|
m_detectMax = etk::max(m_detectMax, etk::abs(tmpData));
|
||||||
} else {
|
} else {
|
||||||
m_silenceCount++;
|
m_silenceCount++;
|
||||||
}
|
}
|
||||||
@ -83,8 +85,8 @@ void appl::widget::DataViewer::start() {
|
|||||||
channel.pushBack(audio::channel_frontLeft);
|
channel.pushBack(audio::channel_frontLeft);
|
||||||
m_interface = m_manager->createInput(m_sampleRate,
|
m_interface = m_manager->createInput(m_sampleRate,
|
||||||
channel,
|
channel,
|
||||||
audio::format_float,
|
audio::format_int16,
|
||||||
"microphone");
|
"microphone_USB");
|
||||||
if(m_interface == null) {
|
if(m_interface == null) {
|
||||||
APPL_ERROR("null interface");
|
APPL_ERROR("null interface");
|
||||||
return;
|
return;
|
||||||
@ -256,6 +258,7 @@ void appl::widget::DataViewer::periodicCall(const ewol::event::Time& _event) {
|
|||||||
void appl::widget::DataViewer::reset() {
|
void appl::widget::DataViewer::reset() {
|
||||||
ethread::RecursiveLock lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
|
m_data16.clear();
|
||||||
m_startDisplayOffset = 0;
|
m_startDisplayOffset = 0;
|
||||||
m_startAnalyse = false;
|
m_startAnalyse = false;
|
||||||
m_silenceCount = 0;
|
m_silenceCount = 0;
|
||||||
@ -263,6 +266,7 @@ void appl::widget::DataViewer::reset() {
|
|||||||
m_detectStopPosition = 0;
|
m_detectStopPosition = 0;
|
||||||
m_detectMax = 0;
|
m_detectMax = 0;
|
||||||
m_data.resize(m_sampleRate*nbSecondOffset, 0.0);
|
m_data.resize(m_sampleRate*nbSecondOffset, 0.0);
|
||||||
|
m_data16.resize(m_sampleRate*nbSecondOffset, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -294,7 +298,7 @@ bool appl::widget::DataViewer::onEventInput(const ewol::event::Input& _event) {
|
|||||||
|
|
||||||
|
|
||||||
void appl::widget::DataViewer::store(const etk::String& _userName, const etk::String& _value, const etk::String& _language) {
|
void appl::widget::DataViewer::store(const etk::String& _userName, const etk::String& _value, const etk::String& _language) {
|
||||||
if (m_data.size() == 0) {
|
if (m_data16.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
etk::String baseName = _language + "_" + _userName + "_" + etk::toString(m_time.get());
|
etk::String baseName = _language + "_" + _userName + "_" + etk::toString(m_time.get());
|
||||||
@ -304,7 +308,7 @@ void appl::widget::DataViewer::store(const etk::String& _userName, const etk::St
|
|||||||
doc.add("value", ejson::String(_value));
|
doc.add("value", ejson::String(_value));
|
||||||
doc.add("language", ejson::String(_language));
|
doc.add("language", ejson::String(_language));
|
||||||
doc.add("time", ejson::Number(m_time.get()));
|
doc.add("time", ejson::Number(m_time.get()));
|
||||||
doc.add("audio_format", ejson::String("float"));
|
doc.add("audio_format", ejson::String("int16"));
|
||||||
doc.add("audio_channel", ejson::Number(1));
|
doc.add("audio_channel", ejson::Number(1));
|
||||||
doc.add("audio_sample_rate", ejson::Number(48000));
|
doc.add("audio_sample_rate", ejson::Number(48000));
|
||||||
doc.add("audio_filename", ejson::String(baseName + ".raw"));
|
doc.add("audio_filename", ejson::String(baseName + ".raw"));
|
||||||
@ -325,7 +329,7 @@ void appl::widget::DataViewer::store(const etk::String& _userName, const etk::St
|
|||||||
if (fileIO->open(etk::io::OpenMode::Write) == false) {
|
if (fileIO->open(etk::io::OpenMode::Write) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fileIO->write(&m_data[posStart], 1*audio::getFormatBytes(audio::format_float), (posStop-posStart));
|
fileIO->write(&m_data16[posStart], 1*audio::getFormatBytes(audio::format_int16), (posStop-posStart));
|
||||||
fileIO->close();
|
fileIO->close();
|
||||||
}
|
}
|
||||||
APPL_WARNING("store: " << fileNameAudioFile);
|
APPL_WARNING("store: " << fileNameAudioFile);
|
||||||
|
@ -36,6 +36,7 @@ namespace appl {
|
|||||||
void reset();
|
void reset();
|
||||||
private:
|
private:
|
||||||
etk::Vector<float> m_data;
|
etk::Vector<float> m_data;
|
||||||
|
etk::Vector<int16_t> m_data16;
|
||||||
int32_t m_startDisplayOffset = 0;
|
int32_t m_startDisplayOffset = 0;
|
||||||
bool m_startAnalyse = false;
|
bool m_startAnalyse = false;
|
||||||
int32_t m_silenceCount = 0;
|
int32_t m_silenceCount = 0;
|
||||||
|
341214
recoWord/appl/wordList_FR.cpp
Normal file
341214
recoWord/appl/wordList_FR.cpp
Normal file
File diff suppressed because it is too large
Load Diff
14
recoWord/appl/wordList_FR.hpp
Normal file
14
recoWord/appl/wordList_FR.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2019, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
namespace wordList {
|
||||||
|
etk::String getWord_FR(int32_t _id);
|
||||||
|
int32_t getRandWord_FR();
|
||||||
|
};
|
||||||
|
}
|
@ -29,6 +29,7 @@ def configure(target, my_module):
|
|||||||
'appl/main.cpp',
|
'appl/main.cpp',
|
||||||
'appl/Windows.cpp',
|
'appl/Windows.cpp',
|
||||||
'appl/widget/DataViewer.cpp',
|
'appl/widget/DataViewer.cpp',
|
||||||
|
'appl/wordList_FR.cpp'
|
||||||
])
|
])
|
||||||
my_module.add_depend(['ewol', 'audio-river'])
|
my_module.add_depend(['ewol', 'audio-river'])
|
||||||
my_module.add_path(".")
|
my_module.add_path(".")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user