This commit is contained in:
2026-02-12 21:00:02 -08:00
parent 77f8236347
commit 8bdbf227ca
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
# 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
It would have been more elegent to use a proper __server library__ - but I did not want to introduce another dependency. So I leave this excercise up to you to implement it with less code by using your preferred library!

View File

@@ -0,0 +1,44 @@
/**
* @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/AudioHttp.h"
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioWAVServer server(ssid, password);
// Sound Generation
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
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
// start server
server.begin(in, sample_rate, channels);
// start generation of sound
sineWave.begin(channels, sample_rate, N_B4);
in.begin();
}
// copy the data
void loop() {
server.copy();
}