Skip to content

Commit 36e97c6

Browse files
committed
Rename to Str and StrView
1 parent 96d4788 commit 36e97c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1271
-1221
lines changed

examples/build-examples-log.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@
8282
../examples/examples-audiokit/streams-synthstk-audiokit -> rc=0
8383
../examples/examples-audiokit/streams-tf-audiokit -> rc=0
8484
../examples/examples-tts/streams-azure_tts-i2s -> rc=0
85-
../examples/examples-tts/streams-espeak-audiokit -> rc=0
86-
../examples/examples-tts/streams-espeak-i2s -> rc=0
85+
../examples/examples-tts/streams-espeak-audiokit -> rc=1
86+
../examples/examples-tts/streams-espeak-i2s -> rc=1
8787
../examples/examples-tts/streams-flite-audiokit -> rc=1
8888
../examples/examples-tts/streams-flite-i2s -> rc=1
8989
../examples/examples-tts/streams-google-audiokit -> rc=0
9090
../examples/examples-tts/streams-sam-audiokit -> rc=0
9191
../examples/examples-tts/streams-sam-i2s -> rc=0
92-
../examples/examples-tts/streams-simple_tts-a2dp -> rc=0
93-
../examples/examples-tts/streams-simple_tts-i2s -> rc=0
92+
../examples/examples-tts/streams-simple_tts-a2dp -> rc=1
93+
../examples/examples-tts/streams-simple_tts-i2s -> rc=1
9494
../examples/examples-tts/streams-tts-i2s -> rc=0
9595
../examples/examples-tts/streams-url_wav-i2s -> rc=0
9696
../examples/examples-dsp/examples-maximilian/01-TestTone -> rc=0
@@ -192,7 +192,7 @@
192192
../examples/examples-communication/http-client/player-url_icy-audiokit -> rc=0
193193
../examples/examples-communication/http-client/player-url_icy-i2s -> rc=0
194194
../examples/examples-communication/http-client/player-url_subclass-i2s -> rc=0
195-
../examples/examples-communication/http-client/streams-eth_url_mp3_helix-i2s -> rc=0
195+
../examples/examples-communication/http-client/streams-eth_url_mp3_helix-i2s -> rc=1
196196
../examples/examples-communication/http-client/streams-http_post -> rc=0
197197
../examples/examples-communication/http-client/streams-url_aac-audiokit -> rc=0
198198
../examples/examples-communication/http-client/streams-url_aac-i2s -> rc=0
@@ -211,17 +211,17 @@
211211
../examples/examples-communication/http-client/streams-url_raw-i2s -> rc=0
212212
../examples/examples-communication/http-client/streams-url_raw-serial -> rc=0
213213
../examples/examples-communication/http-client/streams-url_vorbis_i2s -> rc=0
214-
../examples/examples-communication/http-server/player-sd-webserverex_mp3 -> rc=0
214+
../examples/examples-communication/http-server/player-sd-webserverex_mp3 -> rc=1
215215
../examples/examples-communication/http-server/README.md -> rc=1
216216
../examples/examples-communication/http-server/streams-audiokit-webserver_aac -> rc=0
217-
../examples/examples-communication/http-server/streams-audiokit-webserver_mp3 -> rc=0
217+
../examples/examples-communication/http-server/streams-audiokit-webserver_mp3 -> rc=1
218218
../examples/examples-communication/http-server/streams-audiokit-webserver_wav -> rc=0
219219
../examples/examples-communication/http-server/streams-effect-webserver_wav -> rc=0
220220
../examples/examples-communication/http-server/streams-flite-webserver_wav -> rc=1
221221
../examples/examples-communication/http-server/streams-generator-webserver_aac -> rc=0
222-
../examples/examples-communication/http-server/streams-generator-webserverex_wav -> rc=0
223-
../examples/examples-communication/http-server/streams-generator-webserverex_wav1 -> rc=0
224-
../examples/examples-communication/http-server/streams-generator-webserver_mp3 -> rc=0
222+
../examples/examples-communication/http-server/streams-generator-webserverex_wav -> rc=1
223+
../examples/examples-communication/http-server/streams-generator-webserverex_wav1 -> rc=1
224+
../examples/examples-communication/http-server/streams-generator-webserver_mp3 -> rc=1
225225
../examples/examples-communication/http-server/streams-generator-webserver_ogg -> rc=0
226226
../examples/examples-communication/http-server/streams-generator-webserver_wav -> rc=0
227227
../examples/examples-communication/http-server/streams-i2s-webserver_wav -> rc=0
@@ -258,7 +258,7 @@
258258
../examples/tests/codecs/test-codec-opusogg -> rc=0
259259
../examples/tests/codecs/test-codec-sbc -> rc=0
260260
../examples/tests/codecs/test-codec-wav-adpcm -> rc=0
261-
../examples/tests/codecs/test-compile-all -> rc=0
261+
../examples/tests/codecs/test-compile-all -> rc=1
262262
../examples/tests/codecs/test-container-binary -> rc=0
263263
../examples/tests/codecs/test-container-binary-meta -> rc=0
264264
../examples/tests/codecs/test-container-ogg -> rc=0
@@ -303,9 +303,9 @@
303303
../examples/tests/etc/test-tdm -> rc=0
304304
../examples/tests/etc/test-write-memory -> rc=0
305305
../examples/tests/fft/fft-cmsis -> rc=1
306-
../examples/tests/fft/fft-esp32 -> rc=0
306+
../examples/tests/fft/fft-esp32 -> rc=1
307307
../examples/tests/fft/fft-espressif -> rc=0
308-
../examples/tests/fft/fft-kiss -> rc=0
308+
../examples/tests/fft/fft-kiss -> rc=1
309309
../examples/tests/fft/fft-real -> rc=0
310310
../examples/tests/fft/fft-topn -> rc=0
311311
../examples/tests/fft/fft-window -> rc=0

examples/examples-communication/http-client/player-url_subclass-i2s/AudioSourceIcyUrl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AudioSourceIcyUrl : public AudioSourceURL {
3030
/// Returns the last section of a url: https://22323.live.streamtheworld.com/TOPRETRO.mp3 gives TOPRETRO.mp3
3131
const char *urlName(){
3232
const char* result = "";
33-
Str tmpStr(toStr());
33+
StrView tmpStr(toStr());
3434
int pos = tmpStr.lastIndexOf("/");
3535
if (pos>0){
3636
result = toStr()+pos+1;
@@ -40,7 +40,7 @@ class AudioSourceIcyUrl : public AudioSourceURL {
4040

4141
/// Returns the icy name if available otherwise we use our custom logic
4242
const char* name() {
43-
Str result(icyName());
43+
StrView result(icyName());
4444
if (result.isEmpty()){
4545
result.set(urlName());
4646
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*********************************************************************
2+
This example generates a sawtooth that you can output on your PC
3+
We use the AudioTools to generate the data input.
4+
5+
We could use the callback function here as well, but we demo how
6+
to integrate with a (fast) Arduino Stream.
7+
8+
*********************************************************************/
9+
10+
#include "Adafruit_TinyUSB.h" // https://github.com/pschatzmann/Adafruit_TinyUSB_Arduino
11+
#include "AudioTools.h" // https://github.com/pschatzmann/arduino-audio-tools
12+
13+
Adafruit_USBD_Audio usb;
14+
AudioInfo info(44100, 2, 16);
15+
SawToothGenerator<int16_t> sawtooth;
16+
GeneratedSoundStream<int16_t> sawthooth_stream(sawtooth);
17+
18+
void setup() {
19+
// Manual begin() is required on core without built-in support e.g. mbed rp2040
20+
if (!TinyUSBDevice.isInitialized()) {
21+
TinyUSBDevice.begin(0);
22+
}
23+
24+
Serial.begin(115200);
25+
//while(!Serial); // wait for serial
26+
27+
// generate 493 hz (note B4)
28+
sawtooth.begin(info, 493.0f);
29+
30+
// Start USB device as Audio Source
31+
usb.setInput(sawthooth_stream);
32+
usb.begin(info.sample_rate, info.channels, info.bits_per_sample);
33+
34+
// If already enumerated, additional class driverr begin() e.g msc, hid, midi won't take effect until re-enumeration
35+
if (TinyUSBDevice.mounted()) {
36+
TinyUSBDevice.detach();
37+
delay(10);
38+
TinyUSBDevice.attach();
39+
}
40+
}
41+
42+
void loop() {
43+
#ifdef TINYUSB_NEED_POLLING_TASK
44+
// Manual call tud_task since it isn't called by Core's background
45+
TinyUSBDevice.task();
46+
#endif
47+
// optional: use LED do display status
48+
usb.updateLED();
49+
}

examples/examples-tts/streams-google-audiokit/streams-google-audiokit.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ URLStream url("ssid","password");
2020
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
2121
EncodedAudioStream dec(&i2s, new MP3DecoderHelix()); // Decoding stream
2222
StreamCopy copier(dec, url); // copy url to decoder
23-
StrExt query("http://translate.google.com/translate_tts?ie=UTF-8&tl=%1&client=tw-ob&ttsspeed=%2&q=%3");
23+
Str query("http://translate.google.com/translate_tts?ie=UTF-8&tl=%1&client=tw-ob&ttsspeed=%2&q=%3");
2424

2525
const char* tts(const char* text, const char* lang="en", const char* speed="1"){
2626
query.replace("%1",lang);
2727
query.replace("%2",speed);
2828

29-
StrExt encoded(text);
29+
Str encoded(text);
3030
encoded.urlEncode();
3131
query.replace("%3", encoded.c_str());
3232
return query.c_str();

src/AudioConfig.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ typedef WiFiClient WiFiClientSecure;
234234
# define ESP32X
235235
# define USE_TDM
236236
# define USE_PDM
237+
# define USE_PDM_RX
237238
#endif
238239
#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32H2)
239240
# define ESP32H2
@@ -252,6 +253,7 @@ typedef WiFiClient WiFiClientSecure;
252253
# define ESP32X
253254
# define USE_TDM
254255
# define USE_PDM
256+
# define USE_PDM_RX
255257
#endif
256258

257259
// for all ESP32 families
@@ -278,7 +280,7 @@ typedef WiFiClient WiFiClientSecure;
278280

279281
#define USE_ANALOG
280282
#define USE_I2S
281-
#define USE_PDM
283+
#define USE_PDM_RX
282284

283285
#ifdef ARDUINO
284286
# define USE_PWM

src/AudioTools/AudioCodecs/CodecBase64.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
#pragma once
33

4-
#include "AudioTools/CoreAudio/AudioBasic/Str.h"
54
#include "AudioTools/AudioCodecs/AudioCodecsBase.h"
65

76
namespace audio_tools {

src/AudioTools/AudioCodecs/CodecMTS.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ enum MTSStreamType {
8383
* @copyright GPLv3
8484
*/
8585

86-
class MTSDecoder : public AudioDecoder {
86+
class MTSDecoder1 : public AudioDecoder {
8787
public:
88-
MTSDecoder() = default;
88+
MTSDecoder1() = default;
8989

9090
bool begin() override {
9191
TRACED();

src/AudioTools/AudioCodecs/CodecTSDemux.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ struct AllocSize {
4545
* @copyright GPLv3
4646
*/
4747

48-
class MTSDecoder : public AudioDecoder {
48+
class MTSDecoder1 : public AudioDecoder {
4949
public:
50-
MTSDecoder() {
50+
MTSDecoder1() {
5151
self = this;
5252
};
5353

@@ -111,7 +111,7 @@ class MTSDecoder : public AudioDecoder {
111111

112112
size_t write(const uint8_t *data, size_t len) override {
113113
if (!is_active) return 0;
114-
LOGD("MTSDecoder::write: %d", (int)len);
114+
LOGD("MTSDecoder1::write: %d", (int)len);
115115
size_t result = buffer.writeArray((uint8_t*)data, len);
116116
// demux
117117
demux(underflowLimit);
@@ -150,7 +150,7 @@ class MTSDecoder : public AudioDecoder {
150150
}
151151

152152
protected:
153-
static MTSDecoder *self;
153+
static MTSDecoder1 *self;
154154
int underflowLimit = MTS_UNDERFLOW_LIMIT;
155155
bool is_active = false;
156156
bool is_write_active = false;
@@ -248,8 +248,8 @@ class MTSDecoder : public AudioDecoder {
248248
static void event_cb(TSDemuxContext *ctx, uint16_t pid, TSDEventId event_id,
249249
void *data) {
250250
TRACED();
251-
if (MTSDecoder::self != nullptr) {
252-
MTSDecoder::self->event_cb_local(ctx, pid, event_id, data);
251+
if (MTSDecoder1::self != nullptr) {
252+
MTSDecoder1::self->event_cb_local(ctx, pid, event_id, data);
253253
}
254254
}
255255

@@ -963,6 +963,6 @@ class MTSDecoder : public AudioDecoder {
963963

964964
};
965965
// init static variable
966-
MTSDecoder *MTSDecoder::self = nullptr;
966+
MTSDecoder1 *MTSDecoder1::self = nullptr;
967967

968968
} // namespace audio_tools

src/AudioTools/AudioCodecs/CodecWAV.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "AudioTools/AudioCodecs/AudioCodecsBase.h"
44
#include "AudioTools/AudioCodecs/AudioFormat.h"
5-
#include "AudioTools/CoreAudio/AudioBasic/Str.h"
5+
#include "AudioTools/CoreAudio/AudioBasic/StrView.h"
66

77
#define READ_BUFFER_SIZE 512
88
#define MAX_WAV_HEADER_LEN 200
@@ -93,7 +93,7 @@ class WAVHeader {
9393

9494
/// Determines the data start position using the data tag
9595
int getDataPos() {
96-
int pos = Str((char*)buffer.data(),MAX_WAV_HEADER_LEN, buffer.available()).indexOf("data");
96+
int pos = StrView((char*)buffer.data(),MAX_WAV_HEADER_LEN, buffer.available()).indexOf("data");
9797
return pos > 0 ? pos + 8 : 0;
9898
}
9999

@@ -149,7 +149,7 @@ class WAVHeader {
149149
}
150150

151151
int indexOf(const char* str){
152-
return Str((char*)buffer.data(),MAX_WAV_HEADER_LEN, buffer.available()).indexOf(str);
152+
return StrView((char*)buffer.data(),MAX_WAV_HEADER_LEN, buffer.available()).indexOf(str);
153153
}
154154

155155
uint32_t read_tag() {
@@ -255,6 +255,8 @@ class WAVHeader {
255255
* determine the format. If no AudioDecoderExt is specified we just write the PCM
256256
* data to the output that is defined by calling setOutput(). You can define a
257257
* ADPCM decoder to decode WAV files that contain ADPCM data.
258+
* Please note that you need to call begin() everytime you process a new file to
259+
* let the decoder know that we start with a new header.
258260
* @ingroup codecs
259261
* @ingroup decoder
260262
* @author Phil Schatzmann

src/AudioTools/AudioCodecs/ContainerAVI.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include <string.h>
33
#include "AudioTools/AudioCodecs/AudioCodecsBase.h"
4-
#include "AudioTools/CoreAudio/AudioBasic/StrExt.h"
4+
#include "AudioTools/CoreAudio/AudioBasic/Str.h"
55
#include "AudioTools/AudioCodecs/AudioFormat.h"
66
#include "AudioTools/Video/Video.h"
77
#include "AudioTools/CoreAudio/Buffers.h"
@@ -155,7 +155,7 @@ enum ParseState {
155155
*/
156156
class ParseObject {
157157
public:
158-
void set(size_t currentPos, Str id, size_t size, ParseObjectType type) {
158+
void set(size_t currentPos, StrView id, size_t size, ParseObjectType type) {
159159
set(currentPos, id.c_str(), size, type);
160160
}
161161

@@ -367,8 +367,8 @@ class AVIDecoder : public ContainerDecoder {
367367
long open_subchunk_len = 0;
368368
long current_pos = 0;
369369
long movi_end_pos = 0;
370-
StrExt spaces;
371-
StrExt str;
370+
Str spaces;
371+
Str str;
372372
char video_format[5] = {0};
373373
bool is_metadata_ready = false;
374374
bool (*validation_cb)(AVIDecoder &avi) = nullptr;
@@ -452,9 +452,9 @@ class AVIDecoder : public ContainerDecoder {
452452
if (pos >= 0) {
453453
consume(pos);
454454
ParseObject tmp = tryParseList();
455-
if (Str(tmp.id()).equals("strl")) {
455+
if (StrView(tmp.id()).equals("strl")) {
456456
parse_state = ParseStrl;
457-
} else if (Str(tmp.id()).equals("movi")) {
457+
} else if (StrView(tmp.id()).equals("movi")) {
458458
parse_state = ParseMovi;
459459
} else {
460460
// e.g. ignore info
@@ -470,7 +470,7 @@ class AVIDecoder : public ContainerDecoder {
470470

471471
case ParseMovi: {
472472
ParseObject movi = tryParseList();
473-
if (Str(movi.id()).equals("movi")) {
473+
if (StrView(movi.id()).equals("movi")) {
474474
consume(LIST_HEADER_SIZE);
475475
is_metadata_ready = true;
476476
if (validation_cb)
@@ -486,7 +486,7 @@ class AVIDecoder : public ContainerDecoder {
486486
case SubChunk: {
487487
// rec is optinal
488488
ParseObject hdrl = tryParseList();
489-
if (Str(hdrl.id()).equals("rec")) {
489+
if (StrView(hdrl.id()).equals("rec")) {
490490
consume(CHUNK_HEADER_SIZE);
491491
processStack(hdrl);
492492
}
@@ -623,7 +623,7 @@ class AVIDecoder : public ContainerDecoder {
623623

624624
ParseObject tryParseList(const char *id) {
625625
ParseObject result;
626-
Str &list_id = getStr(8, 4);
626+
StrView &list_id = getStr(8, 4);
627627
if (list_id.equals(id) && getStr(0, 3).equals("LIST")) {
628628
result.set(current_pos, getStr(8, 4), getInt(4), AVIList);
629629
}
@@ -693,7 +693,7 @@ class AVIDecoder : public ContainerDecoder {
693693
}
694694

695695
/// Provides the string at the indicated byte offset with the indicated length
696-
Str &getStr(int offset, int len) {
696+
StrView &getStr(int offset, int len) {
697697
str.setCapacity(len + 1);
698698
const char *data = (const char *)parse_buffer.data();
699699
str.copyFrom((data + offset), len, 5);

0 commit comments

Comments
 (0)