Adopt wave VI for voice mode 16/103316/3
authorsungwook79.park <sungwook79.park@samsung.com>
Thu, 8 Dec 2016 04:50:30 +0000 (13:50 +0900)
committersungwook79.park <sungwook79.park@samsung.com>
Thu, 8 Dec 2016 05:24:29 +0000 (14:24 +0900)
Change-Id: I944da15dc5ce5a28308a6575dde14e2a33100b63
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
inc/MicEffector.h
res/edje/w-input-stt.edc
src/MicEffector.cpp [changed mode: 0755->0644]
src/WInputSttMicEffect.cpp [changed mode: 0755->0644]
src/w-input-stt-voice.cpp

index 8284f1c..aa3b821 100755 (executable)
@@ -18,7 +18,7 @@
 
 #include <vector>
 #include <efl_extension.h>
-#include "Debug.h"
+
 
 #define SAMPLE_COUNT 59
 
@@ -140,14 +140,6 @@ class MicEffector
                void DrawDummyFrame();
 
                /**
-                * Efl vector canvas handle
-                *
-                */
-//             ea_vector_canvas_h *canvas;
-//             ea_vector_path_h *path;
-//             ea_vector_paint_h *paint;
-
-               /**
                 * Volume values.
                 *
                 */
@@ -161,6 +153,10 @@ class MicEffector
                bool started;
                bool fake;
 
+               Evas_Object *vg;
+               Efl_VG *root;
+               Efl_VG *shape;
+
                /**
                 * timer handle
                 *
index b123590..62d648d 100755 (executable)
@@ -603,23 +603,46 @@ collections
                                description
                                {
                                        state, "default" 0.0;
-                                       min, 0 74;
-                                       max, 9999 74;
+                                       min, 0 64;
+                                       max, 360 64;
                                        align, 0.5 1;
                                        rel1
                                        {
                                                relative, 0 1;
                                                to, "bg";
-                                               offset, 0 -14;
+                                               offset, 0 -1;
                                        }
                                        rel2
                                        {
                                                relative, 1 1;
                                                to, "bg";
-                                               offset, 0 -14;
+                                               offset, 0 -1;
+                                       }
+                               }
+
+                               description
+                               {
+                                       state, "hide" 0.0;
+                                       min, 0 64;
+                                       max, 360 64;
+                                       align, 0.5 1;
+                                       rel1
+                                       {
+                                               relative, 0 (360+64)/360;
+                                               to, "bg";
+                                               offset, 0 +13;
                                        }
+                                       rel2
+                                       {
+                                               relative, 1 (360+64)/360;
+                                               to, "bg";
+                                               offset, 0 +13;
+                                       }
+
                                }
+
                        }
+
                        part
                        {
                                name, "EFFECT_BG";
old mode 100755 (executable)
new mode 100644 (file)
index 9010026..b318e57
  * limitations under the License.
  */
 
+#define EFL_BETA_API_SUPPORT 1
+#define EFL_EO_API_SUPPORT 1
+
+#include <Eo.h>
+
 #include <string.h>
 #include "MicEffector.h"
 
+#include <Elementary.h>
+#include <Evas.h>
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "INPUT_DELEGATOR"
+
+
 using namespace is::ui;
 
 /**
@@ -33,28 +45,27 @@ static float timeout_s = 1.0f / 60.0f;
 
 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
  *
@@ -63,30 +74,32 @@ double cubic_easy_out(double index, double start, double end, double duration)
  * #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);
+    vg = evas_object_vg_add(evas_object_evas_get(canvas));
+    evas_object_show(vg);
 
-//     this->canvas = ea_vector_canvas_create(canvas);
+    root = evas_object_vg_root_node_get(vg);
+    shape = evas_vg_shape_add(root);
+    evas_vg_node_color_set(shape, 80, 80, 80, 80);
 
-       DrawDummyFrame();
-};
+    elm_object_part_content_set(layout, "EFFECT_BG", vg);
 
+    evas_vg_shape_stroke_cap_set(shape, EFL_GFX_CAP_BUTT);
+    evas_vg_shape_stroke_join_set(shape, EFL_GFX_JOIN_MITER);
 
+    evas_vg_shape_stroke_width_set(shape, 3.0);
+    evas_vg_shape_stroke_color_set(shape, 255, 255, 255, 255);
+
+    DrawDummyFrame();
+};
 
 /**
  * Destructor
@@ -96,32 +109,32 @@ MicEffector::MicEffector(Evas_Object *canvas, Evas_Object *layout, IMicEffector&
  */
 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;
+    }
+    if (vg)
+        evas_object_del(vg);
+
+    if (root)
+        evas_object_del(root);
+
+    if (shape)
+        evas_object_del(shape);
 }
 
-
-
 /**
  * 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);
-}
-
+    evas_vg_shape_reset(shape);
+    evas_vg_shape_append_move_to(shape, 0, 0);
+    evas_vg_shape_append_line_to(shape, 0, 0);
 
+    evas_object_show(vg);
+}
 
 /**
  * Draw Que animation
@@ -134,83 +147,80 @@ void MicEffector::DrawDummyFrame()
  */
 void MicEffector::DrawQue(int idx, bool is_start)
 {
-//     float margin = spectrum_posx;
-//     float posx = 0.0;
-
-       double speed = cubic_easy_out(idx + 1.0, 0.0, 23.0, 23);
+    float margin = spectrum_posx;
+    float posx = 0.0;
 
-       unsigned int start = start_stop_anim_count - (int) speed;
-       unsigned int end = start_stop_anim_count + (int) speed;
+    double speed = cubic_easy_out(idx + 1.0, 0.0, 23.0, 23);
 
-//     double opacity;
+    unsigned int start = start_stop_anim_count - (int) speed;
+    unsigned int end = start_stop_anim_count + (int) speed;
 
-       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);
-       }
+    double opacity = 0.0;;
 
-//     ea_vector_path_reset(path);
+    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);
+    }
 
-       for(unsigned int i = start; i < end; i++)
-       {
-//             posx = margin + (i * 5);
+    evas_vg_shape_reset(shape);
 
-//             ea_vector_path_move_to(path, posx, 37.0f);
-//             ea_vector_path_line_to(path, posx, 38.0f);
+    for (unsigned int i = start; i < end; i++)
+    {
+        posx = margin + (i * 5);
 
-//             ea_vector_paint_set_color(paint, 1.0f, 1.0f, 1.0f, opacity);
-       }
+        evas_vg_shape_append_move_to(shape, posx, 37);
+        evas_vg_shape_append_line_to(shape, posx, 38);
+        evas_vg_shape_stroke_color_set(shape, 255, 255, 255, opacity);
+    }
 
-//     ea_vector_canvas_draw(canvas, path, paint);
+    evas_object_show(vg);
 }
 
-
-
 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;
 }
 
 /**
@@ -222,84 +232,77 @@ float MicEffector::GetAmplifyValue(unsigned int idx)
  */
 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 * 8;
 
-//     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
-       }
+    evas_vg_shape_append_move_to(shape, posx, (37.0f - (height / 2.0)));
+    evas_vg_shape_append_line_to(shape, posx, (38.0f + (height / 2.0)));
+    evas_vg_shape_stroke_color_set(shape, 255, 255, 255, opacity);
 }
 
-
-
 /**
  * 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);
+
+                        evas_object_show(effector->vg);
+
+                        effector->drawcount = 0;
+                        effector->timer = NULL;
+                        effector->VolumeCheck(true);
+                        effector->Effect();
+                        return ECORE_CALLBACK_CANCEL;
+                    }
+                },
+                this);
 }
 
 /**
@@ -308,90 +311,83 @@ void MicEffector::Start()
  */
 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();
+
+                    evas_vg_shape_reset(effector->shape);
+
+                    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));
+                        }
+                    }
+                    evas_object_show(effector->vg);
+
+                    if (effector->drawcount < 7)    {
+                        effector->drawcount++;
+                        effector->VolumeCheck(true);
+                    } else {
+                        effector->drawcount = 0;
+                        effector->VolumeCheck(true);
+                    }
+
+                    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 {
+                effector->forcestop = false;
+                effector->drawcount = 0;
+                effector->timer = NULL;
+                return ECORE_CALLBACK_CANCEL;
+            }
+        }, this);
 }
 
 /**
@@ -400,80 +396,73 @@ void MicEffector::Stop(bool forced)
  */
 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++) {
-                       unsigned int seed = time(NULL);
-                       volumes.push_back(rand_r(&seed) % 2);
-               }
-       }
+    if (!fake) {
+        volumes = ieffect.GetVolume();
+    } else {
+        for (unsigned int i = 0; i < spectrum_count; i++) {
+            unsigned int seed = time(NULL);
+            volumes.push_back(rand_r(&seed) % 6);
+        }
+    }
 
-       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,listening", "elm");
+    elm_object_signal_emit(layout, "elm,state,eq,show", "eq");
 }
 
-
-
 /**
  * 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();
 }
-
old mode 100755 (executable)
new mode 100644 (file)
index 5454f27..b999be7
 #include <cmath>
 #include <algorithm>
 #include <numeric>
-
+#include <stt.h>
 #include <efl_extension.h>
 #include "WInputSttMicEffect.h"
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "INPUT_DELEGATOR"
 
 namespace {
 template<class T>
-static unsigned long long SumSquare(unsigned long long const& a, T const& b) {
-       return a + b*b;
+static float SumSquare(float const& a, T const& b) {
+    return a + b*b;
 }
 
 const double MAX_AMPLITUDE_MEAN_16 = 23170.115738161934;
@@ -38,118 +41,113 @@ using namespace is::ui;
 
 
 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) {
-               PRINTFUNC(DLOG_ERROR, "stt_audio_snapshot invalid (%d)", 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;
+
+    float pcm[512] = {0};
+    int size = 50;
+    int ret = 0;
+
+    ret = stt_get_recording_volume(handle, pcm);
+    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 = (unsigned long long)std::accumulate(pcm + k*step, pcm + k*step + 5, 0ull, SumSquare<float>);
+            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;
 }
index c135e4c..56514f7 100755 (executable)
@@ -64,7 +64,7 @@ static Elm_Genlist_Item_Class itc_title;
 static Elm_Genlist_Item_Class itc_1text;
 static Elm_Genlist_Item_Class itc_2text;
 
-
+static Eina_Bool change_guide_text(void *data);
 static void set_guide_text(VoiceData *vd, const char* text, bool translatable = false);
 
 const char *supported_language[] = {
@@ -313,7 +313,6 @@ static Eina_Bool _update_textblock_timer_cb(void *data)
 
        if(voicedata->state == STT_STATE_VAL_LISTENING){
                if(voicedata->guide_text_timer != NULL){
-                       PRINTFUNC(DLOG_DEBUG, "Skip hide_guide_text");
                        ecore_timer_del(voicedata->guide_text_timer);
                        voicedata->guide_text_timer = NULL;
                }
@@ -393,21 +392,48 @@ static Eina_Bool _recognition_failure_cb(void *data)
 
 void start_by_press(VoiceData *voicedata)
 {
-       PRINTFUNC(DLOG_DEBUG, "");
-
+       LOGD("start_by_press ");
        edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background");
-
-       return;
 }
 
 static void on_mic_button_press_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       PRINTFUNC(NO_PRINT, "");
-
+       LOGD("on_mic_button_press_cb");
        VoiceData *voicedata = (VoiceData *)data;
-       edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background");
+       if (!voicedata) return;
 
-       return;
+       if (voicedata->sttmanager != NULL &&
+               (voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING
+               || voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING)) {
+               try {
+                       voicedata->state = STT_STATE_VAL_INIT;
+                       voicedata->sttmanager->Stop();
+               }
+               catch (is::stt::SttException &e) {
+               }
+
+               if (voicedata->effector)
+                       voicedata->effector->Stop(true);
+
+               if (NULL != voicedata->start_timer) {
+                       ecore_timer_del(voicedata->start_timer);
+                       voicedata->start_timer = NULL;
+               }
+               if (NULL != voicedata->guide_text_timer) {
+                       ecore_timer_del(voicedata->guide_text_timer);
+                       voicedata->guide_text_timer = NULL;
+               }
+               if (NULL != voicedata->refresh_timer) {
+                       ecore_timer_del(voicedata->refresh_timer);
+                       voicedata->refresh_timer = NULL;
+               }
+       } else {
+               if (NULL != voicedata->guide_text_timer) {
+                       ecore_timer_del(voicedata->guide_text_timer);
+                       voicedata->guide_text_timer = NULL;
+               }
+               edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background");
+       }
 }
 
 
@@ -525,32 +551,33 @@ static Eina_Bool _idler_cb(void *data)
 
 
        if(true == _app_stt_initialize(voicedata)) {
-               PRINTFUNC(NO_PRINT, "_app_stt_initialize None Error");
+               LOGD("_app_stt_initialize None Error");
                voicedata->voicefw_state = 1;
                voicedata->state = STT_STATE_VAL_INIT;
        } else {
                voicedata->voicefw_state = 0;
-               PRINTFUNC(DLOG_ERROR, "Initialization Fail!<br>Check STT-daemon is running");
+               LOGD("Initialization Fail!<br>Check STT-daemon is running");
        }
 
        Evas_Object *canvas = elm_object_part_content_get(voicedata->layout_main, "EFFECT_BG");
 
-
        is::ui::WInputSttMicEffect *ieffect = new is::ui::WInputSttMicEffect();
-       ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle());
+       if (ieffect)
+               ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle());
 
        is::ui::MicEffector *effector = new is::ui::MicEffector(canvas, voicedata->layout_main, *ieffect);
        voicedata->ieffect = ieffect;
        voicedata->effector = effector;
 
-       ieffect->SetProgressBar(voicedata->progressbar);
-       ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle());
+       if (ieffect) {
+               ieffect->SetProgressBar(voicedata->progressbar);
+               ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle());
+       }
 
        voicedata->mo->Update();
 
        elm_access_highlight_set(voicedata->mic_button);
 
-
        return ECORE_CALLBACK_CANCEL;
 }
 
@@ -606,23 +633,21 @@ void powerLock(void *data, bool enable)
        }
 }
 
+static Eina_Bool change_guide_text(void *data){
+       VoiceData *voicedata = (VoiceData *) data;
+       if (!voicedata) return ECORE_CALLBACK_CANCEL;
 
-static Eina_Bool hide_guide_text(void *data){
-       if(data) {
-               VoiceData *voicedata = (VoiceData *) data;
-
-               voicedata->guide_text_timer = NULL;
-
+       stt_state_e state = voicedata->sttmanager->GetCurrent();
+       if (state == STT_STATE_RECORDING || state == STT_STATE_PROCESSING)
+               elm_object_domain_translatable_part_text_set(voicedata->layout_main, "elm.text", PACKAGE, SK_TAP_TO_PAUSE);
 
-               PRINTFUNC(DLOG_ERROR, "");
-               elm_object_part_text_set(voicedata->layout_main, "elm.text", "");
-       }
        return ECORE_CALLBACK_CANCEL;
 }
 
+
 static void set_guide_text(VoiceData *vd, const char* text, bool translatable)
 {
-       //elm_object_signal_emit(vd->layout_main, "idle,state,text,visible", "elm");
+       elm_object_signal_emit(vd->layout_main, "idle,state,guide_text,bottom", "elm");
 
        if(translatable)
                elm_object_domain_translatable_part_text_set(vd->layout_main, "elm.text", PACKAGE, text);
@@ -631,7 +656,7 @@ static void set_guide_text(VoiceData *vd, const char* text, bool translatable)
 
        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);
+                       vd->guide_text_timer = ecore_timer_add(2.0, change_guide_text, vd);
        }
 }
 
@@ -642,22 +667,6 @@ static void set_guide_text(VoiceData *vd, const char* text, bool translatable)
  */
 void set_animation_state(VoiceData *voicedata)
 {
-       PRINTFUNC(DLOG_DEBUG, "");
-
-       PRINTFUNC(DLOG_ERROR, "voicedata->state == %s",
-               voicedata->state == STT_STATE_VAL_INIT ?
-                       "STT_STATE_VAL_INIT" :
-               voicedata->state == STT_STATE_VAL_LISTENING ?
-                       "STT_STATE_VAL_LISTENING" :
-               voicedata->state == STT_STATE_VAL_PREPARE_LISTENING ?
-                       "STT_STATE_VAL_PREPARE_LISTENING" :
-               voicedata->state == STT_STATE_VAL_PROCESSING ?
-                       "STT_STATE_VAL_PROCESSING" :
-               voicedata->state == STT_STATE_VAL_PREPARE_PROCESSING ?
-                       "STT_STATE_VAL_PREPARE_PROCESSING" :
-               voicedata->state == STT_STATE_VAL_TERMINATING ?
-                       "STT_STATE_VAL_TERMINATING" : "STT_STATE_VAL_NOT_RECOGNISED");
-
        if (voicedata->state == STT_STATE_VAL_INIT) {
 #if 0
                if (voicedata->sttmanager->GetCurrent() == STT_STATE_READY) {
@@ -673,9 +682,8 @@ void set_animation_state(VoiceData *voicedata)
                if(voicedata->effector)
                        voicedata->effector->Stop(true);
 
-               set_guide_text(voicedata, "");
+               set_guide_text(voicedata, "Tap mic to speak");
 
-               PRINTFUNC(DLOG_DEBUG, "%d", voicedata->stt_results.size());
                powerLock((void*)voicedata, false);
        } else if (voicedata->state == STT_STATE_VAL_LISTENING) {
                set_guide_text(voicedata, SK_SPEAK_NOW, true);
@@ -691,7 +699,6 @@ void set_animation_state(VoiceData *voicedata)
 
                stt_feedback(VIBRATION_STOP);
        } else {
-               PRINTFUNC(DLOG_DEBUG, "SK_NETWORK_ERROR");
                set_guide_text(voicedata, _(SK_RECOGNITION_FAILED));
                //_elm_access_say(voicedata->layout_main, _(SK_RECOGNITION_FAILED));
 
@@ -705,8 +712,6 @@ void set_animation_state(VoiceData *voicedata)
                        voicedata->effector->Stop(true);
 
                voicedata->refresh_timer = ecore_timer_add(2.0, _recognition_failure_cb, voicedata);
-
-               //powerLock((void*)voicedata, false);
        }
 }
 
@@ -759,20 +764,15 @@ static Eina_Bool _start_timer_cb(void* data)
                        voicedata->sttmanager->Start();
                }
                catch (is::stt::SttException &e) {
-                       PRINTFUNC(DLOG_ERROR, "%s", e.what());
-
                        if (e.GetEcode() == STT_ERROR_OUT_OF_NETWORK)
                        {
-                               PRINTFUNC(DLOG_DEBUG, "SK_NETWORK_ERROR");
                                set_guide_text(voicedata, _(SK_NETWORK_ERROR));
                                voicedata->state = STT_STATE_VAL_INIT;
                        } else if (e.GetEcode() == STT_ERROR_RECORDER_BUSY) {
-                               PRINTFUNC(DLOG_WARN, "STT is used by another application");
-                               show_popup_toast(_(SK_STT_BUSY), false);
+                               set_guide_text(voicedata, _(SK_STT_BUSY));
                                voicedata->state = STT_STATE_VAL_INIT;
                        } else {
-                               PRINTFUNC(DLOG_WARN, "Check error code");
-                               show_popup_toast(_(SK_STT_BUSY), false);
+                               set_guide_text(voicedata, _(SK_STT_BUSY));
                                voicedata->state = STT_STATE_VAL_INIT;
                        }
                }
@@ -791,6 +791,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission
        PRINTFUNC(NO_PRINT, "");
 
        VoiceData *vd = (VoiceData *)data;
+       if (vd == NULL)
+               return;
 
        int tempVal = vd->sttmanager->GetCurrent();
        if(tempVal == STT_STATE_CREATED) {
@@ -856,6 +858,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission
                        catch (is::stt::SttException &e) {
                                PRINTFUNC(DLOG_ERROR, "%s", e.what());
                        }
+                       if (vd->effector)
+                               vd->effector->Stop(true);
 
                        break;