Guest User

ESP32 Stream Generator to Web Server

a guest
Dec 22nd, 2021
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  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. #define USE_FDK
  12. #include "AudioTools.h"
  13. #include "AudioCodecs/CodecAACFDK.h"
  14.  
  15. using namespace audio_tools;
  16.  
  17. // WIFI
  18. const char *ssid = "ssid";
  19. const char *password = "password";
  20.  
  21. //WAVEncoder encoder;
  22. AACEncoderFDK encoder;
  23. AudioEncoderServer server(&encoder, ssid, password);
  24.  
  25. // Sound Generation
  26. const int sample_rate = 44100;
  27. const int channels = 2;
  28.  
  29. SineWaveGenerator<int16_t> sineWave;            // Subclass of SoundGenerator with max amplitude of 32000
  30. GeneratedSoundStream<int16_t> in(sineWave);     // Stream generated from sine wave
  31.  
  32.  
  33. void setup() {
  34.   Serial.begin(115200);
  35.   AudioLogger::instance().begin(Serial,AudioLogger::Info);
  36.  
  37.   // start server
  38.   server.begin(in, sample_rate, channels);
  39.  
  40.   // start generation of sound
  41.   sineWave.begin(channels, sample_rate, N_B4);
  42.   in.begin();
  43. }
  44.  
  45.  
  46. // copy the data
  47. void loop() {
  48.   server.doLoop();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment