数码之家

 找回密码
 立即注册
搜索
查看: 6882|回复: 25

[Arduino] ESP8266播放MP3

[复制链接]
发表于 2020-5-4 08:08:12 | 显示全部楼层 |阅读模式




======================

  1. // 按钮控制播放音频


  2. //#include <ESP8266WiFi.h>


  3. #include <Arduino.h>
  4. #include "AudioFileSourceSPIFFS.h"
  5. #include "AudioGeneratorMP3.h"
  6. #include "AudioOutputI2SNoDAC.h"


  7. //#include <FS.h>




  8. AudioGeneratorMP3 *mp3;
  9. AudioFileSourceSPIFFS *file;
  10. AudioOutputI2SNoDAC *out;



  11. #define   KEY   0  //  按键
  12. #define   LED   2  //  按键

  13. int switchVal = 1;

  14. int BK;


  15. int id;

  16. int ff;

  17. void setup()
  18. {
  19.   Serial.begin(115200);
  20.   delay(1000);



  21.   SPIFFS.begin();
  22.   {
  23.     Dir dir = SPIFFS.openDir("/");
  24.     while (dir.next()) {   
  25.       String fileName = dir.fileName();
  26.       size_t fileSize = dir.fileSize();
  27.     Serial.print( fileName   );
  28.       Serial.println(" //  ");
  29. Serial.println( fileSize );
  30.    Serial.println(" KB");
  31.         
  32.     }
  33.   Serial.println("===========");
  34.   }



  35.   

  36.     delay(1000);
  37.   out = new AudioOutputI2SNoDAC();
  38.   mp3 = new AudioGeneratorMP3();
  39.   


  40.   pinMode(  KEY  ,INPUT_PULLUP);    //定义KEY1为带上拉输入引脚  
  41.   //  pinMode(keys,INPUT);    // 输入引脚  
  42.   pinMode( LED  , OUTPUT);   //

  43.   digitalWrite(   LED   ,   0   );

  44.     Serial.println(" MP3  OPEN ");
  45. }




  46. void loop()
  47. {
  48.   switchVal = digitalRead( KEY );


  49. if( BK !=  switchVal)
  50. {

  51.    Serial.println(switchVal);

  52. id++;
  53. if(id>=2)
  54. id=0;//0.1  

  55. ff=1;

  56.    
  57. }


  58.   BK = switchVal;

  59. if(ff==1)
  60. {
  61.   ff=0;
  62.   if(id==0)
  63.   {

  64.   }

  65.   if(id==1)
  66.       {   
  67.    
  68.     }

  69.    
  70. }


  71.   

  72.   //===================================================



  73.   if (mp3->isRunning())
  74.   {
  75.      digitalWrite(   LED   ,   0   );
  76.     // 是否在播放
  77.     if (!mp3->loop())
  78.     {    // 是否播放完了
  79.       mp3->stop();        // 停止播放
  80.       delete file;
  81.       delete mp3;
  82.       mp3 = new AudioGeneratorMP3();
  83.     }
  84.    
  85.   }
  86.   
  87.   else
  88.   {
  89. digitalWrite(   LED   ,   1  );
  90.    
  91.     if (switchVal == 0)
  92.     {
  93.       // 开关接通为低电平
  94.       file = new AudioFileSourceSPIFFS("/hello.mp3"); // 初始化音频文件
  95.       Serial.printf("MP3 done\n");
  96.       delay(1000);
  97.       mp3->begin(file, out);  // 开始播放文件
  98.     }   
  99.   }  
  100. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

打赏

参与人数 2家元 +55 收起 理由
家睦 + 50
人艰不拆了 + 5

查看全部打赏

发表于 2020-5-4 09:06:59 | 显示全部楼层
楼主好,这个不错啊
回复 支持 反对

使用道具 举报

发表于 2020-5-4 10:31:40 | 显示全部楼层
这个我也试了,没编译过去,就没管了:tongue:
回复 支持 反对

使用道具 举报

发表于 2020-5-4 10:37:51 | 显示全部楼层
没加3级管放大可以推动?库都下了,一直在折腾屏就没搞
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-4 10:49:06 来自手机浏览器 | 显示全部楼层
zxy882266 发表于 2020-5-4 10:37
没加3级管放大可以推动?库都下了,一直在折腾屏就没搞

加三极管直流成分太大,搞坏我一个喇叭,直接加电容隔离,送功放,声音马马虎虎,底噪太大,8266选择160mhz
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-4 12:34:55 | 显示全部楼层
人艰不拆了 发表于 2020-5-4 10:31
这个我也试了,没编译过去,就没管了

ADRUINO安装最新版,8266用2.50那个版本,WIN7系统,保证你什么库都能完美通过

打赏

参与人数 1家元 +10 收起 理由
人艰不拆了 + 10

查看全部打赏

回复 支持 反对

使用道具 举报

发表于 2020-5-4 19:08:18 来自手机浏览器 | 显示全部楼层
我用过这个,能用。省了一个adc呢。真心不错
回复 支持 反对

使用道具 举报

发表于 2020-5-4 19:11:55 | 显示全部楼层
mckk520 发表于 2020-5-4 12:34
ADRUINO安装最新版,8266用2.50那个版本,WIN7系统,保证你什么库都能完美通过 ...

哈哈,原来我用的是2.6几的版本:handshake:
回复 支持 反对

使用道具 举报

发表于 2020-5-4 19:26:56 | 显示全部楼层
:smile:看看这个:
http://electronics.inf.ua/P40.html
MP3编码的在线电台都能放,清单可自行编辑,拿D1Mini刷进去输出串接100uf电容试了试效果还不错,只是界面是俄语且没提供源码。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-5 07:47:08 来自手机浏览器 | 显示全部楼层
skyrusher 发表于 2020-5-4 19:26
看看这个:
http://electronics.inf.ua/P40.html
MP3编码的在线电台都能放,清单可自行编辑,拿D1Mi ...

这个还真不错,老毛子的,要是有源码就好了自己修改一下

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-5 15:37:20 | 显示全部楼层
8266 网络电台收听,

====================

编程后用WEB打开8266设置页面,

https://www.radio.pervii.com/zh/Asian.htm
在这个网站立找到喜欢听的电台地址,传到8266里面,就可以听在线电台了,
==========================









、、、、、、、、、、、、、、、、、、
  1. /*
  2.   WebRadio Example
  3.   Very simple HTML app to control web streaming
  4.   
  5.   Copyright (C) 2017  Earle F. Philhower, III

  6.   This program is free software: you can redistribute it and/or modify
  7.   it under the terms of the GNU General Public License as published by
  8.   the Free Software Foundation, either version 3 of the License, or
  9.   (at your option) any later version.

  10.   This program is distributed in the hope that it will be useful,
  11.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.   GNU General Public License for more details.

  14.   You should have received a copy of the GNU General Public License
  15.   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. */

  17. #include <Arduino.h>
  18. #ifdef ESP32
  19.     #include <WiFi.h>
  20. #else
  21.     #include <ESP8266WiFi.h>
  22. #endif
  23. #include "AudioFileSourceICYStream.h"
  24. #include "AudioFileSourceBuffer.h"
  25. #include "AudioGeneratorMP3.h"
  26. #include "AudioGeneratorAAC.h"
  27. #include "AudioOutputI2S.h"
  28. #include <EEPROM.h>

  29. // Custom web server that doesn't need much RAM
  30. #include "web.h"

  31. // To run, set your ESP8266 build to 160MHz, update the SSID info, and upload.

  32. // Enter your WiFi setup here:
  33. #ifndef STASSID
  34. #define STASSID "TP-LINK_4444"
  35. #define STAPSK  "66XXXXXXXX"
  36. #endif

  37. const char* ssid = STASSID;
  38. const char* password = STAPSK;

  39. WiFiServer server(80);

  40. AudioGenerator *decoder = NULL;
  41. AudioFileSourceICYStream *file = NULL;
  42. AudioFileSourceBuffer *buff = NULL;
  43. AudioOutputI2S *out = NULL;

  44. int volume = 100;
  45. char title[64];
  46. char url[96];
  47. char status[64];
  48. bool newUrl = false;
  49. bool isAAC = false;
  50. int retryms = 0;

  51. typedef struct {
  52.   char url[96];
  53.   bool isAAC;
  54.   int16_t volume;
  55.   int16_t checksum;
  56. } Settings;

  57. // C++11 multiline string constants are neato...
  58. static const char HEAD[] PROGMEM = R"KEWL(
  59. <head>
  60. <title>ESP8266 Web Radio</title>
  61. <script type="text/javascript">
  62.   function updateTitle() {
  63.     var x = new XMLHttpRequest();
  64.     x.open("GET", "title");
  65.     x.onload = function() { document.getElementById("titlespan").innerHTML=x.responseText; setTimeout(updateTitle, 5000); }
  66.     x.onerror = function() { setTimeout(updateTitle, 5000); }
  67.     x.send();
  68.   }
  69.   setTimeout(updateTitle, 1000);
  70.   function showValue(n) {
  71.     document.getElementById("volspan").innerHTML=n;
  72.     var x = new XMLHttpRequest();
  73.     x.open("GET", "setvol?vol="+n);
  74.     x.send();
  75.   }
  76.   function updateStatus() {var x = new XMLHttpRequest();
  77.     x.open("GET", "status");
  78.     x.onload = function() { document.getElementById("statusspan").innerHTML=x.responseText; setTimeout(updateStatus, 5000); }
  79.     x.onerror = function() { setTimeout(updateStatus, 5000); }
  80.     x.send();
  81.   }
  82.   setTimeout(updateStatus, 2000);
  83. </script>
  84. </head>)KEWL";

  85. static const char BODY[] PROGMEM = R"KEWL(
  86. <body>
  87. ESP8266 Web Radio!
  88. <hr>
  89. Currently Playing: <span id="titlespan">%s</span><br>
  90. Volume: <input type="range" name="vol" min="1" max="150" steps="10" value="%d" onchange="showValue(this.value)"/> <span id="volspan">%d</span>%%
  91. <hr>
  92. Status: <span id="statusspan">%s</span>
  93. <hr>
  94. <form action="changeurl" method="GET">
  95. Current URL: %s<br>
  96. Change URL: <input type="text" name="url">
  97. <select name="type"><option value="mp3">MP3</option><option value="aac">AAC</option></select>
  98. <input type="submit" value="Change"></form>
  99. <form action="stop" method="POST"><input type="submit" value="Stop"></form>
  100. </body>)KEWL";

  101. void HandleIndex(WiFiClient *client)
  102. {
  103.   char buff[sizeof(BODY) + sizeof(title) + sizeof(status) + sizeof(url) + 3*2];
  104.   
  105.   Serial.printf_P(PSTR("Sending INDEX...Free mem=%d\n"), ESP.getFreeHeap());
  106.   WebHeaders(client, NULL);
  107.   WebPrintf(client, DOCTYPE);
  108.   client->write_P( PSTR("<html>"), 6 );
  109.   client->write_P( HEAD, strlen_P(HEAD) );
  110.   sprintf_P(buff, BODY, title, volume, volume, status, url);
  111.   client->write(buff, strlen(buff) );
  112.   client->write_P( PSTR("</html>"), 7 );
  113.   Serial.printf_P(PSTR("Sent INDEX...Free mem=%d\n"), ESP.getFreeHeap());
  114. }

  115. void HandleStatus(WiFiClient *client)
  116. {
  117.   WebHeaders(client, NULL);
  118.   client->write(status, strlen(status));
  119. }

  120. void HandleTitle(WiFiClient *client)
  121. {
  122.   WebHeaders(client, NULL);
  123.   client->write(title, strlen(title));
  124. }

  125. void HandleVolume(WiFiClient *client, char *params)
  126. {
  127.   char *namePtr;
  128.   char *valPtr;
  129.   
  130.   while (ParseParam(¶ms, &namePtr, &valPtr)) {
  131.     ParamInt("vol", volume);
  132.   }
  133.   Serial.printf_P(PSTR("Set volume: %d\n"), volume);
  134.   out->SetGain(((float)volume)/100.0);
  135.   RedirectToIndex(client);
  136. }

  137. void HandleChangeURL(WiFiClient *client, char *params)
  138. {
  139.   char *namePtr;
  140.   char *valPtr;
  141.   char newURL[sizeof(url)];
  142.   char newType[4];

  143.   newURL[0] = 0;
  144.   newType[0] = 0;
  145.   while (ParseParam(¶ms, &namePtr, &valPtr)) {
  146.     ParamText("url", newURL);
  147.     ParamText("type", newType);
  148.   }
  149.   if (newURL[0] && newType[0]) {
  150.     newUrl = true;
  151.     strncpy(url, newURL, sizeof(url)-1);
  152.     url[sizeof(url)-1] = 0;
  153.     if (!strcmp_P(newType, PSTR("aac"))) {
  154.       isAAC = true;
  155.     } else {
  156.       isAAC = false;
  157.     }
  158.     strcpy_P(status, PSTR("Changing URL..."));
  159.     Serial.printf_P(PSTR("Changed URL to: %s(%s)\n"), url, newType);
  160.     RedirectToIndex(client);
  161.   } else {
  162.     WebError(client, 404, NULL, false);
  163.   }
  164. }

  165. void RedirectToIndex(WiFiClient *client)
  166. {
  167.   WebError(client, 301, PSTR("Location: /\r\n"), true);
  168. }

  169. void StopPlaying()
  170. {
  171.   if (decoder) {
  172.     decoder->stop();
  173.     delete decoder;
  174.     decoder = NULL;
  175.   }
  176.   if (buff) {
  177.     buff->close();
  178.     delete buff;
  179.     buff = NULL;
  180.   }
  181.   if (file) {
  182.     file->close();
  183.     delete file;
  184.     file = NULL;
  185.   }
  186.   strcpy_P(status, PSTR("Stopped"));
  187.   strcpy_P(title, PSTR("Stopped"));
  188. }

  189. void HandleStop(WiFiClient *client)
  190. {
  191.   Serial.printf_P(PSTR("HandleStop()\n"));
  192.   StopPlaying();
  193.   RedirectToIndex(client);
  194. }

  195. void MDCallback(void *cbData, const char *type, bool isUnicode, const char *str)
  196. {
  197.   const char *ptr = reinterpret_cast<const char *>(cbData);
  198.   (void) isUnicode; // Punt this ball for now
  199.   (void) ptr;
  200.   if (strstr_P(type, PSTR("Title"))) {
  201.     strncpy(title, str, sizeof(title));
  202.     title[sizeof(title)-1] = 0;
  203.   } else {
  204.     // Who knows what to do?  Not me!
  205.   }
  206. }
  207. void StatusCallback(void *cbData, int code, const char *string)
  208. {
  209.   const char *ptr = reinterpret_cast<const char *>(cbData);
  210.   (void) code;
  211.   (void) ptr;
  212.   strncpy_P(status, string, sizeof(status)-1);
  213.   status[sizeof(status)-1] = 0;
  214. }

  215. #ifdef ESP8266
  216. const int preallocateBufferSize = 5*1024;
  217. const int preallocateCodecSize = 29192; // MP3 codec max mem needed
  218. #else
  219. const int preallocateBufferSize = 16*1024;
  220. const int preallocateCodecSize = 85332; // AAC+SBR codec max mem needed
  221. #endif
  222. void *preallocateBuffer = NULL;
  223. void *preallocateCodec = NULL;

  224. void setup()
  225. {
  226.   // First, preallocate all the memory needed for the buffering and codecs, never to be freed
  227.   preallocateBuffer = malloc(preallocateBufferSize);
  228.   preallocateCodec = malloc(preallocateCodecSize);
  229.   if (!preallocateBuffer || !preallocateCodec) {
  230.     Serial.begin(115200);
  231.     Serial.printf_P(PSTR("FATAL ERROR:  Unable to preallocate %d bytes for app\n"), preallocateBufferSize+preallocateCodecSize);
  232.     while (1) delay(1000); // Infinite halt
  233.   }

  234.   Serial.begin(115200);

  235.   delay(1000);
  236.   Serial.printf_P(PSTR("Connecting to WiFi\n"));

  237.   WiFi.disconnect();
  238.   WiFi.softAPdisconnect(true);
  239.   WiFi.mode(WIFI_STA);
  240.   
  241.   WiFi.begin(ssid, password);

  242.   // Try forever
  243.   while (WiFi.status() != WL_CONNECTED) {
  244.     Serial.printf_P(PSTR("...Connecting to WiFi\n"));
  245.     delay(1000);
  246.   }
  247.   Serial.printf_P(PSTR("Connected\n"));
  248.   
  249.   Serial.printf_P(PSTR("Go to http://"));
  250.   Serial.print(WiFi.localIP());
  251.   Serial.printf_P(PSTR("/ to control the web radio.\n"));

  252.   server.begin();
  253.   
  254.   strcpy_P(url, PSTR("none"));
  255.   strcpy_P(status, PSTR("OK"));
  256.   strcpy_P(title, PSTR("Idle"));

  257.   audioLogger = &Serial;
  258.   file = NULL;
  259.   buff = NULL;
  260.   out = new AudioOutputI2S();
  261.   decoder = NULL;

  262.   LoadSettings();
  263. }

  264. void StartNewURL()
  265. {
  266.   Serial.printf_P(PSTR("Changing URL to: %s, vol=%d\n"), url, volume);

  267.   newUrl = false;
  268.   // Stop and free existing ones
  269.   Serial.printf_P(PSTR("Before stop...Free mem=%d\n"), ESP.getFreeHeap());
  270.   StopPlaying();
  271.   Serial.printf_P(PSTR("After stop...Free mem=%d\n"), ESP.getFreeHeap());
  272.   SaveSettings();
  273.   Serial.printf_P(PSTR("Saved settings\n"));
  274.   
  275.   file = new AudioFileSourceICYStream(url);
  276.   Serial.printf_P(PSTR("created icystream\n"));
  277.   file->RegisterMetadataCB(MDCallback, NULL);
  278.   buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize);
  279.   Serial.printf_P(PSTR("created buffer\n"));
  280.   buff->RegisterStatusCB(StatusCallback, NULL);
  281.   decoder = isAAC ? (AudioGenerator*) new AudioGeneratorAAC(preallocateCodec, preallocateCodecSize) : (AudioGenerator*) new AudioGeneratorMP3(preallocateCodec, preallocateCodecSize);
  282.   Serial.printf_P(PSTR("created decoder\n"));
  283.   decoder->RegisterStatusCB(StatusCallback, NULL);
  284.   Serial.printf_P("Decoder start...\n");
  285.   decoder->begin(buff, out);
  286.   out->SetGain(((float)volume)/100.0);
  287.   if (!decoder->isRunning()) {
  288.     Serial.printf_P(PSTR("Can't connect to URL"));
  289.     StopPlaying();
  290.     strcpy_P(status, PSTR("Unable to connect to URL"));
  291.     retryms = millis() + 2000;
  292.   }
  293.   Serial.printf_P("Done start new URL\n");
  294. }

  295. void LoadSettings()
  296. {
  297.   // Restore from EEPROM, check the checksum matches
  298.   Settings s;
  299.   uint8_t *ptr = reinterpret_cast<uint8_t *>(&s);
  300.   EEPROM.begin(sizeof(s));
  301.   for (size_t i=0; i<sizeof(s); i++) {
  302.     ptr[i] = EEPROM.read(i);
  303.   }
  304.   EEPROM.end();
  305.   int16_t sum = 0x1234;
  306.   for (size_t i=0; i<sizeof(url); i++) sum += s.url[i];
  307.   sum += s.isAAC;
  308.   sum += s.volume;
  309.   if (s.checksum == sum) {
  310.     strcpy(url, s.url);
  311.     isAAC = s.isAAC;
  312.     volume = s.volume;
  313.     Serial.printf_P(PSTR("Resuming stream from EEPROM: %s, type=%s, vol=%d\n"), url, isAAC?"AAC":"MP3", volume);
  314.     newUrl = true;
  315.   }
  316. }

  317. void SaveSettings()
  318. {
  319.   // Store in "EEPROM" to restart automatically
  320.   Settings s;
  321.   memset(&s, 0, sizeof(s));
  322.   strcpy(s.url, url);
  323.   s.isAAC = isAAC;
  324.   s.volume = volume;
  325.   s.checksum = 0x1234;
  326.   for (size_t i=0; i<sizeof(url); i++) s.checksum += s.url[i];
  327.   s.checksum += s.isAAC;
  328.   s.checksum += s.volume;
  329.   uint8_t *ptr = reinterpret_cast<uint8_t *>(&s);
  330.   EEPROM.begin(sizeof(s));
  331.   for (size_t i=0; i<sizeof(s); i++) {
  332.     EEPROM.write(i, ptr[i]);
  333.   }
  334.   EEPROM.commit();
  335.   EEPROM.end();
  336. }

  337. void PumpDecoder()
  338. {
  339.   if (decoder && decoder->isRunning()) {
  340.     strcpy_P(status, PSTR("Playing")); // By default we're OK unless the decoder says otherwise
  341.     if (!decoder->loop()) {
  342.       Serial.printf_P(PSTR("Stopping decoder\n"));
  343.       StopPlaying();
  344.       retryms = millis() + 2000;
  345.     }
  346. }

  347. }

  348. void loop()
  349. {
  350.   static int lastms = 0;
  351.   if (millis()-lastms > 1000) {
  352.     lastms = millis();
  353.     Serial.printf_P(PSTR("Running for %d seconds%c...Free mem=%d\n"), lastms/1000, !decoder?' ':(decoder->isRunning()?'*':' '), ESP.getFreeHeap());
  354.   }

  355.   if (retryms && millis()-retryms>0) {
  356.     retryms = 0;
  357.     newUrl = true;
  358.   }
  359.   
  360.   if (newUrl) {
  361.     StartNewURL();
  362.   }

  363.   PumpDecoder();
  364.   
  365.   char *reqUrl;
  366.   char *params;
  367.   WiFiClient client = server.available();
  368.   PumpDecoder();
  369.   char reqBuff[384];
  370.   if (client && WebReadRequest(&client, reqBuff, 384, &reqUrl, ¶ms)) {
  371.     PumpDecoder();
  372.     if (IsIndexHTML(reqUrl)) {
  373.       HandleIndex(&client);
  374.     } else if (!strcmp_P(reqUrl, PSTR("stop"))) {
  375.       HandleStop(&client);
  376.     } else if (!strcmp_P(reqUrl, PSTR("status"))) {
  377.       HandleStatus(&client);
  378.     } else if (!strcmp_P(reqUrl, PSTR("title"))) {
  379.       HandleTitle(&client);
  380.     } else if (!strcmp_P(reqUrl, PSTR("setvol"))) {
  381.       HandleVolume(&client, params);
  382.     } else if (!strcmp_P(reqUrl, PSTR("changeurl"))) {
  383.       HandleChangeURL(&client, params);
  384.     } else {
  385.       WebError(&client, 404, NULL, false);
  386.     }
  387.     // web clients hate when door is violently shut
  388.     while (client.available()) {
  389.       PumpDecoder();
  390.       client.read();
  391.     }
  392.   }
  393.   PumpDecoder();
  394.   if (client) {
  395.     client.flush();
  396.     client.stop();
  397.   }
  398. }
复制代码



====================

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

打赏

参与人数 1家元 +20 收起 理由
jjbboox + 20 精彩回帖

查看全部打赏

回复 支持 1 反对 0

使用道具 举报

发表于 2020-5-5 22:09:24 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2020-5-13 11:21:00 | 显示全部楼层
mckk520 发表于 2020-5-5 15:37
8266 网络电台收听,

====================

:handshake::victory:已收下并刷入8266.
回复 支持 反对

使用道具 举报

发表于 2020-5-13 17:37:23 | 显示全部楼层
一直没注意过,8266或者ESP32能不能删除SD卡里的MP3歌曲? 我的歌太杂太多,想弄个不好听就按个键来删除的播放器,想了很久了一直没动手。
回复 支持 反对

使用道具 举报

发表于 2020-5-14 08:13:03 | 显示全部楼层
msold5 发表于 2020-5-13 17:37
一直没注意过,8266或者ESP32能不能删除SD卡里的MP3歌曲? 我的歌太杂太多,想弄个不好听就按个键来删除的 ...

可以
和播放没啥关系,直接调用SD.remove(filename)就能删除文件了。
回复 支持 反对

使用道具 举报

发表于 2020-5-14 15:38:33 | 显示全部楼层
jjbboox 发表于 2020-5-14 08:13
可以
和播放没啥关系,直接调用SD.remove(filename)就能删除文件了。

这个出来的音质比普通车载MP3如何?
回复 支持 反对

使用道具 举报

发表于 2020-5-14 16:14:51 | 显示全部楼层
本帖最后由 jjbboox 于 2020-5-14 16:17 编辑
msold5 发表于 2020-5-14 15:38
这个出来的音质比普通车载MP3如何?

我不是楼主

楼主是用PWM输出直接驱动喇叭的,音质肯定是比不了车机的。

不过Esp8266Audio这个库支持I2S无损数字输出的。
如果改用I2S直通解码器解码输出的话,音质取决于后级的解码芯片。
用好一点的解码芯片的话,音质绝不会比车机差的。

你可以去看下面的视频,用解码器播放wav,Flac,后半段通过网页控制的部分录音效果比较好。
https://www.acfun.cn/v/ac12678422?shareUid=12663753


回复 支持 反对

使用道具 举报

发表于 2020-5-14 17:41:39 | 显示全部楼层
jjbboox 发表于 2020-5-14 16:14
我不是楼主

楼主是用PWM输出直接驱动喇叭的,音质肯定是比不了车机的。

用MP3了肯定还是要追求点音质,8266貌似也可以支持i2S吧?一定要用ESP32吗?
回复 支持 反对

使用道具 举报

发表于 2020-5-15 12:19:26 | 显示全部楼层
楼主,编译通过烧录进去咋没声音,mp3文件是咋烧进去的。
回复 支持 反对

使用道具 举报

发表于 2020-6-3 20:29:13 | 显示全部楼层
这个硬件是怎么连接的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2024-4-26 18:45 , Processed in 0.109200 second(s), 10 queries , Redis On.

Powered by Discuz!

© 2006-2023 smzj.net

快速回复 返回顶部 返回列表