[DEV] add second microphone, bigger word display and order french words

This commit is contained in:
Edouard DUPIN 2019-01-09 22:06:43 +01:00
parent 2acaac5903
commit 008eac96d9
8 changed files with 1589 additions and 25 deletions

View File

@ -12,11 +12,12 @@
#include <appl/widget/DataViewer.hpp>
#include <etk/tool.hpp>
#include <appl/wordList_FR.hpp>
#include <appl/wordList_FR_ordered.hpp>
appl::Windows::Windows() :
propertyCount(this, "count",
1,
"Number of time we restart a record"),
5,
"Number of time we restart a record"),
m_composer(null) {
addObjectType("appl::Windows");
propertyTitle.setDirectCheck("River IO viewer");
@ -38,11 +39,11 @@ void appl::Windows::init() {
composition += " Reset Currrent Record\n";
composition += " </label>\n";
composition += " </button>\n";
composition += " <label name='text-to-say' expand='true' fill='true'>\n";
composition += " Text to say ...\n";
composition += " </label>\n";
composition += " </sizer>\n";
composition += " <DataViewer name='displayer' expand='true' fill='true'/>\n";
composition += " <label name='text-to-say' expand='true' fill='true' font-size='75'>\n";
composition += " Text to say ...\n";
composition += " </label>\n";
composition += " <DataViewer name='displayer' expand='true' fill='true' min-size='100,60%'/>\n";
composition += "</sizer>\n";
m_composer = ewol::widget::Composer::create();
@ -94,18 +95,23 @@ void appl::Windows::onCallbackGenerate() {
}
void appl::Windows::next() {
m_total++;
m_listPos++;
if (m_listPos >= m_list.size()) {
m_listPos = 0;
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));
#if 0
if (m_listPos >= m_list.size()) {
m_listPos = 0;
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]);
#else
configureNewText(appl::wordList::getWord_FR_ordered(m_listPos-1));
#endif
}
void appl::Windows::updateCurentLabel() {
@ -113,7 +119,7 @@ void appl::Windows::updateCurentLabel() {
if (elem == null) {
return;
}
elem->propertyValue.set("[" + etk::toString(m_count+1) + "/" + etk::toString(propertyCount.get()) + "] "+ m_textToSay);
elem->propertyValue.set("[" + etk::toString(m_count+1) + "/" + etk::toString(propertyCount.get()) + "] "+ m_textToSay + "<br/> " + etk::toString(m_listPos) + " total="+ etk::toString(m_total));
}
void appl::Windows::configureNewText(const etk::String& _text) {

View File

@ -25,15 +25,16 @@ namespace appl {
void onCallbackFinished();
etk::String m_textToSay;
etk::Vector<etk::String> m_list = {
"",
"bonjour", /*"ordinateur", "démarre", "arrête", "joue",
"",/*
"bonjour", */"ordinateur", "oui", "non", /*"démarre", "arrête", "joue",
"suivant", "suivante", "précédent", "précédente", "heure", "jour", "moi", "année",
"oui", "non", "ne", "pas", "est",
"maître", "esclave",
"ne", "pas", "est",
"maître", "esclave",*/
"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_count = 0;
int32_t m_total = 0;
void configureNewText(const etk::String& _text);
void next();
void updateCurentLabel();

View File

@ -35,7 +35,7 @@ void appl::widget::DataViewer::init() {
appl::widget::DataViewer::~DataViewer() {
ioStop();
}
@ -50,6 +50,9 @@ void appl::widget::DataViewer::onDataReceived(const void* _data,
if (_format != audio::format_int16) {
APPL_ERROR("call wrong type ... (need int16_t)");
}
if (m_start == false) {
return;
}
// get the curent power of the signal.
const int16_t* data = static_cast<const int16_t*>(_data);
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {
@ -78,6 +81,7 @@ void appl::widget::DataViewer::onDataReceived(const void* _data,
void appl::widget::DataViewer::start() {
ethread::RecursiveLock lock(m_mutex);
m_start = true;
if (m_interface == null) {
reset();
//Get the generic input:
@ -108,6 +112,12 @@ void appl::widget::DataViewer::start() {
void appl::widget::DataViewer::stop() {
ethread::RecursiveLock lock(m_mutex);
m_start = false;
}
void appl::widget::DataViewer::ioStop() {
ethread::RecursiveLock lock(m_mutex);
stop();
if (m_interface != null) {
m_interface->stop();
m_interface.reset();
@ -118,7 +128,7 @@ void appl::widget::DataViewer::stop() {
void appl::widget::DataViewer::recordToggle() {
ethread::RecursiveLock lock(m_mutex);
if (m_interface == null) {
if (m_start == false) {
start();
} else {
stop();
@ -333,4 +343,6 @@ void appl::widget::DataViewer::store(const etk::String& _userName, const etk::St
fileIO->close();
}
APPL_WARNING("store: " << fileNameAudioFile);
}
reset();
}

View File

@ -32,9 +32,11 @@ namespace appl {
bool onEventInput(const ewol::event::Input& _event) override;
void start();
void stop();
void ioStop();
void recordToggle();
void reset();
private:
bool m_start = false;
etk::Vector<float> m_data;
etk::Vector<int16_t> m_data16;
int32_t m_startDisplayOffset = 0;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
/** @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_ordered(int32_t _id);
int32_t getRandWord_FR_ordered();
int32_t getWord_FR_ordered_count();
};
}

View File

@ -29,7 +29,8 @@ def configure(target, my_module):
'appl/main.cpp',
'appl/Windows.cpp',
'appl/widget/DataViewer.cpp',
'appl/wordList_FR.cpp'
'appl/wordList_FR.cpp',
'appl/wordList_FR_ordered.cpp'
])
my_module.add_depend(['ewol', 'audio-river'])
my_module.add_path(".")