Skip to content

Commit ec2f86b

Browse files
committed
Codec: opus test
1 parent b46c18e commit ec2f86b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

examples/tests/codecs/test-codec-opus/test-codec-opus.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "AudioLibs/AudioKit.h"
1313
#include "AudioCodecs/CodecOpus.h"
1414

15-
AudioInfo info(32000, 1, 16);
15+
AudioInfo info(24000, 1, 16);
1616
SineWaveGenerator<int16_t> sineWave( 32000); // subclass of SoundGenerator with max amplitude of 32000
1717
GeneratedSoundStream<int16_t> sound( sineWave); // Stream generated from sine wave
1818
AudioKitStream out;

src/AudioCodecs/CodecOpus.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class OpusAudioDecoder : public AudioDecoder {
135135
void setOutputStream(Print &out_stream) override { p_print = &out_stream; }
136136

137137
void setNotifyAudioChange(AudioInfoDependent &bi) override {
138-
this->bid = &bi;
138+
this->p_notify = &bi;
139139
}
140140

141141
AudioInfo audioInfo() override { return cfg; }
@@ -144,11 +144,12 @@ class OpusAudioDecoder : public AudioDecoder {
144144
OpusSettings &config() { return cfg; }
145145
OpusSettings &defaultConfig() { return cfg; }
146146

147-
void begin(OpusSettings info) {
147+
void begin(OpusSettings settings) {
148148
TRACED();
149-
cfg = info;
150-
if (bid != nullptr) {
151-
bid->setAudioInfo(cfg);
149+
AudioDecoder::setAudioInfo(settings);
150+
cfg = settings;
151+
if (p_notify != nullptr) {
152+
p_notify->setAudioInfo(cfg);
152153
}
153154
begin();
154155
}
@@ -178,6 +179,8 @@ class OpusAudioDecoder : public AudioDecoder {
178179
}
179180

180181
void setAudioInfo(AudioInfo from) override {
182+
AudioDecoder::setAudioInfo(from);
183+
info = from;
181184
cfg.sample_rate = from.sample_rate;
182185
cfg.channels = from.channels;
183186
cfg.bits_per_sample = from.bits_per_sample;
@@ -205,7 +208,6 @@ class OpusAudioDecoder : public AudioDecoder {
205208

206209
protected:
207210
Print *p_print = nullptr;
208-
AudioInfoDependent *bid = nullptr;
209211
OpusSettings cfg;
210212
OpusDecoder *dec;
211213
bool active;

0 commit comments

Comments
 (0)