src/init/space.c
src/init/windowing.c
+ src/signal/acorr.c
src/signal/aimg.c
src/signal/area.c
src/signal/assignation.c
src/signal/beampattern.c
+ src/signal/category.c
src/signal/coherence.c
src/signal/delta.c
src/signal/demixing.c
src/signal/mixture.c
src/signal/pair.c
src/signal/particle.c
+ src/signal/pitch.c
src/signal/point.c
src/signal/postprob.c
src/signal/pot.c
src/signal/window.c
src/signal/xcorr.c
+ src/system/acorr2pitch.c
src/system/demixing2freq.c
src/system/hop2hop.c
src/system/hop2frame.c
src/system/frame2freq.c
+ src/system/freq2acorr.c
src/system/freq2freq.c
src/system/freq2frame.c
src/system/freq2xcorr.c
src/system/mixture2mixture.c
src/system/particle2coherence.c
src/system/particle2particle.c
+ src/system/pitch2category.c
src/system/steer2demixing.c
src/system/track2gain.c
src/system/track2steer.c
src/amessage/amsg_pots.c
src/amessage/amsg_spectra.c
src/amessage/amsg_tracks.c
- src/amodule/amod_gain.c
src/amodule/amod_istft.c
src/amodule/amod_mapping.c
src/amodule/amod_resample.c
src/message/msg_pots.c
src/message/msg_spectra.c
src/message/msg_tracks.c
- src/module/mod_gain.c
src/module/mod_istft.c
src/module/mod_mapping.c
src/module/mod_resample.c
# Input with raw signal from microphones
interface: {
type = "file";
- path = "input.raw";
+ path = "input_cma.raw";
}
}
interface: {
type = "file";
- path = "separated.raw";
+ path = "separated_cma.raw";
}
};
interface: {
type = "file";
- path = "postfiltered.raw";
+ path = "postfiltered_cma.raw";
}
};
--- /dev/null
+# Configuration file for ReSpeaker circular sound card
+
+version = "2.1";
+
+# Raw
+
+raw:
+{
+
+ fS = 16000;
+ hopSize = 128;
+ nBits = 16;
+ nChannels = 16;
+
+ # Input with raw signal from microphones
+ interface: {
+ type = "file";
+ path = "input_oma.raw";
+ }
+
+}
+
+# Mapping
+
+mapping:
+{
+
+ map: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+
+}
+
+# General
+
+general:
+{
+
+ epsilon = 1E-20;
+
+ size:
+ {
+ hopSize = 128;
+ frameSize = 256;
+ };
+
+ samplerate:
+ {
+ mu = 16000;
+ sigma2 = 0.01;
+ };
+
+ speedofsound:
+ {
+ mu = 343.0;
+ sigma2 = 25.0;
+ };
+
+ mics = (
+
+ # Microphone 1
+ {
+ mu = ( 0.09000, 0.00000, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 2
+ {
+ mu = ( 0.11550, -0.04780, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 3
+ {
+ mu = ( 0.03540, 0.03540, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 4
+ {
+ mu = ( 0.11550, 0.04780, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 5
+ {
+ mu = ( 0.03540, -0.03540, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 6
+ {
+ mu = ( 0.04780, -0.11550, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 7
+ {
+ mu = ( -0.00000, -0.09000, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 8
+ {
+ mu = ( -0.04780, -0.11550, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 9
+ {
+ mu = ( -0.09000, 0.00000, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 10
+ {
+ mu = ( -0.11550, 0.04780, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 11
+ {
+ mu = ( -0.03540, -0.03540, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 12
+ {
+ mu = ( -0.11550, -0.04780, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 13
+ {
+ mu = ( -0.03540, 0.03540, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 14
+ {
+ mu = ( -0.04780, 0.11550, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 15
+ {
+ mu = ( 0.00000, 0.09000, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 16
+ {
+ mu = ( 0.04780, 0.11550, 0.00000 );
+ sigma2 = ( 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000010000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000 );
+ direction = ( 0.00000, 0.00000, 1.00000 );
+ angle = ( 80.0, 100.0 );
+ }
+
+ );
+
+ # Spatial filter to include only a range of direction if required
+ # (may be useful to remove false detections from the floor)
+ spatialfilter: {
+
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ };
+
+ nThetas = 181;
+ gainMin = 0.25;
+
+};
+
+# Sound Source Localization
+
+ssl:
+{
+
+ nPots = 4;
+ nMatches = 10;
+ probMin = 0.3;
+ nRefinedLevels = 1;
+ interpRate = 1;
+
+ # Number of scans: level is the resolution of the sphere
+ # and delta is the size of the maximum sliding window
+ # (delta = -1 means the size is automatically computed)
+ scans = (
+ { level = 2; delta = -1; },
+ { level = 4; delta = -1; }
+ );
+
+ # Output to export potential sources
+ potential: {
+
+ format = "json";
+
+ interface: {
+ type = "blackhole";
+ };
+
+ };
+
+};
+
+# Sound Source Tracking
+
+sst:
+{
+
+ # Mode is either "kalman" or "particle"
+
+ mode = "kalman";
+
+ # Parameters used by both the Kalman and particle filter
+
+ active = (
+ { weight = 1.0; mu = 0.3; sigma2 = 0.0025 }
+ );
+
+ inactive = (
+ { weight = 1.0; mu = 0.15; sigma2 = 0.0025 }
+ );
+
+ sigmaR2_prob = 0.0025;
+ sigmaR2_active = 0.0225;
+ Pfalse = 0.1;
+ Pnew = 0.1;
+ Ptrack = 0.8;
+
+ theta_new = 0.9;
+ N_prob = 5;
+ theta_prob = 0.8;
+ N_inactive = ( 150, 200, 250, 250 );
+ theta_inactive = 0.9;
+
+ # Parameters used by the Kalman filter only
+
+ kalman: {
+
+ sigmaQ = 0.001;
+
+ };
+
+ # Parameters used by the particle filter only
+
+ particle: {
+
+ nParticles = 1000;
+ st_alpha = 2.0;
+ st_beta = 0.04;
+ st_ratio = 0.5;
+ ve_alpha = 0.05;
+ ve_beta = 0.2;
+ ve_ratio = 0.3;
+ ac_alpha = 0.5;
+ ac_beta = 0.2;
+ ac_ratio = 0.2;
+ Nmin = 0.7;
+
+ };
+
+ # Output to export tracked sources
+ tracked: {
+
+ format = "json";
+
+ interface: {
+ type = "blackhole";
+ };
+
+ };
+
+}
+
+sss:
+{
+
+ # Mode is either "dds", "dgss" or "dmvdr"
+
+ mode_sep = "dds";
+ mode_pf = "ms";
+
+ dds: {
+
+ };
+
+ dgss: {
+
+ };
+
+ dmvdr: {
+
+ };
+
+ ms: {
+
+ };
+
+ separated: {
+
+ fS = 44100;
+ hopSize = 512;
+ nBits = 16;
+
+ interface: {
+ type = "file";
+ path = "separated_oma.raw";
+ }
+
+ };
+
+ postfiltered: {
+
+ fS = 44100;
+ hopSize = 512;
+ nBits = 16;
+
+ interface: {
+ type = "file";
+ path = "postfiltered_oma.raw";
+ }
+
+ };
+
+}
#include "../../src/message/msg_pots.h"
#include "../../src/message/msg_spectra.h"
#include "../../src/message/msg_tracks.h"
- #include "../../src/module/mod_gain.h"
#include "../../src/module/mod_istft.h"
#include "../../src/module/mod_mapping.h"
#include "../../src/module/mod_resample.h"
#include "../../src/amessage/amsg_pots.h"
#include "../../src/amessage/amsg_spectra.h"
#include "../../src/amessage/amsg_tracks.h"
- #include "../../src/amodule/amod_gain.h"
#include "../../src/amodule/amod_istft.h"
#include "../../src/amodule/amod_mapping.h"
#include "../../src/amodule/amod_resample.h"
--- /dev/null
+
+ #include "acorr.h"
+
+ acorrs_obj * acorrs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize) {
+
+ acorrs_obj * obj;
+ unsigned int iSignal;
+
+ obj = (acorrs_obj *) malloc(sizeof(acorrs_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);
+
+ }
+
+
+ return obj;
+
+ }
+
+ void acorrs_destroy(acorrs_obj * obj) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+
+ free((void *) obj->array[iSignal]);
+
+ }
+
+ free((void *) obj->array);
+
+ }
+
+ void acorrs_copy(acorrs_obj * dest, const acorrs_obj * src) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < src->nSignals; iSignal++) {
+
+ memcpy(dest->array[iSignal],src->array[iSignal], sizeof(float) * src->halfFrameSize);
+
+ }
+
+ }
+
+ void acorrs_zero(acorrs_obj * obj) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+
+ memset(obj->array[iSignal], 0x00, sizeof(float) * obj->halfFrameSize);
+
+ }
+
+ }
+
+ void acorrs_printf(const acorrs_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");
+
+ }
+
+ }
--- /dev/null
+#ifndef __ODAS_SIGNAL_ACORR
+#define __ODAS_SIGNAL_ACORR
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+
+ typedef struct acorrs_obj {
+
+ unsigned int nSignals;
+ unsigned int halfFrameSize;
+ float ** array;
+
+ } acorrs_obj;
+
+ acorrs_obj * acorrs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize);
+
+ void acorrs_destroy(acorrs_obj * obj);
+
+ void acorrs_copy(acorrs_obj * dest, const acorrs_obj * src);
+
+ void acorrs_zero(acorrs_obj * obj);
+
+ void acorrs_printf(const acorrs_obj * obj);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "category.h"
+
+ categories_obj * categories_construct_zero(const unsigned int nSignals) {
+
+ categories_obj * obj;
+
+ obj = (categories_obj *) malloc(sizeof(categories_obj));
+
+ obj->nSignals = nSignals;
+ obj->array = (char *) malloc(sizeof(char) * nSignals);
+ memset(obj->array, 0x00, sizeof(char) * nSignals);
+
+ return obj;
+
+ }
+
+ void categories_destroy(categories_obj * obj) {
+
+ free((void *) obj->array);
+ free((void *) obj);
+
+ }
+
+ void categories_printf(const categories_obj * obj) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+
+ printf("(%02u): %c\n",iSignal,obj->array[iSignal]);
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SIGNAL_CATEGORY
+#define __ODAS_SIGNAL_CATEGORY
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+
+ typedef struct categories_obj {
+
+ unsigned int nSignals;
+ char * array;
+
+ } categories_obj;
+
+ categories_obj * categories_construct_zero(const unsigned int nSignals);
+
+ void categories_destroy(categories_obj * obj);
+
+ void categories_printf(const categories_obj * obj);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "pitch.h"
+
+ pitches_obj * pitches_construct_zero(const unsigned int nSignals) {
+
+ pitches_obj * obj;
+
+ obj = (pitches_obj *) malloc(sizeof(pitches_obj));
+
+ obj->nSignals = nSignals;
+ obj->array = (float *) malloc(sizeof(float) * nSignals);
+ memset(obj->array, 0x00, sizeof(float) * nSignals);
+
+ return obj;
+
+ }
+
+ void pitches_destroy(pitches_obj * obj) {
+
+ free((void *) obj->array);
+ free((void *) obj);
+
+ }
+
+ void pitches_copy(pitches_obj * dest, const pitches_obj * src) {
+
+ memcpy(dest->array, src->array, sizeof(float) * src->nSignals);
+
+ }
+
+ void pitches_zero(pitches_obj * obj) {
+
+ memset(obj->array, 0x00, sizeof(float) * obj->nSignals);
+
+ }
+
+ void pitches_printf(const pitches_obj * obj) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+
+ printf("(%02u): %1.5f\n",iSignal,obj->array[iSignal]);
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SIGNAL_PITCH
+#define __ODAS_SIGNAL_PITCH
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+
+ typedef struct pitches_obj {
+
+ unsigned int nSignals;
+ float * array;
+
+ } pitches_obj;
+
+ pitches_obj * pitches_construct_zero(const unsigned int nSignals);
+
+ void pitches_destroy(pitches_obj * obj);
+
+ void pitches_copy(pitches_obj * dest, const pitches_obj * src);
+
+ void pitches_zero(pitches_obj * obj);
+
+ void pitches_printf(const pitches_obj * obj);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "acorr2pitch.h"
+
+ acorr2pitch_obj * acorr2pitch_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize, const unsigned int winSize) {
+
+ acorr2pitch_obj * obj;
+
+ obj = (acorr2pitch_obj *) malloc(sizeof(acorr2pitch_obj));
+
+ obj->nSignals = nSignals;
+ obj->halfFrameSize = halfFrameSize;
+ obj->winSize = winSize;
+
+ return obj;
+
+ }
+
+ void acorr2pitch_destroy(acorr2pitch_obj * obj) {
+
+ free((void *) obj);
+
+ }
+
+ void acorr2pitch_process(acorr2pitch_obj * obj, const acorrs_obj * acorrs, pitches_obj * pitches) {
+
+ unsigned int iSignal;
+
+ signed int iBin;
+ signed int iWin;
+ signed int iSample;
+
+ float peakValue;
+ float nextValue;
+
+ float maxValue;
+ unsigned int maxIndex;
+ char isPeak;
+
+ unsigned int peakPrev;
+ unsigned int peakNow;
+ unsigned int peakNext;
+ float RPrev;
+ float RNow;
+ float RNext;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+
+ for (iBin = obj->winSize; iBin < (obj->halfFrameSize - obj->winSize); iBin++) {
+
+ peakValue = acorrs->array[iSignal][iBin];
+ isPeak = 0x01;
+
+ for (iWin = -1 * (obj->winSize); iWin <= obj->winSize; iWin++) {
+
+ iSample = iBin + iWin;
+ nextValue = acorrs->array[iSignal][iSample];
+
+ if (peakValue <= nextValue) {
+
+ isPeak = 0x00;
+ break;
+
+ }
+
+ }
+
+ if (isPeak == 0x01) {
+
+ if (peakValue > maxValue) {
+
+ maxValue = peakValue;
+ maxIndex = iBin;
+
+ }
+
+ }
+
+ }
+
+ peakPrev = maxIndex - 1;
+ peakNow = maxIndex;
+ peakNext = maxIndex + 1;
+ RPrev = acorrs->array[iSignal][peakPrev];
+ RNow = acorrs->array[iSignal][peakNow];
+ RNext = acorrs->array[iSignal][peakNext];
+
+ pitches->array[iSignal] = ((float) peakNow) + ((RPrev - RNext) / (2*RPrev - 4*RNow + 2*RNext));
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SYSTEM_ACORR2PITCH
+#define __ODAS_SYSTEM_ACORR2PITCH
+
+ #include "../signal/acorr.h"
+ #include "../signal/pitch.h"
+
+ typedef struct acorr2pitch_obj {
+
+ unsigned int nSignals;
+ unsigned int halfFrameSize;
+ unsigned int frameSize;
+ unsigned int winSize;
+ unsigned int minBin;
+ unsigned int maxBin;
+
+ } acorr2pitch_obj;
+
+ acorr2pitch_obj * acorr2pitch_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize, const unsigned int winSize);
+
+ void acorr2pitch_destroy(acorr2pitch_obj * obj);
+
+ void acorr2pitch_process(acorr2pitch_obj * obj, const acorrs_obj * acorrs, pitches_obj * pitches);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "freq2acorr.h"
+
+ freq2acorr_obj * freq2acorr_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize) {
+
+ freq2acorr_obj * obj;
+
+ obj = (freq2acorr_obj *) malloc(sizeof(freq2acorr_obj));
+
+ obj->nSignals = nSignals;
+ obj->halfFrameSize = halfFrameSize;
+ obj->frameSize = (halfFrameSize-1)*2;
+
+ obj->array = (float *) malloc(sizeof(float) * obj->frameSize);
+
+ obj->fft = fft_construct(obj->frameSize);
+
+ return obj;
+
+ }
+
+ void freq2acorr_destroy(freq2acorr_obj * obj) {
+
+ free((void *) obj->array);
+ fft_destroy(obj->fft);
+ free((void *) obj);
+
+ }
+
+ void freq2acorr_process(freq2acorr_obj * obj, const freqs_obj * freqs, acorrs_obj * acorrs) {
+
+ unsigned int iSignal;
+
+ for (iSignal = 0; iSignal < obj->nSignals; iSignal++) {
+
+ fft_c2r(obj->fft, freqs->array[iSignal], obj->array);
+
+ memcpy(acorrs->array[iSignal], obj->array, sizeof(float) * obj->halfFrameSize);
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SYSTEM_FREQ2ACORR
+#define __ODAS_SYSTEM_FREQ2ACORR
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+
+ #include "../signal/acorr.h"
+ #include "../signal/freq.h"
+ #include "../utils/fft.h"
+
+ typedef struct freq2acorr_obj {
+
+ unsigned int nSignals;
+ unsigned int halfFrameSize;
+ unsigned int frameSize;
+
+ float * array;
+
+ fft_obj * fft;
+
+ } freq2acorr_obj;
+
+ freq2acorr_obj * freq2acorr_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize);
+
+ void freq2acorr_destroy(freq2acorr_obj * obj);
+
+ void freq2acorr_process(freq2acorr_obj * obj, const freqs_obj * freqs, acorrs_obj * acorrs);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "pitch2category.h"
+
+ pitch2category_obj * pitch2category_construct_zero(const unsigned int nSeps, const float tauMin, const float tauMax, const float deltaTauMax, const float alpha, const float gamma, const float phiMin, const float r0) {
+
+ pitch2category_obj * obj;
+
+ obj = (pitch2category_obj *) malloc(sizeof(pitch2category_obj));
+
+ obj->nSeps = nSeps;
+
+ obj->tauMin = tauMin;
+ obj->tauMax = tauMax;
+ obj->deltaTauMax = deltaTauMax;
+ obj->alpha = alpha;
+ obj->gamma = gamma;
+ obj->phiMin = phiMin;
+ obj->r0 = r0;
+
+ obj->tausNow = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->tausNow, 0x00, sizeof(float) * nSeps);
+
+ obj->tausPrev = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->tausPrev, 0x00, sizeof(float) * nSeps);
+
+ obj->deltaTausNow = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->deltaTausNow, 0x00, sizeof(float) * nSeps);
+
+ obj->deltaTausPrev = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->deltaTausPrev, 0x00, sizeof(float) * nSeps);
+
+ obj->phisNow = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->phisNow, 0x00, sizeof(float) * nSeps);
+
+ obj->phisPrev = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->phisPrev, 0x00, sizeof(float) * nSeps);
+
+ obj->vs = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->vs, 0x00, sizeof(float) * nSeps);
+
+ obj->rs = (float *) malloc(sizeof(float) * nSeps);
+ memset(obj->rs, 0x00, sizeof(float) * nSeps);
+
+ return obj;
+
+ }
+
+ void pitch2category_destroy(pitch2category_obj * obj) {
+
+ free((void *) obj->rs);
+ free((void *) obj->tausNow);
+ free((void *) obj->tausPrev);
+ free((void *) obj->deltaTausNow);
+ free((void *) obj->deltaTausPrev);
+ free((void *) obj->phisNow);
+ free((void *) obj->phisPrev);
+ free((void *) obj->vs);
+ free((void *) obj->rs);
+
+ free((void *) obj);
+
+ }
+
+ void pitch2category_process(pitch2category_obj * obj, const pitches_obj * pitches, categories_obj * categories) {
+
+ unsigned int iSep;
+ float deltaPitch;
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ // tau_i
+ obj->tausNow[iSep] = pitches->array[iSep];
+
+ // delta_tau_i
+ obj->deltaTausNow[iSep] = obj->tausNow[iSep] - obj->tausPrev[iSep];
+
+ // phi_i
+ if ((fabs(obj->deltaTausNow[iSep]) < obj->deltaTauMax) && (fabs(obj->deltaTausPrev[iSep]) < obj->deltaTauMax)) {
+
+ obj->phisNow[iSep] = (1 - obj->alpha) * obj->phisPrev[iSep] + obj->alpha * obj->deltaTausNow[iSep];
+
+ }
+ else if ((fabs(obj->deltaTausNow[iSep]) < obj->deltaTauMax) && (fabs(obj->deltaTausPrev[iSep]) >= obj->deltaTauMax)) {
+
+ obj->phisNow[iSep] = obj->deltaTausNow[iSep];
+
+ }
+ else {
+
+ obj->phisNow[iSep] = 0.0f;
+
+ }
+
+ // v_i
+ if ((obj->tausNow[iSep] >= obj->tauMin) && (obj->tausNow[iSep] <= obj->tauMax) && fabs(obj->phisNow[iSep]) > obj->phiMin) {
+
+ obj->vs[iSep] = 1.0f;
+
+ }
+ else {
+
+ obj->vs[iSep] = 0.0f;
+
+ }
+
+ // r_i
+ obj->rs[iSep] = (1.0f - obj->gamma) * obj->rs[iSep] + obj->gamma * obj->vs[iSep];
+
+ // Classify
+
+ if (obj->rs[iSep] > obj->r0) {
+
+ // Speech
+ categories->array[iSep] = 0x01;
+
+ }
+ else {
+
+ // Non speech
+ categories->array[iSep] = 0x02;
+
+ }
+
+ // tau_i-1 = tau_i
+ memcpy(obj->tausPrev, obj->tausNow, sizeof(float) * obj->nSeps);
+
+ // delta_tau_i-1 = delta_tau_i
+ memcpy(obj->deltaTausPrev, obj->deltaTausNow, sizeof(float) * obj->nSeps);
+
+ // phi_i-1 = phi_i
+ memcpy(obj->phisPrev, obj->phisNow, sizeof(float) * obj->nSeps);
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SYSTEM_PITCH2CATEGORY
+#define __ODAS_SYSTEM_PITCH2CATEGORY
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+ #include <math.h>
+
+ #include "../signal/category.h"
+ #include "../signal/pitch.h"
+
+ typedef struct pitch2category_obj {
+
+ unsigned int nSeps;
+
+ float tauMin;
+ float tauMax;
+ float deltaTauMax;
+ float alpha;
+ float gamma;
+ float phiMin;
+ float r0;
+
+ float * tausNow;
+ float * tausPrev;
+ float * deltaTausNow;
+ float * deltaTausPrev;
+ float * phisNow;
+ float * phisPrev;
+ float * vs;
+ float * rs;
+
+ } pitch2category_obj;
+
+ pitch2category_obj * pitch2category_construct_zero(const unsigned int nSeps, const float tauMin, const float tauMax, const float deltaTauMax, const float alpha, const float gamma, const float phiMin, const float r0);
+
+ void pitch2category_destroy(pitch2category_obj * obj);
+
+ void pitch2category_process(pitch2category_obj * obj, const pitches_obj * pitches, categories_obj * categories);
+
+#endif
\ No newline at end of file