1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #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 信号强度之静音检测阈值(默认-60.0),范围(-100,0],单位dBFS(相对于满量程的分贝)
- * @param db_threshold 能量强度之噪声分贝阈值(默认-70.0),范围[-100,0],单位dB
- * @param cv_threshold 能量强度之变异系数阈值(默认-70.0),范围[-100,0],单位dB
- * @param window_params 窗函数参数,窗函数类型和参数(默认("tukey", 0.25)),alpha (0.0,1.0)
- * @param nperseg 每段样本数(默认256),正整数
- * @param noverlap 重叠样本数(默认32),正整数
- * @param nfft FFT点数(默认256),正整数
- * @return nlohmann::json& 输出结果容器
- */
- EXPORT_API nlohmann::json& detect_signal(
- nlohmann::json &output,
- const std::vector<double> &audio_signal,
- double audio_samplerate,
- double silence_threshold = -60.0,
- 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);
- }
- #endif // SIGNALSTATS_H
|