Skip to content

Commit a652a73

Browse files
committed
2 parents 10663a6 + 61f5f36 commit a652a73

File tree

18 files changed

+356
-35
lines changed

18 files changed

+356
-35
lines changed

examples/examples-audiokit/streams-pins-audiokit/streams-pins-audiokit.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include "AudioLibs/AudioKit.h"
1111
#include "flite_arduino.h"
1212

13-
using namespace audio_tools;
14-
1513
AudioKitStream kit;
1614
Flite flite(kit);
1715

examples/examples-tts/streams-flite-audiokit/streams-flite-audiokit.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include "AudioTools.h"
1111
#include "AudioLibs/AudioKit.h"
1212

13-
using namespace audio_tools;
14-
1513
AudioKitStream kit;
1614
Flite flite(kit);
1715

examples/examples-tts/streams-sam-audiokit/streams-sam-audiokit.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include "AudioLibs/AudioKit.h"
1111
#include "sam_arduino.h"
1212

13-
using namespace audio_tools;
14-
1513
AudioKitStream kit;
1614
SAM sam(kit);
1715

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# A Simple SdFat Audio Player
2+
3+
The example demonstrates how to implement an __MP3 Player__: which provides the data from a SD drive and provides the audio via a Webserver!
4+
5+
## SD Card
6+
7+
Here is the information how to wire the SD card to the ESP32
8+
9+
| SD | ESP32
10+
|-------|-----------------------
11+
| CS | VSPI-CS0 (GPIO 05)
12+
| SCK | VSPI-CLK (GPIO 18)
13+
| MOSI | VSPI-MOSI (GPIO 23)
14+
| MISO | VSPI-MISO (GPIO 19)
15+
| VCC | VIN (5V)
16+
| GND | GND
17+
18+
![SD](https://www.pschatzmann.ch/wp-content/uploads/2021/04/sd-module.jpeg)
19+
20+
21+
## Dependencies
22+
23+
- https://github.com/pschatzmann/arduino-audio-tools
24+
- https://github.com/pschatzmann/TinyHttp.git
25+
- Arduino SD library
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @file player-sdfat-a2dp.ino
3+
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sdfat-a2dp/README.md
4+
*
5+
* @author Phil Schatzmann
6+
* @copyright GPLv3
7+
*/
8+
9+
10+
#include "AudioTools.h"
11+
#include "AudioLibs/AudioSourceSD.h"
12+
#include "AudioLibs/AudioServerEx.h"
13+
#include "AudioCodecs/CodecCopy.h"
14+
15+
const char *ssid = "SSID";
16+
const char *password = "PWD";
17+
const char *startFilePath="/";
18+
const char* ext="mp3";
19+
AudioSourceSD source(startFilePath, ext);
20+
AudioServerEx out;
21+
AudioPlayer player(source, out, *new CopyDecoder());
22+
23+
void setup() {
24+
Serial.begin(115200);
25+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
26+
27+
// setup output - We need to login and serve the data as audio/mp3
28+
auto cfg = out.defaultConfig();
29+
cfg.password = password;
30+
cfg.ssid = ssid;
31+
cfg.mime = "audio/mp3";
32+
out.begin(cfg);
33+
34+
// setup player
35+
player.setVolume(1.0);
36+
player.begin();
37+
38+
}
39+
40+
void loop() {
41+
player.copy();
42+
out.copy();
43+
}

examples/examples-webserver/streams-effect-webserver_wav/streams-effect-webserver_wav.ino

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
#include "AudioTools.h"
1212

13-
using namespace audio_tools;
14-
1513
// WIFI
1614
const char *ssid = "ssid";
1715
const char *password = "password";
@@ -57,5 +55,5 @@ void setup() {
5755

5856
// copy the data
5957
void loop() {
60-
server.doLoop();
58+
server.copy();
6159
}

examples/examples-webserver/streams-flite-webserver_wav/streams-flite-webserver_wav.ino

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include "flite_arduino.h"
1010
#include "AudioTools.h"
1111

12-
13-
1412
AudioWAVServer server("ssid","password");
1513

1614
// Callback which provides the audio data
@@ -34,5 +32,5 @@ void setup(){
3432
// Arduino loop
3533
void loop() {
3634
// Handle new connections
37-
server.doLoop();
35+
server.copy();
3836
}

examples/examples-webserver/streams-generator-webserver_wav/streams-generator-webserver_wav.ino

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
#include "AudioTools.h"
1212

13-
using namespace audio_tools;
14-
1513
// WIFI
1614
const char *ssid = "ssid";
1715
const char *password = "password";
@@ -41,5 +39,5 @@ void setup() {
4139

4240
// copy the data
4341
void loop() {
44-
server.doLoop();
42+
server.copy();
4543
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Webserver
2+
3+
With the help of the ESP32 WIFI functionality we can implement a simple web server.
4+
In the example we use a Sine Wave generator as sound source and return the result as an WAV file
5+
6+
Multiple users can connect to the server!
7+
8+
## Dependencies
9+
10+
- https://github.com/pschatzmann/arduino-audio-tools
11+
- https://github.com/pschatzmann/TinyHttp.git
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @file streams-generator-server_wav.ino
3+
*
4+
* This sketch generates a test sine wave. The result is provided as WAV stream which can be listened to in a Web Browser
5+
*
6+
* @author Phil Schatzmann
7+
* @copyright GPLv3
8+
*
9+
*/
10+
11+
#include "AudioTools.h"
12+
#include "AudioLibs/AudioServerEx.h"
13+
14+
// WIFI
15+
const char *ssid = "ssid";
16+
const char *password = "password";
17+
AudioWAVServerEx server;
18+
// Sound Generation
19+
const int sample_rate = 10000;
20+
const int channels = 1;
21+
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000
22+
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
23+
24+
25+
void setup() {
26+
Serial.begin(115200);
27+
AudioLogger::instance().begin(Serial,AudioLogger::Info);
28+
29+
// start server
30+
auto cfg = server.defaultConfig();
31+
cfg.sample_rate = sample_rate;
32+
cfg.channels = channels;
33+
cfg.ssid = ssid;
34+
cfg.password = password;
35+
cfg.input = &in;
36+
server.begin(cfg);
37+
38+
// start generation of sound
39+
sineWave.begin(channels, sample_rate, N_B4);
40+
in.begin();
41+
}
42+
43+
44+
// copy the data
45+
void loop() {
46+
server.copy();
47+
}

0 commit comments

Comments
 (0)