12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #ifndef SIGNALSTATS_H
- #define SIGNALSTATS_H
- #include <nlohmann/json.hpp>
- // 定义导出宏
- #ifdef _WIN32
- #ifdef BUILDING_DLL
- #define EXPORT_API __declspec(dllexport)
- #else
- #define EXPORT_API __declspec(dllimport)
- #endif
- #else
- #define EXPORT_API __attribute__((visibility("default")))
- #endif
- namespace signalstats
- {
- /**
- * @brief 初始化
- * 必须在使用前调用此函数。
- *
- * @param debug 是否输出调试信息
- */
- EXPORT_API void initialize(bool debug=false);
- /**
- * @brief 释放资源
- *
- * 应在程序结束时调用此函数。
- */
- EXPORT_API void finalize();
- /**
- * @brief 信号检测
- *
- * @param output 输出结果容器
- * @param audio_signal 音频信号数据(vector)
- * @param audio_samplerate 采样率(Hz)
- * @param silence_threshold 静音检测阈值
- * @param db_threshold 分贝阈值
- * @param cv_threshold 变异系数阈值
- * @param window_params 窗函数参数
- * @param nperseg 每段样本数
- * @param noverlap 重叠样本数
- * @param nfft FFT点数
- * @param debug 是否输出调试信息
- * @return nlohmann::json& 输出结果容器
- */
- EXPORT_API nlohmann::json& detect_signal(
- nlohmann::json &output,
- const std::vector<double> &audio_signal,
- double audio_samplerate,
- double silence_threshold = 3e-3,
- double db_threshold = -70.0,
- double cv_threshold = -70.0,
- const std::vector<std::string> &window_params = {"tukey", "0.25"},
- int nperseg = 256,
- int noverlap = 32,
- int nfft = 256,
- bool debug = false);
- }
- #endif // SIGNALSTATS_H
|