| 6 | are met: |
| 7 |
| 8 | - Redistributions of source code must retain the above copyright |
| 9 | notice, this list of conditions and the following disclaimer. |
| 10 |
| 11 | - Redistributions in binary form must reproduce the above copyright |
| 12 | notice, this list of conditions and the following disclaimer in the |
| 13 | documentation and/or other materials provided with the distribution. |
| 14 |
| 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| 19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 |
| 28 | #ifndef RNNOISE_H |
| 29 | #define RNNOISE_H 1 |
| 30 |
| 31 | #include <stdio.h> |
| 32 |
| 33 | #ifdef __cplusplus |
| 34 | extern "C" { |
| 35 | #endif |
| 36 |
| 37 | #ifndef RNNOISE_EXPORT |
| 38 | # if defined(WIN32) |
| 39 | # if defined(RNNOISE_BUILD) && defined(DLL_EXPORT) |
| 40 | # define RNNOISE_EXPORT __declspec(dllexport) |
| 41 | # else |
| 42 | # define RNNOISE_EXPORT |
| 43 | # endif |
| 44 | # elif defined(__GNUC__) && defined(RNNOISE_BUILD) |
| 45 | # define RNNOISE_EXPORT __attribute__ ((visibility ("default"))) |
| 46 | # else |
| 47 | # define RNNOISE_EXPORT |
| 48 | # endif |
| 49 | #endif |
| 50 |
| 51 | typedef struct DenoiseState DenoiseState; |
| 52 | typedef struct RNNModel RNNModel; |
| 53 |
| 54 | /** |
| 55 | * Return the size of DenoiseState |
| 56 | */ |
| 57 | RNNOISE_EXPORT int rnnoise_get_size(); |
| 58 |
| 59 | /** |
| 60 | * Return the number of samples processed by rnnoise_process_frame at a time |
| 61 | */ |
| 62 | RNNOISE_EXPORT int rnnoise_get_frame_size(); |
| 63 |
| 64 | /** |
| 65 | * Initializes a pre-allocated DenoiseState |
| 66 | * |
| 67 | * If model is NULL the default model is used. |
| 68 | * |
| 69 | * See: rnnoise_create() and rnnoise_model_from_file() |
| 70 | */ |
| 71 | RNNOISE_EXPORT int rnnoise_init(DenoiseState *st, RNNModel *model); |
| 72 |
| 73 | /** |
| 74 | * Allocate and initialize a DenoiseState |
| 75 | * |
| 76 | * If model is NULL the default model is used. |
| 77 | * |
| 78 | * The returned pointer MUST be freed with rnnoise_destroy(). |
| 79 | */ |
| 80 | RNNOISE_EXPORT DenoiseState *rnnoise_create(RNNModel *model); |
| 81 |
| 82 | /** |
| 83 | * Free a DenoiseState produced by rnnoise_create. |
| 84 | * |
| 85 | * The optional custom model must be freed by rnnoise_model_free() after. |
| 86 | */ |
| 87 | RNNOISE_EXPORT void rnnoise_destroy(DenoiseState *st); |
| 88 |
| 89 | /** |
| 90 | * Denoise a frame of samples |
| 91 | * |
| 92 | * in and out must be at least rnnoise_get_frame_size() large. |
| 93 | */ |
| 94 | RNNOISE_EXPORT float rnnoise_process_frame(DenoiseState *st, float *out, const float *in); |
| 95 |
| 96 | /** |
| 97 | * Load a model from a file |
| 98 | * |
| 99 | * It must be deallocated with rnnoise_model_free() |
| 100 | */ |
| 101 | RNNOISE_EXPORT RNNModel *rnnoise_model_from_file(FILE *f); |
| 102 |
| 103 | /** |
| 104 | * Free a custom model |
| 105 | * |
| 106 | * It must be called after all the DenoiseStates referring to it are freed. |
| 107 | */ |
| 108 | RNNOISE_EXPORT void rnnoise_model_free(RNNModel *model); |
| 109 |
| 110 | #ifdef __cplusplus |
| 111 | } |
| 112 | #endif |
| 113 |
| 114 | #endif |
| 115 |