Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32
// buffers for receiving and sending data
char rxBuffer[UDP_TX_PACKET_MAX_SIZE + 1]; // buffer to hold incoming packet
char txBuffer[UDP_TX_PACKET_MAX_SIZE + 1]; // buffer to hold outgoing packet
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
Serial.printf("UDP server on port %d\n", localPort);
Serial.printf("Max packet size: %d\n", UDP_TX_PACKET_MAX_SIZE);
udp.begin(localPort);
out = new AudioOutputI2SNoDAC();
out->begin();
Serial.println("Ready!");
}
void loop() {
process_udp();
}
void process_udp() {
int packetSize = udp.parsePacket();
if (packetSize) {
digitalWrite(LED_BUILTIN, LOW);
Serial.printf("Received packet of size %d from %s:%d\n (to %s:%d, free heap = %d B)\n",
packetSize,
udp.remoteIP().toString().c_str(), udp.remotePort(),
udp.destinationIP().toString().c_str(), udp.localPort(),
ESP.getFreeHeap());
// read the packet into rxBufffer
int16_t *samples;
int n = udp.read(rxBuffer, UDP_TX_PACKET_MAX_SIZE);
// str_to_uint16(rxBuffer,samples);
// out->write(out,rxBuffer,n);
out->ConsumeSamples((short int )rxBuffer,n);
}
I see a project in internet (https://tomeko.net/projects/rtp_pager/index.php?lang=en) and want to run it by your library my code is :
`include
include
include
include
include
include "config.h"
// buffers for receiving and sending data char rxBuffer[UDP_TX_PACKET_MAX_SIZE + 1]; // buffer to hold incoming packet char txBuffer[UDP_TX_PACKET_MAX_SIZE + 1]; // buffer to hold outgoing packet
WiFiUDP udp; AudioOutputI2S *out; void setup() { IPAddress myIP; IPAddress myGW; IPAddress myNM; IPAddress myDNS;
WiFi.setAutoConnect (true); WiFi.setAutoReconnect (true);
myIP.fromString(WiFiIP); myGW.fromString(WiFiGW); myNM.fromString(WiFiNM); myDNS.fromString(WiFiDNS);
pinMode(LED_BUILTIN, OUTPUT); Serial.begin(115200); WiFi.mode(WIFI_STA); WiFi.config(myIP, myGW, myNM, myDNS);
digitalWrite(LED_BUILTIN, LOW); if (String(WiFiSSID) != WiFi.SSID()) { Serial.print("Wifi initializing...\r\n"); WiFi.begin(WiFiSSID, WiFiPSK); } while (WiFi.status() != WL_CONNECTED) { Serial.print('.'); delay(250); } digitalWrite(LED_BUILTIN, HIGH);
WiFi.persistent(true);
Serial.print("Connected! IP address: "); Serial.println(WiFi.localIP()); Serial.printf("UDP server on port %d\n", localPort); Serial.printf("Max packet size: %d\n", UDP_TX_PACKET_MAX_SIZE); udp.begin(localPort); out = new AudioOutputI2SNoDAC(); out->begin();
Serial.println("Ready!"); }
void loop() { process_udp(); }
void process_udp() { int packetSize = udp.parsePacket(); if (packetSize) { digitalWrite(LED_BUILTIN, LOW); Serial.printf("Received packet of size %d from %s:%d\n (to %s:%d, free heap = %d B)\n", packetSize, udp.remoteIP().toString().c_str(), udp.remotePort(), udp.destinationIP().toString().c_str(), udp.localPort(), ESP.getFreeHeap());
// str_to_uint16(rxBuffer,samples); // out->write(out,rxBuffer,n); out->ConsumeSamples((short int )rxBuffer,n); }
} ` Can anyone help me ?