src/signal/coherence.c
src/signal/delta.c
src/signal/demixing.c
+ src/signal/env.c
src/signal/frame.c
src/signal/freq.c
src/signal/gain.c
src/system/acorr2pitch.c
src/system/demixing2freq.c
+ src/system/env2env.c
src/system/hop2hop.c
src/system/hop2frame.c
src/system/frame2freq.c
src/system/freq2acorr.c
+ src/system/freq2env.c
src/system/freq2freq.c
src/system/freq2frame.c
src/system/freq2xcorr.c
src/connector/con_categories.c
src/connector/con_hops.c
src/connector/con_pots.c
+ src/connector/con_powers.c
src/connector/con_spectra.c
src/connector/con_tracks.c
src/message/msg_categories.c
src/message/msg_hops.c
src/message/msg_pots.c
+ src/message/msg_powers.c
src/message/msg_spectra.c
src/message/msg_tracks.c
src/module/mod_classify.c
odas
)
+add_executable(server
+ demo/server.c
+)
+target_link_libraries(server
+ odas
+)
+
install(TARGETS odas DESTINATION lib)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+ #include <signal.h>
+ #include <getopt.h>
int main(int argc, char* argv[])
{
char * message;
int messageSize;
- if (argc != 2) {
+ int c;
+ unsigned int portNumber;
+ char * fileName;
+ FILE * fp;
+
+ const unsigned int nBytes = 10240;
+
+ while ((c = getopt(argc,argv, "p:o:")) != -1) {
+
+ switch(c) {
+
+ case 'p':
+
+ portNumber = atoi(optarg);
+
+ break;
+
+ case 'o':
+
+ fileName = (char *) malloc(sizeof(char) * (strlen(optarg)+1));
+ strcpy(fileName, optarg);
+
+ break;
+
+ }
- printf("Expecting one argument\n");
- exit(EXIT_FAILURE);
}
server_id = socket(AF_INET, SOCK_STREAM, 0);
server_address.sin_family = AF_INET;
server_address.sin_addr.s_addr = htonl(INADDR_ANY);
- server_address.sin_port = htons(atoi(argv[1]));
+ server_address.sin_port = htons(portNumber);
+
+ printf("Opening file............. "); fflush(stdout);
+ fp = fopen(fileName, "wb");
+ printf("[OK]\n");
- printf("Binding socket... "); fflush(stdout);
+ printf("Binding socket........... "); fflush(stdout);
bind(server_id, (struct sockaddr *) &server_address, sizeof(server_address));
printf("[OK]\n");
- printf("Listening socket... "); fflush(stdout);
+ printf("Listening socket......... "); fflush(stdout);
listen(server_id, 1);
printf("[OK]\n");
- printf("Waiting for connection..."); fflush(stdout);
+ printf("Waiting for connection... "); fflush(stdout);
connection_id = accept(server_id, (struct sockaddr*) NULL, NULL);
printf("[OK]\n");
- message = (char *) malloc(sizeof(char) * 1024 * 10);
+ message = (char *) malloc(sizeof(char) * nBytes);
- while( (messageSize = recv(connection_id, message, 1024 * 10, 0)) > 0) {
+ while( (messageSize = recv(connection_id, message, nBytes, 0)) > 0) {
message[messageSize] = 0x00;
- printf("Received (%u): %s\n",messageSize,message);
+ fwrite(message, messageSize, sizeof(char), fp);
}
- printf("messageSize = %d\n",messageSize);
+ fclose(fp);
}
\ No newline at end of file
--- /dev/null
+
+ #include "con_powers.h"
+
+ con_powers_obj * con_powers_construct(const unsigned int nOuts, const msg_powers_cfg * msg_powers_config) {
+
+ con_powers_obj * obj;
+ unsigned int iOut;
+
+ obj = (con_powers_obj *) malloc(sizeof(con_powers_obj));
+
+ obj->nOuts = nOuts;
+
+ obj->in = msg_powers_construct(msg_powers_config);
+
+ obj->outs = (msg_powers_obj **) malloc(sizeof(msg_powers_obj *) * nOuts);
+ for (iOut = 0; iOut < obj->nOuts; iOut++) {
+ obj->outs[iOut] = msg_powers_construct(msg_powers_config);
+ }
+
+ return obj;
+
+ }
+
+ void con_powers_destroy(con_powers_obj * obj) {
+
+ unsigned int iOut;
+
+ for (iOut = 0; iOut < obj->nOuts; iOut++) {
+ msg_powers_destroy(obj->outs[iOut]);
+ }
+ free((void *) obj->outs);
+
+ msg_powers_destroy(obj->in);
+
+ free((void *) obj);
+
+ }
+
+ int con_powers_process(con_powers_obj * obj) {
+
+ unsigned int iOut;
+ int rtnValue;
+
+ for (iOut = 0; iOut < obj->nOuts; iOut++) {
+ msg_powers_copy(obj->outs[iOut], obj->in);
+ }
+
+ if (msg_powers_isZero(obj->in) == 1) {
+ rtnValue = -1;
+ }
+ else {
+ rtnValue = 0;
+ }
+
+ return rtnValue;
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_CONNECTOR_POWERS
+#define __ODAS_CONNECTOR_POWERS
+
+ #include "../message/msg_powers.h"
+
+ #include <stdlib.h>
+ #include <stdio.h>
+
+ typedef struct con_powers_obj {
+
+ msg_powers_obj * in;
+ msg_powers_obj ** outs;
+
+ unsigned int nOuts;
+
+ } con_powers_obj;
+
+ con_powers_obj * con_powers_construct(const unsigned int nOuts, const msg_powers_cfg * msg_powers_config);
+
+ void con_powers_destroy(con_powers_obj * obj);
+
+ int con_powers_process(con_powers_obj * obj);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "msg_powers.h"
+
+ msg_powers_obj * msg_powers_construct(const msg_powers_cfg * msg_powers_config) {
+
+ msg_powers_obj * obj;
+
+ obj = (msg_powers_obj *) malloc(sizeof(msg_powers_obj));
+
+ obj->timeStamp = 0;
+ obj->fS = msg_powers_config->fS;
+ obj->envs = envs_construct_zero(msg_powers_config->nChannels, msg_powers_config->halfFrameSize);
+
+ return obj;
+
+ }
+
+ void msg_powers_destroy(msg_powers_obj * obj) {
+
+ envs_destroy(obj->envs);
+ free((void *) obj);
+
+ }
+
+ void msg_powers_copy(msg_powers_obj * dest, const msg_powers_obj * src) {
+
+ dest->timeStamp = src->timeStamp;
+ dest->fS = src->fS;
+ envs_copy(dest->envs, src->envs);
+
+ }
+
+ void msg_powers_zero(msg_powers_obj * obj) {
+
+ obj->timeStamp = 0;
+ obj->fS = 0;
+ envs_zero(obj->envs);
+
+ }
+
+ unsigned int msg_powers_isZero(const msg_powers_obj * obj) {
+
+ unsigned int rtnValue;
+
+ if (obj->timeStamp == 0) {
+ rtnValue = 1;
+ }
+ else {
+ rtnValue = 0;
+ }
+
+ return rtnValue;
+
+ }
+
+ msg_powers_cfg * msg_powers_cfg_construct(void) {
+
+ msg_powers_cfg * cfg;
+
+ cfg = (msg_powers_cfg *) malloc(sizeof(msg_powers_cfg));
+
+ cfg->halfFrameSize = 0;
+ cfg->nChannels = 0;
+ cfg->fS = 0;
+
+ return cfg;
+
+ }
+
+ void msg_powers_cfg_destroy(msg_powers_cfg * msg_powers_config) {
+
+ free((void *) msg_powers_config);
+
+ }
+
+ void msg_powers_cfg_printf(const msg_powers_cfg * msg_powers_config) {
+
+ if (msg_powers_config != NULL) {
+
+ printf("halfFrameSize = %u\n", msg_powers_config->halfFrameSize);
+ printf("nChannels = %u\n", msg_powers_config->nChannels);
+ printf("fS = %u\n", msg_powers_config->fS);
+
+ }
+ else {
+
+ printf("(null)\n");
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_MESSAGE_POWERS
+#define __ODAS_MESSAGE_POWERS
+
+ #include <stdlib.h>
+
+ #include "../signal/env.h"
+
+ typedef struct msg_powers_obj {
+
+ unsigned long long timeStamp;
+ unsigned int fS;
+ envs_obj * envs;
+
+ } msg_powers_obj;
+
+ typedef struct msg_powers_cfg {
+
+ unsigned int halfFrameSize;
+ unsigned int nChannels;
+ unsigned int fS;
+
+ } msg_powers_cfg;
+
+ msg_powers_obj * msg_powers_construct(const msg_powers_cfg * msg_powers_config);
+
+ void msg_powers_destroy(msg_powers_obj * obj);
+
+ void msg_powers_copy(msg_powers_obj * dest, const msg_powers_obj * src);
+
+ void msg_powers_zero(msg_powers_obj * obj);
+
+ unsigned int msg_powers_isZero(const msg_powers_obj * obj);
+
+ msg_powers_cfg * msg_powers_cfg_construct(void);
+
+ void msg_powers_cfg_destroy(msg_powers_cfg * msg_powers_config);
+
+ void msg_powers_cfg_printf(const msg_powers_cfg * msg_powers_config);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "env.h"
+
+ envs_obj * envs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize) {
+
+ envs_obj * obj;
+ unsigned int iSignal;
+
+ obj = (envs_obj *) malloc(sizeof(envs_obj));
+
+ obj->nSignals = nSignals;
+ obj->halfFrameSize = halfFrameSize;
+
+ obj->array = (float **) malloc(sizeof(float *) * nSignals);
+ for (iSignal = 0; iSignal < nSignals; iSignal++) {
+ obj->array[iSignal] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->array[iSignal], 0x00, halfFrameSize * sizeof(float));
+ }
+
+ return obj;
+
+ }
+
+ envs_obj * envs_clone(const envs_obj * obj) {
+
+ envs_obj * clone;
+ unsigned int iSignal;
+
+ clone = (envs_obj *) malloc(sizeof(envs_obj));
+
+ clone->nSignals = obj->nSignals;
+ clone->halfFrameSize = obj->halfFrameSize;
+
+ clone->array = (float **) malloc(sizeof(float *) * obj->nSignals);
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+ clone->array[iSignal] = (float *) malloc(sizeof(float) * obj->halfFrameSize);
+ memcpy(clone->array[iSignal], obj->array[iSignal], obj->halfFrameSize * sizeof(float));
+ }
+
+ return clone;
+
+ }
+
+ void envs_copy(envs_obj * dest, const envs_obj * src) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < src->nSignals; iSignal++) {
+ memcpy(dest->array[iSignal], src->array[iSignal], src->halfFrameSize * sizeof(float));
+ }
+
+ }
+
+ void envs_zero(envs_obj * obj) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+ memset(obj->array[iSignal], 0x00, obj->halfFrameSize * sizeof(float));
+ }
+
+ }
+
+ void envs_destroy(envs_obj * obj) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+ free((void *) obj->array[iSignal]);
+ }
+ free((void *) obj->array);
+
+ free((void *) obj);
+
+ }
+
+ void envs_printf(const envs_obj * obj) {
+
+ unsigned int iSignal;
+ unsigned int iSample;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+
+ printf("(%04u): ",iSignal);
+
+ for (iSample = 0; iSample < obj->halfFrameSize; iSample++) {
+
+ printf("%+1.5f ",
+ obj->array[iSignal][iSample]);
+
+ if ((((iSample+1) % 16) == 0) && ((iSample+1)!=obj->halfFrameSize)) {
+ printf("\n ");
+ }
+
+ }
+
+ printf("\n");
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SIGNAL_ENV
+#define __ODAS_SIGNAL_ENV
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+
+ typedef struct envs_obj {
+
+ unsigned int nSignals;
+ unsigned int halfFrameSize;
+ float ** array;
+
+ } envs_obj;
+
+ envs_obj * envs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize);
+
+ envs_obj * envs_clone(const envs_obj * obj);
+
+ void envs_copy(envs_obj * dest, const envs_obj * src);
+
+ void envs_zero(envs_obj * obj);
+
+ void envs_destroy(envs_obj * obj);
+
+ void envs_printf(const envs_obj * obj);
+
+#endif
\ No newline at end of file
}
+ obj->smessage = (char *) malloc(sizeof(char) * msg_hops_config->nChannels * msg_hops_config->hopSize * 4);
+ memset(obj->smessage, 0x00, sizeof(char) * msg_hops_config->nChannels * msg_hops_config->hopSize * 4);
+
obj->in = (msg_hops_obj *) NULL;
return obj;
format_destroy(obj->format);
interface_destroy(obj->interface);
+ free((void *) obj->smessage);
free((void *) obj);
case interface_socket:
- printf("Not implemented yet.\n");
- exit(EXIT_FAILURE);
+ obj->sserver.sin_family = AF_INET;
+ obj->sserver.sin_port = htons(obj->interface->port);
+ inet_aton(obj->interface->ip, &(obj->sserver.sin_addr));
+
+ obj->sid = socket(AF_INET, SOCK_STREAM, 0);
+
+ if ( (connect(obj->sid, (struct sockaddr *) &(obj->sserver), sizeof(obj->sserver))) < 0 ) {
+
+ printf("Cannot connect to server\n");
+ exit(EXIT_FAILURE);
+
+ }
break;
case interface_socket:
- printf("Not implemented yet.\n");
- exit(EXIT_FAILURE);
+ close(obj->sid);
break;
int snk_hops_process_socket(snk_hops_obj * obj) {
- printf("Not implemented\n");
- exit(EXIT_FAILURE);
+ unsigned int iChannel;
+ unsigned int iSample;
+ float sample;
+ unsigned int nBytes;
+ unsigned int nBytesTotal;
+ int rtnValue;
+
+ if (obj->in->timeStamp != 0) {
+
+ switch (obj->format->type) {
+
+ case format_binary_int08: nBytes = 1; break;
+ case format_binary_int16: nBytes = 2; break;
+ case format_binary_int24: nBytes = 3; break;
+ case format_binary_int32: nBytes = 4; break;
+
+ }
+
+ nBytesTotal = 0;
+
+ for (iSample = 0; iSample < obj->hopSize; iSample++) {
+
+ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+ nBytesTotal += nBytes;
+
+ sample = obj->in->hops->array[iChannel][iSample];
+ pcm_normalized2signedXXbits(sample, nBytes, obj->bytes);
+ memcpy(&(obj->smessage[nBytesTotal]), &(obj->bytes[4-nBytes]), sizeof(char) * nBytes);
+
+ }
+
+ }
+
+ if (send(obj->sid, obj->smessage, nBytesTotal, 0) < 0) {
+ printf("Could not send message.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ rtnValue = 0;
+
+ }
+ else {
+
+ rtnValue = -1;
+
+ }
+
+ return rtnValue;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+ #include <unistd.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
#include "../general/format.h"
#include "../general/interface.h"
FILE * fp;
- //struct sockaddr_in sserver;
- //char * smessage;
- //int sid;
+ struct sockaddr_in sserver;
+ char * smessage;
+ int sid;
char bytes[4];
--- /dev/null
+
+ #include "env2env.h"
+
+ 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) {
+
+ env2env_mcra_obj * obj;
+ unsigned int n;
+ unsigned int iChannel;
+ float bTotal;
+
+ obj = (env2env_mcra_obj *) malloc(sizeof(env2env_mcra_obj));
+
+ obj->nChannels = nChannels;
+ obj->halfFrameSize = halfFrameSize;
+
+ obj->bSize = bSize;
+ obj->alphaS = alphaS;
+ obj->L = L;
+ obj->delta = delta;
+ obj->alphaD = alphaD;
+
+ obj->l = 0;
+
+ obj->b = (float *) malloc(sizeof(float) * bSize);
+ for (n = 0; n < obj->bSize; n++) {
+ obj->b[n] = 0.5f * (1.0f * cosf(2.0f * M_PI * ((float) (n + 1)) / ((float) (obj->bSize + 1))));
+ bTotal += (float) (obj->b[n]);
+ }
+ for (n = 0; n < obj->bSize; n++) {
+ 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);
+ obj->Smin = (float **) malloc(sizeof(float *) * obj->nChannels);
+ obj->SminPrev = (float **) malloc(sizeof(float *) * obj->nChannels);
+ obj->Stmp = (float **) malloc(sizeof(float *) * obj->nChannels);
+ obj->StmpPrev = (float **) malloc(sizeof(float *) * obj->nChannels);
+ obj->lambdaD = (float **) malloc(sizeof(float *) * obj->nChannels);
+ obj->lambdaDnext = (float **) malloc(sizeof(float *) * obj->nChannels);
+
+ for (iChannel = 0; iChannel < nChannels; iChannel++) {
+
+ obj->Sf[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->Sf[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->S[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->S[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->SPrev[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->SPrev[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->Smin[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->Smin[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->SminPrev[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->SminPrev[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->Stmp[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->Stmp[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->StmpPrev[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->StmpPrev[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->lambdaD[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->lambdaD[iChannel], 0x00, sizeof(float) * halfFrameSize);
+ obj->lambdaDnext[iChannel] = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->lambdaDnext[iChannel], 0x00, sizeof(float) * halfFrameSize);
+
+ }
+
+ return obj;
+
+ }
+
+ void env2env_mcra_destroy(env2env_mcra_obj * obj) {
+
+ free((void *) obj);
+
+ }
+
+ void env2env_mcra_process(env2env_mcra_obj * obj, const envs_obj * noisy, envs_obj * noise) {
+
+ unsigned int iChannel;
+ unsigned int iBin;
+ signed int iSample;
+ unsigned int iBinWrapped;
+ float sample;
+
+ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+ // 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] * noisy->array[iChannel][iBinWrapped];
+
+ }
+
+ obj->Sf[iChannel][iBin] = sample;
+
+ }
+
+ //
+ // S_l[k] = (1 - alphaS) * S_l-1[k] + alphaS * Sf_l[k]
+ //
+
+ for (iBin = 0; iBin < obj->halfFrameSize; 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 < 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 {
+
+ // 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];
+
+ }
+
+ }
+
+ // \
+ // | 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++) {
+
+ if ((obj->S[iChannel][iBin] < (obj->Smin[iChannel][iBin] * obj->delta)) || (obj->lambdaD[iChannel][iBin] > noisy->array[iChannel][iBin])) {
+
+ obj->lambdaDnext[iChannel][iBin] = obj->lambdaD[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);
+
+ }
+
+ // Count frames
+
+ (obj->l)++;
+
+ if (obj->l >= obj->L) {
+ obj->l = 0;
+ }
+
+ }
--- /dev/null
+#ifndef __ODAS_SYSTEM_ENV2ENV
+#define __ODAS_SYSTEM_ENV2ENV
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <math.h>
+
+ #include "../signal/env.h"
+
+ typedef struct env2env_mcra_obj {
+
+ unsigned int nChannels;
+ unsigned int halfFrameSize;
+
+ unsigned int bSize;
+ float alphaS;
+ unsigned int L;
+ float delta;
+ float alphaD;
+
+ unsigned int l;
+
+ float * b;
+ float ** S;
+ float ** Smin;
+ float ** SminPrev;
+ float ** SPrev;
+ float ** Stmp;
+ float ** StmpPrev;
+ float ** Sf;
+ float ** lambdaD;
+ float ** lambdaDnext;
+
+ } env2env_mcra_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);
+
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "freq2env.h"
+
+ freq2env_obj * freq2env_construct_zero(const unsigned int halfFrameSize) {
+
+ freq2env_obj * obj;
+
+ obj = (freq2env_obj *) malloc(sizeof(freq2env_obj));
+
+ obj->halfFrameSize = halfFrameSize;
+
+ return obj;
+
+ }
+
+ void freq2env_destroy(freq2env_obj * obj) {
+
+ free((void *) obj);
+
+ }
+
+ void freq2env_process(freq2env_obj * obj, const freqs_obj * freqs, envs_obj * envs) {
+
+ unsigned int iSignal;
+ unsigned int iBin;
+
+ float Xreal;
+ float Ximag;
+ float X2;
+
+ for (iSignal = 0; iSignal < freqs->nSignals; iSignal++) {
+
+ for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
+
+ Xreal = freqs->array[iSignal][iBin * 2 + 0];
+ Ximag = freqs->array[iSignal][iBin * 2 + 1];
+
+ X2 = Xreal * Xreal + Ximag * Ximag;
+
+ envs->array[iSignal][iBin] = X2;
+
+ }
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SYSTEM_FREQ2ENV
+#define __ODAS_SYSTEM_FREQ2ENV
+
+ #include <stdlib.h>
+
+ #include "../signal/freq.h"
+ #include "../signal/env.h"
+
+ typedef struct freq2env_obj {
+
+ unsigned int halfFrameSize;
+
+ } freq2env_obj;
+
+ freq2env_obj * freq2env_construct_zero(const unsigned int halfFrameSize);
+
+ void freq2env_destroy(freq2env_obj * obj);
+
+ void freq2env_process(freq2env_obj * obj, const freqs_obj * freqs, envs_obj * envs);
+
+#endif
\ No newline at end of file