Big Mouth Billy Bass automation library

Dependents:   BillyBass_with_SD

Files at this revision

API Documentation at this revision

Comitter:
bikeNomad
Date:
Thu Jun 20 15:03:49 2013 +0000
Parent:
7:dba9221acf48
Commit message:
Made main loop repeat forever; eliminated time shifting

Changed in this revision

config_sample.hpp Show annotated file Show diff for this revision Revisions of this file
song.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r dba9221acf48 -r ad0c038ebfc1 config_sample.hpp
--- a/config_sample.hpp	Thu Jun 20 04:10:22 2013 +0000
+++ b/config_sample.hpp	Thu Jun 20 15:03:49 2013 +0000
@@ -1,4 +1,4 @@
-// COPY THIS FILE AS config.hpp and edit as needed
+// copy this to config.hpp and edit as needed
 #ifndef __included_config_hpp
 #define __included_config_hpp
 
@@ -28,6 +28,10 @@
 #define MAX_ACTIONS_PER_SONG MAX_ACTIONS_LINES_PER_SONG*2
 #define MAX_TEXT_FILE_LENGTH 2048
 
+// define this to 1 to make start times earlier and
+// enforce minimum on times
+#define FIX_TIMES 0
+
 // Sample configuration
 typedef int16_t Sample_t;   // 16-bit raw, LE samples
 const float SAMPLE_RATE_HZ = 8000.0;
@@ -41,6 +45,13 @@
 #define SERIAL_BAUD 115200
 #define ANALOG_OUTPUT_BIAS  0x8000
 
+#define BODY_ON_DELAY 0.65
+#define BODY_OFF_DELAY 0.65
+#define TAIL_ON_DELAY 0.40
+#define TAIL_OFF_DELAY 0.40
+#define MOUTH_ON_DELAY 0.10
+#define MOUTH_OFF_DELAY 0.10
+#define MOUTH_MIN_ON_TIME 0.05
 
 // Power:
 // Power GND  J9/14
diff -r dba9221acf48 -r ad0c038ebfc1 song.cpp
--- a/song.cpp	Thu Jun 20 04:10:22 2013 +0000
+++ b/song.cpp	Thu Jun 20 15:03:49 2013 +0000
@@ -84,17 +84,6 @@
 
 bool Song::addAction(float _time, int _state, DigitalOut* _out, char _code)
 {
-    Action *priorAction = (numActions > 0) ? actions + numActions - 1 : 0;
-    if (priorAction ) {
-        if (priorAction->output == _out) {
-            if (priorAction->actionTime >= _time && priorAction->desiredState != _state)
-                return true;
-            if (priorAction->actionTime < _time && priorAction->desiredState == _state) {
-                priorAction->actionTime = _time;
-                return true;
-            }
-        }
-    }
     if (numActions >= MAX_ACTIONS_PER_SONG) return false;
     actions[numActions++].set(_time, _state, _out, _code);
     return true;
@@ -148,14 +137,16 @@
             goto done;
         }
 
+#if FIX_TIMES
         startTime -= onDelay;
-        startTime -= remainder(startTime, SECONDS_PER_CHUNK);
         if (startTime < 0.0) startTime = 0.0;
 
-        endTime -= offDelay;
-        endTime += remainder(endTime, SECONDS_PER_CHUNK);
         if (endTime < startTime + minOnTime)
             endTime = startTime + minOnTime;
+#endif
+
+        startTime -= remainder(startTime, SECONDS_PER_CHUNK);
+        endTime += remainder(endTime, SECONDS_PER_CHUNK);
 
         fprintf(stderr, "%d %f %f %s\r\n", line, startTime, endTime, outName);
 
@@ -164,9 +155,11 @@
     }
     fprintf(stderr, "Added %d actions\r\n", numActions);
     qsort(actions, numActions, sizeof(Action), &Action::compare);
+#if 0
     for (int i = 0; i < numActions; i++ ) {
         fprintf(stderr, "%f %c\r\n", actions[i].actionTime, actions[i].code);
     }
+#endif
     retval = true;
 
 done: