rnnoise-nu.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright (c) 2018 Gregor Richards
  2. * Copyright (c) 2017 Mozilla */
  3. /*
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. - Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  13. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  14. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  15. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  16. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  17. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  20. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #ifndef RNNOISE_NU_H
  25. #define RNNOISE_NU_H 1
  26. #include <stdio.h>
  27. #ifndef RNNOISE_EXPORT
  28. # if defined(WIN32)
  29. # if defined(RNNOISE_BUILD) && defined(DLL_EXPORT)
  30. # define RNNOISE_EXPORT __declspec(dllexport)
  31. # else
  32. # define RNNOISE_EXPORT
  33. # endif
  34. # elif defined(__GNUC__) && defined(RNNOISE_BUILD)
  35. # define RNNOISE_EXPORT __attribute__ ((visibility ("default")))
  36. # else
  37. # define RNNOISE_EXPORT
  38. # endif
  39. #endif
  40. typedef struct DenoiseState DenoiseState;
  41. typedef struct RNNModel RNNModel;
  42. RNNOISE_EXPORT int rnnoise_get_size();
  43. RNNOISE_EXPORT int rnnoise_init(DenoiseState *st, RNNModel *model);
  44. RNNOISE_EXPORT DenoiseState *rnnoise_create(RNNModel *model);
  45. RNNOISE_EXPORT void rnnoise_destroy(DenoiseState *st);
  46. RNNOISE_EXPORT float rnnoise_process_frame(DenoiseState *st, float *out, const float *in);
  47. RNNOISE_EXPORT RNNModel *rnnoise_model_from_file(FILE *f);
  48. RNNOISE_EXPORT void rnnoise_model_free(RNNModel *model);
  49. RNNOISE_EXPORT const char **rnnoise_models(void);
  50. RNNOISE_EXPORT RNNModel *rnnoise_get_model(const char *name);
  51. /* Parameters to a denoise state */
  52. /* RNNOISE_PARAM_MAX_ATTENUATION: The maximum attenuation to perform. Note that
  53. * this is described in terms of *minimum* gain, so for a 20dB maximum
  54. * attenuation, the correct value is 0.01. */
  55. #define RNNOISE_PARAM_MAX_ATTENUATION 1
  56. /* RNNOISE_PARAM_SAMPLE_RATE: Sets the sample rate. This is just used to decide
  57. * how to bin the audio so that it matches the bins in the neural network. This
  58. * does not affect the frame size, which is always 480 samples. */
  59. #define RNNOISE_PARAM_SAMPLE_RATE 2
  60. RNNOISE_EXPORT void rnnoise_set_param(DenoiseState *st, int param, float value);
  61. #endif