Skip to content

Commit b3dec88

Browse files
committed
MetaDataFilter
1 parent d2539de commit b3dec88

File tree

3 files changed

+163
-160
lines changed

3 files changed

+163
-160
lines changed

examples/examples-custom-boards/cross_band_handy_walkie_talkie/cross_band_handy_walkie_talkie.ino

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,38 @@
1212
#include "SD.h"
1313

1414
AudioInfo info(32000, 2, 16);
15-
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
16-
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
17-
AudioBoardStream out(AudioKitEs8388V1);
18-
StreamCopy copier(out, sound); // copies sound into i2s
15+
SineWaveGenerator<int16_t> sineWave(
16+
32000); // subclass of SoundGenerator with max amplitude of 32000
17+
GeneratedSoundStream<int16_t> sound(
18+
sineWave); // Stream generated from sine wave
19+
DriverPins my_pins;
20+
AudioBoard board(AudioDriverES8388, my_pins);
21+
AudioBoardStream out(board);
22+
StreamCopy copier(out, sound); // copies sound into i2s
1923

2024
// Arduino Setup
2125
void setup(void) {
2226
// Open Serial
2327
Serial.begin(115200);
24-
while(!Serial);
28+
while (!Serial);
2529
AudioLogger::instance().begin(Serial, AudioLogger::Info);
26-
//LOGLEVEL_AUDIOKIT = AudioKitDebug;
30+
31+
// sd pins: clk, miso, mosi,cs,
32+
my_pins.addSPI(ESP32PinsSD{PinFunction::SD, 44, 42, 43, 2, SPI});
33+
// add i2c codec pins: scl, sda, port, frequency
34+
my_pins.addI2C(PinFunction::CODEC, 35, 36);
35+
// add i2s pins: mclk, bck, ws,data_out, data_in ,(port)
36+
my_pins.addI2S(PinFunction::CODEC, 47, 21, 12, 14, 11);
2737

2838
// start I2S
2939
Serial.println("starting I2S...");
3040
auto config = out.defaultConfig(TX_MODE);
3141
config.copyFrom(info);
32-
config.sd_active = false;
33-
// i2c
34-
config.pins.i2c_sda = 36;
35-
config.pins.i2c_scl = 35;
36-
// i2s
37-
config.pin_mck = 47;
38-
config.pin_bck = 21;
39-
config.pin_ws = 12;
40-
config.pin_data = 14;
41-
config.pin_data_rx = 11;
42-
43-
//config.sd_active = false;
44-
config.pins.sd_cs = 2;
45-
config.pins.sd_miso = 42;
46-
config.pins.sd_mosi = 43;
47-
config.pins.sd_clk = 44;
48-
out.begin(config, false);
42+
config.sd_active = true;
43+
out.begin(config);
4944

5045
// check SD drive
51-
if(!SD.begin(config.pins.sd_cs)){
46+
if (!SD.begin(2)) {
5247
Serial.println("Card Mount Failed");
5348
stop();
5449
}
@@ -59,6 +54,4 @@ void setup(void) {
5954
}
6055

6156
// Arduino loop - copy sound to out
62-
void loop() {
63-
copier.copy();
64-
}
57+
void loop() { copier.copy(); }

src/AudioTools/AudioCodecs/CodecMP3Helix.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class MP3DecoderHelix : public AudioDecoder {
2222
mp3 = new libhelix::MP3DecoderHelix();
2323
if (mp3!=nullptr){
2424
mp3->setReference(this);
25-
filter.setDecoder(mp3);
2625
} else {
2726
LOGE("Not enough memory for libhelix");
2827
}
@@ -37,7 +36,6 @@ class MP3DecoderHelix : public AudioDecoder {
3736
mp3 = new libhelix::MP3DecoderHelix();
3837
if (mp3!=nullptr){
3938
mp3->setReference(this);
40-
filter.setDecoder(mp3);
4139
} else {
4240
LOGE("Not enough memory for libhelix");
4341
}
@@ -56,7 +54,6 @@ class MP3DecoderHelix : public AudioDecoder {
5654
mp3 = new libhelix::MP3DecoderHelix();
5755
if (mp3!=nullptr){
5856
mp3->setReference(this);
59-
filter.setDecoder(mp3);
6057
} else {
6158
LOGE("Not enough memory for libhelix");
6259
}
@@ -83,7 +80,6 @@ class MP3DecoderHelix : public AudioDecoder {
8380
if (mp3!=nullptr) {
8481
//mp3->setDelay(CODEC_DELAY_MS);
8582
mp3->begin();
86-
filter.begin();
8783
}
8884
return true;
8985
}
@@ -111,7 +107,7 @@ class MP3DecoderHelix : public AudioDecoder {
111107
size_t write(const uint8_t* data, size_t len) {
112108
LOGD("%s: %zu", LOG_METHOD, len);
113109
if (mp3==nullptr) return 0;
114-
return use_filter ? filter.write((uint8_t*)data, len): mp3->write((uint8_t*)data, len);
110+
return mp3->write((uint8_t*)data, len);
115111
}
116112

117113
/// checks if the class is active
@@ -146,16 +142,6 @@ class MP3DecoderHelix : public AudioDecoder {
146142
}
147143
}
148144

149-
/// Activates a filter that makes sure that helix does not get any metadata segments
150-
void setFilterMetaData(bool filter){
151-
use_filter = filter;
152-
}
153-
154-
/// Check if the metadata filter is active
155-
bool isFilterMetaData() {
156-
return use_filter;
157-
}
158-
159145
/// Provides the maximum frame size - this is allocated on the heap and you can reduce the heap size my minimizing this value
160146
size_t maxFrameSize() {
161147
return mp3->maxFrameSize();
@@ -177,8 +163,6 @@ class MP3DecoderHelix : public AudioDecoder {
177163
}
178164
protected:
179165
libhelix::MP3DecoderHelix *mp3=nullptr;
180-
MetaDataFilter<libhelix::MP3DecoderHelix> filter;
181-
bool use_filter = false;
182166

183167
};
184168

0 commit comments

Comments
 (0)