-
-
Notifications
You must be signed in to change notification settings - Fork 309
Unable to play opus(ogg) in littlefs #2110
-
Hello, All
I wrote a code to play the opus in littlefs, but it always says CodecOpus.h: 152 - Sample rate not supported: 44100. But I am sure that my audio sampling rate is 48000, so I don't know what the problem is.
`
#include <Arduino.h>
#include <AudioTools.h>
#include <LittleFS.h>
#include "AudioTools/AudioCodecs/CodecOpusOgg.h"
#define I2S_BCLK 16
#define I2S_LRC 17
#define I2S_DOUT 15
using namespace audio_tools;
I2SStream i2sOut;
OpusOggDecoder oggDecoder;
EncodedAudioStream decStream(&i2sOut, &oggDecoder);
void setup() {
Serial.begin(115200);
if (!LittleFS.begin()) {
Serial.println("LittleFS mount failed!");
while(1);
}
Serial.println("LittleFS ready");
auto config = i2sOut.defaultConfig(TX_MODE);
config.sample_rate = 48000;
config.bits_per_sample = 16;
config.channels = 1;
config.pin_bck = I2S_BCLK;
config.pin_ws = I2S_LRC;
config.pin_data = I2S_DOUT;
i2sOut.begin(config);
decStream.begin();
File file = LittleFS.open("/1.opus", "r");
if (!file) {
Serial.println("File open failed!");
return;
}
uint8_t buf[512];
size_t n;
while ((n = file.read(buf, sizeof(buf))) > 0) {
decStream.write(buf, n);
yield();
}
file.close();
Serial.println("end");
}
void loop() {}
`
Here is the usart print:
LittleFS ready [E] CodecOpus.h : 152 - Sample rate not supported: 44100 [E] CodecOpus.h : 152 - Sample rate not supported: 44100
please help me, THANKS
Beta Was this translation helpful? Give feedback.
All reactions
Please read the error message: you are setting up the decoder with 44100 which is the default ocnfiguration!
Provide a proper config when calling decStream.begin();
Replies: 1 comment 1 reply
-
Please read the error message: you are setting up the decoder with 44100 which is the default ocnfiguration!
Provide a proper config when calling decStream.begin();
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Thank for your replay, it's work. Thank you very much!!!
Beta Was this translation helpful? Give feedback.