ESP32 audioI2S
3.0.12
외부 하드웨어를 사용하여 I2S를 통해 SD 카드의 mp3, m4a 및 wav 파일을 재생합니다. HELIX-mp3 및 -aac 디코더가 포함되어 있습니다. Fullband용 OPUS 디코더, n VORBIS 디코더 및 FLAC 디코더도 있습니다. MAX98357A(DAC가 있는 3W 증폭기)와 함께 작동하며 3개 라인(DOUT, BLCK, LRC)을 I2S에 연결합니다. 스테레오에는 두 개의 MAX98357A가 필요합니다. AudioI2S는 UDA1334A(Adafruit I2S 스테레오 디코더 브레이크아웃 보드), PCM5102A 및 CS4344와 함께 작동합니다. 다른 HW는 작동할 수 있지만 테스트되지 않았습니다. 얼음물 스트림과 GoogleTTS도 재생합니다. Arduino IDE로 컴파일할 수 있습니다. 위키
# include " Arduino.h "
# include " WiFi.h "
# include " Audio.h "
# include " SD.h "
# include " FS.h "
// Digital I/O used
# define SD_CS 5
# define SPI_MOSI 23
# define SPI_MISO 19
# define SPI_SCK 18
# define I2S_DOUT 25
# define I2S_BCLK 27
# define I2S_LRC 26
Audio audio;
String ssid = " ******* " ;
String password = " ******* " ;
void setup () {
pinMode (SD_CS, OUTPUT); digitalWrite (SD_CS, HIGH);
SPI. begin (SPI_SCK, SPI_MISO, SPI_MOSI);
Serial. begin ( 115200 );
SD. begin (SD_CS);
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 ( 21 ); // default 0...21
// or alternative
// audio.setVolumeSteps(64); // max 255
// audio.setVolume(63);
//
// *** radio streams ***
audio. connecttohost ( " http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/ " ); // aac
// audio.connecttohost("http://mcrscast.mcr.iol.pt/cidadefm"); // mp3
// audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u"); // m3u
// audio.connecttohost("https://stream.srg-ssr.ch/rsp/aacp_48.asx"); // asx
// audio.connecttohost("http://tuner.classical102.com/listen.pls"); // pls
// audio.connecttohost("http://stream.radioparadise.com/flac"); // flac
// audio.connecttohost("http://stream.sing-sing-bis.org:8000/singsingFlac"); // flac (ogg)
// audio.connecttohost("http://s1.knixx.fm:5347/dein_webradio_vbr.opus"); // opus (ogg)
// audio.connecttohost("http://stream2.dancewave.online:8080/dance.ogg"); // vorbis (ogg)
// audio.connecttohost("http://26373.live.streamtheworld.com:3690/XHQQ_FMAAC/HLSTS/playlist.m3u8"); // HLS
// audio.connecttohost("http://eldoradolive02.akamaized.net/hls/live/2043453/eldorado/master.m3u8"); // HLS (ts)
// *** web files ***
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Pink-Panther.wav"); // wav
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Santiano-Wellerman.flac"); // flac
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Olsen-Banden.mp3"); // mp3
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Miss-Marple.m4a"); // m4a (aac)
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Collide.ogg"); // vorbis
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/sample.opus"); // opus
// *** local files ***
// audio.connecttoFS(SD, "/test.wav"); // SD
// audio.connecttoFS(SD_MMC, "/test.wav"); // SD_MMC
// audio.connecttoFS(SPIFFS, "/test.wav"); // SPIFFS
// audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de"); // Google TTS
}
void loop (){
audio. loop ();
vTaskDelay ( 1 );
}
// optional
void audio_info ( const char *info){
Serial. print ( " info " ); Serial. println (info);
}
void audio_id3data ( const char *info){ // id3 metadata
Serial. print ( " id3data " );Serial. println (info);
}
void audio_eof_mp3 ( const char *info){ // end of file
Serial. print ( " eof_mp3 " );Serial. println (info);
}
void audio_showstation ( const char *info){
Serial. print ( " station " );Serial. println (info);
}
void audio_showstreamtitle ( const char *info){
Serial. print ( " streamtitle " );Serial. println (info);
}
void audio_bitrate ( const char *info){
Serial. print ( " bitrate " );Serial. println (info);
}
void audio_commercial ( const char *info){ // duration in sec
Serial. print ( " commercial " );Serial. println (info);
}
void audio_icyurl ( const char *info){ // homepage
Serial. print ( " icyurl " );Serial. println (info);
}
void audio_lasthost ( const char *info){ // stream URL played
Serial. print ( " lasthost " );Serial. println (info);
}
void audio_eof_speech ( const char *info){
Serial. print ( " eof_speech " );Serial. println (info);
}
코덱 | ESP32 | ESP32 PSRAM | ESP32-S3 PSRAM | |
---|---|---|---|---|
mp3 | 와이 | 와이 | 와이 | |
aac | N | 와이 | 와이 | |
aacp | N | y(모노) | y(+SBR, +PS) | |
웨이브 | 와이 | 와이 | 와이 | |
flac | N | 와이 | 와이 | 블록 크기 최대 8192바이트 |
보비스 | N | 와이 | 와이 | <=196Kbit/s |
m4a | N | 와이 | 와이 | |
작 | N | 와이 | 와이 | 켈트족만 |
브레드보드배선
임펄스 다이어그램
옐로바이트가 올인원 보드를 개발했습니다. ESP32-S3 N8R2, 2x MAX98357 및 SD 카드 어댑터가 포함되어 있습니다. 문서, 회로도 및 예제는 여기에서 찾을 수 있습니다: https://github.com/yellobyte/ESP32-DevBoards-Getting-Started