Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to play opus(ogg) in littlefs #2110

Answered by pschatzmann
maxzhangzhang asked this question in Q&A
Discussion options

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

You must be logged in to vote

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

Comment options

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();

You must be logged in to vote
1 reply
Comment options

Thank for your replay, it's work. Thank you very much!!!

Answer selected by pschatzmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /