Open powersoft opened 1 year ago
Hi powersoft,
You need to set the pinout using out->SetPinout(). I'm getting sound using the following setup. See my complete script in issue #609. Does that work for you?
file = new AudioFileSourceICYStream(URL);
file->RegisterMetadataCB(MDCallback, (void*)"ICY");
buff = new AudioFileSourceBuffer(file, 65536); // playing with this value did not help Jazz24
buff->RegisterStatusCB(StatusCallback, (void*)"buffer");
out = new AudioOutputI2S();
out->SetGain(0.1);
out->SetPinout(27, 26, 25);
mp3 = new AudioGeneratorMP3();
mp3->RegisterStatusCB(StatusCallback, (void*)"mp3");
delay(1000); // Don't start and stop while filling first buffer
mp3->begin(buff, out);
Cheers, Daniel
Daniel tanks for your response, but no results. This is my play routine. Hope that I interpret the SetPinout well.
bclkPin=clock => 27 wclkPin=select L/R => 26 doutPin=I2S. => 25
Cheers, Jan
void StartPlaying() { file = new AudioFileSourceICYStream(URL); file->RegisterMetadataCB(MDCallback, (void*)"ICY"); buff = new AudioFileSourceBuffer(file, bufferSize); buff->RegisterStatusCB(StatusCallback, (void*)"buffer"); out = new AudioOutputI2S(); // Output to I2S out->SetOutputModeMono(false); out->SetGain(fgain*0.5); out->SetPinout( 27, 26, 25); mp3 = new AudioGeneratorMP3(); mp3->RegisterStatusCB(StatusCallback, (void*)"mp3"); delay(1000); mp3->begin(buff, out); Serial.printf("STATUS(URL) %s \n", URL); Serial.flush(); }
Hi Jan, the pin allocation looks good to me. Maybe you try with another I2S audio library first to see if your H/W and wiring are good. You can not change the buffer size, but it plays well if you have a strong Wifi signal. Have a look here: ESP32-audioI2S
A simple sketch can look something like this (I didn't test this particular one, but there is a full sketch in the readme.md).
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
// Digital I/O used
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Audio audio;
String ssid = "*******";
String password = "*******";
void setup() {
Serial.begin(115200);
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED) delay(1500);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(10); // default 0...21
audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u"); // m3u
}
void loop()
{
audio.loop();
}
Ciao, Daniel
Thanks Daniel. I was using this librarian before, and it is working wel. Even with my working “pins” the program still not working. Have read some comment that setpins is not working properly. Do you have a running web radio with the program as in my first question? Cheers, Jan
Hi Jan, yes, I have the ESP8266Audio library running on an ESP32 as per my sketch above. It plays many stations, but can not handle Jazz24 (mp3 or AAS) for some reason. Why don‘t you use the ESP32-audioI2S library? For me it plays very well on an ESP32-Wrover-IE board with 8MB PSRAM and external antenna for better WiFi signal. Are you running out of buffer and the stream stops? Best, Daniel
Hi Daniel,
Yes I have good results with the ESP32-audioI2S. Not all stations can be listened. The reason for trying the other library was to experiment with it. But I order a ESP32 with 8MB of PSRAM so hope of a beter result . Do you have soldered the connections or using dupont connectors to the DAC?
Find out that dupont cable gives some interference between the lines (big noise-scatter) when lines are to long. Kindly regards Jan (NL)
Hi Jan, I have just plugged it together on a breadboard so far with 10cm jumper wires. No issues with the PCM5102A or noise. Going from there directly to my stereo with chinch cable. Coding a simple internet radio with 2.4in SPI TFT ILI9341 display, web interface for configuration, and rotary encoder & IR control for changing stations now. I can recommend the 8MB ESP32-WROVER-IE (on dev board ESP32-DevKitC-VIE). I also recommend an external u.fl pigtail antenna, because you get such a good amplification on the Wifi input with a real antenna and good, sustained throughput. I got the board here: https://www.tme.eu/de/details/esp32-devkitc-vie/entwicklungsboards-sonstige/espressif/
Good luck, Daniel
Hi Daniel,
I found a LILIGO T-Display ESP32-S3 in my processor box. Has enough PSRAM, seems to run excelent. Put the minimum program on it and have now enough room. Order to day small dupont cable max 10 cm now, hope that the interference is gone. Than I have a good starting point to go further. I think I will use a next display, I have it anyway. Thanks again for your help.
Cheers, Jan
audio_info: PSRAM found, inputBufferSize: 283615 bytes audio_info: buffers freed, free Heap: 248968 bytes audio_info: Connect to new host: "http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR18.mp3" audio_info: Connect to "playerservices.streamtheworld.com" on port 80, extension "/api/livestream-redirect/TLPSTR18.mp3" audio_info: Connection has been established in 49 ms, free Heap: 245972 bytes audio_info: HTTP/1.1 302 Found audio_info: date: Tue, 28 Mar 2023 15:09:00 GMT audio_info: redirect to new host "http://22323.live.streamtheworld.com:80/TLPSTR18.mp3" audio_info: buffers freed, free Heap: 248308 bytes audio_info: Connect to new host: "http://22323.live.streamtheworld.com:80/TLPSTR18.mp3" audio_info: Connect to "22323.live.streamtheworld.com" on port 80, extension "/TLPSTR18.mp3" audio_info: Connection has been established in 164 ms, free Heap: 245620 bytes audio_info: HTTP/1.0 200 OK audio_info: access-control-allow-origin: * audio_info: access-control-allow-credentials: true audio_info: content-type: audio/mpeg, format is mp3 audio_info: MP3Decoder has been initialized, free Heap: 246248 bytes audio_info: icy-name: Radio 10 60&70's Hits audio_showstation: Radio 10 60&70's Hitsaudio_info: server: MediaGateway 5.8.4-0.3.dev_hotfix_5_8_x.el6 audio_info: Switch to DATA, metaint is 16000 audio_info: stream ready audio_info: buffer filled in 2 ms audio_info: syncword found at pos 0 audio_info: Channels: 2 audio_info: SampleRate: 44100 audio_info: BitsPerSample: 16 audio_info: BitRate: 128000 audio_info: StreamTitle='Temptations - My Girl' audio_showstreamtitle: Temptations - My Girlaudio_info: StreamTitle='Ellen Foley - What's A Matter Baby' audio_showstreamtitle: Ellen Foley - What's A Matter Babyaudio_info: StreamTitle='Queen - We Will Rock You' audio_showstreamtitle: Queen - We Will Rock You
Hi Daniel,
Please can you help me out with the web interface (code example). Have this done never before!
Cheers, Jan
I have an esp32 and connected the UDA1334 via the I2S connection. Try to run a web radio. What to do to get output to my selected my I2S pins? Wont to use the pins 33,32 and 35.
Here my simple web-radio
`#include
include
include
include
include
include
include
/ bclkPin = 26; wclkPin = 25; doutPin = 22; /
const char SSID = ""; const char PASSWORD = "";
const int bufferSize = 16 1024; // buffer in byte, default 16 1024 = 16kb
char * arrayURL[8] = { "http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR18.mp3", "http://188.165.212.154:8478/stream", "https://igor.torontocast.com:1025/;.mp3", "http://streamer.radio.co/s06b196587/listen", "http://media-ice.musicradio.com:80/ClassicFMMP3", "http://naxos.cdnstream.com:80/1255_128", "http://149.56.195.94:8015/steam", "http://ice2.somafm.com/christmas-128-mp3" };
String arrayStation[8] = { "Mega Shuffle", "WayUp Radio", "Asia Dream", "KPop Radio", "Classic FM", "Lite Favorites", "MAXXED Out", "SomaFM Xmas" };
AudioGeneratorTalkie talkie;
AudioGeneratorMP3 mp3; AudioFileSourceICYStream file; AudioFileSourceBuffer buff; AudioOutputI2S *out;
const int numCh = sizeof(arrayURL)/sizeof(char ); bool TestMode = true; uint32_t LastTime = 0; int playflag = 0; int ledflag = 0; float fgain = 4.0; int sflag = 0; char URL = arrayURL[sflag]; String station = arrayStation[sflag];
void setup() { Serial.begin(250000); initwifi(); out = new AudioOutputI2S(0, 1, 8, 0); out->SetOutputModeMono(false); out->SetGain(fgain*0.05); URL = arrayURL[0]; Serial.println(URL); StartPlaying(); }
void loop() { }
/ bclkPin = 26; wclkPin = 25; doutPin = 22; / void StartPlaying() { file = new AudioFileSourceICYStream(URL); file->RegisterMetadataCB(MDCallback, (void)"ICY"); buff = new AudioFileSourceBuffer(file, bufferSize); buff->RegisterStatusCB(StatusCallback, (void)"buffer"); out = new AudioOutputI2S(0, 1, 8, 0); // Output to I2S out->SetOutputModeMono(false); out->SetGain(fgain0.05); mp3 = new AudioGeneratorMP3(); mp3->RegisterStatusCB(StatusCallback, (void)"mp3"); mp3->begin(buff, out); Serial.printf("STATUS(URL) %s \n", URL); Serial.flush(); }
void StopPlaying() { if (mp3) { mp3->stop(); delete mp3; mp3 = NULL; } if (buff) { buff->close(); delete buff; buff = NULL; } if (file) { file->close(); delete file; file = NULL; } Serial.printf("STATUS(Stopped)\n"); Serial.flush(); }
void initwifi() { WiFi.disconnect(); WiFi.softAPdisconnect(true); WiFi.mode(WIFI_STA); WiFi.begin(SSID, PASSWORD); int i = 0; while (WiFi.status() != WL_CONNECTED) { Serial.print("STATUS(Connecting to WiFi) "); delay(1000); i = i + 1; if (i > 10) { ESP.restart(); } } Serial.println("OK"); }
void MDCallback(void cbData, const char type, bool isUnicode, const char string) { const char ptr = reinterpret_cast<const char *>(cbData); (void) isUnicode; // Punt this ball for now // Note that the type and string may be in PROGMEM, so copy them to RAM for printf char s1[32], s2[64]; strncpy_P(s1, type, sizeof(s1)); s1[sizeof(s1) - 1] = 0; strncpy_P(s2, string, sizeof(s2)); s2[sizeof(s2) - 1] = 0; Serial.printf("METADATA(%s) '%s' = '%s'\n", ptr, s1, s2);
Serial.flush(); }
void StatusCallback(void cbData, int code, const char string) { const char ptr = reinterpret_cast<const char >(cbData); // Note that the string may be in PROGMEM, so copy it to RAM for printf char s1[64]; strncpy_P(s1, string, sizeof(s1)); s1[sizeof(s1) - 1] = 0; Serial.printf("STATUS(%s) '%d' = '%s'\n", ptr, code, s1); Serial.flush(); } `