);
- # Spatial filter to include only a range of direction if required
- # (may be useful to remove false detections from the floor)
- spatialfilter: {
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
- direction = ( +0.000, +0.000, +1.000 );
- angle = (80.0, 90.0);
+ {
- };
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ }
+
+ );
nThetas = 181;
gainMin = 0.25;
);
- # Spatial filter to include only a range of direction if required
- # (may be useful to remove false detections from the floor)
- spatialfilter: {
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
- direction = ( +0.000, +0.000, +1.000 );
- angle = (80.0, 100.0);
+ {
- };
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ }
+
+ );
nThetas = 181;
gainMin = 0.25;
mu = ( +0.000, +0.000, +0.000 );
sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
direction = ( +0.000, +0.000, +1.000 );
- angle = ( 80.0, 100.0 );
+ angle = ( 90.0, 100.0 );
},
# Microphone 1
mu = ( +0.000, +0.043, +0.000 );
sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
direction = ( +0.000, +0.000, +1.000 );
- angle = ( 80.0, 100.0 );
+ angle = ( 90.0, 100.0 );
},
# Microphone 2
mu = ( +0.037, +0.021, +0.000 );
sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
direction = ( +0.000, +0.000, +1.000 );
- angle = ( 80.0, 100.0 );
+ angle = ( 90.0, 100.0 );
},
# Microphone 3
mu = ( +0.037, -0.021, +0.000 );
sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
direction = ( +0.000, +0.000, +1.000 );
- angle = ( 80.0, 100.0 );
+ angle = ( 90.0, 100.0 );
},
# Microphone 4
mu = ( +0.000, -0.043, +0.000 );
sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
direction = ( +0.000, +0.000, +1.000 );
- angle = ( 80.0, 100.0 );
+ angle = ( 90.0, 100.0 );
},
# Microphone 5
mu = ( -0.037, -0.021, +0.000 );
sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
direction = ( +0.000, +0.000, +1.000 );
- angle = ( 80.0, 100.0 );
+ angle = ( 90.0, 100.0 );
},
# Microphone 6
mu = ( -0.037, +0.021, +0.000 );
sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
direction = ( +0.000, +0.000, +1.000 );
- angle = ( 80.0, 100.0 );
+ angle = ( 90.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: {
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
- direction = ( +0.000, +0.000, +1.000 );
- angle = (80.0, 100.0);
+ {
- };
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (90.0, 95.0);
+
+ }
+
+ );
nThetas = 181;
gainMin = 0.25;
);
- # Spatial filter to include only a range of direction if required
- # (may be useful to remove false detections from the floor)
- spatialfilter: {
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
- direction = ( +0.000, +0.000, +1.000 );
- angle = (80.0, 100.0);
+ {
+
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ }
- };
+ );
nThetas = 181;
gainMin = 0.25;
--- /dev/null
+# Configuration file for XMOS circular sound card
+
+version = "2.1";
+
+# Raw
+
+raw:
+{
+
+ fS = 48000;
+ hopSize = 512;
+ nBits = 16;
+ nChannels = 4;
+
+ # Input with raw signal from microphones
+ interface: {
+ type = "soundcard";
+ card = 2;
+ device = 0;
+ }
+
+}
+
+# Mapping
+
+mapping:
+{
+
+ map: (1, 2, 3, 4);
+
+}
+
+# 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 0
+ {
+ mu = ( +0.000, -0.030, +0.000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 90.0, 100.0 );
+ },
+
+ # Microphone 1
+ {
+ mu = ( +0.000, +0.010, +0.000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 90.0, 100.0 );
+ },
+
+ # Microphone 2
+ {
+ mu = ( +0.000, +0.010, +0.000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 90.0, 100.0 );
+ },
+
+ # Microphone 3
+ {
+ mu = ( +0.000, +0.030, +0.000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 90.0, 100.0 );
+ }
+
+ );
+
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
+
+ {
+
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (90.0, 95.0);
+
+ },
+
+ {
+
+ direction = ( +0.000, +0.000, -1.000 );
+ angle = (90.0, 95.0);
+
+ }
+
+ );
+
+ nThetas = 181;
+ gainMin = 0.25;
+
+};
+
+# Stationnary noise estimation
+
+sne:
+{
+
+ b = 3;
+ alphaS = 0.1;
+ L = 150;
+ delta = 3.0;
+ alphaD = 0.1;
+
+}
+
+# Sound Source Localization
+
+ssl:
+{
+
+ nPots = 4;
+ nMatches = 10;
+ probMin = 0.5;
+ nRefinedLevels = 1;
+ interpRate = 4;
+
+ # 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 = "undefined";
+
+ interface: {
+ type = "blackhole";
+ };
+
+ };
+
+};
+
+# Sound Source Tracking
+
+sst:
+{
+
+ # Mode is either "kalman" or "particle"
+
+ mode = "kalman";
+
+ # Add is either "static" or "dynamic"
+
+ add = "dynamic";
+
+ # Parameters used by both the Kalman and particle filter
+
+ active = (
+ { weight = 1.0; mu = 0.4; sigma2 = 0.0025 }
+ );
+
+ inactive = (
+ { weight = 1.0; mu = 0.25; sigma2 = 0.0025 }
+ );
+
+ sigmaR2_prob = 0.0025;
+ sigmaR2_active = 0.0225;
+ sigmaR2_target = 0.0025;
+ Pfalse = 0.1;
+ Pnew = 0.1;
+ Ptrack = 0.8;
+
+ theta_new = 0.3;
+ N_prob = 5;
+ theta_prob = 0.8;
+ N_inactive = ( 150, 150, 150, 150 );
+ 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;
+
+ };
+
+ target: ();
+
+ # Output to export tracked sources
+ tracked: {
+
+ format = "json";
+
+ interface: {
+ type = "terminal";
+ };
+
+ };
+
+}
+
+sss:
+{
+
+ # Mode is either "dds", "dgss" or "dmvdr"
+
+ mode_sep = "dds";
+ mode_pf = "ss";
+
+ gain_sep = 1.0;
+ gain_pf = 10.0;
+
+ dds: {
+
+ };
+
+ dgss: {
+
+ mu = 0.01;
+ lambda = 0.5;
+
+ };
+
+ dmvdr: {
+
+ };
+
+ ms: {
+
+ alphaPmin = 0.07;
+ eta = 0.5;
+ alphaZ = 0.8;
+ thetaWin = 0.3;
+ alphaWin = 0.3;
+ maxAbsenceProb = 0.9;
+ Gmin = 0.01;
+ winSizeLocal = 3;
+ winSizeGlobal = 23;
+ winSizeFrame = 256;
+
+ };
+
+ ss: {
+
+ Gmin = 0.01;
+ Gmid = 0.5;
+ Gslope = 10.0;
+
+ }
+
+ separated: {
+
+ fS = 16000;
+ hopSize = 128;
+ nBits = 16;
+
+ interface: {
+ type = "file";
+ path = "test_separated.raw";
+ };
+
+ };
+
+ postfiltered: {
+
+ fS = 16000;
+ hopSize = 128;
+ nBits = 16;
+ gain = 10.0;
+
+ interface: {
+ type = "file";
+ path = "test_postfiltered.raw";
+ };
+
+ };
+
+};
+
+classify:
+{
+
+ frameSize = 4096;
+ winSize = 3;
+ tauMin = 88;
+ tauMax = 551;
+ deltaTauMax = 20;
+ alpha = 0.3;
+ gamma = 0.05;
+ phiMin = 0.5;
+ r0 = 0.2;
+
+ category: {
+
+ format = "undefined";
+
+ interface: {
+ type = "blackhole";
+ }
+
+ }
+
+}
);
- # Spatial filter to include only a range of direction if required
- # (may be useful to remove false detections from the floor)
- spatialfilter: {
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
- direction = ( +0.000, +0.000, +1.000 );
- angle = (80.0, 90.0);
+ {
- };
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ }
+
+ );
nThetas = 181;
gainMin = 0.25;
);
- # Spatial filter to include only a range of direction if required
- # (may be useful to remove false detections from the floor)
- spatialfilter: {
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
- direction = ( +0.000, +0.000, +1.000 );
- angle = (80.0, 100.0);
+ {
- };
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ }
+
+ );
nThetas = 181;
gainMin = 0.25;
);
- # Spatial filter to include only a range of direction if required
- # (may be useful to remove false detections from the floor)
- spatialfilter: {
+ # Spatial filters to include only a range of direction if required
+ # (may be useful to remove false detections from the floor, or
+ # limit the space search to a restricted region)
+ spatialfilters = (
- direction = ( +0.000, +0.000, +1.000 );
- angle = (80.0, 100.0);
+ {
- };
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ }
+
+ );
nThetas = 181;
gainMin = 0.25;
// +--------------------------------------------------+
// | Module |
// +--------------------------------------------------+
-
+
objs->mod_ssl_object = mod_ssl_construct(cfgs->mod_ssl_config,
cfgs->msg_spectra_mics_config,
cfgs->msg_pots_ssl_config);
-
+
// +--------------------------------------------------+
// | Sinks |
// +--------------------------------------------------+
mod_ssl_cfg * cfg;
unsigned int nChannels;
+ unsigned int nFilters;
unsigned int iChannel;
+ unsigned int iFilter;
unsigned int iSample;
unsigned int iLevel;
// | Spatial filter |
// +----------------------------------------------------------+
- cfg->spatialfilter = spatialfilter_construct_zero();
+ nFilters = parameters_count(fileConfig, "general.spatialfilters");
- cfg->spatialfilter->direction[0] = parameters_lookup_float(fileConfig, "general.spatialfilter.direction.[0]");
- cfg->spatialfilter->direction[1] = parameters_lookup_float(fileConfig, "general.spatialfilter.direction.[1]");
- cfg->spatialfilter->direction[2] = parameters_lookup_float(fileConfig, "general.spatialfilter.direction.[2]");
- cfg->spatialfilter->thetaAllPass = parameters_lookup_float(fileConfig, "general.spatialfilter.angle.[0]");
- cfg->spatialfilter->thetaNoPass = parameters_lookup_float(fileConfig, "general.spatialfilter.angle.[1]");
+ cfg->spatialfilters = spatialfilters_construct_zero(nFilters);
+
+ for (iFilter = 0; iFilter < nFilters; iFilter++) {
+
+ // +--------------------------------------------------+
+ // | Direction |
+ // +--------------------------------------------------+
+
+ for (iSample = 0; iSample < 3; iSample++) {
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.spatialfilters.[%u].direction.[%u]", iFilter, iSample);
+ cfg->spatialfilters->direction[iFilter * 3 + iSample] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ }
+
+ // +--------------------------------------------------+
+ // | thetaAllPass |
+ // +--------------------------------------------------+
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.spatialfilters.[%u].angle.[0]", iFilter);
+ cfg->spatialfilters->thetaAllPass[iFilter] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ // +--------------------------------------------------+
+ // | thetaNoPass |
+ // +--------------------------------------------------+
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.spatialfilters.[%u].angle.[1]", iFilter);
+ cfg->spatialfilters->thetaNoPass[iFilter] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ }
return cfg;
cfg->soundspeed->mu = parameters_lookup_float(fileConfig, "general.speedofsound.mu");
cfg->soundspeed->sigma2 = parameters_lookup_float(fileConfig, "general.speedofsound.sigma2");
- // +----------------------------------------------------------+
- // | Spatial filter |
- // +----------------------------------------------------------+
-
- cfg->spatialfilter = spatialfilter_construct_zero();
-
- cfg->spatialfilter->direction[0] = parameters_lookup_float(fileConfig, "general.spatialfilter.direction.[0]");
- cfg->spatialfilter->direction[1] = parameters_lookup_float(fileConfig, "general.spatialfilter.direction.[1]");
- cfg->spatialfilter->direction[2] = parameters_lookup_float(fileConfig, "general.spatialfilter.direction.[2]");
- cfg->spatialfilter->thetaAllPass = parameters_lookup_float(fileConfig, "general.spatialfilter.angle.[0]");
- cfg->spatialfilter->thetaNoPass = parameters_lookup_float(fileConfig, "general.spatialfilter.angle.[1]");
-
// +----------------------------------------------------------+
// | Number of thetas |
// +----------------------------------------------------------+
#include <string.h>
#include <stdio.h>
- typedef struct spatialfilter_obj {
+ typedef struct spatialfilters_obj {
+ unsigned int nFilters;
float * direction;
- float thetaAllPass;
- float thetaNoPass;
+ float * thetaAllPass;
+ float * thetaNoPass;
- } spatialfilter_obj;
+ } spatialfilters_obj;
- spatialfilter_obj * spatialfilter_construct_zero(void);
+ spatialfilters_obj * spatialfilters_construct_zero(unsigned int nFilters);
- spatialfilter_obj * spatialfilter_clone(const spatialfilter_obj * obj);
+ spatialfilters_obj * spatialfilters_clone(const spatialfilters_obj * obj);
- void spatialfilter_destroy(spatialfilter_obj * obj);
+ void spatialfilters_destroy(spatialfilters_obj * obj);
- void spatialfilter_printf(const spatialfilter_obj * obj);
+ void spatialfilters_printf(const spatialfilters_obj * obj);
#endif
\ No newline at end of file
beampatterns_obj * directivity_beampattern_mics(const mics_obj * mics, const unsigned int nThetas);
- beampatterns_obj * directivity_beampattern_spatialfilter(const spatialfilter_obj * spatialfilter, const unsigned int nThetas);
+ beampatterns_obj * directivity_beampattern_spatialfilters(const spatialfilters_obj * spatialfilters, const unsigned int nThetas);
- spatialgains_obj * directivity_spatialgains(const mics_obj * mics, const beampatterns_obj * beampatterns_mics, const spatialfilter_obj * spatialfilter, const beampatterns_obj * beampatterns_spatialfilter, const points_obj * points);
+ spatialgains_obj * directivity_spatialgains(const mics_obj * mics, const beampatterns_obj * beampatterns_mics, const spatialfilters_obj * spatialfilters, const beampatterns_obj * beampatterns_spatialfilter, const points_obj * points);
spatialmasks_obj * directivity_spatialmasks(const spatialgains_obj * spatialgains, const float minGain);
#include <init/linking.h>
#include <init/space.h>
- scans_obj * scanning_init_scans(const mics_obj * mics, const spatialfilter_obj * spatialfilter, const unsigned int nLevels, const unsigned int * levels, const unsigned int fS, const soundspeed_obj * soundspeed, const unsigned int nMatches, const unsigned int frameSize, const signed int * deltas, const float probMin, const unsigned int nRefineLevels, const unsigned int nThetas, const float gainMin, const unsigned int interpRate);
+ scans_obj * scanning_init_scans(const mics_obj * mics, const spatialfilters_obj * spatialfilters, const unsigned int nLevels, const unsigned int * levels, const unsigned int fS, const soundspeed_obj * soundspeed, const unsigned int nMatches, const unsigned int frameSize, const signed int * deltas, const float probMin, const unsigned int nRefineLevels, const unsigned int nThetas, const float gainMin, const unsigned int interpRate);
#endif
mics_obj * mics;
samplerate_obj * samplerate;
soundspeed_obj * soundspeed;
- spatialfilter_obj * spatialfilter;
+ spatialfilters_obj * spatialfilters;
unsigned int interpRate;
float epsilon;
#include "../general/mic.h"
#include "../general/samplerate.h"
#include "../general/soundspeed.h"
- #include "../general/spatialfilter.h"
#include "../init/directivity.h"
char mode_pf;
beampatterns_obj * sep_ds_beampatterns_mics;
- beampatterns_obj * sep_ds_beampatterns_spatialfilter;
steers_obj * sep_ds_steers;
gains_obj * sep_ds_gains;
masks_obj * sep_ds_masks;
demixing2freq_obj * sep_ds_demixing2freq;
beampatterns_obj * sep_gss_beampatterns_mics;
- beampatterns_obj * sep_gss_beampatterns_spatialfilter;
steers_obj * sep_gss_steers;
gains_obj * sep_gss_gains;
masks_obj * sep_gss_masks;
mics_obj * mics;
samplerate_obj * samplerate;
soundspeed_obj * soundspeed;
- spatialfilter_obj * spatialfilter;
float sep_gss_lambda;
float sep_gss_mu;
} track2gain_obj;
- track2gain_obj * track2gain_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const float * directions, const float * direction);
+ track2gain_obj * track2gain_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const float * directions);
void track2gain_destroy(track2gain_obj * obj);
- void track2gain_process(track2gain_obj * obj, const beampatterns_obj * beampatterns_mics, const beampatterns_obj * beampatterns_spatialfilter, const tracks_obj * tracks, gains_obj * gains);
+ void track2gain_process(track2gain_obj * obj, const beampatterns_obj * beampatterns_mics, const tracks_obj * tracks, gains_obj * gains);
#endif
#include <general/spatialfilter.h>
- spatialfilter_obj * spatialfilter_construct_zero(void) {
+ spatialfilters_obj * spatialfilters_construct_zero(unsigned int nFilters) {
- spatialfilter_obj * obj;
+ spatialfilters_obj * obj;
- obj = (spatialfilter_obj *) malloc(sizeof(spatialfilter_obj));
+ obj = (spatialfilters_obj *) malloc(sizeof(spatialfilters_obj));
- obj->direction = (float *) malloc(sizeof(float) * 3);
- memset(obj->direction, 0x00, sizeof(float) * 3);
+ obj->nFilters = nFilters;
- obj->thetaAllPass = 0.0f;
- obj->thetaNoPass = 0.0f;
+ obj->direction = (float *) malloc(sizeof(float) * nFilters * 3);
+ memset(obj->direction, 0x00, sizeof(float) * nFilters * 3);
+
+ obj->thetaAllPass = (float *) malloc(sizeof(float) * nFilters);
+ memset(obj->thetaAllPass, 0x00, sizeof(float) * nFilters);
+
+ obj->thetaNoPass = (float *) malloc(sizeof(float) * nFilters);
+ memset(obj->thetaNoPass, 0x00, sizeof(float) * nFilters);
return obj;
}
- spatialfilter_obj * spatialfilter_clone(const spatialfilter_obj * obj) {
+ spatialfilters_obj * spatialfilters_clone(const spatialfilters_obj * obj) {
+
+ spatialfilters_obj * clone;
- spatialfilter_obj * clone;
+ clone = (spatialfilters_obj *) malloc(sizeof(spatialfilters_obj));
- clone = (spatialfilter_obj *) malloc(sizeof(spatialfilter_obj));
+ clone->direction = (float *) malloc(sizeof(float) * obj->nFilters * 3);
+ memcpy(clone->direction, obj->direction, sizeof(float) * obj->nFilters * 3);
- clone->direction = (float *) malloc(sizeof(float) * 3);
- memcpy(clone->direction, obj->direction, sizeof(float) * 3);
+ clone->thetaAllPass = (float *) malloc(sizeof(float) * obj->nFilters);
+ memcpy(clone->thetaAllPass, obj->thetaAllPass, sizeof(float) * obj->nFilters);
- clone->thetaAllPass = obj->thetaAllPass;
- clone->thetaNoPass = obj->thetaNoPass;
+ clone->thetaNoPass = (float *) malloc(sizeof(float) * obj->nFilters);
+ memcpy(clone->thetaNoPass, obj->thetaNoPass, sizeof(float) * obj->nFilters);
return clone;
}
- void spatialfilter_destroy(spatialfilter_obj * obj) {
+ void spatialfilters_destroy(spatialfilters_obj * obj) {
free((void *) obj->direction);
+ free((void *) obj->thetaAllPass);
+ free((void *) obj->thetaNoPass);
free((void *) obj);
}
- void spatialfilter_printf(const spatialfilter_obj * obj) {
+ void spatialfilters_printf(const spatialfilters_obj * obj) {
+
+ unsigned int iFilter;
+
+ for (iFilter = 0; iFilter < obj->nFilters; iFilter++) {
+
+ printf("direction = (%+1.3f,%+1.3f,%+1.3f), thetaAllPass = %f, thetaNoPass = %f\n",
+ obj->direction[iFilter * 3 + 0], obj->direction[iFilter * 3 + 1], obj->direction[iFilter * 3 + 2],
+ obj->thetaAllPass[iFilter],
+ obj->thetaNoPass[iFilter]);
- printf("direction = (%+1.3f,%+1.3f,%+1.3f)\n", obj->direction[0], obj->direction[1], obj->direction[2]);
- printf("thetaAllPass = %f\n", obj->thetaAllPass);
- printf("thetaNoPass = %f\n", obj->thetaNoPass);
+ }
}
}
- beampatterns_obj * directivity_beampattern_spatialfilter(const spatialfilter_obj * spatialfilter, const unsigned int nThetas) {
+ beampatterns_obj * directivity_beampattern_spatialfilters(const spatialfilters_obj * spatialfilters, const unsigned int nThetas) {
beampatterns_obj * obj;
+ unsigned int nFilters;
+ unsigned int iFilter;
unsigned int iTheta;
float theta;
float xap, xnp, x0;
float alpha;
- obj = beampatterns_construct_zero(1, nThetas);
+ nFilters = spatialfilters->nFilters;
- obj->minThetas[0] = 0.0f;
- obj->maxThetas[0] = 180.0f;
- obj->deltaThetas[0] = (obj->maxThetas[0] - obj->minThetas[0]) / ((float) (nThetas - 1));
+ obj = beampatterns_construct_zero(nFilters, nThetas);
- for (iTheta = 0; iTheta < nThetas; iTheta++) {
+ for (iFilter = 0; iFilter < nFilters; iFilter++) {
- theta = ((float) iTheta) * obj->deltaThetas[0] + obj->minThetas[0];
+ obj->minThetas[iFilter] = 0.0f;
+ obj->maxThetas[iFilter] = 180.0f;
+ obj->deltaThetas[iFilter] = (obj->maxThetas[iFilter] - obj->minThetas[iFilter]) / ((float) (nThetas - 1));
- if (theta <= spatialfilter->thetaAllPass) {
+ for (iTheta = 0; iTheta < nThetas; iTheta++) {
- obj->gains[iTheta] = 1.0f;
+ theta = ((float) iTheta) * obj->deltaThetas[iFilter] + obj->minThetas[iFilter];
- }
- else if (theta >= spatialfilter->thetaNoPass) {
+ if (theta <= spatialfilters->thetaAllPass[iFilter]) {
- obj->gains[iTheta] = 0.0f;
+ obj->gains[iFilter * nThetas + iTheta] = 1.0f;
- }
- else {
+ }
+ else if (theta >= spatialfilters->thetaNoPass[iFilter]) {
- xap = spatialfilter->thetaAllPass;
- xnp = spatialfilter->thetaNoPass;
+ obj->gains[iFilter * nThetas + iTheta] = 0.0f;
- x0 = (xap + xnp) / 2.0f;
- alpha = 20.0f / (xnp - xap);
+ }
+ else {
- obj->gains[iTheta] = 1.0f / (1.0f + expf(alpha * (theta - x0)));
+ xap = spatialfilters->thetaAllPass[iFilter];
+ xnp = spatialfilters->thetaNoPass[iFilter];
+
+ x0 = (xap + xnp) / 2.0f;
+ alpha = 20.0f / (xnp - xap);
+
+ obj->gains[iFilter * nThetas + iTheta] = 1.0f / (1.0f + expf(alpha * (theta - x0)));
+
+ }
}
}
- spatialgains_obj * directivity_spatialgains(const mics_obj * mics, const beampatterns_obj * beampatterns_mics, const spatialfilter_obj * spatialfilter, const beampatterns_obj * beampatterns_spatialfilter, const points_obj * points) {
+ spatialgains_obj * directivity_spatialgains(const mics_obj * mics, const beampatterns_obj * beampatterns_mics, const spatialfilters_obj * spatialfilters, const beampatterns_obj * beampatterns_spatialfilter, const points_obj * points) {
spatialgains_obj * obj;
+ unsigned int nFilters;
+ unsigned int iFilter;
unsigned int nChannels;
unsigned int iChannel;
unsigned int nPoints;
unsigned int nThetasMic;
unsigned int nThetasFilter;
- float gainMic;
float gainFilter;
-
+ float gainFilters;
+ float gainMic;
+
+ nFilters = spatialfilters->nFilters;
nChannels = mics->nChannels;
nPoints = points->nPoints;
nThetasMic = beampatterns_mics->nThetas;
obj = spatialgains_construct_zero(nChannels, nPoints);
- for (iChannel = 0; iChannel < nChannels; iChannel++) {
-
- dx = mics->direction[iChannel * 3 + 0];
- dy = mics->direction[iChannel * 3 + 1];
- dz = mics->direction[iChannel * 3 + 2];
+ for (iPoint = 0; iPoint < nPoints; iPoint++) {
- dNorm = sqrtf(dx * dx + dy * dy + dz * dz);
+ ux = points->array[iPoint * 3 + 0];
+ uy = points->array[iPoint * 3 + 1];
+ uz = points->array[iPoint * 3 + 2];
- sx = spatialfilter->direction[0];
- sy = spatialfilter->direction[1];
- sz = spatialfilter->direction[2];
+ uNorm = sqrtf(ux * ux + uy * uy + uz * uz);
- sNorm = sqrtf(sx * sx + sy * sy + sz * sz);
+ gainFilters = 1.0f;
- for (iPoint = 0; iPoint < nPoints; iPoint++) {
+ for (iFilter = 0; iFilter < nFilters; iFilter++) {
- ux = points->array[iPoint * 3 + 0];
- uy = points->array[iPoint * 3 + 1];
- uz = points->array[iPoint * 3 + 2];
+ sx = spatialfilters->direction[iFilter * 3 + 0];
+ sy = spatialfilters->direction[iFilter * 3 + 1];
+ sz = spatialfilters->direction[iFilter * 3 + 2];
- uNorm = sqrtf(ux * ux + uy * uy + uz * uz);
+ sNorm = sqrtf(sx * sx + sy * sy + sz * sz);
- projMic = dx * ux + dy * uy + dz * uz;
projFilter = sx * ux + sy * uy + sz * uz;
-
- thetaMic = (360.0f/(2.0f * M_PI)) * acosf(projMic / (dNorm * uNorm));
thetaFilter = (360.0f/(2.0f * M_PI)) * acosf(projFilter / (sNorm * uNorm));
+ iThetaFilter = roundf((thetaFilter - beampatterns_spatialfilter->minThetas[0]) / (beampatterns_spatialfilter->deltaThetas[0]) + beampatterns_spatialfilter->minThetas[0]);
+
+ if (iThetaFilter < 0) {
+ iThetaFilter = 0;
+ }
+ if (iThetaFilter >= nThetasFilter) {
+ iThetaFilter = nThetasFilter - 1;
+ }
+
+ gainFilter = beampatterns_spatialfilter->gains[iThetaFilter];
+
+ gainFilters *= gainFilter;
+
+ }
+
+ for (iChannel = 0; iChannel < nChannels; iChannel++) {
+
+ dx = mics->direction[iChannel * 3 + 0];
+ dy = mics->direction[iChannel * 3 + 1];
+ dz = mics->direction[iChannel * 3 + 2];
+ dNorm = sqrtf(dx * dx + dy * dy + dz * dz);
+
+ projMic = dx * ux + dy * uy + dz * uz;
+ thetaMic = (360.0f/(2.0f * M_PI)) * acosf(projMic / (dNorm * uNorm));
iThetaMic = roundf((thetaMic - beampatterns_mics->minThetas[iChannel]) / (beampatterns_mics->deltaThetas[iChannel]) + beampatterns_mics->minThetas[iChannel]);
- iThetaFilter = roundf((thetaFilter - beampatterns_spatialfilter->minThetas[0]) / (beampatterns_spatialfilter->deltaThetas[0]) + beampatterns_spatialfilter->minThetas[0]);
if (iThetaMic < 0) {
iThetaMic = 0;
}
if (iThetaMic >= nThetasMic) {
iThetaMic = nThetasMic - 1;
- }
-
- if (iThetaFilter < 0) {
- iThetaFilter = 0;
- }
- if (iThetaFilter >= nThetasFilter) {
- iThetaFilter = nThetasFilter - 1;
}
gainMic = beampatterns_mics->gains[iChannel * nThetasMic + iThetaMic];
- gainFilter = beampatterns_spatialfilter->gains[iThetaFilter];
- obj->array[iPoint * nChannels + iChannel] = gainMic * gainFilter;
+ obj->array[iPoint * nChannels + iChannel] = gainFilters * gainMic;
}
#include <init/scanning.h>
- scans_obj * scanning_init_scans(const mics_obj * mics, const spatialfilter_obj * spatialfilter, const unsigned int nLevels, const unsigned int * levels, const unsigned int fS, const soundspeed_obj * soundspeed, const unsigned int nMatches, const unsigned int frameSize, const signed int * deltas, const float probMin, const unsigned int nRefineLevels, const unsigned int nThetas, const float gainMin, const unsigned int interpRate) {
+ scans_obj * scanning_init_scans(const mics_obj * mics, const spatialfilters_obj * spatialfilters, const unsigned int nLevels, const unsigned int * levels, const unsigned int fS, const soundspeed_obj * soundspeed, const unsigned int nMatches, const unsigned int frameSize, const signed int * deltas, const float probMin, const unsigned int nRefineLevels, const unsigned int nThetas, const float gainMin, const unsigned int interpRate) {
scans_obj * obj;
unsigned int iLevel;
beampatterns_obj * beampatterns_mics;
- beampatterns_obj * beampatterns_spatialfilter;
+ beampatterns_obj * beampatterns_spatialfilters;
spatialgains_obj * spatialgains;
spatialmasks_obj ** spatialmasks;
pairs_obj * pairs;
obj = scans_construct_null(nLevels);
obj->pairs = pairs_construct_zero(mics->nPairs);
- beampatterns_mics = directivity_beampattern_mics(mics, nThetas);
- beampatterns_spatialfilter = directivity_beampattern_spatialfilter(spatialfilter, nThetas);
+ beampatterns_mics = directivity_beampattern_mics(mics, nThetas);
+ beampatterns_spatialfilters = directivity_beampattern_spatialfilters(spatialfilters, nThetas);
spatialmasks = (spatialmasks_obj **) malloc(sizeof(spatialmasks_obj *) * nLevels);
// Generate gains in space
spatialgains = directivity_spatialgains(mics,
beampatterns_mics,
- spatialfilter,
- beampatterns_spatialfilter,
+ spatialfilters,
+ beampatterns_spatialfilters,
obj->points[iLevel]);
// Generate masks in space
}
beampatterns_destroy(beampatterns_mics);
- beampatterns_destroy(beampatterns_spatialfilter);
+ beampatterns_destroy(beampatterns_spatialfilters);
for (iLevel = 0; iLevel < obj->nLevels; iLevel++) {
obj->interpRate = mod_ssl_config->interpRate;
obj->scans = scanning_init_scans(mod_ssl_config->mics,
- mod_ssl_config->spatialfilter,
+ mod_ssl_config->spatialfilters,
mod_ssl_config->nLevels,
mod_ssl_config->levels,
mod_ssl_config->samplerate->mu,
obj->in = (msg_spectra_obj *) NULL;
obj->out = (msg_pots_obj *) NULL;
- //obj->tmpFile = fopen("weights.bin","wb");
-
return obj;
}
unsigned int iLevel;
unsigned int iPot;
- //fclose(obj->tmpFile);
-
scans_destroy(obj->scans);
freq2freq_phasor_destroy(obj->freq2freq_phasor);
cfg->mics = (mics_obj *) NULL;
cfg->samplerate = (samplerate_obj *) NULL;
cfg->soundspeed = (soundspeed_obj *) NULL;
- cfg->spatialfilter = (spatialfilter_obj *) NULL;
+ cfg->spatialfilters = (spatialfilters_obj *) NULL;
cfg->nLevels = 0;;
cfg->levels = (unsigned int *) NULL;
soundspeed_destroy(cfg->soundspeed);
}
- if (cfg->spatialfilter != NULL) {
- spatialfilter_destroy(cfg->spatialfilter);
+ if (cfg->spatialfilters != NULL) {
+ spatialfilters_destroy(cfg->spatialfilters);
}
if (cfg->levels != NULL) {
mics_printf(cfg->mics);
samplerate_printf(cfg->samplerate);
soundspeed_printf(cfg->soundspeed);
- spatialfilter_printf(cfg->spatialfilter);
+ spatialfilters_printf(cfg->spatialfilters);
for (iLevel = 0; iLevel < cfg->nLevels; iLevel++) {
obj->mode_pf = mod_sss_config->mode_pf;
obj->sep_ds_beampatterns_mics = (beampatterns_obj *) NULL;
- obj->sep_ds_beampatterns_spatialfilter = (beampatterns_obj *) NULL;
obj->sep_ds_steers = (steers_obj *) NULL;
obj->sep_ds_gains = (gains_obj *) NULL;
obj->sep_ds_masks = (masks_obj *) NULL;
obj->sep_ds_demixing2freq = (demixing2freq_obj *) NULL;
obj->sep_gss_beampatterns_mics = (beampatterns_obj *) NULL;
- obj->sep_gss_beampatterns_spatialfilter = (beampatterns_obj *) NULL;
obj->sep_gss_steers = (steers_obj *) NULL;
obj->sep_gss_gains = (gains_obj *) NULL;
obj->sep_gss_masks = (masks_obj *) NULL;
obj->sep_ds_beampatterns_mics = directivity_beampattern_mics(mod_sss_config->mics,
mod_sss_config->nThetas);
- obj->sep_ds_beampatterns_spatialfilter = directivity_beampattern_spatialfilter(mod_sss_config->spatialfilter,
- mod_sss_config->nThetas);
-
obj->sep_ds_steers = steers_construct_zero(msg_spectra_config->halfFrameSize,
msg_tracks_config->nTracks,
msg_spectra_config->nChannels);
obj->sep_ds_track2gain = track2gain_construct_zero(msg_tracks_config->nTracks,
msg_spectra_config->nChannels,
- mod_sss_config->mics->direction,
- mod_sss_config->spatialfilter->direction);
+ mod_sss_config->mics->direction);
obj->sep_ds_gain2mask = gain2mask_construct_zero(msg_tracks_config->nTracks,
msg_spectra_config->nChannels,
obj->sep_gss_beampatterns_mics = directivity_beampattern_mics(mod_sss_config->mics,
mod_sss_config->nThetas);
- obj->sep_gss_beampatterns_spatialfilter = directivity_beampattern_spatialfilter(mod_sss_config->spatialfilter,
- mod_sss_config->nThetas);
-
obj->sep_gss_steers = steers_construct_zero(msg_spectra_config->halfFrameSize,
msg_tracks_config->nTracks,
msg_spectra_config->nChannels);
obj->sep_gss_track2gain = track2gain_construct_zero(msg_tracks_config->nTracks,
msg_spectra_config->nChannels,
- mod_sss_config->mics->direction,
- mod_sss_config->spatialfilter->direction);
+ mod_sss_config->mics->direction);
obj->sep_gss_gain2mask = gain2mask_construct_zero(msg_tracks_config->nTracks,
msg_spectra_config->nChannels,
case 'd':
beampatterns_destroy(obj->sep_ds_beampatterns_mics);
- beampatterns_destroy(obj->sep_ds_beampatterns_spatialfilter);
steers_destroy(obj->sep_ds_steers);
gains_destroy(obj->sep_ds_gains);
masks_destroy(obj->sep_ds_masks);
case 'g':
beampatterns_destroy(obj->sep_gss_beampatterns_mics);
- beampatterns_destroy(obj->sep_gss_beampatterns_spatialfilter);
steers_destroy(obj->sep_gss_steers);
gains_destroy(obj->sep_gss_gains);
masks_destroy(obj->sep_gss_masks);
track2gain_process(obj->sep_ds_track2gain,
obj->sep_ds_beampatterns_mics,
- obj->sep_ds_beampatterns_spatialfilter,
obj->sep_ds_tracksNow,
obj->sep_ds_gains);
obj->in3->tracks);
track2gain_process(obj->sep_gss_track2gain,
- obj->sep_gss_beampatterns_mics,
- obj->sep_gss_beampatterns_spatialfilter,
+ obj->sep_gss_beampatterns_mics,
obj->sep_gss_tracksNow,
obj->sep_gss_gains);
cfg->mics = (mics_obj *) NULL;
cfg->samplerate = (samplerate_obj *) NULL;
cfg->soundspeed = (soundspeed_obj *) NULL;
- cfg->spatialfilter = (spatialfilter_obj *) NULL;
return cfg;
soundspeed_destroy(cfg->soundspeed);
}
- if (cfg->spatialfilter != NULL) {
- spatialfilter_destroy(cfg->spatialfilter);
- }
-
free((void *) cfg);
}
unsigned int iTrackMax;
points_obj * points;
beampatterns_obj * beampatterns_mics;
- beampatterns_obj * beampatterns_spatialfilter;
+ beampatterns_obj * beampatterns_spatialfilters;
spatialgains_obj * spatialgains;
spatialmasks_obj * spatialmasks;
spatialindexes_obj * spatialindexes;
points = space_sphere(mod_ssl_config->levels[mod_ssl_config->nLevels-1]);
beampatterns_mics = directivity_beampattern_mics(mod_ssl_config->mics, mod_ssl_config->nThetas);
- beampatterns_spatialfilter = directivity_beampattern_spatialfilter(mod_ssl_config->spatialfilter, mod_ssl_config->nThetas);
- spatialgains = directivity_spatialgains(mod_ssl_config->mics, beampatterns_mics, mod_ssl_config->spatialfilter, beampatterns_spatialfilter, points);
+ beampatterns_spatialfilters = directivity_beampattern_spatialfilters(mod_ssl_config->spatialfilters, mod_ssl_config->nThetas);
+ spatialgains = directivity_spatialgains(mod_ssl_config->mics, beampatterns_mics, mod_ssl_config->spatialfilters, beampatterns_spatialfilters, points);
spatialmasks = directivity_spatialmasks(spatialgains, mod_ssl_config->gainMin);
spatialindexes = directivity_spatialindexes(spatialmasks);
points_destroy(points);
beampatterns_destroy(beampatterns_mics);
- beampatterns_destroy(beampatterns_spatialfilter);
+ beampatterns_destroy(beampatterns_spatialfilters);
spatialgains_destroy(spatialgains);
spatialmasks_destroy(spatialmasks);
spatialindexes_destroy(spatialindexes);
memset(obj->out->tracks->array, 0x00, sizeof(float) * obj->out->tracks->nTracks * 3);
memset(obj->out->tracks->ids, 0x00, sizeof(unsigned long long) * obj->out->tracks->nTracks);
+ memset(obj->out->tracks->activity, 0x00, sizeof(float) * obj->out->tracks->nTracks);
for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+ strcpy(obj->out->tracks->tags[iTrackMax], "");
+
if (obj->ids[iTrackMax] != 0) {
if ((obj->type[iTrackMax] == 'A') || (obj->type[iTrackMax] == 'T')) {
#include <system/track2gain.h>
- track2gain_obj * track2gain_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const float * directions, const float * direction) {
+ track2gain_obj * track2gain_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const float * directions) {
track2gain_obj * obj;
obj->directions = (float *) malloc(sizeof(float) * nChannels * 3);
memcpy(obj->directions, directions, sizeof(float) * nChannels * 3);
- obj->direction = (float *) malloc(sizeof(float) * 3);
- memcpy(obj->direction, direction, sizeof(float) * 3);
-
return obj;
}
void track2gain_destroy(track2gain_obj * obj) {
free((void *) obj->directions);
- free((void *) obj->direction);
free((void *) obj);
}
- void track2gain_process(track2gain_obj * obj, const beampatterns_obj * beampatterns_mics, const beampatterns_obj * beampatterns_spatialfilter, const tracks_obj * tracks, gains_obj * gains) {
+ void track2gain_process(track2gain_obj * obj, const beampatterns_obj * beampatterns_mics, const tracks_obj * tracks, gains_obj * gains) {
unsigned int iSep;
unsigned int iChannel;
float uNorm;
float dx, dy, dz;
float dNorm;
- float sx, sy, sz;
- float sNorm;
float projMic;
- float projFilter;
float thetaMic;
- float thetaFilter;
float gainMic;
- float gainFilter;
for (iSep = 0; iSep < obj->nSeps; iSep++) {
uNorm = sqrtf(ux * ux + uy * uy + uz * uz);
- sx = obj->direction[0];
- sy = obj->direction[1];
- sz = obj->direction[2];
-
- sNorm = sqrtf(sx * sx + sy * sy + sz * sz);
-
for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
dx = obj->directions[iChannel * 3 + 0];
dNorm = sqrtf(dx * dx + dy * dy + dz * dz);
projMic = dx * ux + dy * uy + dz * uz;
- projFilter = sx * ux + sy * uy + sz * uz;
-
thetaMic = (360.0f/(2.0f * M_PI)) * acosf(projMic / (dNorm * uNorm));
- thetaFilter = (360.0f/(2.0f * M_PI)) * acosf(projFilter / (sNorm * uNorm));
-
iThetaMic = roundf((thetaMic - beampatterns_mics->minThetas[iChannel]) / (beampatterns_mics->deltaThetas[iChannel]) + beampatterns_mics->minThetas[iChannel]);
- iThetaFilter = roundf((thetaFilter - beampatterns_spatialfilter->minThetas[0]) / (beampatterns_spatialfilter->deltaThetas[0]) + beampatterns_spatialfilter->minThetas[0]);
if (iThetaMic < 0) {
iThetaMic = 0;
iThetaMic = beampatterns_mics->nThetas - 1;
}
- if (iThetaFilter < 0) {
- iThetaFilter = 0;
- }
- if (iThetaFilter >= beampatterns_spatialfilter->nThetas) {
- iThetaFilter = beampatterns_spatialfilter->nThetas - 1;
- }
-
gainMic = beampatterns_mics->gains[iChannel * beampatterns_mics->nThetas + iThetaMic];
- gainFilter = beampatterns_spatialfilter->gains[iThetaFilter];
- gains->array[iSep * obj->nChannels + iChannel] = gainMic * gainFilter;
+ gains->array[iSep * obj->nChannels + iChannel] = gainMic;
}