@geastack/targets 0.1.87 → 0.1.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/targets/esp32/app_project.cmake +18 -1
- package/targets/esp32/chip_bindings/audio/echo_cancellation.cpp +229 -0
- package/targets/esp32/chip_bindings/audio/echo_cancellation.h +13 -0
- package/targets/esp32/chip_bindings/audio/es8311.cpp +293 -45
- package/targets/esp32/chip_bindings/displays/rgb_panel.cpp +115 -12
- package/targets/esp32/chip_bindings/expanders/io_expander.h +2 -0
- package/targets/esp32/chip_bindings/expanders/tca9554.cpp +74 -0
- package/targets/esp32/chip_bindings/touch/ft3168.cpp +23 -1
- package/targets/esp32/chip_bindings/touch/ft3168_controller.h +1 -0
- package/targets/esp32/chip_bindings/touch/gt911.cpp +4 -3
- package/targets/esp32/components/gea_framework/CMakeLists.txt +8 -1
- package/targets/esp32/components/gea_juice/CMakeLists.txt +46 -0
- package/targets/esp32/components/gea_juice/README.md +20 -0
- package/targets/esp32/components/gea_juice/juice_memory.c +19 -0
- package/targets/esp32/components/gea_juice/juice_memory.h +16 -0
- package/targets/esp32/components/gea_juice/patch_threads.py +50 -0
- package/targets/esp32/components/gea_vp8_peer/CMakeLists.txt +16 -0
- package/targets/esp32/components/gea_vp8_peer/README.md +39 -0
- package/targets/esp32/components/gea_vp8_peer/gea_vp8_peer.h +21 -0
- package/targets/esp32/components/gea_vp8_peer/vp8_peer.cpp +538 -0
- package/targets/esp32/components/gea_vpx/CMakeLists.txt +235 -0
- package/targets/esp32/components/gea_vpx/README.md +133 -0
- package/targets/esp32/components/gea_vpx/i420_rgb565_s3.S +169 -0
- package/targets/esp32/components/gea_vpx/vp8_blocks_s3.c +42 -0
- package/targets/esp32/components/gea_vpx/vp8_copy_s3.S +39 -0
- package/targets/esp32/components/gea_vpx/vp8_entropy_s3.c +76 -0
- package/targets/esp32/components/gea_vpx/vp8_filter_s3.S +58 -0
- package/targets/esp32/components/gea_vpx/vp8_idct_s3.S +269 -0
- package/targets/esp32/components/gea_vpx/vp8_intrapred_s3.S +65 -0
- package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.S +333 -0
- package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.c +62 -0
- package/targets/esp32/components/gea_vpx/vp8_profile_s3.c +22 -0
- package/targets/esp32/components/gea_vpx/vp8_profile_s3.h +20 -0
- package/targets/esp32/components/gea_vpx/vp8_s3.c +120 -0
- package/targets/esp32/components/gea_vpx/vp8_s3.h +58 -0
- package/targets/esp32/components/gea_vpx/vp8_workspace_s3.c +14 -0
- package/targets/esp32/components/gea_vpx/vpx_memory.c +41 -0
- package/targets/esp32/connectivity/diagnostics_transport.cpp +18 -0
- package/targets/esp32/connectivity/wifi.cpp +30 -13
- package/targets/esp32/crypto/srtp_hmac_psa.c +118 -0
- package/targets/esp32/display.cpp +21 -0
- package/targets/esp32/gea_framework.cmake +7 -0
- package/targets/esp32/host_sources.cmake +2 -0
- package/targets/esp32/i2c_completion_order.cmake +57 -0
- package/targets/esp32/patch_streaming_dependencies.py +233 -0
- package/targets/esp32/services/device_control.cpp +209 -7
- package/targets/esp32/services/frame_scheduler.cpp +36 -1
- package/targets/esp32/services/opus_benchmark.h +82 -0
- package/targets/esp32/services/pcm_simd_check.h +73 -0
- package/targets/esp32/services/srtp_benchmark.h +106 -0
- package/targets/esp32/services/video_simd_benchmark.h +477 -0
- package/targets/esp32/services/vp8_benchmark.h +147 -0
- package/targets/esp32/streaming_dependency_patches.cmake +103 -0
- package/targets/esp32-m5stack-m5paper/main/idf_component.yml +2 -0
- package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +2 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +2 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +2 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +2 -0
- package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +2 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +2 -0
- package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +2 -0
- package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +2 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +2 -0
- package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +125 -2
- package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +29 -3
- package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +6 -3
- package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +15 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +12 -0
- package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +9 -1
- package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +2 -0
- package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +172 -8
- package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +9 -1
- package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +10 -3
- package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +21 -1
- package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +10 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +7 -0
- package/targets/esp32-s3-touch-amoled-2.41/dependencies.lock +57 -1
- package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +10 -0
- package/targets/esp32-s3-waveshare-touch-lcd-4b.json +504 -0
- package/targets.json +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/targets",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.89",
|
|
4
4
|
"description": "Native embedded build targets (ESP32-IDF, RP2350) for geastack apps: board sources, target catalog, and CMake glue driven by the gea CLI.",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@geastack/chips": "^0.1.
|
|
39
|
+
"@geastack/chips": "^0.1.5",
|
|
40
40
|
"@geastack/compiler": "^1.0.20",
|
|
41
|
-
"@geastack/core": "^0.1.
|
|
42
|
-
"@geastack/elements": "^0.1.
|
|
43
|
-
"@geastack/engine": "^0.1.
|
|
41
|
+
"@geastack/core": "^0.1.34",
|
|
42
|
+
"@geastack/elements": "^0.1.4",
|
|
43
|
+
"@geastack/engine": "^0.1.9",
|
|
44
44
|
"@geastack/geaos": "^0.1.3",
|
|
45
|
-
"@geastack/geatsc-plugin-gea": "^0.1.
|
|
46
|
-
"@geastack/host": "^0.1.
|
|
45
|
+
"@geastack/geatsc-plugin-gea": "^0.1.15",
|
|
46
|
+
"@geastack/host": "^0.1.13"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"test": "for f in $(git ls-files | grep -E '(^|/)(test[-_][^/]*|[^/]*\\.test)\\.mjs$'); do echo \"==> $f\"; node \"$f\" || exit 1; done"
|
|
@@ -18,6 +18,14 @@ foreach(_GEA_APP_COMPONENT_DIR IN LISTS GEA_EMBEDDED_APP_COMPONENT_DIRS)
|
|
|
18
18
|
list(APPEND EXTRA_COMPONENT_DIRS "${_GEA_APP_COMPONENT_DIR}")
|
|
19
19
|
endforeach()
|
|
20
20
|
|
|
21
|
+
# ESP-SR is needed only by apps opting into the shared audio echo canceller.
|
|
22
|
+
# Derive this before IDF resolves managed dependencies, including its script pass.
|
|
23
|
+
set(_GEA_AUDIO_DEFINES "${GEA_EMBEDDED_APP_DEFINES};$ENV{GEA_EMBEDDED_APP_DEFINES}")
|
|
24
|
+
set(ENV{GEA_EMBEDDED_CAPABILITY_AEC} "0")
|
|
25
|
+
if(";${_GEA_AUDIO_DEFINES};" MATCHES ";GEA_AUDIO_ECHO_CANCELLATION=1;")
|
|
26
|
+
set(ENV{GEA_EMBEDDED_CAPABILITY_AEC} "1")
|
|
27
|
+
endif()
|
|
28
|
+
|
|
21
29
|
# The managed-dependency manifests (main/idf_component.yml) gate the registry
|
|
22
30
|
# components that belong to one capability -- the codec, the WebSocket client,
|
|
23
31
|
# the WebRTC peer -- on these variables, and the component manager treats an
|
|
@@ -28,6 +36,15 @@ endforeach()
|
|
|
28
36
|
foreach(_GEA_CAPABILITY NETWORK BLE AUDIO)
|
|
29
37
|
if(NOT DEFINED ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}
|
|
30
38
|
OR "$ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}" STREQUAL "")
|
|
31
|
-
|
|
39
|
+
# Incremental Ninja/CMake reconfiguration does not inherit the CLI's
|
|
40
|
+
# original environment. Keep its cached analysis instead of silently
|
|
41
|
+
# enabling BLE (and consuming the audio DMA heap) on the next build.
|
|
42
|
+
if(DEFINED CACHE{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}
|
|
43
|
+
AND NOT "$CACHE{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}" STREQUAL "")
|
|
44
|
+
set(ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}
|
|
45
|
+
"$CACHE{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}")
|
|
46
|
+
else()
|
|
47
|
+
set(ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}} "1")
|
|
48
|
+
endif()
|
|
32
49
|
endif()
|
|
33
50
|
endforeach()
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Official Espressif ESP-SR AEC; adapter only, no custom cancellation DSP.
|
|
2
|
+
#include "echo_cancellation.h"
|
|
3
|
+
#include "esp_aec.h"
|
|
4
|
+
#include "esp_heap_caps.h"
|
|
5
|
+
#include "esp_log.h"
|
|
6
|
+
#include "esp_timer.h"
|
|
7
|
+
#include "freertos/FreeRTOS.h"
|
|
8
|
+
#include <algorithm>
|
|
9
|
+
#include <atomic>
|
|
10
|
+
#include <cmath>
|
|
11
|
+
#include <cstdint>
|
|
12
|
+
#include <cstdio>
|
|
13
|
+
#include <cstring>
|
|
14
|
+
#include <mutex>
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
constexpr uint32_t kMaxFrame = 512, kDmaFrames = 240, kCaptureRing = 1024;
|
|
18
|
+
portMUX_TYPE dmaMux = portMUX_INITIALIZER_UNLOCKED;
|
|
19
|
+
int16_t dmaMic[kCaptureRing]{}, dmaRef[kCaptureRing]{};
|
|
20
|
+
int16_t previousMic[kDmaFrames]{}, latestTx[kDmaFrames]{}, captureRef[320]{};
|
|
21
|
+
uint32_t dmaWritten = 0, dmaRead = 0, dmaDrops = 0;
|
|
22
|
+
bool dmaActive = false, previousMicReady = false;
|
|
23
|
+
bool hardwareReference = false;
|
|
24
|
+
float outputGain = 1.0f;
|
|
25
|
+
std::mutex aecMutex;
|
|
26
|
+
aec_handle_t *aec = nullptr;
|
|
27
|
+
alignas(16) int16_t mic[kMaxFrame], ref[kMaxFrame], clean[kMaxFrame], linear[kMaxFrame],
|
|
28
|
+
output[kMaxFrame * 2];
|
|
29
|
+
size_t fill = 0, frameSize = 0;
|
|
30
|
+
|
|
31
|
+
uint64_t rawEnergy = 0, cleanEnergy = 0, linearEnergy = 0, refEnergy = 0, totalSamples = 0;
|
|
32
|
+
int64_t logAt = 0, processUs = 0;
|
|
33
|
+
uint32_t processedFrames = 0, clippedSamples = 0, clippedReferenceSamples = 0;
|
|
34
|
+
int rawPeak = 0, cleanPeak = 0, referencePeak = 0;
|
|
35
|
+
} // namespace
|
|
36
|
+
|
|
37
|
+
bool geaAudioAecStart(bool useHardwareReference, float gain, bool aggressiveNlp) {
|
|
38
|
+
std::lock_guard<std::mutex> lock(aecMutex);
|
|
39
|
+
if (aec)
|
|
40
|
+
return true;
|
|
41
|
+
if (!std::isfinite(gain) || gain <= 0)
|
|
42
|
+
return false;
|
|
43
|
+
outputGain = gain;
|
|
44
|
+
aec_config_t config{};
|
|
45
|
+
config.mic_num = 1;
|
|
46
|
+
config.ref_num = 1;
|
|
47
|
+
config.out_num = 1;
|
|
48
|
+
config.filter_length = 4;
|
|
49
|
+
config.sample_rate = 16000;
|
|
50
|
+
config.caps = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT;
|
|
51
|
+
config.mode = AEC_MODE_FD_HIGH_PERF;
|
|
52
|
+
// Select residual echo suppression independently of the output gain.
|
|
53
|
+
config.nlp_level = aggressiveNlp ? AEC_NLP_LEVEL_AGGR : AEC_NLP_LEVEL_NORMAL;
|
|
54
|
+
aec = aec_create_from_config(&config);
|
|
55
|
+
if (!aec) {
|
|
56
|
+
ESP_LOGE("gea_aec", "ESP-SR AEC allocation failed");
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
frameSize = aec_get_chunksize(aec);
|
|
60
|
+
if (!frameSize || frameSize > kMaxFrame) {
|
|
61
|
+
ESP_LOGE("gea_aec", "Unsupported AEC frame size %u", unsigned(frameSize));
|
|
62
|
+
aec_destroy(aec);
|
|
63
|
+
aec = nullptr;
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
fill = 0;
|
|
67
|
+
portENTER_CRITICAL(&dmaMux);
|
|
68
|
+
dmaWritten = dmaRead = dmaDrops = 0;
|
|
69
|
+
previousMicReady = false;
|
|
70
|
+
hardwareReference = useHardwareReference;
|
|
71
|
+
std::memset(latestTx, 0, sizeof(latestTx));
|
|
72
|
+
dmaActive = true;
|
|
73
|
+
portEXIT_CRITICAL(&dmaMux);
|
|
74
|
+
rawEnergy = cleanEnergy = linearEnergy = refEnergy = totalSamples = 0;
|
|
75
|
+
processUs = processedFrames = clippedSamples = clippedReferenceSamples = 0;
|
|
76
|
+
rawPeak = cleanPeak = referencePeak = 0;
|
|
77
|
+
logAt = esp_timer_get_time();
|
|
78
|
+
ESP_LOGI("gea_aec",
|
|
79
|
+
"ESP-SR full-duplex high-performance AEC ready: rate=16000 frame=%u NLP=%s "
|
|
80
|
+
"reference=%s internal_free=%u",
|
|
81
|
+
unsigned(frameSize), aggressiveNlp ? "aggressive" : "normal",
|
|
82
|
+
hardwareReference ? "ADC" : "TX-DMA",
|
|
83
|
+
unsigned(heap_caps_get_free_size(MALLOC_CAP_INTERNAL)));
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void geaAudioAecStop() {
|
|
88
|
+
std::lock_guard<std::mutex> lock(aecMutex);
|
|
89
|
+
portENTER_CRITICAL(&dmaMux);
|
|
90
|
+
dmaActive = false;
|
|
91
|
+
portEXIT_CRITICAL(&dmaMux);
|
|
92
|
+
if (aec) {
|
|
93
|
+
aec_destroy(aec);
|
|
94
|
+
aec = nullptr;
|
|
95
|
+
}
|
|
96
|
+
fill = 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The RX/TX callbacks run on the I2S clock, independently of task scheduling.
|
|
100
|
+
// Retain one RX block so the reference always precedes its acoustic echo.
|
|
101
|
+
void geaAudioAecReference(const int16_t *pcm, size_t count) {
|
|
102
|
+
portENTER_CRITICAL_ISR(&dmaMux);
|
|
103
|
+
if (dmaActive && count == kDmaFrames)
|
|
104
|
+
std::memcpy(latestTx, pcm, sizeof(latestTx));
|
|
105
|
+
else if (dmaActive && count == kDmaFrames * 2) {
|
|
106
|
+
for (size_t i = 0; i < kDmaFrames; ++i)
|
|
107
|
+
latestTx[i] = int16_t((int32_t(pcm[i * 2]) + pcm[i * 2 + 1]) / 2);
|
|
108
|
+
}
|
|
109
|
+
portEXIT_CRITICAL_ISR(&dmaMux);
|
|
110
|
+
}
|
|
111
|
+
void geaAudioAecReceive(const int16_t *stereo, size_t count) {
|
|
112
|
+
portENTER_CRITICAL_ISR(&dmaMux);
|
|
113
|
+
if (dmaActive && count == kDmaFrames * 2) {
|
|
114
|
+
if (hardwareReference) {
|
|
115
|
+
// ES7210 analog loopback or ES8311 ADCL + DACR arrive in the same RX
|
|
116
|
+
// frame. Keep them paired across callback/task scheduling jitter.
|
|
117
|
+
if (dmaWritten - dmaRead + kDmaFrames > kCaptureRing) {
|
|
118
|
+
dmaRead = dmaWritten;
|
|
119
|
+
++dmaDrops;
|
|
120
|
+
}
|
|
121
|
+
for (size_t i = 0; i < kDmaFrames; ++i) {
|
|
122
|
+
dmaMic[(dmaWritten + i) % kCaptureRing] = stereo[i * 2];
|
|
123
|
+
dmaRef[(dmaWritten + i) % kCaptureRing] = stereo[i * 2 + 1];
|
|
124
|
+
}
|
|
125
|
+
dmaWritten += kDmaFrames;
|
|
126
|
+
portEXIT_CRITICAL_ISR(&dmaMux);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (previousMicReady) {
|
|
130
|
+
if (dmaWritten - dmaRead + kDmaFrames > kCaptureRing) {
|
|
131
|
+
dmaRead = dmaWritten;
|
|
132
|
+
++dmaDrops;
|
|
133
|
+
}
|
|
134
|
+
for (size_t i = 0; i < kDmaFrames; ++i) {
|
|
135
|
+
dmaMic[(dmaWritten + i) % kCaptureRing] = previousMic[i];
|
|
136
|
+
dmaRef[(dmaWritten + i) % kCaptureRing] = latestTx[i];
|
|
137
|
+
}
|
|
138
|
+
dmaWritten += kDmaFrames;
|
|
139
|
+
}
|
|
140
|
+
for (size_t i = 0; i < kDmaFrames; ++i)
|
|
141
|
+
previousMic[i] = stereo[i * 2];
|
|
142
|
+
previousMicReady = true;
|
|
143
|
+
}
|
|
144
|
+
portEXIT_CRITICAL_ISR(&dmaMux);
|
|
145
|
+
}
|
|
146
|
+
bool geaAudioAecRead(int16_t *pcm, size_t count) {
|
|
147
|
+
if (count > 320)
|
|
148
|
+
return false;
|
|
149
|
+
portENTER_CRITICAL(&dmaMux);
|
|
150
|
+
const bool ready = dmaActive && dmaWritten - dmaRead >= count;
|
|
151
|
+
if (ready) {
|
|
152
|
+
for (size_t i = 0; i < count; ++i) {
|
|
153
|
+
pcm[i] = dmaMic[(dmaRead + i) % kCaptureRing];
|
|
154
|
+
captureRef[i] = dmaRef[(dmaRead + i) % kCaptureRing];
|
|
155
|
+
}
|
|
156
|
+
dmaRead += count;
|
|
157
|
+
}
|
|
158
|
+
portEXIT_CRITICAL(&dmaMux);
|
|
159
|
+
return ready;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
size_t geaAudioAecProcess(const int16_t *pcm, size_t count,
|
|
163
|
+
const int16_t **result) {
|
|
164
|
+
std::lock_guard<std::mutex> lock(aecMutex);
|
|
165
|
+
*result = output;
|
|
166
|
+
if (!aec)
|
|
167
|
+
return 0; // Never silently forward uncancelled audio after an AEC failure.
|
|
168
|
+
size_t produced = 0;
|
|
169
|
+
for (size_t i = 0; i < count; ++i) {
|
|
170
|
+
mic[fill] = pcm[i];
|
|
171
|
+
ref[fill] = captureRef[i];
|
|
172
|
+
if (++fill == frameSize) {
|
|
173
|
+
for (size_t j = 0; j < frameSize; ++j) {
|
|
174
|
+
rawPeak = std::max(rawPeak, std::abs(int(mic[j])));
|
|
175
|
+
referencePeak = std::max(referencePeak, std::abs(int(ref[j])));
|
|
176
|
+
clippedSamples += std::abs(int(mic[j])) >= 32760;
|
|
177
|
+
clippedReferenceSamples += std::abs(int(ref[j])) >= 32760;
|
|
178
|
+
rawEnergy += int64_t(mic[j]) * mic[j];
|
|
179
|
+
refEnergy += int64_t(ref[j]) * ref[j];
|
|
180
|
+
}
|
|
181
|
+
auto before = esp_timer_get_time();
|
|
182
|
+
// ESP-SR's documented two-stage API preserves both cancellation stages.
|
|
183
|
+
// Snapshot the linear result so telemetry can identify suppression of
|
|
184
|
+
// near-end speech separately from cancellation of the speaker echo.
|
|
185
|
+
aec_linear_process(aec, mic, ref, clean);
|
|
186
|
+
std::memcpy(linear, clean, frameSize * sizeof(int16_t));
|
|
187
|
+
aec_nlp_process(aec, clean);
|
|
188
|
+
processUs += esp_timer_get_time() - before;
|
|
189
|
+
++processedFrames;
|
|
190
|
+
for (size_t j = 0; j < frameSize; ++j) {
|
|
191
|
+
linearEnergy += int64_t(linear[j]) * linear[j];
|
|
192
|
+
cleanEnergy += int64_t(clean[j]) * clean[j];
|
|
193
|
+
cleanPeak = std::max(cleanPeak, std::abs(int(clean[j])));
|
|
194
|
+
}
|
|
195
|
+
totalSamples += frameSize;
|
|
196
|
+
// Apply the board's calibrated voice gain after AEC, keeping the ADC
|
|
197
|
+
// unclipped. Unity-gain boards retain the direct copy. Never gate speech.
|
|
198
|
+
if (outputGain == 1.0f) {
|
|
199
|
+
std::memcpy(output + produced, clean, frameSize * sizeof(int16_t));
|
|
200
|
+
} else {
|
|
201
|
+
for (size_t j = 0; j < frameSize; ++j) {
|
|
202
|
+
const float amplified = clean[j] * outputGain;
|
|
203
|
+
output[produced + j] = int16_t(std::lround(std::clamp(amplified, -32768.0f, 32767.0f)));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
produced += frameSize;
|
|
207
|
+
fill = 0;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const auto now = esp_timer_get_time();
|
|
211
|
+
if (now - logAt >= 1000000 && totalSamples) {
|
|
212
|
+
ESP_LOGI("gea_aec",
|
|
213
|
+
"raw_rms=%.0f clean_rms=%.0f ref_rms=%.0f linear_rms=%.0f reduction_db=%.1f "
|
|
214
|
+
"process_us=%lld dma_drops=%lu clipped=%lu ref_clipped=%lu raw_peak=%d clean_peak=%d ref_peak=%d",
|
|
215
|
+
std::sqrt(double(rawEnergy) / totalSamples),
|
|
216
|
+
std::sqrt(double(cleanEnergy) / totalSamples),
|
|
217
|
+
std::sqrt(double(refEnergy) / totalSamples),
|
|
218
|
+
std::sqrt(double(linearEnergy) / totalSamples),
|
|
219
|
+
10 * std::log10(double(rawEnergy + 1) / double(cleanEnergy + 1)),
|
|
220
|
+
(long long)(processUs / std::max<uint32_t>(1, processedFrames)),
|
|
221
|
+
(unsigned long)dmaDrops, (unsigned long)clippedSamples,
|
|
222
|
+
(unsigned long)clippedReferenceSamples, rawPeak, cleanPeak, referencePeak);
|
|
223
|
+
rawEnergy = cleanEnergy = linearEnergy = refEnergy = totalSamples = 0;
|
|
224
|
+
rawPeak = cleanPeak = referencePeak = 0;
|
|
225
|
+
processUs = processedFrames = clippedSamples = clippedReferenceSamples = 0;
|
|
226
|
+
logAt = now;
|
|
227
|
+
}
|
|
228
|
+
return produced;
|
|
229
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cstddef>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
|
|
6
|
+
bool geaAudioAecStart(bool hardwareReference = false, float outputGain = 1.0f,
|
|
7
|
+
bool aggressiveNlp = true);
|
|
8
|
+
void geaAudioAecStop();
|
|
9
|
+
void geaAudioAecReference(const int16_t *pcm, size_t count);
|
|
10
|
+
void geaAudioAecReceive(const int16_t *stereo, size_t count);
|
|
11
|
+
bool geaAudioAecRead(int16_t *pcm, size_t count);
|
|
12
|
+
size_t geaAudioAecProcess(const int16_t *pcm, size_t count,
|
|
13
|
+
const int16_t **result);
|