iOS webRTCオーディオノイズ低減


オーディオノイズ低減機能
https://download.csdn.net/download/ffffuckyou/11227044インポートnoise_suppression.hとnoise_suppression.cは工事の中に着いて、#include“noise_suppression.h”、それから次のc関数を呼び出します
パラメータ説明bufferノイズ低減オーディオbuf sampleRateオーディオサンプリング率samplesCountオーディオビット数int levelノイズ低減レベル0-3最高3
int nsProcess(int16_t *buffer, uint32_t sampleRate ,int samplesCount, int level)
{
    if (buffer == 0) return -1;
    if (samplesCount == 0) return -1;
    size_t samples = MIN(160, sampleRate / 100);
    if (samples == 0) return -1;
    uint32_t num_bands = 1;
    int16_t *input = buffer;
    size_t nTotal = (samplesCount / samples);
    NsHandle *nsHandle = WebRtcNs_Create();
    int status = WebRtcNs_Init(nsHandle, sampleRate);
    if (status != 0) {
        printf("WebRtcNs_Init fail
"); return -1; } status = WebRtcNs_set_policy(nsHandle, level); if (status != 0) { printf("WebRtcNs_set_policy fail
"); return -1; } for (int i = 0; i < nTotal; i++) { int16_t *nsIn[1] = {input}; //ns input[band][data] int16_t *nsOut[1] = {input}; //ns output[band][data] WebRtcNs_Analyze(nsHandle, nsIn[0]); WebRtcNs_Process(nsHandle, (const int16_t *const *) nsIn, num_bands, nsOut); input += samples; } WebRtcNs_Free(nsHandle); return 1; }