tmedia_denoise.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2010-2015 Mamadou DIOP.
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. *
  19. */
  20. /**@file tmedia_denoise.h
  21. * @brief Denoiser (Noise suppression, AGC, AEC, VAD) Plugin
  22. */
  23. #ifndef TINYMEDIA_DENOISE_H
  24. #define TINYMEDIA_DENOISE_H
  25. #include "tinymedia_config.h"
  26. #include "tinymedia/tmedia_params.h"
  27. #include "tsk_buffer.h"
  28. #include "tsk_object.h"
  29. TMEDIA_BEGIN_DECLS
  30. /** cast any pointer to @ref tmedia_denoise_t* object */
  31. #define TMEDIA_DENOISE(self) ((tmedia_denoise_t*)(self))
  32. /** Base object for all Denoisers */
  33. typedef struct tmedia_denoise_s {
  34. TSK_DECLARE_OBJECT;
  35. tsk_bool_t opened;
  36. uint32_t echo_tail;
  37. uint32_t echo_skew;
  38. tsk_bool_t echo_supp_enabled;
  39. tsk_bool_t agc_enabled ;
  40. float agc_level;
  41. tsk_bool_t vad_enabled;
  42. tsk_bool_t noise_supp_enabled;
  43. int32_t noise_supp_level;
  44. tsk_buffer_t *record_frame;
  45. tsk_buffer_t *playback_frame;
  46. const struct tmedia_denoise_plugin_def_s* plugin;
  47. }
  48. tmedia_denoise_t;
  49. #define TMEDIA_DECLARE_DENOISE tmedia_denoise_t __denoise__
  50. /** Virtual table used to define a consumer plugin */
  51. typedef struct tmedia_denoise_plugin_def_s {
  52. //! object definition used to create an instance of the denoiser
  53. const tsk_object_def_t* objdef;
  54. //! full description (usefull for debugging)
  55. const char* desc;
  56. int (*set) (tmedia_denoise_t* , const tmedia_param_t*);
  57. int (* open) (tmedia_denoise_t*, uint32_t record_frame_size_samples, uint32_t record_sampling_rate, uint32_t record_channels, uint32_t playback_frame_size_samples, uint32_t playback_sampling_rate, uint32_t playback_channels);
  58. int (*echo_playback) (tmedia_denoise_t* self, const void* echo_frame, uint32_t echo_frame_size_bytes);
  59. //! aec, vad, noise suppression, echo cancellation before sending packet over network
  60. int (* process_record) (tmedia_denoise_t*, void* audio_frame, uint32_t audio_frame_size_bytes, tsk_bool_t* silence_or_noise);
  61. //! noise suppression before playing sound
  62. int (* process_playback) (tmedia_denoise_t*, void* audio_frame, uint32_t audio_frame_size_bytes);
  63. int (* close) (tmedia_denoise_t* );
  64. }
  65. tmedia_denoise_plugin_def_t;
  66. TINYMEDIA_API int tmedia_denoise_init(tmedia_denoise_t* self);
  67. TINYMEDIA_API int tmedia_denoise_set(tmedia_denoise_t* self, const tmedia_param_t* param);
  68. TINYMEDIA_API int tmedia_denoise_open(tmedia_denoise_t* self, uint32_t record_frame_size_samples, uint32_t record_sampling_rate, uint32_t record_channels, uint32_t playback_frame_size_samples, uint32_t playback_sampling_rate, uint32_t playback_channels);
  69. TINYMEDIA_API int tmedia_denoise_echo_playback(tmedia_denoise_t* self, const void* echo_frame, uint32_t echo_frame_size_bytes);
  70. TINYMEDIA_API int tmedia_denoise_process_record(tmedia_denoise_t* self, void* audio_frame, uint32_t audio_frame_size_bytes, tsk_bool_t* silence_or_noise);
  71. TINYMEDIA_API int tmedia_denoise_process_playback(tmedia_denoise_t* self, void* audio_frame, uint32_t audio_frame_size_bytes);
  72. TINYMEDIA_API int tmedia_denoise_close(tmedia_denoise_t* self);
  73. TINYMEDIA_API int tmedia_denoise_deinit(tmedia_denoise_t* self);
  74. TINYMEDIA_API int tmedia_denoise_plugin_register(const tmedia_denoise_plugin_def_t* plugin);
  75. TINYMEDIA_API int tmedia_denoise_plugin_unregister(const tmedia_denoise_plugin_def_t* plugin);
  76. TINYMEDIA_API tmedia_denoise_t* tmedia_denoise_create();
  77. TMEDIA_END_DECLS
  78. #endif /* TINYMEDIA_DENOISE_H */