3141| 0
|
[求助] 急求!关于ESP8266播放音乐的问题 |
#include <Arduino.h> #ifdef ESP32 #include <WiFi.h> #include "SPIFFS.h" #else #include <ESP8266WiFi.h> #endif #include <AudioOutputNull.h> #include <AudioOutputI2S.h> #include <AudioGeneratorMIDI.h> #include <AudioFileSourceSPIFFS.h> AudioFileSourceSPIFFS *sf2; AudioFileSourceSPIFFS *mid; AudioOutputI2S *dac; AudioGeneratorMIDI *midi; void setup() { const char *soundfont = "/1mgm.sf2"; const char *midifile = "/furelise.mid"; WiFi.mode(WIFI_OFF); Serial.begin(115200); Serial.println("Starting up...\n"); audioLogger = &Serial; sf2 = new AudioFileSourceSPIFFS(soundfont); mid = new AudioFileSourceSPIFFS(midifile); dac = new AudioOutputI2S(); midi = new AudioGeneratorMIDI(); midi->SetSoundfont(sf2); midi->SetSampleRate(22050); Serial.printf("BEGIN...\n"); midi->begin(mid, dac); } void loop() { if (midi->isRunning()) { if (!midi->loop()) { uint32_t e = millis(); midi->stop(); } } else { Serial.printf("MIDI done\n"); delay(1000); } } 我尝试用 ESP8266Audio 这个库做 MP3播放的 PlayMP3FromSPIFFS 这个例子,上传正常,连接电路也正常,可是开机为啥只有一直嘟的声音? |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed