diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-03-30 19:07:17 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-03-30 19:07:17 +1000 |
commit | cd5abc421d3d129983479c9dda8a5fec24506e47 (patch) | |
tree | 6f2a73ea7be3452027cd9dfbbdc1e61f656c3e6c /demos/modules/gaudio/play-wave | |
parent | 1e1385d569335995a3eb40c8ba3bc27c8d28f311 (diff) | |
download | uGFX-cd5abc421d3d129983479c9dda8a5fec24506e47.tar.gz uGFX-cd5abc421d3d129983479c9dda8a5fec24506e47.tar.bz2 uGFX-cd5abc421d3d129983479c9dda8a5fec24506e47.zip |
Update audio play demo to play in a loop (easier for testing)
Diffstat (limited to 'demos/modules/gaudio/play-wave')
-rw-r--r-- | demos/modules/gaudio/play-wave/main.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/demos/modules/gaudio/play-wave/main.c b/demos/modules/gaudio/play-wave/main.c index 855c39ff..888e4c8e 100644 --- a/demos/modules/gaudio/play-wave/main.c +++ b/demos/modules/gaudio/play-wave/main.c @@ -52,7 +52,7 @@ int main(void) { uint32_t frequency; ArrayDataFormat datafmt; uint32_t len; - GAudioData *paud; + GDataBuffer *pd; // Initialise everything gfxInit(); @@ -69,6 +69,7 @@ int main(void) { goto theend; } +repeatplay: // Open the wave file if (!(f = gfileOpen("allwrong.wav", "r"))) { errmsg = "Err: Open WAV"; @@ -164,20 +165,20 @@ int main(void) { gdispDrawString(0, gdispGetHeight()/2, "Playing...", font, Yellow); while(toplay) { // Get a buffer to put the data into - paud = gfxBufferGet(TIME_INFINITE); // This should never fail as we are waiting forever + pd = gfxBufferGet(TIME_INFINITE); // This should never fail as we are waiting forever // How much data can we put in - len = toplay > paud->size ? paud->size : toplay; - paud->len = len; + len = toplay > pd->size ? pd->size : toplay; + pd->len = len; toplay -= len; // Read the data - if (gfileRead(f, paud+1, len) != len) { + if (gfileRead(f, pd+1, len) != len) { errmsg = "Err: Read fail"; goto theend; } - gaudioPlay(paud); + gaudioPlay(pd); } gfileClose(f); @@ -185,6 +186,11 @@ int main(void) { gaudioPlayWait(TIME_INFINITE); gdispDrawString(0, gdispGetHeight()/2+10, "Done", font, Green); + // Repeat the whole thing + gfxSleepMilliseconds(1500); + gdispClear(Black); + goto repeatplay; + // The end theend: if (errmsg) |