From 8135a5195f6b5794a6ee5c2c0ffa76c9d5273897 Mon Sep 17 00:00:00 2001 From: FrancoisGrondin Date: Wed, 1 Nov 2017 14:02:23 -0400 Subject: [PATCH] Bugs fixed --- src/module/mod_noise.c | 2 + src/module/mod_resample.c | 14 +- src/module/mod_resample.h | 2 +- src/module/mod_ssl.c | 50 ++- src/module/mod_ssl.h | 15 +- src/module/mod_sss.c | 8 +- src/sink/snk_hops.c | 17 +- src/system/demixing2env.c | 82 ++++ src/system/demixing2env.h | 28 ++ src/system/env2env.c | 832 ++++++++++++++++++++++++++++++++++--- src/system/env2env.h | 116 +++++- src/system/freq2freq.c | 131 +++++- src/system/freq2freq.h | 67 ++- src/utils/transcendental.c | 72 ++++ src/utils/transcendental.h | 26 ++ 15 files changed, 1310 insertions(+), 152 deletions(-) create mode 100644 src/system/demixing2env.c create mode 100644 src/system/demixing2env.h create mode 100644 src/utils/transcendental.c create mode 100644 src/utils/transcendental.h diff --git a/src/module/mod_noise.c b/src/module/mod_noise.c index 1dad394..0ea5be9 100644 --- a/src/module/mod_noise.c +++ b/src/module/mod_noise.c @@ -46,7 +46,9 @@ obj->envs); env2env_mcra_process(obj->env2env_mcra, + NULL, obj->envs, + NULL, obj->out->envs); obj->out->timeStamp = obj->in->timeStamp; diff --git a/src/module/mod_resample.c b/src/module/mod_resample.c index 1063704..07d0ee8 100644 --- a/src/module/mod_resample.c +++ b/src/module/mod_resample.c @@ -41,7 +41,7 @@ obj->framesAnalysis = frames_construct_zero(obj->nChannels, obj->frameSize); obj->frame2freq = frame2freq_construct_zero(obj->frameSize, obj->halfFrameSize); obj->freqsAnalysis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); - obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, 0, obj->lowPassCut, 0.0f, 0.0f, 0.0f, 0.0f); + obj->freq2freq_lowpass = freq2freq_lowpass_construct_zero(obj->halfFrameSize, obj->lowPassCut); obj->freqsSynthesis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); obj->freq2frame = freq2frame_construct_zero(obj->frameSize, obj->halfFrameSize); obj->framesSynthesis = frames_construct_zero(obj->nChannels, obj->frameSize); @@ -62,7 +62,7 @@ obj->framesAnalysis = frames_construct_zero(obj->nChannels, obj->frameSize); obj->frame2freq = frame2freq_construct_zero(obj->frameSize, obj->halfFrameSize); obj->freqsAnalysis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); - obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, 0, obj-> lowPassCut, 0.0f, 0.0f, 0.0f, 0.0f); + obj->freq2freq_lowpass = freq2freq_lowpass_construct_zero(obj->halfFrameSize, obj-> lowPassCut); obj->freqsSynthesis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); obj->freq2frame = freq2frame_construct_zero(obj->frameSize, obj->halfFrameSize); obj->framesSynthesis = frames_construct_zero(obj->nChannels, obj->frameSize); @@ -83,7 +83,7 @@ obj->framesAnalysis = (frames_obj *) NULL; obj->frame2freq = (frame2freq_obj *) NULL; obj->freqsAnalysis = (freqs_obj *) NULL; - obj->freq2freq = (freq2freq_obj *) NULL; + obj->freq2freq_lowpass = (freq2freq_lowpass_obj *) NULL; obj->freqsSynthesis = (freqs_obj *) NULL; obj->freq2frame = (freq2frame_obj *) NULL; obj->framesSynthesis = (frames_obj *) NULL; @@ -123,8 +123,8 @@ freqs_destroy(obj->freqsAnalysis); } - if (obj->freq2freq != NULL) { - freq2freq_destroy(obj->freq2freq); + if (obj->freq2freq_lowpass != NULL) { + freq2freq_lowpass_destroy(obj->freq2freq_lowpass); } if (obj->freqsSynthesis != NULL) { @@ -227,7 +227,7 @@ obj->framesAnalysis, obj->freqsAnalysis); - freq2freq_process_lowpass(obj->freq2freq, + freq2freq_lowpass_process(obj->freq2freq_lowpass, obj->freqsAnalysis, obj->freqsSynthesis); @@ -373,7 +373,7 @@ obj->framesAnalysis, obj->freqsAnalysis); - freq2freq_process_lowpass(obj->freq2freq, + freq2freq_lowpass_process(obj->freq2freq_lowpass, obj->freqsAnalysis, obj->freqsSynthesis); diff --git a/src/module/mod_resample.h b/src/module/mod_resample.h index 45f7b58..f2b28b7 100644 --- a/src/module/mod_resample.h +++ b/src/module/mod_resample.h @@ -42,7 +42,7 @@ frames_obj * framesAnalysis; frame2freq_obj * frame2freq; freqs_obj * freqsAnalysis; - freq2freq_obj * freq2freq; + freq2freq_lowpass_obj * freq2freq_lowpass; freqs_obj * freqsSynthesis; freq2frame_obj * freq2frame; frames_obj * framesSynthesis; diff --git a/src/module/mod_ssl.c b/src/module/mod_ssl.c index 07f0c9d..9db1b94 100644 --- a/src/module/mod_ssl.c +++ b/src/module/mod_ssl.c @@ -36,20 +36,20 @@ mod_ssl_config->gainMin, mod_ssl_config->interpRate); - obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, - obj->halfFrameSizeInterp, - 0, - mod_ssl_config->epsilon, - 0.0f, - 0.0f, - 0.0f); + obj->freq2freq_phasor = freq2freq_phasor_construct_zero(obj->halfFrameSize, + mod_ssl_config->epsilon); obj->phasors = freqs_construct_zero(mod_ssl_config->mics->nChannels, msg_spectra_config->halfFrameSize); + obj->freq2freq_product = freq2freq_product_construct_zero(obj->halfFrameSize); + obj->products = freqs_construct_zero(mod_ssl_config->mics->nPairs, msg_spectra_config->halfFrameSize); + obj->freq2freq_interpolate = freq2freq_interpolate_construct_zero(obj->halfFrameSize, + obj->halfFrameSizeInterp); + obj->productsInterp = freqs_construct_zero(mod_ssl_config->mics->nPairs, obj->halfFrameSizeInterp); @@ -82,10 +82,11 @@ obj->pots = pots_construct_zero(msg_pots_config->nPots); - obj->in1 = (msg_spectra_obj *) NULL; - obj->in2 = (msg_powers_obj *) NULL; + obj->in = (msg_spectra_obj *) NULL; obj->out = (msg_pots_obj *) NULL; + //obj->tmpFile = fopen("weights.bin","wb"); + return obj; } @@ -95,9 +96,13 @@ unsigned int iLevel; unsigned int iPot; + //fclose(obj->tmpFile); + scans_destroy(obj->scans); - freq2freq_destroy(obj->freq2freq); + freq2freq_phasor_destroy(obj->freq2freq_phasor); + freq2freq_product_destroy(obj->freq2freq_product); + freq2freq_interpolate_destroy(obj->freq2freq_interpolate); freqs_destroy(obj->phasors); freqs_destroy(obj->products); freqs_destroy(obj->productsInterp); @@ -135,24 +140,19 @@ float maxValue; unsigned int maxIndex; - if (obj->in1->timeStamp != obj->in2->timeStamp) { - printf("Time stamp mismatch.\n"); - exit(EXIT_FAILURE); - } - - if (msg_spectra_isZero(obj->in1) == 0) { + if (msg_spectra_isZero(obj->in) == 0) { - freq2freq_process_phasor(obj->freq2freq, - obj->in1->freqs, + freq2freq_phasor_process(obj->freq2freq_phasor, + obj->in->freqs, obj->phasors); - freq2freq_process_product(obj->freq2freq, + freq2freq_product_process(obj->freq2freq_product, obj->phasors, obj->phasors, obj->scans->pairs, obj->products); - freq2freq_process_interpolate(obj->freq2freq, + freq2freq_interpolate_process(obj->freq2freq_interpolate, obj->products, obj->productsInterp); @@ -217,7 +217,7 @@ memcpy(obj->out->pots->array, obj->pots->array, sizeof(float) * obj->pots->nPots * 4); - obj->out->timeStamp = obj->in1->timeStamp; + obj->out->timeStamp = obj->in->timeStamp; rtnValue = 0; @@ -234,18 +234,16 @@ } - void mod_ssl_connect(mod_ssl_obj * obj, msg_spectra_obj * in1, msg_powers_obj * in2, msg_pots_obj * out) { + void mod_ssl_connect(mod_ssl_obj * obj, msg_spectra_obj * in, msg_pots_obj * out) { - obj->in1 = in1; - obj->in2 = in2; + obj->in = in; obj->out = out; } void mod_ssl_disconnect(mod_ssl_obj * obj) { - obj->in1 = (msg_spectra_obj *) NULL; - obj->in2 = (msg_powers_obj *) NULL; + obj->in = (msg_spectra_obj *) NULL; obj->out = (msg_pots_obj *) NULL; } diff --git a/src/module/mod_ssl.h b/src/module/mod_ssl.h index 3ec310c..74344f9 100644 --- a/src/module/mod_ssl.h +++ b/src/module/mod_ssl.h @@ -10,9 +10,12 @@ #include "../general/spatialfilter.h" #include "../signal/aimg.h" + #include "../signal/env.h" #include "../signal/freq.h" #include "../signal/xcorr.h" + #include "../system/env2env.h" + #include "../system/freq2env.h" #include "../system/freq2freq.h" #include "../system/freq2xcorr.h" #include "../system/xcorr2aimg.h" @@ -44,8 +47,11 @@ freqs_obj * productsInterp; xcorrs_obj * xcorrs; xcorrs_obj * xcorrsMax; - - freq2freq_obj * freq2freq; + + freq2env_obj * freq2env; + freq2freq_phasor_obj * freq2freq_phasor; + freq2freq_product_obj * freq2freq_product; + freq2freq_interpolate_obj * freq2freq_interpolate; freq2xcorr_obj * freq2xcorr; xcorr2xcorr_obj * xcorr2xcorr; @@ -54,8 +60,7 @@ pots_obj * pots; - msg_spectra_obj * in1; - msg_powers_obj * in2; + msg_spectra_obj * in; msg_pots_obj * out; } mod_ssl_obj; @@ -86,7 +91,7 @@ int mod_ssl_process(mod_ssl_obj * obj); - void mod_ssl_connect(mod_ssl_obj * obj, msg_spectra_obj * in1, msg_powers_obj * in2, msg_pots_obj * out); + void mod_ssl_connect(mod_ssl_obj * obj, msg_spectra_obj * in, msg_pots_obj * out); void mod_ssl_disconnect(mod_ssl_obj * obj); diff --git a/src/module/mod_sss.c b/src/module/mod_sss.c index cb6b50f..557ecad 100644 --- a/src/module/mod_sss.c +++ b/src/module/mod_sss.c @@ -221,7 +221,7 @@ int rtnValue; - if ((msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in2)) || + if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) || (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) { printf("Time stamp mismatch.\n"); @@ -288,7 +288,7 @@ int rtnValue; - if ((msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in2)) || + if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) || (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) { printf("Time stamp mismatch.\n"); @@ -342,7 +342,7 @@ int rtnValue; - if ((msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in2)) || + if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) || (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) { printf("Time stamp mismatch.\n"); @@ -386,7 +386,7 @@ int rtnValue; - if ((msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in2)) || + if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) || (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) { printf("Time stamp mismatch.\n"); diff --git a/src/sink/snk_hops.c b/src/sink/snk_hops.c index b54b31d..3536264 100644 --- a/src/sink/snk_hops.c +++ b/src/sink/snk_hops.c @@ -304,12 +304,12 @@ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - nBytesTotal += nBytes; - sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + nBytesTotal += nBytes; + } } @@ -333,12 +333,13 @@ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - nBytesTotal += nBytes; - sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + nBytesTotal += nBytes; + + } } @@ -362,12 +363,12 @@ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - nBytesTotal += nBytes; - sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + nBytesTotal += nBytes; + } } @@ -391,12 +392,12 @@ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - nBytesTotal += nBytes; - sample = obj->in->hops->array[iChannel][iSample]; pcm_normalized2signedXXbits(sample, nBytes, obj->bytes); memcpy(&(obj->buffer[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes); + nBytesTotal += nBytes; + } } diff --git a/src/system/demixing2env.c b/src/system/demixing2env.c new file mode 100644 index 0000000..5296152 --- /dev/null +++ b/src/system/demixing2env.c @@ -0,0 +1,82 @@ + + #include "demixing2env.h" + + demixing2env_obj * demixing2env_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize) { + + demixing2env_obj * obj; + + obj = (demixing2env_obj *) malloc(sizeof(demixing2env_obj)); + + obj->nSeps = nSeps; + obj->nChannels = nChannels; + obj->halfFrameSize = halfFrameSize; + + return obj; + + } + + void demixing2env_destroy(demixing2env_obj * obj) { + + free((void *) obj); + + } + + void demixing2env_process(demixing2env_obj * obj, const tracks_obj * tracks, const demixings_obj * demixings, const masks_obj * masks, const envs_obj * envsChannel, envs_obj * envsSeparated) { + + unsigned int iSep; + unsigned int iChannel; + unsigned int iBin; + + unsigned int iSampleSC; + unsigned int iSampleBC; + unsigned int iSampleB; + + float X2; + float Wreal; + float Wimag; + float W2; + float Y2; + + for (iSep = 0; iSep < obj->nSeps; iSep++) { + + if (tracks->ids[iSep] != 0) { + + memset(envsSeparated->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize * 2); + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + iSampleSC = iSep * obj->nChannels + iChannel; + + if (masks->array[iSampleSC] == 1) { + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + iSampleBC = iBin * obj->nChannels + iChannel; + iSampleB = iBin; + + X2 = envsChannel->array[iChannel][iSampleB]; + + Wreal = demixings->array[iSep][iSampleBC * 2 + 0]; + Wimag = demixings->array[iSep][iSampleBC * 2 + 1]; + W2 = Wreal * Wreal + Wimag * Wimag; + + Y2 = W2 * X2; + + envsSeparated->array[iSep][iSampleB] += Y2; + + } + + } + + } + + } + else { + + memset(envsSeparated->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize); + + } + + } + + } \ No newline at end of file diff --git a/src/system/demixing2env.h b/src/system/demixing2env.h new file mode 100644 index 0000000..ddada11 --- /dev/null +++ b/src/system/demixing2env.h @@ -0,0 +1,28 @@ +#ifndef __ODAS_SYSTEM_DEMIXING2ENV +#define __ODAS_SYSTEM_DEMIXING2ENV + + #include + #include + #include + #include + + #include "../signal/demixing.h" + #include "../signal/env.h" + #include "../signal/mask.h" + #include "../signal/track.h" + + typedef struct demixing2env_obj { + + unsigned int nSeps; + unsigned int nChannels; + unsigned int halfFrameSize; + + } demixing2env_obj; + + demixing2env_obj * demixing2env_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize); + + void demixing2env_destroy(demixing2env_obj * obj); + + void demixing2env_process(demixing2env_obj * obj, const tracks_obj * tracks, const demixings_obj * demixings, const masks_obj * masks, const envs_obj * envsChannel, envs_obj * envsSeparated); + +#endif \ No newline at end of file diff --git a/src/system/env2env.c b/src/system/env2env.c index 68e7f37..f9727d8 100644 --- a/src/system/env2env.c +++ b/src/system/env2env.c @@ -19,7 +19,10 @@ obj->delta = delta; obj->alphaD = alphaD; - obj->l = 0; + obj->l = (unsigned int *) malloc(sizeof(unsigned int) * nChannels); + memset(obj->l, 0x00, sizeof(unsigned int) * nChannels); + obj->first = (char *) malloc(sizeof(char) * nChannels); + memset(obj->first, 0x00, sizeof(char) * nChannels); obj->b = (float *) malloc(sizeof(float) * bSize); for (n = 0; n < obj->bSize; n++) { @@ -30,7 +33,6 @@ obj->b[n] /= bTotal; } - obj->Sf = (float **) malloc(sizeof(float *) * obj->nChannels); obj->S = (float **) malloc(sizeof(float *) * obj->nChannels); obj->SPrev = (float **) malloc(sizeof(float *) * obj->nChannels); @@ -70,11 +72,25 @@ void env2env_mcra_destroy(env2env_mcra_obj * obj) { + free((void *) obj->l); + free((void *) obj->first); + free((void *) obj->b); + + free((void *) obj->Sf); + free((void *) obj->S); + free((void *) obj->SPrev); + free((void *) obj->Smin); + free((void *) obj->SminPrev); + free((void *) obj->Stmp); + free((void *) obj->StmpPrev); + free((void *) obj->lambdaD); + free((void *) obj->lambdaDnext); + free((void *) obj); } - void env2env_mcra_process(env2env_mcra_obj * obj, const envs_obj * noisy, envs_obj * noise) { + void env2env_mcra_process(env2env_mcra_obj * obj, const tracks_obj * tracks, const envs_obj * noisys, const envs_obj * estNoises, envs_obj * noises) { unsigned int iChannel; unsigned int iBin; @@ -82,129 +98,809 @@ unsigned int iBinWrapped; float sample; + char doProcess; + char doReset; + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - // N-1 - // +-- - // Sf_l[k] = > b[n] |X_l[k+n-(N-1)/2]|^2 - // +-- - // n=0 + if (tracks != NULL) { - for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + if (tracks->ids[iChannel] != 0) { - sample = 0.0f; + doProcess = 0x01; + doReset = 0x00; - for (iSample = 0; iSample < obj->bSize; iSample++) { + } + else { - iBinWrapped = (unsigned int) abs(((signed int) iBin) + iSample - ((obj->bSize-1)/2)); - sample += obj->b[iSample] * noisy->array[iChannel][iBinWrapped]; + doProcess = 0x00; + doReset = 0x01; } - obj->Sf[iChannel][iBin] = sample; + } + else { + + doProcess = 0x01; + doReset = 0x00; } - // - // S_l[k] = (1 - alphaS) * S_l-1[k] + alphaS * Sf_l[k] - // + if (doReset == 0x01) { - for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + obj->l[iChannel] = 0; - obj->S[iChannel][iBin] = (1 - obj->alphaS) * obj->SPrev[iChannel][iBin] + obj->alphaS * obj->Sf[iChannel][iBin]; + if (estNoises != NULL) { + + memcpy(obj->Sf[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->S[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->SPrev[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->Smin[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->SminPrev[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->Stmp[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->StmpPrev[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->lambdaD[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->lambdaDnext[iChannel], estNoises->array[iChannel], sizeof(float) * obj->halfFrameSize); + + obj->first[iChannel] = 0x00; + + } + else { + + memset(obj->Sf[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->S[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->SPrev[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->Smin[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->SminPrev[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->Stmp[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->StmpPrev[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->lambdaD[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->lambdaDnext[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + + obj->first[iChannel] = 0x01; + + } } - // \ - // Smin_l[k] = min{Smin_l-1[k],S_l[k]} | l < L - // Stmp_l[k] = min{Stmp_l-1[k],S_l[k]} | - // / - // \ - // Smin_l[k] = min{Stmp_l-1[k],S_l[k]} | l = L - // Stmp_l[k] = S_l[k] | - // / + if (doProcess == 0x01) { + + // N-1 + // +-- + // Sf_l[k] = > b[n] |X_l[k+n-(N-1)/2]|^2 + // +-- + // n=0 + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + sample = 0.0f; + + for (iSample = 0; iSample < obj->bSize; iSample++) { + + iBinWrapped = (unsigned int) abs(((signed int) iBin) + iSample - ((obj->bSize-1)/2)); + sample += obj->b[iSample] * noisys->array[iChannel][iBinWrapped]; + + } + + obj->Sf[iChannel][iBin] = sample; - if (obj->l < obj->L) { + } - // Smin_l[k] = min{Smin_l-1[k],S_l[k]} - // Stmp_l[k] = min{Stmp_l-1[k],S_l[k]} + // + // S_l[k] = (1 - alphaS) * S_l-1[k] + alphaS * Sf_l[k] + // for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { - if (obj->SminPrev[iChannel][iBin] < obj->S[iChannel][iBin]) { - obj->Smin[iChannel][iBin] = obj->SminPrev[iChannel][iBin]; + obj->S[iChannel][iBin] = (1 - obj->alphaS) * obj->SPrev[iChannel][iBin] + obj->alphaS * obj->Sf[iChannel][iBin]; + + } + + // \ + // Smin_l[k] = min{Smin_l-1[k],S_l[k]} | l < L + // Stmp_l[k] = min{Stmp_l-1[k],S_l[k]} | + // / + // \ + // Smin_l[k] = min{Stmp_l-1[k],S_l[k]} | l = L + // Stmp_l[k] = S_l[k] | + // / + + if (obj->l[iChannel] <= obj->L) { + + // Smin_l[k] = min{Smin_l-1[k],S_l[k]} + // Stmp_l[k] = min{Stmp_l-1[k],S_l[k]} + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + if (obj->SminPrev[iChannel][iBin] < obj->S[iChannel][iBin]) { + obj->Smin[iChannel][iBin] = obj->SminPrev[iChannel][iBin]; + } + else { + obj->Smin[iChannel][iBin] = obj->S[iChannel][iBin]; + } + + if (obj->StmpPrev[iChannel][iBin] < obj->S[iChannel][iBin]) { + obj->Stmp[iChannel][iBin] = obj->StmpPrev[iChannel][iBin]; + } + else { + obj->Stmp[iChannel][iBin] = obj->S[iChannel][iBin]; + } + } - else { - obj->Smin[iChannel][iBin] = obj->S[iChannel][iBin]; + + // Count frames + + (obj->l[iChannel])++; + + } + else { + + // Smin_l[k] = min{Stmp_l-1[k],S_l[k]} + // Stmp_l[k] = S_l[k] + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + if (obj->StmpPrev[iChannel][iBin] < obj->S[iChannel][iBin]) { + obj->Smin[iChannel][iBin] = obj->StmpPrev[iChannel][iBin]; + } + else { + obj->Smin[iChannel][iBin] = obj->S[iChannel][iBin]; + } + + obj->Stmp[iChannel][iBin] = obj->S[iChannel][iBin]; + } - if (obj->StmpPrev[iChannel][iBin] < obj->S[iChannel][iBin]) { - obj->Stmp[iChannel][iBin] = obj->StmpPrev[iChannel][iBin]; + // Reset frame counter + + obj->l[iChannel] = 0; + obj->first[iChannel] = 0x00; + + } + + // \ + // | S_l[k] < Smin_l[k] * delta + // lambdaD_l+1[k] = (1-alphaD) * lambdaD_l[k] + alphaD * |Y_l[k]|^2 | lambdaD_l[k] > |Y_l[k]|^2 + // | + // / + // + // lambdaD_l+1[k] = lambdaD_l[k] otherwise + // + + if (obj->first[iChannel] = 0x00) { + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + if ((obj->S[iChannel][iBin] < (obj->Smin[iChannel][iBin] * obj->delta)) || (obj->lambdaD[iChannel][iBin] > obj->S[iChannel][iBin])) { + + obj->lambdaDnext[iChannel][iBin] = (1.0f - obj->alphaD) * obj->lambdaD[iChannel][iBin] + obj->alphaD * obj->S[iChannel][iBin]; + + } + } - else { - obj->Stmp[iChannel][iBin] = obj->S[iChannel][iBin]; + + } + else { + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + obj->lambdaDnext[iChannel][iBin] = (1.0f - obj->alphaD) * obj->lambdaD[iChannel][iBin] + obj->alphaD * obj->S[iChannel][iBin]; + obj->StmpPrev[iChannel][iBin] = obj->lambdaDnext[iChannel][iBin]; + } } + // Copy to output + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + noises->array[iChannel][iBin] = obj->lambdaDnext[iChannel][iBin]; + + } + + // Smin_l-1 = Smin_l + // S_l-1 = S_l + // Stmp_l-1 = Stmp_l + // lambdaD_l = lambdaD_l+1 + + memcpy(obj->SminPrev[iChannel], obj->Smin[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->SPrev[iChannel], obj->S[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->StmpPrev[iChannel], obj->Stmp[iChannel], sizeof(float) * obj->halfFrameSize); + memcpy(obj->lambdaD[iChannel], obj->lambdaDnext[iChannel], sizeof(float) * obj->halfFrameSize); + + } + + } + + } + + env2env_weight_obj * env2env_weight_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float alphaD, const float epsilon) { + + env2env_weight_obj * obj; + unsigned int iChannel; + + obj = (env2env_weight_obj *) malloc(sizeof(env2env_weight_obj)); + + obj->nChannels = nChannels; + obj->halfFrameSize = halfFrameSize; + obj->alphaD = alphaD; + obj->epsilon = epsilon; + + obj->XPrev = (float **) malloc(sizeof(float *) * nChannels); + obj->xi = (float **) malloc(sizeof(float *) * nChannels); + obj->zetaPrev = (float **) malloc(sizeof(float *) * nChannels); + + for (iChannel = 0; iChannel < nChannels; iChannel++) { + + obj->XPrev[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->XPrev[iChannel], 0x00, sizeof(float) * halfFrameSize); + obj->xi[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->xi[iChannel], 0x00, sizeof(float) * halfFrameSize); + obj->zetaPrev[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->zetaPrev[iChannel], 0x00, sizeof(float) * halfFrameSize); + + } + + return obj; + + } + + void env2env_weight_destroy(env2env_weight_obj * obj) { + + unsigned int iChannel; + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + free((void *) obj->XPrev[iChannel]); + free((void *) obj->xi[iChannel]); + free((void *) obj->zetaPrev[iChannel]); + + } + + free((void *) obj->XPrev); + free((void *) obj->xi); + free((void *) obj->zetaPrev); + + } + + void env2env_weight_process(env2env_weight_obj * obj, const tracks_obj * tracks, const envs_obj * noisys, const envs_obj * noises, envs_obj * weights) { + + unsigned int iChannel; + unsigned int iBin; + + char doProcess; + char doReset; + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + if (tracks != NULL) { + + if (tracks->ids[iChannel] != 0) { + + doProcess = 0x01; + doReset = 0x00; + + } + else { + + doProcess = 0x00; + doReset = 0x01; + + } + } else { - // Smin_l[k] = min{Stmp_l-1[k],S_l[k]} - // Stmp_l[k] = S_l[k] + doProcess = 0x01; + doReset = 0x00; + + } + + if (doReset == 0x01) { + + memset(obj->XPrev[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->xi[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->zetaPrev[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + + } + + if (doProcess == 0x01) { for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { - if (obj->StmpPrev[iChannel][iBin] < obj->S[iChannel][iBin]) { - obj->Smin[iChannel][iBin] = obj->StmpPrev[iChannel][iBin]; + obj->xi[iChannel][iBin] = ((1 - obj->alphaD) * obj->zetaPrev[iChannel][iBin] * obj->XPrev[iChannel][iBin] + obj->alphaD * noisys->array[iChannel][iBin]) / (noises->array[iChannel][iBin] + obj->epsilon); + weights->array[iChannel][iBin] = obj->xi[iChannel][iBin] / (obj->xi[iChannel][iBin] + 1.0f); + + obj->XPrev[iChannel][iBin] = noisys->array[iChannel][iBin]; + obj->zetaPrev[iChannel][iBin] = weights->array[iChannel][iBin]; + + } + + } + + } + + } + + env2env_interf_obj * env2env_interf_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float eta) { + + env2env_interf_obj * obj; + + obj = (env2env_interf_obj *) malloc(sizeof(env2env_interf_obj)); + + obj->nChannels = nChannels; + obj->halfFrameSize = halfFrameSize; + obj->eta = eta; + + return obj; + + } + + void env2env_interf_destroy(env2env_interf_obj * obj) { + + free((void *) obj); + + } + + void env2env_interf_process(env2env_interf_obj * obj, const tracks_obj * tracks, const envs_obj * seps, const envs_obj * noises, envs_obj * interfs) { + + unsigned int iChannel1; + unsigned int iChannel2; + unsigned int iBin; + + for (iChannel1 = 0; iChannel1 < obj->nChannels; iChannel1++) { + + if (tracks->ids[iChannel1] != 0) { + + memset(interfs->array[iChannel1], 0x00, sizeof(float) * obj->halfFrameSize); + + for (iChannel2 = 0; iChannel2 < obj->nChannels; iChannel2++) { + + if (tracks->ids[iChannel2] != 0) { + + if (iChannel1 != iChannel2) { + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + interfs->array[iChannel1][iBin] += seps->array[iChannel2][iBin] * obj->eta; + + } + + } + + } + + } + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + interfs->array[iChannel1][iBin] += noises->array[iChannel1][iBin]; + + } + + } + + } + + } + + env2env_gainspeech_obj * env2env_gainspeech_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float alphaPmin, const float epsilon) { + + env2env_gainspeech_obj * obj; + unsigned int iChannel; + + obj = (env2env_gainspeech_obj *) malloc(sizeof(env2env_gainspeech_obj)); + + obj->nChannels = nChannels; + obj->halfFrameSize = halfFrameSize; + + obj->alphaPmin = alphaPmin; + obj->epsilon = epsilon; + + obj->gamma = (float **) malloc(sizeof(float *) * nChannels); + obj->alphaP = (float **) malloc(sizeof(float *) * nChannels); + obj->xi = (float **) malloc(sizeof(float *) * nChannels); + obj->GH1 = (float **) malloc(sizeof(float *) * nChannels); + obj->v = (float **) malloc(sizeof(float *) * nChannels); + + for (iChannel = 0; iChannel < nChannels; iChannel++) { + + obj->gamma[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->gamma[iChannel], 0x00, sizeof(float) * halfFrameSize); + obj->alphaP[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->alphaP[iChannel], 0x00, sizeof(float) * halfFrameSize); + obj->xi[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->xi[iChannel], 0x00, sizeof(float) * halfFrameSize); + obj->GH1[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->GH1[iChannel], 0x00, sizeof(float) * halfFrameSize); + obj->v[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->v[iChannel], 0x00, sizeof(float) * halfFrameSize); + + } + + obj->transcendental = transcendental_construct_zero(0.0f, 5.0f, 5001); + + return obj; + + } + + void env2env_gainspeech_destroy(env2env_gainspeech_obj * obj) { + + unsigned int iChannel; + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + free((void *) obj->gamma[iChannel]); + free((void *) obj->alphaP[iChannel]); + free((void *) obj->xi[iChannel]); + free((void *) obj->GH1[iChannel]); + free((void *) obj->v[iChannel]); + + } + + free((void *) obj->gamma); + free((void *) obj->alphaP); + free((void *) obj->xi); + free((void *) obj->GH1); + free((void *) obj->v); + + transcendental_destroy(obj->transcendental); + + free((void *) obj); + + } + + void env2env_gainspeech_process(env2env_gainspeech_obj * obj, const tracks_obj * tracks, const envs_obj * seps, const envs_obj * noises, envs_obj * gains, envs_obj * snrs) { + + unsigned int iChannel; + unsigned int iBin; + float xi_plus_1; + float max_gamma_minus_1_vs_0; + float GH1_2; + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + if (tracks->ids[iChannel] != 0) { + + memset(obj->gamma[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->alphaP[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->xi[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->GH1[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + memset(obj->v[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + + } + else { + + // + // gamma_l[k] = |Y_l(k)|^2 / (lambda_l[k] + epsilon) + // + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + obj->gamma[iChannel][iBin] = seps->array[iChannel][iBin] / (noises->array[iChannel][iBin] + obj->epsilon); + + } + + // + // alphaP_l[k] = (xi_l-1[k] / (xi_l-1[k] + 1)^2) + alphaPmin + // + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + xi_plus_1 = obj->xi[iChannel][iBin] + 1; + + obj->alphaP[iChannel][iBin] = obj->xi[iChannel][iBin] / (xi_plus_1*xi_plus_1) + obj->alphaPmin; + + } + + // + // xi_l[k] = (1 - alphaP_l[k]) * (GH1_l-1[k])^2 * gamma_l[k] + alphaP_l[k] * max{gamma_l[k]-1,0} + // + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + if ((obj->gamma[iChannel][iBin] - 1.0f) > 0.0f) { + max_gamma_minus_1_vs_0 = 0.0f; } else { - obj->Smin[iChannel][iBin] = obj->S[iChannel][iBin]; + max_gamma_minus_1_vs_0 = obj->gamma[iChannel][iBin] - 1.0f; } - obj->Stmp[iChannel][iBin] = obj->S[iChannel][iBin]; + GH1_2 = obj->GH1[iChannel][iBin] * obj->GH1[iChannel][iBin]; + + obj->xi[iChannel][iBin] = (1.0f - obj->alphaP[iChannel][iBin]) * GH1_2 * obj->gamma[iChannel][iBin] + obj->alphaP[iChannel][iBin] * max_gamma_minus_1_vs_0; } - } + // + // v_l[k] = gamma_l[k] * xi_l[k] / (xi_l[k] + 1) + // - // \ - // | S_l[k] < Smin_l[k] * delta - // lambdaD_l+1[k] = (1-alphaD) * lambdaD_l[k] + alphaD * |Y_l[k]|^2 | lambdaD_l[k] > |Y_l[k]|^2 - // | - // / - // - // lambdaD_l+1[k] = lambdaD_l[k] otherwise - // + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { - for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + obj->v[iChannel][iBin] = obj->gamma[iChannel][iBin] * obj->xi[iChannel][iBin] / (obj->xi[iChannel][iBin] + 1.0f); + + } - if ((obj->S[iChannel][iBin] < (obj->Smin[iChannel][iBin] * obj->delta)) || (obj->lambdaD[iChannel][iBin] > noisy->array[iChannel][iBin])) { + // + // GH1_l[k] = fcn(v_l[k]) + // - obj->lambdaDnext[iChannel][iBin] = obj->lambdaD[iChannel][iBin]; + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + obj->GH1[iChannel][iBin] = transcendental_process(obj->transcendental, obj->v[iChannel][iBin]); } } - // Smin_l-1 = Smin_l - // S_l-1 = S_l - // Stmp_l-1 = Stmp_l - // lambdaD_l = lambdaD_l+1 + } + + } + + env2env_probspeech_obj * env2env_probspeech_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float theta, const float alpha, const float maxAbsenceProb, const float Gmin, const unsigned int winSizeLocal, const unsigned int winSizeGlobal, const unsigned int winSizeFrame) { + + env2env_probspeech_obj * obj; + unsigned int iSample; + unsigned int iChannel; - memcpy(obj->SminPrev[iChannel], obj->Smin[iChannel], sizeof(float) * obj->halfFrameSize); - memcpy(obj->SPrev[iChannel], obj->S[iChannel], sizeof(float) * obj->halfFrameSize); - memcpy(obj->StmpPrev[iChannel], obj->Stmp[iChannel], sizeof(float) * obj->halfFrameSize); - memcpy(obj->lambdaD[iChannel], obj->lambdaDnext[iChannel], sizeof(float) * obj->halfFrameSize); + obj = (env2env_probspeech_obj *) malloc(sizeof(env2env_probspeech_obj)); + obj->nChannels = nChannels; + obj->halfFrameSize = halfFrameSize; + obj->frameSize = (halfFrameSize-1) * 2; + obj->theta = theta; + obj->alpha = alpha; + obj->maxAbsenceProb = maxAbsenceProb; + obj->Gmin = Gmin; + obj->winSizeLocal = winSizeLocal; + obj->winSizeGlobal = winSizeGlobal; + obj->winSizeFrame = winSizeFrame; + + obj->fft = fft_construct(obj->frameSize); + + obj->winLocal = (float *) malloc(sizeof(float) * winSizeLocal); + memset(obj->winLocal, 0x00, sizeof(float) * winSizeLocal); + obj->winGlobal = (float *) malloc(sizeof(float) * winSizeGlobal); + memset(obj->winGlobal, 0x00, sizeof(float) * winSizeGlobal); + obj->winFrame = (float *) malloc(sizeof(float) * winSizeFrame); + memset(obj->winFrame, 0x00, sizeof(float) * winSizeFrame); + + if ( winSizeLocal == 1 ) { + obj->winLocal[0] = 1.0f; } + else { + for ( iSample = 0; iSample < winSizeLocal; iSample++ ) { + obj->winLocal[iSample] = 0.5f * ( 1.0f - cosf( 2 * M_PI * ( (float) iSample ) / ( (float) ( winSizeLocal - 1 ) ) ) ); + } + } + + if ( winSizeGlobal == 1 ) { + obj->winGlobal[0] = 1.0f; + } + else { + for ( iSample = 0; iSample < winSizeGlobal; iSample++ ) { + obj->winGlobal[iSample] = 0.5f * ( 1.0f - cosf( 2 * M_PI * ( (float) iSample ) / ( (float) ( winSizeGlobal - 1 ) ) ) ); + } + } + + if ( winSizeFrame == 1 ) { + obj->winFrame[0] = 1.0f; + } + else { + for ( iSample = 0; iSample < winSizeFrame; iSample++ ) { + obj->winFrame[iSample] = 0.5f * ( 1.0f - cosf( 2 * M_PI * ( (float) iSample ) / ( (float) ( winSizeFrame - 1 ) ) ) ); + } + } + + obj->winLocalShifted = (float *) malloc(sizeof(float) * obj->frameSize); + memset(obj->winLocalShifted, 0x00, sizeof(float) * obj->frameSize); + obj->winGlobalShifted = (float *) malloc(sizeof(float) * obj->frameSize); + memset(obj->winGlobalShifted, 0x00, sizeof(float) * obj->frameSize); + obj->winFrameShifted = (float *) malloc(sizeof(float) * obj->frameSize); + memset(obj->winFrameShifted, 0x00, sizeof(float) * obj->frameSize); + + obj->winLocalShifted[0] = obj->winLocal[0]; + for (iSample = 1; iSample < obj->winSizeLocal; iSample++) { + obj->winLocalShifted[iSample] = obj->winLocal[iSample]; + obj->winLocalShifted[obj->frameSize-iSample] = obj->winLocal[iSample]; + } + obj->winGlobalShifted[0] = obj->winGlobal[0]; + for (iSample = 1; iSample < obj->winSizeGlobal; iSample++) { + obj->winGlobalShifted[iSample] = obj->winGlobal[iSample]; + obj->winGlobalShifted[obj->frameSize-iSample] = obj->winGlobal[iSample]; + } + obj->winFrameShifted[0] = obj->winFrame[0]; + for (iSample = 1; iSample < obj->winSizeFrame; iSample++) { + obj->winFrameShifted[iSample] = obj->winFrame[iSample]; + obj->winFrameShifted[obj->frameSize-iSample] = obj->winFrame[iSample]; + } + + obj->winLocalShiftedFreq = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memset(obj->winLocalShiftedFreq, 0x00, sizeof(float) * obj->halfFrameSize * 2); + obj->winGlobalShiftedFreq = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memset(obj->winGlobalShiftedFreq, 0x00, sizeof(float) * obj->halfFrameSize * 2); + obj->winFrameShiftedFreq = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memset(obj->winFrameShiftedFreq, 0x00, sizeof(float) * obj->halfFrameSize * 2); + + fft_r2c(obj->fft, obj->winLocalShifted, obj->winLocalShiftedFreq); + fft_r2c(obj->fft, obj->winGlobalShifted, obj->winGlobalShiftedFreq); + fft_r2c(obj->fft, obj->winFrameShifted, obj->winFrameShiftedFreq); + + obj->xiTime = (float **) malloc(sizeof(float *) * nChannels); + obj->xiFreq = (float **) malloc(sizeof(float *) * nChannels); + + obj->xiSmoothedLocalFreq = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedGlobalFreq = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedFrameFreq = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedLocalTime = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedGlobalTime = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedFrameTime = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedLocal = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedGlobal = (float **) malloc(sizeof(float *) * nChannels); + obj->xiSmoothedFrame = (float **) malloc(sizeof(float *) * nChannels); + + for (iChannel = 0; iChannel < nChannels; iChannel++) { + + obj->xiTime[iChannel] = (float *) malloc(sizeof(float) * obj->frameSize); + memset(obj->xiTime[iChannel], 0x00, sizeof(float) * obj->frameSize); + obj->xiFreq[iChannel] = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memset(obj->xiFreq[iChannel], 0x00, sizeof(float) * obj->halfFrameSize * 2); + + obj->xiSmoothedLocalFreq[iChannel] = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memset(obj->xiSmoothedLocalFreq[iChannel], 0x00, sizeof(float) * obj->halfFrameSize * 2); + obj->xiSmoothedGlobalFreq[iChannel] = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memset(obj->xiSmoothedGlobalFreq[iChannel], 0x00, sizeof(float) * obj->halfFrameSize * 2); + obj->xiSmoothedFrameFreq[iChannel] = (float *) malloc(sizeof(float) * obj->halfFrameSize * 2); + memset(obj->xiSmoothedFrameFreq[iChannel], 0x00, sizeof(float) * obj->halfFrameSize * 2); + obj->xiSmoothedLocalTime[iChannel] = (float *) malloc(sizeof(float) * obj->frameSize); + memset(obj->xiSmoothedLocalTime[iChannel], 0x00, sizeof(float) * obj->frameSize); + obj->xiSmoothedGlobalTime[iChannel] = (float *) malloc(sizeof(float) * obj->frameSize); + memset(obj->xiSmoothedGlobalTime[iChannel], 0x00, sizeof(float) * obj->frameSize); + obj->xiSmoothedFrameTime[iChannel] = (float *) malloc(sizeof(float) * obj->frameSize); + memset(obj->xiSmoothedFrameTime[iChannel], 0x00, sizeof(float) * obj->frameSize); + obj->xiSmoothedLocal[iChannel] = (float *) malloc(sizeof(float) * obj->halfFrameSize); + memset(obj->xiSmoothedLocalTime[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + obj->xiSmoothedGlobal[iChannel] = (float *) malloc(sizeof(float) * obj->halfFrameSize); + memset(obj->xiSmoothedGlobalTime[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + obj->xiSmoothedFrame[iChannel] = (float *) malloc(sizeof(float) * obj->halfFrameSize); + memset(obj->xiSmoothedFrameTime[iChannel], 0x00, sizeof(float) * obj->halfFrameSize); + + } + + return obj; + + } + + void env2env_probspeech_destroy(env2env_probspeech_obj * obj) { + + unsigned int iChannel; + + fft_destroy(obj->fft); + + free((void *) obj->winLocal); + free((void *) obj->winGlobal); + free((void *) obj->winFrame); + + free((void *) obj->winLocalShifted); + free((void *) obj->winGlobalShifted); + free((void *) obj->winFrameShifted); + + free((void *) obj->winLocalShiftedFreq); + free((void *) obj->winGlobalShiftedFreq); + free((void *) obj->winFrameShiftedFreq); - // Count frames + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + free((void *) obj->xiTime[iChannel]); + free((void *) obj->xiFreq[iChannel]); - (obj->l)++; + free((void *) obj->xiSmoothedLocalFreq[iChannel]); + free((void *) obj->xiSmoothedGlobalFreq[iChannel]); + free((void *) obj->xiSmoothedFrameFreq[iChannel]); + free((void *) obj->xiSmoothedLocalTime[iChannel]); + free((void *) obj->xiSmoothedGlobalTime[iChannel]); + free((void *) obj->xiSmoothedFrameTime[iChannel]); + free((void *) obj->xiSmoothedLocal[iChannel]); + free((void *) obj->xiSmoothedGlobal[iChannel]); + free((void *) obj->xiSmoothedFrame[iChannel]); - if (obj->l >= obj->L) { - obj->l = 0; } + free((void *) obj->xiTime); + free((void *) obj->xiFreq); + + free((void *) obj->xiSmoothedLocalFreq); + free((void *) obj->xiSmoothedGlobalFreq); + free((void *) obj->xiSmoothedFrameFreq); + free((void *) obj->xiSmoothedLocalTime); + free((void *) obj->xiSmoothedGlobalTime); + free((void *) obj->xiSmoothedFrameTime); + free((void *) obj->xiSmoothedLocal); + free((void *) obj->xiSmoothedGlobal); + free((void *) obj->xiSmoothedFrame); + } + + void env2env_probspeech_process(env2env_probspeech_obj * obj, const envs_obj * snrs, envs_obj * probspeechs) { + + unsigned int iChannel; + unsigned int iBin; + + float hLocalReal; + float hLocalImag; + float hGlobalReal; + float hGlobalImag; + float hFrameReal; + float hFrameImag; + float xiReal; + float xiImag; + + float hLocalxiReal; + float hLocalxiImag; + float hGlobalxiReal; + float hGlobalxiImag; + float hFramexiReal; + float hFramexiImag; + + // + // Circular convolution with local, global and frame windows + // + + for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { + + obj->xiTime[iChannel][0] = snrs->array[iChannel][0]; + obj->xiTime[iChannel][obj->halfFrameSize-1] = snrs->array[iChannel][obj->halfFrameSize-1]; + + for (iBin = 1; iBin < (obj->halfFrameSize-1); iBin++) { + + obj->xiTime[iChannel][iBin] = snrs->array[iChannel][iBin]; + obj->xiTime[iChannel][obj->frameSize-iBin] = snrs->array[iChannel][iBin]; + + } + + fft_r2c(obj->fft, obj->xiTime[iChannel], obj->xiFreq[iChannel]); + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + hLocalReal = obj->winLocalShiftedFreq[iBin*2+0]; + hLocalImag = obj->winLocalShiftedFreq[iBin*2+1]; + hGlobalReal = obj->winGlobalShiftedFreq[iBin*2+0]; + hGlobalImag = obj->winGlobalShiftedFreq[iBin*2+1]; + hFrameReal = obj->winFrameShiftedFreq[iBin*2+0]; + hFrameImag = obj->winFrameShiftedFreq[iBin*2+1]; + xiReal = obj->xiFreq[iChannel][iBin*2+0]; + xiImag = obj->xiFreq[iChannel][iBin*2+1]; + + hLocalxiReal = hLocalReal * xiReal - hLocalImag * xiImag; + hLocalxiImag = hLocalReal * xiImag + hLocalImag * xiReal; + hGlobalxiReal = hGlobalReal * xiReal - hGlobalImag * xiImag; + hGlobalxiImag = hGlobalReal * xiImag + hGlobalImag * xiReal; + hFramexiReal = hFrameReal * xiReal - hFrameImag * xiImag; + hFramexiImag = hFrameReal * xiImag + hFrameImag * xiReal; + + obj->xiSmoothedLocalFreq[iChannel][iBin*2+0] = hLocalxiReal; + obj->xiSmoothedLocalFreq[iChannel][iBin*2+1] = hLocalxiImag; + obj->xiSmoothedGlobalFreq[iChannel][iBin*2+0] = hGlobalxiReal; + obj->xiSmoothedGlobalFreq[iChannel][iBin*2+1] = hGlobalxiImag; + obj->xiSmoothedFrameFreq[iChannel][iBin*2+0] = hFramexiReal; + obj->xiSmoothedFrameFreq[iChannel][iBin*2+1] = hFramexiImag; + + } + + fft_c2r(obj->fft, obj->xiSmoothedLocalFreq[iChannel], obj->xiSmoothedLocalTime[iChannel]); + fft_c2r(obj->fft, obj->xiSmoothedGlobalFreq[iChannel], obj->xiSmoothedGlobalTime[iChannel]); + fft_c2r(obj->fft, obj->xiSmoothedFrameFreq[iChannel], obj->xiSmoothedFrameTime[iChannel]); + + for (iBin = 0; iBin < obj->halfFrameSize; iBin++) { + + obj->xiSmoothedLocal[iChannel][iBin] = obj->xiSmoothedLocalTime[iChannel][iBin]; + obj->xiSmoothedGlobal[iChannel][iBin] = obj->xiSmoothedGlobalTime[iChannel][iBin]; + obj->xiSmoothedFrame[iChannel][iBin] = obj->xiSmoothedFrameTime[iChannel][iBin]; + + } + + } + + } \ No newline at end of file diff --git a/src/system/env2env.h b/src/system/env2env.h index 55cb3db..e615c46 100644 --- a/src/system/env2env.h +++ b/src/system/env2env.h @@ -6,6 +6,9 @@ #include #include "../signal/env.h" + #include "../signal/track.h" + #include "../utils/fft.h" + #include "../utils/transcendental.h" typedef struct env2env_mcra_obj { @@ -18,7 +21,8 @@ float delta; float alphaD; - unsigned int l; + unsigned int * l; + char * first; float * b; float ** S; @@ -33,11 +37,119 @@ } env2env_mcra_obj; + typedef struct env2env_weight_obj { + + unsigned int nChannels; + unsigned int halfFrameSize; + + float alphaD; + float epsilon; + + float ** XPrev; + float ** xi; + float ** zetaPrev; + + } env2env_weight_obj; + + typedef struct env2env_interf_obj { + + unsigned int nChannels; + unsigned int halfFrameSize; + + float eta; + + } env2env_interf_obj; + + typedef struct env2env_gainspeech_obj { + + unsigned int nChannels; + unsigned int halfFrameSize; + + float alphaPmin; + float epsilon; + + float ** gamma; + float ** alphaP; + float ** xi; + float ** GH1; + float ** v; + + transcendental_obj * transcendental; + + } env2env_gainspeech_obj; + + typedef struct env2env_probspeech_obj { + + unsigned int nChannels; + unsigned int halfFrameSize; + unsigned int frameSize; + + float theta; + float alpha; + float maxAbsenceProb; + float Gmin; + + unsigned int winSizeLocal; + unsigned int winSizeGlobal; + unsigned int winSizeFrame; + + fft_obj * fft; + + float * winLocal; + float * winGlobal; + float * winFrame; + + float * winLocalShifted; + float * winGlobalShifted; + float * winFrameShifted; + + float * winLocalShiftedFreq; + float * winGlobalShiftedFreq; + float * winFrameShiftedFreq; + + float ** xiTime; + float ** xiFreq; + + float ** xiSmoothedLocalFreq; + float ** xiSmoothedGlobalFreq; + float ** xiSmoothedFrameFreq; + float ** xiSmoothedLocalTime; + float ** xiSmoothedGlobalTime; + float ** xiSmoothedFrameTime; + float ** xiSmoothedLocal; + float ** xiSmoothedGlobal; + float ** xiSmoothedFrame; + + } env2env_probspeech_obj; + env2env_mcra_obj * env2env_mcra_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const unsigned int bSize, const float alphaS, const unsigned int L, const float delta, const float alphaD); void env2env_mcra_destroy(env2env_mcra_obj * obj); - void env2env_mcra_process(env2env_mcra_obj * obj, const envs_obj * noisy, envs_obj * noise); + void env2env_mcra_process(env2env_mcra_obj * obj, const tracks_obj * tracks, const envs_obj * noisys, const envs_obj * estNoises, envs_obj * noises); + + env2env_weight_obj * env2env_weight_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float alphaD, const float epsilon); + + void env2env_weight_destroy(env2env_weight_obj * obj); + + void env2env_weight_process(env2env_weight_obj * obj, const tracks_obj * tracks, const envs_obj * noisys, const envs_obj * noises, envs_obj * weights); + + env2env_interf_obj * env2env_interf_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float eta); + + void env2env_interf_destroy(env2env_interf_obj * obj); + + void env2env_interf_process(env2env_interf_obj * obj, const tracks_obj * tracks, const envs_obj * seps, const envs_obj * noises, envs_obj * interfs); + + env2env_gainspeech_obj * env2env_gainspeech_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float alphaPmin, const float epsilon); + + void env2env_gainspeech_destroy(env2env_gainspeech_obj * obj); + + void env2env_gainspeech_process(env2env_gainspeech_obj * obj, const tracks_obj * tracks, const envs_obj * seps, const envs_obj * noises, envs_obj * gains, envs_obj * snrs); + + env2env_probspeech_obj * env2env_probspeech_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize, const float theta, const float alpha, const float maxAbsenceProb, const float Gmin, const unsigned int winSizeLocal, const unsigned int winSizeGlobal, const unsigned int winSizeFrame); + + void env2env_probspeech_destroy(env2env_probspeech_obj * obj); + void env2env_probspeech_process(env2env_probspeech_obj * obj, const envs_obj * snrs, envs_obj * probspeechs); #endif \ No newline at end of file diff --git a/src/system/freq2freq.c b/src/system/freq2freq.c index 21f55c6..426b850 100644 --- a/src/system/freq2freq.c +++ b/src/system/freq2freq.c @@ -1,32 +1,26 @@ #include "freq2freq.h" - freq2freq_obj * freq2freq_construct_zero(const unsigned int halfFrameSize, const unsigned int halfFrameSizeInterp, const unsigned int lowPassCut, const float epsilon, const float alpha, const float beta, const float Ginterf) { + freq2freq_phasor_obj * freq2freq_phasor_construct_zero(const unsigned int halfFrameSize, const float epsilon) { - freq2freq_obj * obj; + freq2freq_phasor_obj * obj; - obj = (freq2freq_obj *) malloc(sizeof(freq2freq_obj)); + obj = (freq2freq_phasor_obj *) malloc(sizeof(freq2freq_phasor_obj)); obj->halfFrameSize = halfFrameSize; - obj->halfFrameSizeInterp = halfFrameSizeInterp; - obj->lowPassCut = lowPassCut; obj->epsilon = epsilon; - obj->alpha = alpha; - obj->beta = beta; - obj->Ginterf = Ginterf; - return obj; } - void freq2freq_destroy(freq2freq_obj * obj) { + void freq2freq_phasor_destroy(freq2freq_phasor_obj * obj) { free((void *) obj); } - void freq2freq_process_phasor(freq2freq_obj * obj, const freqs_obj * freqs, freqs_obj * phasors) { + void freq2freq_phasor_process(freq2freq_phasor_obj * obj, const freqs_obj * freqs, freqs_obj * phasors) { unsigned int iSignal, iSample; float real, imag; @@ -45,11 +39,73 @@ } - } + } + + } + + freq2freq_weightedphasor_obj * freq2freq_weightedphasor_construct_zero(const unsigned int halfFrameSize, const float epsilon) { + + freq2freq_weightedphasor_obj * obj; + + obj = (freq2freq_weightedphasor_obj *) malloc(sizeof(freq2freq_weightedphasor_obj)); + + obj->halfFrameSize = halfFrameSize; + obj->epsilon = epsilon; + + return obj; } - void freq2freq_process_product(freq2freq_obj * obj, const freqs_obj * freqs1, const freqs_obj * freqs2, const pairs_obj * pairs, freqs_obj * freqs12) { + void freq2freq_weightedphasor_destroy(freq2freq_weightedphasor_obj * obj) { + + free((void *) obj); + + } + + void freq2freq_weightedphasor_process(freq2freq_weightedphasor_obj * obj, const freqs_obj * freqs, const envs_obj * weights, freqs_obj * weightedphasors) { + + unsigned int iSignal, iSample; + float real, imag; + float magnitude; + float weight; + + for (iSignal = 0; iSignal < freqs->nSignals; iSignal++) { + + for (iSample = 0; iSample < freqs->halfFrameSize; iSample++) { + + real = freqs->array[iSignal][iSample * 2 + 0]; + imag = freqs->array[iSignal][iSample * 2 + 1]; + magnitude = sqrtf(real*real+imag*imag) + obj->epsilon; + weight = weights->array[iSignal][iSample]; + + weightedphasors->array[iSignal][iSample * 2 + 0] = weight * real / magnitude; + weightedphasors->array[iSignal][iSample * 2 + 1] = weight * imag / magnitude; + + } + + } + + } + + freq2freq_product_obj * freq2freq_product_construct_zero(const unsigned int halfFrameSize) { + + freq2freq_product_obj * obj; + + obj = (freq2freq_product_obj *) malloc(sizeof(freq2freq_product_obj)); + + obj->halfFrameSize = halfFrameSize; + + return obj; + + } + + void freq2freq_product_destroy(freq2freq_product_obj * obj) { + + free((void *) obj); + + } + + void freq2freq_product_process(freq2freq_product_obj * obj, const freqs_obj * freqs1, const freqs_obj * freqs2, const pairs_obj * pairs, freqs_obj * freqs12) { unsigned int iSignal1, iSignal2, iSignal12, iSample; float real1, imag1; @@ -85,7 +141,26 @@ } - void freq2freq_process_lowpass(freq2freq_obj * obj, const freqs_obj * freqsAllPass, freqs_obj * freqsLowPass) { + freq2freq_lowpass_obj * freq2freq_lowpass_construct_zero(const unsigned int halfFrameSize, const unsigned int lowPassCut) { + + freq2freq_lowpass_obj * obj; + + obj = (freq2freq_lowpass_obj *) malloc(sizeof(freq2freq_lowpass_obj)); + + obj->halfFrameSize = halfFrameSize; + obj->lowPassCut = lowPassCut; + + return obj; + + } + + void freq2freq_lowpass_destroy(freq2freq_lowpass_obj * obj) { + + free((void *) obj); + + } + + void freq2freq_lowpass_process(freq2freq_lowpass_obj * obj, const freqs_obj * freqsAllPass, freqs_obj * freqsLowPass) { unsigned int iSignal; @@ -95,11 +170,30 @@ memcpy(freqsLowPass->array[iSignal], freqsAllPass->array[iSignal], sizeof(float) * 2 * obj->lowPassCut); - } + } } - void freq2freq_process_interpolate(freq2freq_obj * obj, const freqs_obj * freqs, const freqs_obj * freqsInterp) { + freq2freq_interpolate_obj * freq2freq_interpolate_construct_zero(const unsigned int halfFrameSize, const unsigned int halfFrameSizeInterp) { + + freq2freq_interpolate_obj * obj; + + obj = (freq2freq_interpolate_obj *) malloc(sizeof(freq2freq_interpolate_obj)); + + obj->halfFrameSize = halfFrameSize; + obj->halfFrameSizeInterp = halfFrameSizeInterp; + + return obj; + + } + + void freq2freq_interpolate_destroy(freq2freq_interpolate_obj * obj) { + + free((void *) obj); + + } + + void freq2freq_interpolate_process(freq2freq_interpolate_obj * obj, const freqs_obj * freqs, const freqs_obj * freqsInterp) { unsigned int iSignal; @@ -108,6 +202,7 @@ memset(freqsInterp->array[iSignal], 0x00, sizeof(float) * 2 * obj->halfFrameSizeInterp); memcpy(freqsInterp->array[iSignal], freqs->array[iSignal], sizeof(float) * 2 * obj->halfFrameSize); - } + } + + } - } \ No newline at end of file diff --git a/src/system/freq2freq.h b/src/system/freq2freq.h index a3816bc..bd97d8f 100644 --- a/src/system/freq2freq.h +++ b/src/system/freq2freq.h @@ -5,31 +5,72 @@ #include #include "../signal/freq.h" + #include "../signal/env.h" #include "../signal/pair.h" #include "../signal/track.h" - typedef struct freq2freq_obj { + typedef struct freq2freq_phasor_obj { unsigned int halfFrameSize; - unsigned int halfFrameSizeInterp; - unsigned int lowPassCut; float epsilon; - float alpha; - float beta; - float Ginterf; - } freq2freq_obj; + } freq2freq_phasor_obj; + + typedef struct freq2freq_weightedphasor_obj { + + unsigned int halfFrameSize; + float epsilon; + + } freq2freq_weightedphasor_obj; + + typedef struct freq2freq_product_obj { + + unsigned int halfFrameSize; + + } freq2freq_product_obj; + + typedef struct freq2freq_lowpass_obj { + + unsigned int halfFrameSize; + unsigned int lowPassCut; + + } freq2freq_lowpass_obj; + + typedef struct freq2freq_interpolate_obj { + + unsigned halfFrameSize; + unsigned halfFrameSizeInterp; + + } freq2freq_interpolate_obj; + + freq2freq_phasor_obj * freq2freq_phasor_construct_zero(const unsigned int halfFrameSize, const float epsilon); + + void freq2freq_phasor_destroy(freq2freq_phasor_obj * obj); + + void freq2freq_phasor_process(freq2freq_phasor_obj * obj, const freqs_obj * freqs, freqs_obj * phasors); + + freq2freq_weightedphasor_obj * freq2freq_weightedphasor_construct_zero(const unsigned int halfFrameSize, const float epsilon); + + void freq2freq_weightedphasor_destroy(freq2freq_weightedphasor_obj * obj); + + void freq2freq_weightedphasor_process(freq2freq_weightedphasor_obj * obj, const freqs_obj * freqs, const envs_obj * weights, freqs_obj * weightedphasors); + + freq2freq_product_obj * freq2freq_product_construct_zero(const unsigned int halfFrameSize); + + void freq2freq_product_destroy(freq2freq_product_obj * obj); + + void freq2freq_product_process(freq2freq_product_obj * obj, const freqs_obj * freqs1, const freqs_obj * freqs2, const pairs_obj * pairs, freqs_obj * freqs12); - freq2freq_obj * freq2freq_construct_zero(const unsigned int halfFrameSize, const unsigned int halfFrameSizeInterp, const unsigned int lowPassCut, const float epsilon, const float alpha, const float beta, const float Ginterf); + freq2freq_lowpass_obj * freq2freq_lowpass_construct_zero(const unsigned int halfFrameSize, const unsigned int lowPassCut); - void freq2freq_destroy(freq2freq_obj * obj); + void freq2freq_lowpass_destroy(freq2freq_lowpass_obj * obj); - void freq2freq_process_phasor(freq2freq_obj * obj, const freqs_obj * freqs, freqs_obj * phasors); + void freq2freq_lowpass_process(freq2freq_lowpass_obj * obj, const freqs_obj * freqsAllPass, freqs_obj * freqsLowPass); - void freq2freq_process_product(freq2freq_obj * obj, const freqs_obj * freqs1, const freqs_obj * freqs2, const pairs_obj * pairs, freqs_obj * freqs12); + freq2freq_interpolate_obj * freq2freq_interpolate_construct_zero(const unsigned int halfFrameSize, const unsigned int halfFrameSizeInterp); - void freq2freq_process_lowpass(freq2freq_obj * obj, const freqs_obj * freqsAllPass, freqs_obj * freqsLowPass); + void freq2freq_interpolate_destroy(freq2freq_interpolate_obj * obj); - void freq2freq_process_interpolate(freq2freq_obj * obj, const freqs_obj * freqs, const freqs_obj * freqsInterp); + void freq2freq_interpolate_process(freq2freq_interpolate_obj * obj, const freqs_obj * freqs, const freqs_obj * freqsInterp); #endif \ No newline at end of file diff --git a/src/utils/transcendental.c b/src/utils/transcendental.c new file mode 100644 index 0000000..780bf59 --- /dev/null +++ b/src/utils/transcendental.c @@ -0,0 +1,72 @@ + + #include "transcendental.h" + + transcendental_obj * transcendental_construct_zero(const float minValue, const float maxValue, const unsigned int nElements) { + + transcendental_obj * obj; + unsigned int iElement; + float v; + float g; + float intPart; + float fracPart; + + const float table[21] = {0.75008f,0.93640f,1.11688f,1.28852f,1.45013f,1.60184f,1.74422f, + 1.87812f,2.00448f,2.12417f,2.23799f,2.34656f,2.45053f,2.55031f, + 2.64646f,2.73921f,2.82895f,2.91602f,3.00049f,3.08265f,3.16270f}; + + obj = (transcendental_obj *) malloc(sizeof(transcendental_obj)); + + obj->minValue = minValue; + obj->maxValue = maxValue; + obj->interval = (maxValue-minValue) / ((float) (nElements-1)); + + obj->array = (float *) malloc(sizeof(float) * nElements); + memset(obj->array, 0x00, sizeof(float) * nElements); + + v = 0.0f; + + for (iElement = 0; iElement < nElements; iElement++) { + + if (v > 9.5f) { + + intPart = floorf(2.0f * v); + fracPart = 2.0f * v - intPart; + + g = ((1-fracPart) * table[((unsigned int) intPart)] + fracPart * table[((unsigned int) intPart) + 1]) / sqrtf(v + 0.0001f); + + } + else { + g = 1.0f; + } + + v += obj->interval; + + } + + return obj; + + } + + void transcendental_destroy(transcendental_obj * obj) { + + free((void *) obj->array); + free((void *) obj); + + } + + float transcendental_process(const transcendental_obj * obj, const float value) { + + signed int iElement; + + iElement = ((unsigned int) floorf(value / obj->interval)) + 1; + + if (iElement < 0) { + iElement = 0; + } + if (iElement > (obj->nElements - 1)) { + iElement = obj->nElements - 1; + } + + return obj->array[iElement]; + + } \ No newline at end of file diff --git a/src/utils/transcendental.h b/src/utils/transcendental.h new file mode 100644 index 0000000..b87f491 --- /dev/null +++ b/src/utils/transcendental.h @@ -0,0 +1,26 @@ +#ifndef __ODAS_UTILS_TRANSCENDENTAL +#define __ODAS_UTILS_TRANSCENDENTAL + + #include + #include + #include + #include + + typedef struct transcendental_obj { + + float maxValue; + float minValue; + float interval; + + float * array; + unsigned int nElements; + + } transcendental_obj; + + transcendental_obj * transcendental_construct_zero(const float minValue, const float maxValue, const unsigned int nElements); + + void transcendental_destroy(transcendental_obj * obj); + + float transcendental_process(const transcendental_obj * obj, const float value); + +#endif \ No newline at end of file -- 2.34.1