Files
2026-10-10 16:03:44 +02:00

28 lines
974 B
C++

#include "../BoomCast_Waveshare_Arduino/boomcast_detector.h"
#include <cstdio>
#include <cstdint>
int main() {
BoomDetector detector(16000, 533, 32000, 16000, 48000,
0.01f, 0.02f, 2.0f, 0.075f, 5.0f, 0.16f);
int16_t sample;
uint64_t frame = 0;
uint64_t listeningStart = 1;
uint64_t captureStart = 0;
while (std::fread(&sample, sizeof(sample), 1, stdin) == 1) {
++frame;
auto result = detector.process(float(sample) / 32768.0f);
if (result == BoomDetector::Result::Trigger) {
captureStart = frame >= listeningStart + 128000 ? frame - 128000 + 1 : listeningStart;
std::printf("T %llu\n", (unsigned long long)frame);
}
if (result == BoomDetector::Result::TailDone) {
std::printf("S %llu\n", (unsigned long long)captureStart);
std::printf("E %llu\n", (unsigned long long)frame);
detector.reset();
listeningStart = frame + 1;
}
}
std::printf("B %.8f\n", detector.baseline());
}