snapshot
This commit is contained in:
@@ -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 server can be used like any other output stream and we can use a StreamCopy to provide it with data.
|
||||
|
||||
Multiple users can connect to the server!
|
||||
|
||||
## Dependencies
|
||||
|
||||
- https://github.com/pschatzmann/arduino-audio-tools
|
||||
- https://github.com/pschatzmann/TinyHttp.git
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @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 "AudioTools/Communication/AudioServerEx.h"
|
||||
|
||||
// WIFI
|
||||
const char *ssid = "SSID";
|
||||
const char *password = "password";
|
||||
|
||||
AudioInfo info(10000, 1, 16);
|
||||
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000
|
||||
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
|
||||
AudioWAVServerEx server;
|
||||
StreamCopy copier(server, in); // copy mic to tfl
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioLogger::instance().begin(Serial,AudioLogger::Info);
|
||||
HttpLogger.setLevel(tinyhttp::Info);
|
||||
|
||||
// activate additional checks
|
||||
copier.setCheckAvailableForWrite(true);
|
||||
|
||||
// start server
|
||||
auto cfg = server.defaultConfig();
|
||||
cfg.copyFrom(info);
|
||||
cfg.ssid = ssid;
|
||||
cfg.password = password;
|
||||
server.begin(cfg);
|
||||
|
||||
// start generation of sound
|
||||
sineWave.begin(info, N_B4);
|
||||
in.begin();
|
||||
}
|
||||
|
||||
|
||||
// copy the data
|
||||
void loop() {
|
||||
copier.copy(); // copy data to server
|
||||
server.copy(); // from server to client
|
||||
}
|
||||
Reference in New Issue
Block a user