Skip to content

Commit 41e5e7a

Browse files
committed
Finta sostituzione Serial con audioLogger
1 parent 12131e9 commit 41e5e7a

18 files changed

+87
-127
lines changed

README.md

+25-17
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
1-
# ESP8266Audio - supports ESP8266 & ESP32 & Raspberry Pi Pico RP2040 [![Gitter](https://badges.gitter.im/ESP8266Audio/community.svg)](https://gitter.im/ESP8266Audio/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1+
# ESP8266Audio - supports ESP8266 & ESP32 & Raspberry Pi RP2040 [![Gitter](https://badges.gitter.im/ESP8266Audio/community.svg)](https://gitter.im/ESP8266Audio/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
22
Arduino library for parsing and decoding MOD, WAV, MP3, FLAC, MIDI, AAC, and RTTL files and playing them on an I2S DAC or even using a software-simulated delta-sigma DAC with dynamic 32x-128x oversampling.
33

44
ESP8266 is fully supported and most mature, but ESP32 is also mostly there with built-in DAC as well as external ones.
55

66
For real-time, autonomous speech synthesis, check out [ESP8266SAM](https://github.com/earlephilhower/ESP8266SAM), a library which uses this one and a port of an ancient format-based synthesis program to allow your ESP8266 to talk with low memory and no network required.
77

88
## Disclaimer
9-
All this code is released under the GPL, and all of it is to be used at your own risk. If you find any bugs, please let me know via the GitHub issue tracker or drop me an email.
9+
All this code is released under the GPL, and all of it is to be used at your own risk. If you find any bugs, please let me know via the GitHub issue tracker or drop me an email. The MOD and MP3 routines were taken from StellaPlayer and libMAD respectively. The software I2S delta-sigma 32x oversampling DAC was my own creation, and sounds quite good if I do say so myself.
1010

11-
* The MOD and MP3 routines were taken from StellarPlayer and libMAD respectively.
12-
* The software I2S delta-sigma 32x oversampling DAC was my own creation, and sounds quite good if I do say so myself.
13-
* The AAC decode code is from the Helix project and licensed under RealNetwork's RSPL license. For commercial use you're still going to need the usual AAC licensing from [Via Licensing](http://www.via-corp.com/us/en/licensing/aac/overview.html). On the ESP32, AAC-SBR is supported (many webradio stations use this to reduce bandwidth even further). The ESP8266, however, does not support it due to a lack of onboard RAM.
14-
* MIDI decoding comes from a highly ported [MIDITONES](https://github.com/LenShustek/miditones) combined with a massively memory-optimized [TinySoundFont](https://github.com/schellingb/TinySoundFont), see the respective source files for more information.
15-
* Opus, OGG, and OpusFile are from [Xiph.org](https://xiph.org) with the Xiph license and patent described in src/{opusfile,libggg,libopus}/COPYING.. **NOTE** Opus decoding currently only works on the ESP32 due to the large memory requirements of opusfile. PRs to rewrite it to be less memory intensive would be much appreciated.
11+
The AAC decode code is from the Helix project and licensed under RealNetwork's RSPL license. For commercial use you're still going to need the usual AAC licensing from [Via Licensing](http://www.via-corp.com/us/en/licensing/aac/overview.html).
12+
13+
On the ESP32, AAC-SBR is supported (many webradio stations use this to reduce bandwidth even further). The ESP8266, however, does not support it due to a lack of onboard RAM.
14+
15+
MIDI decoding comes from a highly ported [MIDITONES](https://github.com/LenShustek/miditones) combined with a massively memory-optimized [TinySoundFont](https://github.com/schellingb/TinySoundFont), see the respective source files for more information.
16+
17+
Opus, OGG, and OpusFile are from [Xiph.org](https://xiph.org) with the Xiph license and patent described in src/{opusfile,libggg,libopus}/COPYING.. **NOTE** Opus decoding currently only works on the ESP32 due to the large memory requirements of opusfile. PRs to rewrite it to be less memory intensive would be much appreciated.
1618

1719
## Neat Things People Have Done With ESP8266Audio
1820
If you have a neat use for this library, [I'd love to hear about it](mailto:[email protected])!
1921

20-
* My personal use of the ESP8266Audio library is only to drive a 3D-printed, network-time-setting alarm clock for my kids which can play an MP3 instead of a bell to wake them up, called [Psychoclock](https://github.com/earlephilhower/psychoclock).
21-
* Harald Sattler has built a neat German [word clock with MP3 alarm](http://www.harald-sattler.de/html/mini-wecker.htm). Detailed discussion on the process and models are included.
22-
* Erich Heinemann has developed a Stomper (instrument for playing samples in real-time during a live stage performance) that you can find more info about [here](https://github.com/ErichHeinemann/hman-stomper).
23-
* Dagnall53 has integrated this into a really neat MQTT based model train controller to add sounds to his set. More info is available [here](https://github.com/dagnall53/ESPMQTTRocnetSound), including STL files for 3D printed components!
24-
* JohannesMTC has built a similar project especially for model trains: https://github.com/JohannesMTC/ESP32_MAS
25-
* A neat MQTT-driven ESP8266 light-and-sound device (alarm? toy? who can say!) was built by @CosmicMac, available at https://github.com/CosmicMac/ESParkle
26-
* A very interesting "linear clock" with a stepper motor, NTP time keeping, and configurable recorded chimes with schematics, 3D printer plans, and source code, is now available https://janderogee.com/projects/linear_clock/linear_clock.htm
27-
* Source and instructions for a gorgeous wooden MP3-playing clock, FM radio and a walkie-talkie using the ESP8266 and AVR microcontrollers is available https://github.com/zduka/mp3-player
22+
My personal use of the ESP8266Audio library is only to drive a 3D-printed, network-time-setting alarm clock for my kids which can play an MP3 instead of a bell to wake them up, called [Psychoclock](https://github.com/earlephilhower/psychoclock).
23+
24+
Harald Sattler has built a neat German [word clock with MP3 alarm](http://www.harald-sattler.de/html/mini-wecker.htm). Detailed discussion on the process and models are included.
25+
26+
Erich Heinemann has developed a Stomper (instrument for playing samples in real-time during a live stage performance) that you can find more info about [here](https://github.com/ErichHeinemann/hman-stomper).
27+
28+
Dagnall53 has integrated this into a really neat MQTT based model train controller to add sounds to his set. More info is available [here](https://github.com/dagnall53/ESPMQTTRocnetSound), including STL files for 3D printed components!
29+
30+
JohannesMTC has built a similar project especially for model trains: https://github.com/JohannesMTC/ESP32_MAS
31+
32+
A neat MQTT-driven ESP8266 light-and-sound device (alarm? toy? who can say!) was built by @CosmicMac, available at https://github.com/CosmicMac/ESParkle
33+
34+
A very interesting "linear clock" with a stepper motor, NTP time keeping, and configurable recorded chimes with schematics, 3D printer plans, and source code, is now available https://janderogee.com/projects/linear_clock/linear_clock.htm
35+
36+
Source and instructions for a gorgeous wooden MP3-playing clock, FM radio and a walkie-talkie using the ESP8266 and AVR microcontrollers is available https://github.com/zduka/mp3-player
2837

2938
## Prerequisites
3039
First, make sure you are running the 2.6.3/later or GIT head version of the Arduino libraries for ESP8266, or the latest ESP32 SDK from Espressif.
@@ -256,11 +265,10 @@ I've been told the Wemos SD card shield uses GPIO15 as the SD chip select. This
256265
There's no ESP8266-specific code in the AudioGenerator routines, so porting to other controllers should be relatively easy assuming they have the same endianness as the Xtensa core used. Drop me a line if you're doing this, I may be able to help point you in the right direction.
257266
258267
## Thanks
259-
Thanks to the authors of StellarPlayer and libMAD for releasing their code freely, and to the maintainers and contributors to the ESP8266 Arduino port.
268+
Thanks to the authors of StellaPlayer and libMAD for releasing their code freely, and to the maintainers and contributors to the ESP8266 Arduino port.
260269
261270
Also, big thanks to @tueddy for getting the initial ESP32 porting into the tree!
262271
263272
-Earle F. Philhower, III
264-
265273
266274

examples/PlayMIDIFromSPIFFS/PlayMIDIFromSPIFFS.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Do not build on GCC8, GCC8 has a compiler bug
44

5-
#if defined(ARDUINO_ARCH_RP2040) || ((__GNUC__ == 8) && (__XTENSA__))
5+
#if defined(ARDUINO_ARCH_RP2040) || (__GNUC__ == 8)
66
void setup() {}
77
void loop() {}
88
#else

keywords.txt

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ AudioOutput KEYWORD1
2323
AudioOutputI2S KEYWORD1
2424
AudioOutputI2SNoDAC KEYWORD1
2525
AudioOutputI2SClass KEYWORD1
26-
AudioOutputPWM KEYWORD1
2726
AudioOutputNull KEYWORD1
2827
AudioOutputBuffer KEYWORD1
2928
AudioOutputSerialWAV KEYWORD1

src/AudioFileSourceICYStream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ uint32_t AudioFileSourceICYStream::readInternal(void *data, uint32_t len, bool n
128128
size_t avail = stream->available();
129129
if (!nonBlock && !avail) {
130130
cb.st(STATUS_NODATA, PSTR("No stream data available"));
131-
http.end();
131+
http.end();
132132
goto retry;
133133
}
134134
if (avail == 0) return 0;

src/AudioGeneratorAAC.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ AudioGeneratorAAC::AudioGeneratorAAC()
3535
outSample = (int16_t*)malloc(1024 * 2 * sizeof(uint16_t));
3636
if (!buff || !outSample) {
3737
audioLogger->printf_P(PSTR("ERROR: Out of memory in AAC\n"));
38-
Serial.flush();
38+
audioLogger->flush();
3939
}
4040

4141
hAACDecoder = AACInitDecoder();
4242
if (!hAACDecoder) {
4343
audioLogger->printf_P(PSTR("Out of memory error! hAACDecoder==NULL\n"));
44-
Serial.flush();
44+
audioLogger->flush();
4545
}
4646

4747
buffValid = 0;
@@ -75,7 +75,7 @@ AudioGeneratorAAC::AudioGeneratorAAC(void *preallocateData, int preallocateSz)
7575
hAACDecoder = AACInitDecoderPre(p, availSpace);
7676
if (!hAACDecoder) {
7777
audioLogger->printf_P(PSTR("Out of memory error! hAACDecoder==NULL\n"));
78-
Serial.flush();
78+
audioLogger->flush();
7979
}
8080
buffValid = 0;
8181
lastFrameEnd = 0;

src/AudioGeneratorMIDI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
#include "AudioGeneratorMIDI.h"
6060

61-
#if (__GNUC__ == 8) && (__XTENSA__)
61+
#if __GNUC__ == 8
6262
// Do not build, GCC8 has a compiler bug
6363
#else // __GNUC__ == 8
6464

src/AudioGeneratorMIDI.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef _AUDIOGENERATORMIDI_H
2222
#define _AUDIOGENERATORMIDI_H
2323

24-
#if (__GNUC__ == 8) && (__XTENSA__)
24+
#if __GNUC__ == 8
2525
// Do not build, GCC8 has a compiler bug
2626
#else // __GNUC__ == 8
2727

src/AudioGeneratorMP3.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,6 @@ bool AudioGeneratorMP3::loop()
248248
running = false;
249249
goto done;
250250
}
251-
if (lastChannels == 1)
252-
{
253-
lastSample[1] = lastSample[0];
254-
}
255251
} while (running && output->ConsumeSample(lastSample));
256252

257253
done:
@@ -388,7 +384,7 @@ extern "C" {
388384
if (freeheap < 1024) {
389385
audioLogger->printf_P(PSTR("out of heap!\n"));
390386
}
391-
Serial.flush();
387+
audioLogger->flush();
392388
laststack = freestack;
393389
lastheap = freeheap;
394390
}

src/AudioGeneratorMP3a.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ AudioGeneratorMP3a::AudioGeneratorMP3a()
3131
hMP3Decoder = MP3InitDecoder();
3232
if (!hMP3Decoder) {
3333
audioLogger->printf_P(PSTR("Out of memory error! hMP3Decoder==NULL\n"));
34-
Serial.flush();
34+
audioLogger->flush();
3535
}
3636
// For sanity's sake...
3737
memset(buff, 0, sizeof(buff));

0 commit comments

Comments
 (0)