-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c5e65b
commit 80659b8
Showing
5 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
examples/examples-webserver/streams-generator-webserverex_wav1/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Webserver | ||
|
||
With the help of the ESP32 WIFI functionality we can implement a simple web server. | ||
In the example we use a Sine Wave generator as sound source and return the result as an WAV file | ||
|
||
The input is defied as part of the configuration | ||
|
||
Multiple users can connect to the server! | ||
|
||
## Dependencies | ||
|
||
- https://github.com/pschatzmann/arduino-audio-tools | ||
- https://github.com/pschatzmann/TinyHttp.git |
48 changes: 48 additions & 0 deletions
48
...mples-webserver/streams-generator-webserverex_wav1/streams-generator-webserverex_wav1.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* @file streams-generator-server_wav.ino | ||
* | ||
* This sketch generates a test sine wave. The result is provided as WAV stream which can be listened to in a Web Browser | ||
* | ||
* @author Phil Schatzmann | ||
* @copyright GPLv3 | ||
* | ||
*/ | ||
|
||
#include "AudioTools.h" | ||
#include "AudioLibs/AudioServerEx.h" | ||
|
||
// WIFI | ||
const char *ssid = "Phil Schatzmann"; | ||
const char *password = "sabrina01"; | ||
const int sample_rate = 10000; | ||
const int channels = 1; | ||
|
||
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000 | ||
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave | ||
AudioWAVServerEx server; | ||
|
||
|
||
void setup() { | ||
Serial.begin(115200); | ||
AudioLogger::instance().begin(Serial,AudioLogger::Info); | ||
HttpLogger.setLevel(tinyhttp::Info); | ||
|
||
// start server | ||
auto cfg = server.defaultConfig(); | ||
cfg.sample_rate = sample_rate; | ||
cfg.channels = channels; | ||
cfg.ssid = ssid; | ||
cfg.password = password; | ||
cfg.input = ∈ // Define input | ||
server.begin(cfg); | ||
|
||
// start generation of sound | ||
sineWave.begin(channels, sample_rate, N_B4); | ||
in.begin(); | ||
} | ||
|
||
|
||
// copy the data | ||
void loop() { | ||
server.copy(); | ||
} |