Now I'm trying to use the esp32E to send this tone to html using this code:
Code: Select all
ESP_ERROR_CHECK(httpd_resp_set_status(req, HTTPD_200));
ESP_ERROR_CHECK(httpd_resp_set_type(req,"audio/wav"));
ESP_ERROR_CHECK(httpd_resp_send(req,(const char *)buff_wav,sizeof(buff_wav)));
return ESP_OK;
Code: Select all
struct wav_header
{
char riff[4];
int32_t flength; // file length in bytes
char wave[4]; // "WAVE"
char fmt[4]; // "fmt "
int32_t chunk_size; // size of FMT chunk in bytes (usually 16)
int16_t format_tag; // 1=PCM, 257=Mu-Law, 258=A-Law, 259=ADPCM
int16_t num_chans; // 1=mono, 2=stereo
int32_t srate; // Sampling rate in samples per second
int32_t bytes_per_sec; // bytes per second = srate*bytes_per_samp
int16_t bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo
int16_t bits_per_samp; // Number of bits per sample
char data[4]; // "data"
int32_t dlength; // data length in bytes (filelength - 44)
};
Code: Select all
static char buff_test[NUM_SAMPLES];
Code: Select all
for(unsigned i=0;i<BUFFER_LEN;i++)
{
buff_test[i]=(short int)(cos(step*i)*SCALE);
}
but why? is the httpd Content-type correct? this is how i see the wav in the html (image below)