Skip to content

Commit cd98763

Browse files
committed
2 parents 3477de5 + 7496aa5 commit cd98763

File tree

8 files changed

+78
-62
lines changed

8 files changed

+78
-62
lines changed

examples/build-arch-log.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ arduino:samd:arduino_zero_native ./examples-stream/streams-generator-serial -> r
1313
arduino:renesas_uno:unor4wifi ./examples-stream/streams-generator-serial -> rc=0
1414
arduino:mbed_nano:nano33ble ./examples-stream/streams-generator-serial -> rc=0
1515
arduino:mbed_rp2040:pico ./examples-stream/streams-generator-serial -> rc=0
16+
arduino:mbed_giga:giga ./examples-stream/streams-generator-serial -> rc=0
17+
arduino:zephyr:nano33ble ./examples-stream/streams-generator-serial -> rc=0
18+
STMicroelectronics:stm32:GenF4 ./examples-stream/streams-generator-serial -> rc=0

examples/build-arch.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ compile_example "arduino:samd:arduino_zero_native"
3333
compile_example "arduino:renesas_uno:unor4wifi"
3434
compile_example "arduino:mbed_nano:nano33ble"
3535
compile_example "arduino:mbed_rp2040:pico"
36-
#compile_example "arduino:zephyr:nano33ble"
37-
#compile_example "STMicroelectronics:stm32:GenF4"
36+
compile_example "arduino:mbed_giga:giga"
37+
compile_example "arduino:zephyr:nano33ble"
38+
compile_example "STMicroelectronics:stm32:GenF4"
3839

3940
./cleanup.sh
4041

src/AudioTools/AudioCodecs/CodecChain.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ class CodecChain : public AudioDecoder, AudioEncoder {
6060
}
6161
}
6262

63+
void addNotifyAudioChange(AudioInfoSupport &bi) override {
64+
for (auto &stream : streams) {
65+
stream.addNotifyAudioChange(bi);
66+
}
67+
}
68+
6369
size_t write(const uint8_t *data, size_t len) override {
6470
if (streams.size() == 0) return 0;
6571
return streams[0].write(data, len);

src/AudioTools/CoreAudio/AudioAnalog/AnalogDriverMBED.h

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace audio_tools {
1414
*/
1515

1616
class AnalogDriverMBED : public AnalogDriverBase {
17-
public:
17+
public:
1818
/// Default constructor
1919
AnalogDriverMBED() = default;
2020

@@ -37,20 +37,20 @@ class AnalogDriverMBED : public AnalogDriverBase {
3737
return false;
3838
}
3939
info = cfg;
40-
auto_center.begin(config.channels, config.bits_per.sample);
40+
auto_center.begin(cfg.channels, cfg.bits_per_sample);
4141
int n_samples = cfg.buffer_size / (cfg.bits_per_sample / 8);
4242
ring_buffer.resize(n_samples);
4343
switch (info.channels) {
44-
case 1:
45-
dac1.begin(AN_RESOLUTION_12, info.sample_rate, n_samples,
46-
cfg.buffer_count);
47-
break;
48-
case 2:
49-
dac1.begin(AN_RESOLUTION_12, info.sample_rate, n_samples / 2,
50-
cfg.buffer_count);
51-
dac2.begin(AN_RESOLUTION_12, info.sample_rate, n_samples / 2,
52-
cfg.buffer_count);
53-
break;
44+
case 1:
45+
dac1.begin(AN_RESOLUTION_12, info.sample_rate, n_samples,
46+
cfg.buffer_count);
47+
break;
48+
case 2:
49+
dac1.begin(AN_RESOLUTION_12, info.sample_rate, n_samples / 2,
50+
cfg.buffer_count);
51+
dac2.begin(AN_RESOLUTION_12, info.sample_rate, n_samples / 2,
52+
cfg.buffer_count);
53+
break;
5454
}
5555
return true;
5656
}
@@ -64,15 +64,12 @@ class AnalogDriverMBED : public AnalogDriverBase {
6464
adc2.stop();
6565
}
6666

67-
int availableForWrite() {
68-
return dac1.available() ? info.buffer_size : 0;
69-
}
67+
int availableForWrite() { return dac1.available() ? info.buffer_size : 0; }
7068

7169
/// writes the data to the I2S interface
7270
size_t write(const uint8_t *src, size_t size_bytes) override {
7371
TRACED();
74-
if (!dac1.available())
75-
return 0;
72+
if (!dac1.available()) return 0;
7673

7774
// collect data in ringbuffer
7875
size_t result = 0;
@@ -101,32 +98,32 @@ class AnalogDriverMBED : public AnalogDriverBase {
10198
int16_t *data = (int16_t *)dest;
10299
size_t samples = size_bytes / 2;
103100
switch (info.channels) {
104-
case 1:
105-
for (int j = 0; j < samples; j++) {
106-
data[j] = adc1.read();
107-
result += 2;
108-
}
109-
break;
110-
case 2:
111-
for (int j = 0; j < samples; j += 2) {
112-
data[j] = adc1.read();
113-
data[j + 1] = adc2.read();
114-
result += 4;
115-
}
116-
break;
101+
case 1:
102+
for (int j = 0; j < samples; j++) {
103+
data[j] = adc1.read();
104+
result += 2;
105+
}
106+
break;
107+
case 2:
108+
for (int j = 0; j < samples; j += 2) {
109+
data[j] = adc1.read();
110+
data[j + 1] =adc2.read();
111+
result += 4;
112+
}
113+
break;
117114
}
118115

119116
// make sure that the center is at 0
120-
if (adc_config.is_auto_center_read){
121-
auto_center.convert(dest, result);
117+
if (info.is_auto_center_read) {
118+
auto_center.convert(dest, result);
122119
}
123120

124121
return result;
125122
}
126123

127124
virtual int available() override { return info.buffer_size; }
128125

129-
protected:
126+
protected:
130127
audio_tools::RingBuffer<Sample> ring_buffer{0};
131128
AnalogConfig info;
132129
ConverterAutoCenter auto_center;
@@ -140,25 +137,25 @@ class AnalogDriverMBED : public AnalogDriverBase {
140137
size_t writeBuffer() {
141138
size_t result = 0;
142139
switch (info.channels) {
143-
case 1: {
144-
SampleBuffer buf = dac1.dequeue();
145-
for (size_t i = 0; i < buf.size(); i++) {
146-
buf[i] = ring_buffer.read();
147-
result += 2;
148-
}
149-
dac1.write(buf);
150-
} break;
151-
case 2: {
152-
SampleBuffer buf1 = dac1.dequeue();
153-
SampleBuffer buf2 = dac2.dequeue();
154-
for (size_t i = 0; i < buf1.size(); i += 2) {
155-
buf1[i] = ring_buffer.read();
156-
buf2[i] = ring_buffer.read();
157-
result += 4;
158-
}
159-
dac1.write(buf1);
160-
dac2.write(buf2);
161-
} break;
140+
case 1: {
141+
SampleBuffer buf = dac1.dequeue();
142+
for (size_t i = 0; i < buf.size(); i++) {
143+
ring_buffer.read(buf[i]);
144+
result += 2;
145+
}
146+
dac1.write(buf);
147+
} break;
148+
case 2: {
149+
SampleBuffer buf1 = dac1.dequeue();
150+
SampleBuffer buf2 = dac2.dequeue();
151+
for (size_t i = 0; i < buf1.size(); i += 2) {
152+
ring_buffer.read(buf1[i]);
153+
ring_buffer.read(buf2[i] );
154+
result += 4;
155+
}
156+
dac1.write(buf1);
157+
dac2.write(buf2);
158+
} break;
162159
}
163160
assert(ring_buffer.isEmpty());
164161
return result;
@@ -168,6 +165,6 @@ class AnalogDriverMBED : public AnalogDriverBase {
168165
/// @brief AnalogAudioStream
169166
using AnalogDriver = AnalogDriverMBED;
170167

171-
} // namespace audio_tools
168+
} // namespace audio_tools
172169

173-
#endif // USE_ANALOG
170+
#endif // USE_ANALOG

src/AudioTools/CoreAudio/GoerzelStream.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#pragma once
2-
#include <math.h>
32

3+
#include <math.h>
44
#include "AudioStreams.h"
55

6+
#ifndef M_PI
7+
# define M_PI (3.14159265358979323846f)
8+
#endif
9+
610
/**
711
* @defgroup dsp DSP
812
* @ingroup main

src/AudioTools/PlatformConfig/giga.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#define USE_TYPETRAITS
1111
#define USE_ANALOG
1212
#define USE_STREAM_WRITE_OVERRIDE
13-
#define ANALOG_BUFFER_SIZE 1024
13+
#ifndef ANALOG_BUFFER_SIZE
14+
# define ANALOG_BUFFER_SIZE 1024
15+
#endif
1416
#define ANALOG_BUFFERS 10
1517
#define USE_URL_ARDUINO
1618
#define USE_AUDIO_SERVER

src/AudioTools/PlatformConfig/portenta.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#define USE_TIMER
1313
#define USE_PWM
1414
#define USE_STREAM_WRITE_OVERRIDE
15-
#define ANALOG_BUFFER_SIZE 1024
15+
#ifndef ANALOG_BUFFER_SIZE
16+
# define ANALOG_BUFFER_SIZE 1024
17+
#endif
1618
#define ANALOG_BUFFERS 10
1719
#define USE_URL_ARDUINO
1820
#define USE_AUDIO_SERVER

src/AudioTools/PlatformConfig/stm32.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
#define SOFT_MUTE_VALUE 0
2626
#define PIN_CS -1
2727

28-
#define USE_ETHERNET
29-
#define USE_URL_ARDUINO
30-
#define USE_AUDIO_SERVER
28+
// Uncomment to activate networking
29+
//#define USE_ETHERNET
30+
//#define USE_URL_ARDUINO
31+
//#define USE_AUDIO_SERVER
3132

0 commit comments

Comments
 (0)