OSDN Git Service

Updated the implementation of the level meter.
authorShinichiro Nakamura <shinta.main.jp@gmail.com>
Wed, 22 Aug 2012 18:07:11 +0000 (03:07 +0900)
committerShinichiro Nakamura <shinta.main.jp@gmail.com>
Wed, 22 Aug 2012 18:07:11 +0000 (03:07 +0900)
firm/bare_metal/main.c

index b074c70..1a65bc4 100644 (file)
  * @brief Volume Memory.
  */
 typedef struct {
-    int32_t left;   /**< Left. */
-    int32_t right;  /**< Right. */
+    uint32_t left;   /**< Left. */
+    uint32_t right;  /**< Right. */
 } volume_t;
 
 static volume_t volume;
 
-/*
- * See 'Blackfin GCC Built-in Functions'
- */
-
 static void effect_through(
         UZUME *p,
         const int32_t *src, int32_t *des, int32_t count)
@@ -63,7 +59,6 @@ static void effect_karaoke(
         UZUME *p,
         const int32_t *src, int32_t *des, int32_t count)
 {
-    int32_t vl, vr;
     int i;
     volume.left = 0;
     volume.right = 0;
@@ -81,21 +76,15 @@ static void effect_karaoke(
         /*
          * Volume.
          */
-        vl = *(des + i + 0);
-        vr = *(des + i + 1);
-        if (vl < 0) { vl = -vl; }
-        if (vr < 0) { vr = -vr; }
-        volume.left += vl >> 1;
-        volume.right += vr >> 1;
+        volume.left += abs(*(des + i + 0)) >> 1;
+        volume.right += abs(*(des + i + 1)) >> 1;
     }
 }
 
 static void system_default(UZUME *p)
 {
-    int32_t vl = volume.left;
-    int32_t vr = volume.right;
-    vl = ((uint32_t)vl) >> 29;
-    vr = ((uint32_t)vr) >> 29;
+    uint32_t vl = volume.left >> 29;
+    uint32_t vr = volume.right >> 29;
     lcd_goto(0, 0);
     lcd_putc(0x08 + vl);
     lcd_putc(0x08 + vr);