Big Mouth Billy Bass player that takes raw wavefiles and decision list text files from an SD card

Dependencies:   SDFileSystem mbed BillyBass

Files at this revision

API Documentation at this revision

Comitter:
bikeNomad
Date:
Tue Jun 18 00:07:56 2013 +0000
Parent:
7:ce27f959813b
Child:
9:99213347474f
Commit message:
don't store songs in list.

Changed in this revision

BillyBass.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BillyBass.lib	Mon Jun 17 22:18:12 2013 +0000
+++ b/BillyBass.lib	Tue Jun 18 00:07:56 2013 +0000
@@ -1,1 +1,1 @@
-BillyBass#84aaade0de8f
+BillyBass#9b1f3eb204ac
--- a/main.cpp	Mon Jun 17 22:18:12 2013 +0000
+++ b/main.cpp	Tue Jun 18 00:07:56 2013 +0000
@@ -32,12 +32,59 @@
 
 Serial pc(USBTX, USBRX);
 
+void biggestAllocation()
+{
+    size_t blksize = 16384;
+    char *m;
+
+    while (blksize > 0 && (m = (char *)malloc(blksize)) == 0) {
+        blksize -= 1024;
+    }
+
+    char *heaptop = m + blksize;
+    fprintf(stderr, "biggest: %u, heaptop: %p, current SP: %p, room: %u\r\n",
+            blksize,
+            heaptop,
+            __current_sp(),
+            (char *)__current_sp() - heaptop);
+
+    free(m);
+}
+
+void dumpHeap()
+{
+    biggestAllocation();
+    __heapstats((__heapprt)fprintf,stderr);
+    __heapvalid((__heapprt)fprintf,stderr, 0);
+}
+
 int main()
 {
     SongPlayer player;
     pc.baud(SERIAL_BAUD);
 
-    pc.printf("*** REBOOT ***\r\n");
+    fprintf(stderr, "*** REBOOT ***\r\n");
+    fprintf(stderr, "sizeof Action=%u, Song=%u\r\n", sizeof(Action), sizeof(Song));
+    dumpHeap();
+    Song *song = Song::newSong("6_1_sciencefish.raw");
+    delete song;
+    dumpHeap();
+    song = Song::newSong("2_1_i_hardly_slept.raw");
+    dumpHeap();
+    delete song;
+    dumpHeap();
+    song = Song::newSong("1_1_a_sound.raw");
+    dumpHeap();
+    delete song;
+    song = Song::newSong("4_1_GoodEvening.raw");
+    dumpHeap();
+    delete song;
+    song = Song::newSong("5_1_listen_kid_THISONE.raw");
+    dumpHeap();
+    delete song;
+    Song::newSong("3_1_BoatingThemeSong.raw");
+    dumpHeap();
+    delete song;
 
     // read the directory
     DIR *bassDir = 0;
@@ -48,12 +95,6 @@
         wait(1.0);
     }
 
-    if (!Song::readAllSongs(bassDir)) {
-        pc.printf("Found no songs!\r\n");
-    } else {
-        for (std::list<Song *>::const_iterator song_it = Song::songs.begin(); song_it != Song::songs.end(); song_it++) {
-            Song *song = *song_it;
-            song->print(pc);
-        }
-    }
+    closedir(bassDir);
 }
+