noiseTest.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef SIGNALSTATS_WRAPPER_H
  2. #define SIGNALSTATS_WRAPPER_H
  3. #include <vector>
  4. #include <string>
  5. #include <nlohmann/json.hpp>
  6. // 定义导出宏
  7. #ifdef _WIN32
  8. #ifdef BUILDING_DLL
  9. #define EXPORT_API __declspec(dllexport)
  10. #else
  11. #define EXPORT_API __declspec(dllimport)
  12. #endif
  13. #else
  14. #define EXPORT_API __attribute__((visibility("default")))
  15. #endif
  16. namespace signalstats_wrapper
  17. {
  18. /**
  19. * @brief 初始化Python解释器
  20. *
  21. * 初始化嵌入式Python解释器并设置必要的Python路径。
  22. * 必须在调用任何Python相关功能前调用此函数。
  23. */
  24. EXPORT_API void initialize();
  25. /**
  26. * @brief 释放Python解释器
  27. *
  28. * 释放嵌入式Python解释器资源。
  29. * 应在程序结束时调用此函数。
  30. */
  31. EXPORT_API void finalize();
  32. /**
  33. * @brief C++接口封装函数
  34. *
  35. * @param audio_signal 音频信号数据(vector)
  36. * @param audio_samplerate 采样率(Hz)
  37. * @param silence_threshold 静音检测阈值
  38. * @param db_threshold 分贝阈值
  39. * @param cv_threshold 变异系数阈值
  40. * @param window_params 窗函数参数
  41. * @param nperseg 每段样本数
  42. * @param noverlap 重叠样本数
  43. * @param nfft FFT点数
  44. * @param debug 是否输出调试信息
  45. * @param output 输出结果容器
  46. */
  47. EXPORT_API nlohmann::json& detect_signal_wrapper(
  48. const std::vector<double> &audio_signal,
  49. double audio_samplerate,
  50. double silence_threshold,
  51. double db_threshold,
  52. double cv_threshold,
  53. const std::vector<std::string> &window_params,
  54. int nperseg,
  55. int noverlap,
  56. int nfft,
  57. bool debug,
  58. nlohmann::json &output);
  59. }
  60. #endif // SIGNALSTATS_WRAPPER_H