Last active
February 26, 2024 15:39
-
-
Save me-no-dev/e8b5131f840822cdd14b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ffmpeg -i "$file" -f s32be -acodec pcm_s32be -ar 44100 -af "volume=0.5" tcp://espip:5522 | |
*/ | |
#include "i2s.h" | |
#include <ESP8266WiFi.h> | |
const char* ssid = "***********"; | |
const char* password = "**********"; | |
WiFiServer pcmServer(5522); | |
static WiFiClient pcmClient; | |
void setup() { | |
Serial.begin(115200); | |
Serial.print("\n"); | |
Serial.setDebugOutput(true); | |
if (String(WiFi.SSID()) != String(ssid)) WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) delay(100); | |
pcmServer.begin(); | |
pcmServer.setNoDelay(true); | |
i2s_begin(); | |
i2s_set_rate(44100); | |
Serial.printf("Connected to: %s\n", ssid); | |
Serial.print("IP address: "); Serial.println(WiFi.localIP()); | |
} | |
void loop() { | |
if (pcmServer.hasClient()){ | |
if (!pcmClient || !pcmClient.connected()){ | |
if(pcmClient) pcmClient.stop(); | |
pcmClient = pcmServer.available(); | |
} else { | |
pcmServer.available().stop(); | |
} | |
} | |
if (pcmClient && pcmClient.connected()){ | |
while(pcmClient.available() >= 8){ | |
uint32_t data = 0; | |
//Right Channel | |
data |= (uint32_t)(pcmClient.read()) << 24; | |
data |= (uint32_t)(pcmClient.read()) << 16; | |
pcmClient.read();pcmClient.read(); | |
//Left Channel | |
data |= (uint32_t)(pcmClient.read()) << 8; | |
data |= pcmClient.read(); | |
pcmClient.read();pcmClient.read(); | |
i2s_write_sample(data); | |
} | |
} | |
} |
preciso de ajuda, como enviar a musica que está tocando no meu smartphone para o esp? Por favor me ajudem.
Hello also possible the other way around send audio from Esp32 to PC??
Hi, I try this code but unfortunatky it did'nt work. Can you give me a hi t. Thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello.

Have the script on the ESP8266 on it and connected the VS1053.
Data stream is running, sound comes from the VS1053.
What must be the pinout between the ESP and the VS1053?
I connected so:
Thanks