From 8b080899af42dba87a7297f5ae1386ce055ce4a6 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 20 Nov 2017 07:11:17 -0800 Subject: [PATCH] Fix buffer example snippet to actually work @gerardwr found that the cut-n-pasted original example code could never actually work, in issue 9. Rewrite so instead of a full working sample (which would be 40+ lines due to WiFi setup) only the relevant changes are shown. --- README.md | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 5aaebbe..84833b1 100644 --- a/README.md +++ b/README.md @@ -62,38 +62,22 @@ AudioFileSourceBuffer is an input source that simpy adds an additional RAM buffe Simply create your standard input file source, create the buffer with the original source as its input, and pass this buffer object to the generator. ```` -#include -#include -#include "AudioFileSourceHTTPStream.h" -#include "AudioFileSourceBuffer.h" -#include "AudioGeneratorMP3.h" -#include "AudioOutputI2SNoDAC.h" - +... AudioGeneratorMP3 *mp3; AudioFileSourceHTTPStream *file; AudioFileSourceBuffer *buff; AudioOutputI2SNoDAC *out; -void setup() -{ - WiFi.forceSleepBegin(); - Serial.begin(115200); - delay(1000); - file = new AudioFileSourceHTTPStream("http://mp3radio.com/playback"); +... + // Create the HTTP stream normally + file = new AudioFileSourceHTTPStream("http://your.url.here/mp3"); + // Create a buffer using that stream buff = new AudioFileSourceBuffer(file, 2048); out = new AudioOutputI2SNoDAC(); mp3 = new AudioGeneratorMP3(); + // Pass in the *buffer*, not the *http stream* to enable buffering mp3->begin(buff, out); -} +... -void loop() -{ - if (mp3->isRunning()) { - if (!mp3->loop()) mp3->stop(); - } else { - Serial.printf("MP3 done\n"); - delay(1000); - } -} ```` ## AudioGenerator classes