Skip to content

Commit

Permalink
Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Sep 12, 2022
1 parent 0c5e65b commit 80659b8
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ As “Audio Sinks” we will have e.g:
- Tensorflow Lite - [TfLiteAudioStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_tf_lite_audio_stream.html)
- Converting Streams - [VolumeStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_volume_stream.html), [ResampleStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_resample_stream.html), [FormatConverterStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_format_converter_stream.html), [NumberFormatConverterStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_number_format_converter_stream.html), [ChannelFormatConverterStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_channel_format_converter_stream.html), [ConvertedStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_converted_stream.html)
- Communication - [ESPNowStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_e_s_p_now_stream.html), [UDPStream](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_u_d_p_stream.html)
- Multiuser-Webserver for PCM Output - [AudioWAVServerEx](https://pschatzmann.github.io/arduino-audio-tools/html/classaudio__tools_1_1_audio_w_a_v_server_ex.html)
- Any other Arduino Classes implementing Streams: SD, Ethernet etc

### Examples
Expand Down Expand Up @@ -137,8 +138,8 @@ Dependent on the example you might need to install some of the following librari
- [rp2040-i2s](https://github.com/pschatzmann/rp2040-i2s) I2S library for MBED RP2040
- [SdFat Library](https://github.com/greiman/SdFat) to read and write files supporting SD cards with FAT16/FAT32 and exFAT
- [SD Library](https://www.arduino.cc/en/reference/SD) to read and write files supporting SD cards with FAT16 and FAT32
- [TinyHttp](https://github.com/pschatzmann/TinyHttp) a http server that also supports audio for multiple users

After installing a library, you might need to activate it's usage in the ```AudioConfig.h``` file!

## Show and Tell

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
// WIFI
const char *ssid = "Phil Schatzmann";
const char *password = "sabrina01";
AudioWAVServerEx server;
// 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
AudioWAVServerEx server;
StreamCopy copier(server, in); // copy mic to tfl


void setup() {
Expand All @@ -33,7 +34,6 @@ void setup() {
cfg.channels = channels;
cfg.ssid = ssid;
cfg.password = password;
cfg.input = &in;
server.begin(cfg);

// start generation of sound
Expand All @@ -44,5 +44,5 @@ void setup() {

// copy the data
void loop() {
server.copy();
copier.copy();
}
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
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 = &in; // 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();
}

0 comments on commit 80659b8

Please sign in to comment.