12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #ifndef SIGNALSTATS_WRAPPER_H
- #define SIGNALSTATS_WRAPPER_H
- #include <vector>
- #include <string>
- // #include <pybind11/pybind11.h>
- // #include <pybind11/numpy.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 py = pybind11;
- namespace signalstats_wrapper
- {
- /**
- * @brief 初始化Python解释器
- *
- * 初始化嵌入式Python解释器并设置必要的Python路径。
- * 必须在调用任何Python相关功能前调用此函数。
- */
- EXPORT_API void initialize();
- /**
- * @brief 释放Python解释器
- *
- * 释放嵌入式Python解释器资源。
- * 应在程序结束时调用此函数。
- */
- EXPORT_API void finalize();
- /**
- * @brief C++接口封装函数
- *
- * @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 是否输出调试信息
- */
- EXPORT_API nlohmann::json& detect_signal_wrapper(
- 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_WRAPPER_H
|