double cubic_easy_in_out(double index, double start, double end, double duration)
{
- index /= duration/2;
- if (index < 1)
- return end/2*index*index*index + start;
+ index /= duration/2;
+ if (index < 1)
+ return end/2*index*index*index + start;
- index -= 2;
- return end/2*(index*index*index + 2) + start;
+ index -= 2;
+ return end/2*(index*index*index + 2) + start;
}
double cubic_easy_in(double index, double start, double end, double duration)
{
- index /= duration;
- return end*index*index*index*index*index + start;
+ index /= duration;
+ return end*index*index*index*index*index + start;
}
double cubic_easy_out(double index, double start, double end, double duration)
{
- index /= duration;
- index--;
- return end*(index*index*index + 1) + start;
+ index /= duration;
+ index--;
+ return end*(index*index*index + 1) + start;
}
-
/**
* Constructor
*
* #2. Drawing empty frame to avoid broken screen.
*
*/
-
MicEffector::MicEffector(Evas_Object *canvas, Evas_Object *layout, IMicEffector& effect)
- : drawcount(0)
- , forcestop(false)
- , started(false)
- , fake(false)
- , timer(NULL)
- , layout(layout)
- , ieffect(effect)
+ : drawcount(0)
+ , forcestop(false)
+ , started(false)
+ , fake(false)
+ , timer(NULL)
+ , layout(layout)
+ , ieffect(effect)
{
-// path = ea_vector_path_create();
-// paint = ea_vector_paint_create();
-// ea_vector_paint_set_style(paint, EA_VECTOR_PAINT_STYLE_STROKE);
-// ea_vector_paint_set_line_cap(paint, EA_VECTOR_PAINT_LINE_CAP_ROUND);
-// ea_vector_paint_set_line_join(paint, EA_VECTOR_PAINT_LINE_JOIN_ROUND);
-// ea_vector_paint_set_line_width(paint, 3.0);
-// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, 1.0f);
+// path = ea_vector_path_create();
+// paint = ea_vector_paint_create();
+// ea_vector_paint_set_style(paint, EA_VECTOR_PAINT_STYLE_STROKE);
+// ea_vector_paint_set_line_cap(paint, EA_VECTOR_PAINT_LINE_CAP_ROUND);
+// ea_vector_paint_set_line_join(paint, EA_VECTOR_PAINT_LINE_JOIN_ROUND);
+// ea_vector_paint_set_line_width(paint, 3.0);
+// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, 1.0f);
-// this->canvas = ea_vector_canvas_create(canvas);
+// this->canvas = ea_vector_canvas_create(canvas);
- DrawDummyFrame();
+ DrawDummyFrame();
};
-
-
/**
* Destructor
*
*/
MicEffector::~MicEffector()
{
- if(timer)
- {
- ecore_timer_del(timer);
- timer = NULL;
- }
-
-// ea_vector_path_destroy(path);
-// ea_vector_paint_destroy(paint);
-// ea_vector_canvas_destroy(canvas);
+ if(timer)
+ {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+
+// ea_vector_path_destroy(path);
+// ea_vector_paint_destroy(paint);
+// ea_vector_canvas_destroy(canvas);
}
-
-
/**
* Draw empty frame to remove or initiate screen
*
*/
void MicEffector::DrawDummyFrame()
{
-// ea_vector_path_reset(path);
-// ea_vector_path_move_to(path, 0, 0);
-// ea_vector_path_line_to(path, 0, 0);
-// ea_vector_canvas_draw(canvas, path, paint);
+// ea_vector_path_reset(path);
+// ea_vector_path_move_to(path, 0, 0);
+// ea_vector_path_line_to(path, 0, 0);
+// ea_vector_canvas_draw(canvas, path, paint);
}
-
-
/**
* Draw Que animation
*
*/
void MicEffector::DrawQue(int idx, bool is_start)
{
-// float margin = spectrum_posx;
-// float posx = 0.0;
+// float margin = spectrum_posx;
+// float posx = 0.0;
- double speed = cubic_easy_out(idx + 1.0, 0.0, 23.0, 23);
+ double speed = cubic_easy_out(idx + 1.0, 0.0, 23.0, 23);
- unsigned int start = start_stop_anim_count - (int) speed;
- unsigned int end = start_stop_anim_count + (int) speed;
+ unsigned int start = start_stop_anim_count - (int) speed;
+ unsigned int end = start_stop_anim_count + (int) speed;
-// double opacity;
+// double opacity;
- if (is_start) {
-// opacity = cubic_easy_out(idx, 0.0, 1.0, 26.0);
- } else {
-// opacity = cubic_easy_out(idx, 0, 1.0, 26.0);
- }
+ if (is_start) {
+// opacity = cubic_easy_out(idx, 0.0, 1.0, 26.0);
+ } else {
+// opacity = cubic_easy_out(idx, 0, 1.0, 26.0);
+ }
-// ea_vector_path_reset(path);
+// ea_vector_path_reset(path);
- for(unsigned int i = start; i < end; i++)
- {
-// posx = margin + (i * 5);
+ for(unsigned int i = start; i < end; i++)
+ {
+// posx = margin + (i * 5);
-// ea_vector_path_move_to(path, posx, 37.0f);
-// ea_vector_path_line_to(path, posx, 38.0f);
+// ea_vector_path_move_to(path, posx, 37.0f);
+// ea_vector_path_line_to(path, posx, 38.0f);
-// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity);
- }
+// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity);
+ }
-// ea_vector_canvas_draw(canvas, path, paint);
+// ea_vector_canvas_draw(canvas, path, paint);
}
-
-
float MicEffector::GetAmplifyValue(unsigned int idx)
{
- float amplify = 0.0;
+ float amplify = 0.0;
- int max[SAMPLE_COUNT] = {
- /**
- * dot "A" (9)
- *
- */
- 1, 1, 1, 1,
+ int max[SAMPLE_COUNT] = {
+ /**
+ * dot "A" (9)
+ *
+ */
+ 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /**
- * dot "B" (9)
- *
- */
- 10, 8, 2, 3, 10, 11, 6, 12, 4,
+ /**
+ * dot "B" (9)
+ *
+ */
+ 10, 8, 2, 3, 10, 11, 6, 12, 4,
- /**
- * dot "C" (15)
- *
- */
- 3, 5, 9, 12, 11, 8, 14, 15, 13, 11, 12, 6, 8, 3, 2,
+ /**
+ * dot "C" (15)
+ *
+ */
+ 3, 5, 9, 12, 11, 8, 14, 15, 13, 11, 12, 6, 8, 3, 2,
- /**
- * reverse dot "B" (9)
- *
- */
- 4, 12, 6, 11, 10, 3, 2, 8, 10,
+ /**
+ * reverse dot "B" (9)
+ *
+ */
+ 4, 12, 6, 11, 10, 3, 2, 8, 10,
- /**
- * dot "A" (9)
- *
- */
- 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ /**
+ * dot "A" (9)
+ *
+ */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1
- };
+ 1, 1, 1, 1
+ };
- amplify = (float) max[idx] / 10.0f * 1.9f;
+ amplify = (float) max[idx] / 10.0f * 1.9f;
- return amplify;
+ return amplify;
}
/**
*/
void MicEffector::DrawWave(unsigned int idx, int amount, int prev_amount, double opacity, bool is_lastcmd)
{
-// float ratio = GetAmplifyValue(idx);
+// float ratio = GetAmplifyValue(idx);
-// float am = ((float) amount) * ratio;
-// float pam = ((float) prev_amount) * ratio;
-// float cnt = (float) drawcount;
+// float am = ((float) amount) * ratio;
+// float pam = ((float) prev_amount) * ratio;
+// float cnt = (float) drawcount;
- float posx = spectrum_posx;
+ float posx = spectrum_posx;
-// float height = pam > am?
-// pam - cubic_easy_in_out(cnt + 1.0, am, pam, 7):
-// cubic_easy_in_out(cnt + 1.0, pam, am, 7);
+// float height = pam > am?
+// pam - cubic_easy_in_out(cnt + 1.0, am, pam, 7):
+// cubic_easy_in_out(cnt + 1.0, pam, am, 7);
- posx += idx * 5;
+ posx += idx * 5;
-// ea_vector_path_move_to(path, posx, (37.0f - (height / 2.0)));
-// ea_vector_path_line_to(path, posx, (38.0f + (height / 2.0)));
+// ea_vector_path_move_to(path, posx, (37.0f - (height / 2.0)));
+// ea_vector_path_line_to(path, posx, (38.0f + (height / 2.0)));
- if (is_lastcmd) {
-// ea_vector_paint_set_color(paint, 0.1451f, 0.204f, 0.255f, opacity);//RGB = 37:52:65
- } else {
-// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity);//RGB: 255 255 255
- }
+ if (is_lastcmd) {
+// ea_vector_paint_set_color(paint, 0.1451f, 0.204f, 0.255f, opacity);//RGB = 37:52:65
+ } else {
+// ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity);//RGB: 255 255 255
+ }
}
-
-
/**
* Effect Start
*
*/
void MicEffector::Start()
{
- if(timer) {
- ecore_timer_del(timer);
- timer = NULL;
- }
-
- drawcount = 0;
-
- prev.clear();
- current.clear();
-
- for(size_t i = 0; i < spectrum_count; i++)
- {
- prev.push_back(0);
- current.push_back(0);
- }
-
- Listening();
-
- /**
- * Que animation
- *
- */
- timer = ecore_timer_add(timeout_s,
- [](void *data)->Eina_Bool
- {
- MicEffector *effector = static_cast<MicEffector*>(data);
-
- effector->DrawQue(effector->drawcount);
-
- if(effector->drawcount < (int) start_stop_anim_count) {
- effector->drawcount += 2;
- return ECORE_CALLBACK_RENEW;
- } else {
- for(unsigned int i = 0; i < spectrum_count; i++)
- effector->DrawWave(i, 0, 0);
-
-// ea_vector_canvas_draw(effector->canvas, effector->path, effector->paint);
-
- effector->drawcount = 0;
- effector->timer = NULL;
- effector->VolumeCheck();
- effector->Effect();
- return ECORE_CALLBACK_CANCEL;
- }
- },
- this);
+ if(timer) {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+
+ drawcount = 0;
+
+ prev.clear();
+ current.clear();
+
+ for(size_t i = 0; i < spectrum_count; i++)
+ {
+ prev.push_back(0);
+ current.push_back(0);
+ }
+
+ Listening();
+
+ /**
+ * Que animation
+ *
+ */
+ timer = ecore_timer_add(timeout_s,
+ [](void *data)->Eina_Bool
+ {
+ MicEffector *effector = static_cast<MicEffector*>(data);
+
+ effector->DrawQue(effector->drawcount);
+
+ if(effector->drawcount < (int) start_stop_anim_count) {
+ effector->drawcount += 2;
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ for(unsigned int i = 0; i < spectrum_count; i++)
+ effector->DrawWave(i, 0, 0);
+
+// ea_vector_canvas_draw(effector->canvas, effector->path, effector->paint);
+
+ effector->drawcount = 0;
+ effector->timer = NULL;
+ effector->VolumeCheck();
+ effector->Effect();
+ return ECORE_CALLBACK_CANCEL;
+ }
+ },
+ this);
}
/**
*/
void MicEffector::Effect(bool fake)
{
- /**
- * Volume effect animation
- *
- */
- if ( timer ) {
- ecore_timer_del(timer);
- timer = NULL;
- }
-
- timer = ecore_timer_add(timeout_s,
- [](void *data)->Eina_Bool
- {
- MicEffector *effector = static_cast<MicEffector *>(data);
-
- bool is_empty_prev = effector->prev.empty();
-
-
-// ea_vector_path_reset(effector->path);
-
- for(unsigned int i = 0; i < effector->current.size(); i++)
- {
- if (is_empty_prev)
- effector->DrawWave(i, effector->current.at(i), 0);
- else
- effector->DrawWave(i, effector->current.at(i), effector->prev.at(i));
- }
-// ea_vector_canvas_draw(effector->canvas, effector->path, effector->paint);
-
- if (effector->drawcount < 7) {
- effector->drawcount++;
- } else {
- effector->drawcount = 0;
- effector->VolumeCheck(effector->fake);
- }
-
- return ECORE_CALLBACK_RENEW;
- }, this);
+ /**
+ * Volume effect animation
+ *
+ */
+ if ( timer ) {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+
+ timer = ecore_timer_add(timeout_s,
+ [](void *data)->Eina_Bool
+ {
+ MicEffector *effector = static_cast<MicEffector *>(data);
+
+ bool is_empty_prev = effector->prev.empty();
+
+
+// ea_vector_path_reset(effector->path);
+
+ for(unsigned int i = 0; i < effector->current.size(); i++)
+ {
+ if (is_empty_prev)
+ effector->DrawWave(i, effector->current.at(i), 0);
+ else
+ effector->DrawWave(i, effector->current.at(i), effector->prev.at(i));
+ }
+// ea_vector_canvas_draw(effector->canvas, effector->path, effector->paint);
+
+ if (effector->drawcount < 7) {
+ effector->drawcount++;
+ } else {
+ effector->drawcount = 0;
+ effector->VolumeCheck(effector->fake);
+ }
+
+ return ECORE_CALLBACK_RENEW;
+ }, this);
}
-
-
/**
* Stop volume animation effect
*
*/
void MicEffector::Stop(bool forced)
{
- if(timer)
- {
- ecore_timer_del(timer);
- timer = NULL;
- }
-
- if(!started)
- {
- Idle();
- return;
- }
-
- forcestop = forced;
-
- timer = ecore_timer_add(timeout_s,
- [](void *data)->Eina_Bool
- {
- MicEffector *effector = static_cast<MicEffector*>(data);
-
- effector->DrawQue(start_stop_anim_count - effector->drawcount, false);
-
- if(effector->drawcount < (int) start_stop_anim_count) {
- effector->drawcount += 2;
- return ECORE_CALLBACK_RENEW;
- } else {
- if(!effector->forcestop) {
- effector->Processing();
- } else {
- effector->Idle();
- }
-
- effector->forcestop = false;
- effector->drawcount = 0;
- effector->timer = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
- }, this);
+ if(timer)
+ {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+
+ if(!started)
+ {
+ Idle();
+ return;
+ }
+
+ forcestop = forced;
+
+ timer = ecore_timer_add(timeout_s,
+ [](void *data)->Eina_Bool
+ {
+ MicEffector *effector = static_cast<MicEffector*>(data);
+
+ effector->DrawQue(start_stop_anim_count - effector->drawcount, false);
+
+ if(effector->drawcount < (int) start_stop_anim_count) {
+ effector->drawcount += 2;
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ if(!effector->forcestop) {
+ effector->Processing();
+ } else {
+ effector->Idle();
+ }
+
+ effector->forcestop = false;
+ effector->drawcount = 0;
+ effector->timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ }, this);
}
/**
*/
void MicEffector::VolumeCheck(bool fake)
{
- std::vector<int> volumes;
+ std::vector<int> volumes;
- this->fake = fake;
+ this->fake = fake;
- if(!fake) {
- volumes = ieffect.GetVolume();
- } else {
- for(unsigned int i = 0; i < spectrum_count; i++) {
- volumes.push_back(rand_r((unsigned int*)time(NULL)) % 2);
- }
- }
+ if(!fake) {
+ volumes = ieffect.GetVolume();
+ } else {
+ for(unsigned int i = 0; i < spectrum_count; i++) {
+ volumes.push_back(rand_r((unsigned int*)time(NULL)) % 2);
+ }
+ }
- prev.clear();
- prev.assign(current.begin(), current.end());
+ prev.clear();
+ prev.assign(current.begin(), current.end());
- current.clear();
- current.assign(volumes.begin(), volumes.end());
+ current.clear();
+ current.assign(volumes.begin(), volumes.end());
}
-
-
/**
* Signal. Listening effect
*
*/
void MicEffector::Listening()
{
- started = true;
+ started = true;
- elm_object_signal_emit(layout, "elm,state,eq,show", "eq");
- elm_object_signal_emit(layout, "elm,state,listening", "elm");
+ elm_object_signal_emit(layout, "elm,state,eq,show", "eq");
+ elm_object_signal_emit(layout, "elm,state,listening", "elm");
}
-
-
/**
* Signal. Processing effect
*
*/
void MicEffector::Processing()
{
- started = false;
+ started = false;
- elm_object_signal_emit(layout, "elm,state,eq,hide", "eq");
- elm_object_signal_emit(layout, "elm,state,processing", "elm");
+ elm_object_signal_emit(layout, "elm,state,eq,hide", "eq");
+ elm_object_signal_emit(layout, "elm,state,processing", "elm");
- ieffect.ProcessingAnimationStart();
+ ieffect.ProcessingAnimationStart();
}
-
-
/**
* Signal. Idle effect
*
*/
void MicEffector::Idle()
{
- const char *text;
- const char *state;
- double val;
+ const char *text;
+ const char *state;
+ double val;
- started = false;
+ started = false;
- elm_object_signal_emit(layout, "elm,state,eq,hide", "eq");
+ elm_object_signal_emit(layout, "elm,state,eq,hide", "eq");
- text = elm_object_part_text_get(layout, "elm.text");
- state = edje_object_part_state_get(elm_layout_edje_get(layout), "guide_text_block", &val);
+ text = elm_object_part_text_get(layout, "elm.text");
+ state = edje_object_part_state_get(elm_layout_edje_get(layout), "guide_text_block", &val);
- if ((text && strlen(text) > 0) && (state && !strcmp(state, "bottom")))
- elm_object_signal_emit(layout, "elm,state,init_message", "elm");
- else
- elm_object_signal_emit(layout, "elm,state,init", "elm");
+ if ((text && strlen(text) > 0) && (state && !strcmp(state, "bottom")))
+ elm_object_signal_emit(layout, "elm,state,init_message", "elm");
+ else
+ elm_object_signal_emit(layout, "elm,state,init", "elm");
- ieffect.ProcessingAnimationStop();
+ ieffect.ProcessingAnimationStop();
}
-
namespace {
template<class T>
static unsigned long long SumSquare(unsigned long long const& a, T const& b) {
- return a + b*b;
+ return a + b*b;
}
const double MAX_AMPLITUDE_MEAN_16 = 23170.115738161934;
WInputSttMicEffect::WInputSttMicEffect()
- : square_sum(0)
- , count(5)
- , handle(NULL)
- , processing_effect_timer(NULL)
- , progressbar(NULL) {
+ : square_sum(0)
+ , count(5)
+ , handle(NULL)
+ , processing_effect_timer(NULL)
+ , progressbar(NULL) {
}
WInputSttMicEffect::~WInputSttMicEffect() {
- ProcessingAnimationStop();
+ ProcessingAnimationStop();
}
std::vector<int> WInputSttMicEffect::GetVolume() {
- std::vector<int> result;
-
- short pcm[512] = {0};
- int size = 0;
- int ret = 0;
-
-// ret = stt_get_spectrum(handle, (void *) pcm, &size);
- count = 5;
-
- if (STT_ERROR_NONE != ret) {
-
- } else {
- unsigned int level = 0;
- unsigned int step = (unsigned int) (size/2/sample_count);
-
- for (unsigned int k = 0; k < sample_count; k++ ){
- square_sum = std::accumulate(pcm + k*step, pcm + k*step + 5, 0ull, SumSquare<short>);
- level = ConvertLevel();
- result.push_back(level);
- }
- }
- return result;
+ std::vector<int> result;
+
+ short pcm[512] = {0};
+ int size = 0;
+ int ret = 0;
+
+// ret = stt_get_spectrum(handle, (void *) pcm, &size);
+ count = 5;
+
+ if (STT_ERROR_NONE != ret) {
+ } else {
+ unsigned int level = 0;
+ unsigned int step = (unsigned int) (size/2/sample_count);
+
+ for (unsigned int k = 0; k < sample_count; k++ ){
+ square_sum = std::accumulate(pcm + k*step, pcm + k*step + 5, 0ull, SumSquare<short>);
+ level = ConvertLevel();
+ result.push_back(level);
+ }
+ }
+ return result;
}
float WInputSttMicEffect::GetDecibel() const
{
- float rms = std::sqrt(square_sum/count);
- return 20.0*log10(rms);
+ float rms = std::sqrt(square_sum/count);
+ return 20.0*log10(rms);
}
int WInputSttMicEffect::ConvertLevel()
{
- float db = GetDecibel();
-
- if ( db <= 30.0 ){
- return 0;
- } else if ( db <= 33.3 ){
- return 1;
- } else if ( db <= 36.6 ){
- return 2;
- } else if ( db <= 40 ){
- return 3;
- } else if ( db <= 43.3 ){
- return 4;
- } else if ( db <= 46.6 ){
- return 5;
- } else if ( db <= 50 ){
- return 6;
- } else if ( db <= 53.3 ){
- return 7;
- } else if ( db <= 56.6 ){
- return 8;
- } else if ( db <= 60 ){
- return 9;
- } else {
- return 10;
- }
+ float db = GetDecibel();
+
+ if ( db <= 30.0 ){
+ return 0;
+ } else if ( db <= 33.3 ){
+ return 1;
+ } else if ( db <= 36.6 ){
+ return 2;
+ } else if ( db <= 40 ){
+ return 3;
+ } else if ( db <= 43.3 ){
+ return 4;
+ } else if ( db <= 46.6 ){
+ return 5;
+ } else if ( db <= 50 ){
+ return 6;
+ } else if ( db <= 53.3 ){
+ return 7;
+ } else if ( db <= 56.6 ){
+ return 8;
+ } else if ( db <= 60 ){
+ return 9;
+ } else {
+ return 10;
+ }
}
void WInputSttMicEffect::ProcessingAnimationStart() {
- elm_progressbar_pulse(progressbar, EINA_TRUE);
+ elm_progressbar_pulse(progressbar, EINA_TRUE);
- processing_effect_timer = ecore_timer_add(0.1,
- [](void *data)->Eina_Bool
- {
- if(!data) return ECORE_CALLBACK_CANCEL;
+ processing_effect_timer = ecore_timer_add(0.1,
+ [](void *data)->Eina_Bool
+ {
+ if(!data) return ECORE_CALLBACK_CANCEL;
/*
- WInputSttMicEffect *effect = (WInputSttMicEffect *) data;
- Evas_Object *progressbar = effect->progressbar;
+ WInputSttMicEffect *effect = (WInputSttMicEffect *) data;
+ Evas_Object *progressbar = effect->progressbar;
- double progress = eext_circle_value_get(progressbar);
+ double progress = eext_circle_value_get(progressbar);
- if (progress < 100)
- progress += 5.0;
- else
- progress = 0.0;
+ if (progress < 100)
+ progress += 5.0;
+ else
+ progress = 0.0;
- eext_circle_value_set(progressbar, progress);
+ eext_circle_value_set(progressbar, progress);
*/
- return ECORE_CALLBACK_RENEW;
- }, this);
+ return ECORE_CALLBACK_RENEW;
+ }, this);
}
void WInputSttMicEffect::ProcessingAnimationStop() {
- if(processing_effect_timer)
- {
- ecore_timer_del(processing_effect_timer);
- processing_effect_timer = NULL;
- }
- elm_progressbar_pulse(progressbar, EINA_FALSE);
+ if(processing_effect_timer)
+ {
+ ecore_timer_del(processing_effect_timer);
+ processing_effect_timer = NULL;
+ }
+ elm_progressbar_pulse(progressbar, EINA_FALSE);
}
-
-
void WInputSttMicEffect::SetSttHandle(stt_h handle) {
- this->handle = handle;
+ this->handle = handle;
}
-
-
void WInputSttMicEffect::SetProgressBar(Evas_Object *progress) {
- this->progressbar = progress;
+ this->progressbar = progress;
}
void send_result_text(void *data)
{
- if(!data)
+ if (!data)
return;
VoiceData* voicedata = (VoiceData*)data;
void voice_get_string(const char *keyValue, VoiceData *voicedata)
{
- if(!voicedata)
+ if (!voicedata)
return;
char* strbuf = NULL;
LOGD("text : %s, voicedata->partial_result=%s", strbuf, voicedata->partial_result);
- if(strbuf){
- if(voicedata->partial_result){ // partial_result is not Null so replace
- if(strcmp(voicedata->partial_result, strbuf)){
+ if (strbuf){
+ if (voicedata->partial_result){ // partial_result is not Null so replace
+ if (strcmp(voicedata->partial_result, strbuf)){
// different replace
LOGD("different replace");
send_result_text(voicedata);
- if(strbuf)
+ if (strbuf)
free(strbuf);
LOGD("ends");
}
-
static Eina_Bool _recognition_failure_cb(void *data)
{
- if(data) {
+ if (data) {
VoiceData *voicedata = (VoiceData *) data;
voicedata->state = STT_STATE_VAL_INIT;
static Eina_Bool hide_guide_text(void *data)
{
- if(data) {
+ if (data) {
VoiceData *voicedata = (VoiceData *) data;
voicedata->guide_text_timer = NULL;
elm_object_part_text_set(voicedata->layout_main, "elm.text", "");
{
elm_object_signal_emit(vd->layout_main, "idle,state,guide_text,bottom", "elm");
- if(translatable)
+ if (translatable)
elm_object_domain_translatable_part_text_set(vd->layout_main, "elm.text", PACKAGE, text);
else
elm_object_part_text_set(vd->layout_main, "elm.text", text);
- if(!strcmp(text, SK_SPEAK_NOW)){
- if(vd->guide_text_timer == NULL)
+ if (!strcmp(text, SK_SPEAK_NOW)){
+ if (vd->guide_text_timer == NULL)
vd->guide_text_timer = ecore_timer_add(2.0, hide_guide_text, vd);
}
}
elm_image_file_set(img, path_ic.c_str(), NULL);
elm_object_part_content_set(popup, "toast,icon", img);
}
- if(text) {
+ if (text) {
elm_object_part_text_set(popup, "elm.text", text);
}
static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
{
- if(obj){
+ if (obj){
evas_object_hide(obj);
evas_object_del(obj);
}
static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
{
- if(obj)
+ if (obj)
elm_popup_dismiss(obj);
}
-
void start_by_press(VoiceData *voicedata)
{
LOGD("start_by_press ");
static Eina_Bool _mic_button_enable_cb(void *data)
{
- if(!data)
+ if (!data)
return ECORE_CALLBACK_CANCEL;
VoiceData* voicedata = (VoiceData*)data;
return ECORE_CALLBACK_CANCEL;
}
-
void init_customizing_theme(void)
{
std::string stt_edj_path = app_get_resource_path();
VoiceData *vd = (VoiceData *)voice_data;
try {
- if(vd != NULL && vd->sttmanager) {
+ if (vd != NULL && vd->sttmanager) {
vd->sttmanager->Cancel();
delete vd->sttmanager;
vd->sttmanager = NULL;
}
- if(vd != NULL && vd->sttfeedback) {
+ if (vd != NULL && vd->sttfeedback) {
delete vd->sttfeedback;
vd->sttfeedback = NULL;
}
static Eina_Bool _idler_cb(void *data)
{
LOGD("_idler_cb");
- if(!data) return ECORE_CALLBACK_CANCEL;
+ if (!data) return ECORE_CALLBACK_CANCEL;
- if(my_voicedata == NULL) {
+ if (my_voicedata == NULL) {
LOGD("_idler_cb : my_voicedata is null");
return ECORE_CALLBACK_CANCEL;
}
}
#endif
- if(voicedata->effector)
+ if (voicedata->effector)
voicedata->effector->Stop(true);
set_guide_text(voicedata, "");
} else if (voicedata->state == STT_STATE_VAL_LISTENING) {
set_guide_text(voicedata, SK_SPEAK_NOW, true);
- if(voicedata->effector)
+ if (voicedata->effector)
voicedata->effector->Start();
} else if (voicedata->state == STT_STATE_VAL_PROCESSING) {
set_guide_text(voicedata, "");
- if(voicedata->effector)
+ if (voicedata->effector)
voicedata->effector->Stop();
} else {
voicedata->state = STT_STATE_VAL_NOT_RECOGNISED;
- if(voicedata->refresh_timer) {
+ if (voicedata->refresh_timer) {
ecore_timer_del(voicedata->refresh_timer);
}
- if(voicedata->effector)
+ if (voicedata->effector)
voicedata->effector->Stop(true);
voicedata->refresh_timer = ecore_timer_add(2.0, _recognition_failure_cb, voicedata);
void show_error_message(VoiceData *vd, stt_error_e reason)
{
- if(reason == STT_ERROR_OUT_OF_NETWORK) {
+ if (reason == STT_ERROR_OUT_OF_NETWORK) {
show_popup_toast(_(SK_NETWORK_ERROR), false);
vd->state = STT_STATE_VAL_INIT;
} else if (reason == STT_ERROR_RECORDER_BUSY) {
static Eina_Bool _start_timer_cb(void* data)
{
LOGD("_start_timer_cb");
- if(data) {
+ if (data) {
VoiceData *voicedata = (VoiceData *) data;
try {
VoiceData *vd = (VoiceData *)data;
int tempVal = vd->sttmanager->GetCurrent();
- if(tempVal == STT_STATE_CREATED) {
+ if (tempVal == STT_STATE_CREATED) {
LOGD("IGNORE TOUCH event before STT READY. STT is preparing", vd->state);
return;
}
LOGD("SttManager State : %d", vd->sttmanager->GetCurrent());
LOGD("Ui Voice State : %d", vd->state);
- switch(vd->state) {
+ switch (vd->state) {
case STT_STATE_VAL_INIT:
LOGD("%s", "STT_STATE_VAL_INIT");
get_stt_default_language(vd);
vd->sttmanager->SetLanguage(std::string(vd->kbd_lang));
- if(vd->start_timer) {
+ if (vd->start_timer) {
ecore_timer_del(vd->start_timer);
vd->start_timer = NULL;
}
*/
set_guide_text(vd, "");
- if(vd->effector)
+ if (vd->effector)
vd->effector->Stop();
}
catch (is::stt::SttException &e) {
LOGD("%s", e.what());
- if(e.GetEcode() != STT_ERROR_INVALID_STATE) {
+ if (e.GetEcode() != STT_ERROR_INVALID_STATE) {
set_guide_text(vd, _(SK_RECOGNITION_FAILED));
vd->state = STT_STATE_VAL_INIT;
- if(vd->effector)
+ if (vd->effector)
vd->effector->Stop(true);
}
}
vd->sttmanager->Cancel();
}
catch (is::stt::SttException &e) {
-
}
break;
voicedata->voicefw_state = 0;
/* Set Voice Language */
- if(voicedata->kbd_lang){
+ if (voicedata->kbd_lang){
free(voicedata->kbd_lang);
voicedata->kbd_lang = NULL;
}
//stt_get_default_language(my_voicedata->voicefw_handle, &my_voicedata->kbd_lang);
get_stt_default_language(voicedata);
- if(NULL == voicedata->kbd_lang || FALSE == is_lang_supported_by_stt(voicedata->kbd_lang)) {
+ if (NULL == voicedata->kbd_lang || FALSE == is_lang_supported_by_stt(voicedata->kbd_lang)) {
voicedata->kbd_lang = strdup("en_US");
}
LOGD("Voice input active language is : %s", voicedata->kbd_lang);
- voicedata->naviframe= parent;
+ voicedata->naviframe = parent;
if (NULL == voicedata->naviframe) {
return FALSE;
voicedata->mic_button = m_mic_button;
- if(voicedata->btn_disabling_timer == NULL){
+ if (voicedata->btn_disabling_timer == NULL){
voicedata->btn_disabling_timer = ecore_timer_add(2.0, _mic_button_enable_cb, voicedata);
}
VoiceData *voicedata = (VoiceData *)data;
- if(voicedata == NULL) {
+ if (voicedata == NULL) {
LOGD("init_view : voicedata == NULL");
return ECORE_CALLBACK_CANCEL;
}
return ECORE_CALLBACK_CANCEL;
}
-
Evas_Object *show_voice_window(Evas_Object *parent, VoiceData *r_voicedata)
{
LOGD("show_voice_window");
voicedata->power_unlock_timer = NULL;
}
- if(voicedata->kbd_lang) {
+ if (voicedata->kbd_lang) {
free(voicedata->kbd_lang);
voicedata->kbd_lang = NULL;
}
- if(voicedata->ieffect) {
+ if (voicedata->ieffect) {
delete voicedata->ieffect;
voicedata->ieffect = NULL;
}
- if(voicedata->effector) {
+ if (voicedata->effector) {
delete voicedata->effector;
voicedata->effector = NULL;
}
- if(voicedata->sttmanager) {
+ if (voicedata->sttmanager) {
delete voicedata->sttmanager;
voicedata->sttmanager = NULL;
}
- if(voicedata->sttfeedback) {
+ if (voicedata->sttfeedback) {
delete voicedata->sttfeedback;
voicedata->sttfeedback = NULL;
}
void ise_show_stt_mode(Evas_Object *win)
{
- if(!win)
+ if (!win)
return;
show_voice_input(win, NULL, NULL);