Multiple spatial filters added to restrict the search space for linear arrays
authorFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Sat, 24 Mar 2018 23:43:23 +0000 (19:43 -0400)
committerFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Sat, 24 Mar 2018 23:43:23 +0000 (19:43 -0400)
23 files changed:
config/beam.cfg
config/matrix_voice.cfg
config/minidsp.cfg
config/pepper.cfg
config/pseye.cfg [new file with mode: 0644]
config/respeaker.cfg
config/respeaker_4_mic_array.cfg
config/xmos.cfg
demo/objects.c
demo/parameters.c
include/odas/general/spatialfilter.h
include/odas/init/directivity.h
include/odas/init/scanning.h
include/odas/module/mod_ssl.h
include/odas/module/mod_sss.h
include/odas/system/track2gain.h
src/general/spatialfilter.c
src/init/directivity.c
src/init/scanning.c
src/module/mod_ssl.c
src/module/mod_sss.c
src/module/mod_sst.c
src/system/track2gain.c

index a74c175b472f02bea69918c8769fce0aabeb64b1..af93715afba7e9ee030220755c1d0247d9cfbb09 100644 (file)
@@ -122,14 +122,19 @@ general:
         
     );
 
-    # 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;
index fae1d2a0b1636982d6f2efa4997d68d59c566770..a59292106b606ec13d2004c343c0163038c21d46 100644 (file)
@@ -122,14 +122,19 @@ general:
         
     );
 
-    # 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;
index 06ec9891cc3b258d46d9c8f1c452f9ad3ed12e79..d47d321fbc577ae8c1db781a275026ec535a0356 100644 (file)
@@ -62,7 +62,7 @@ general:
             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
@@ -70,7 +70,7 @@ general:
             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
@@ -78,7 +78,7 @@ general:
             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
@@ -86,7 +86,7 @@ general:
             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
@@ -94,7 +94,7 @@ general:
             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
@@ -102,7 +102,7 @@ general:
             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
@@ -110,19 +110,24 @@ general:
             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;
index be59be17ad5757150185756b907a796de9f7f5c9..f24e1004611b458e6499206a9ca82d62fdb25b6c 100644 (file)
@@ -90,14 +90,19 @@ general:
         
     );
 
-    # 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;
diff --git a/config/pseye.cfg b/config/pseye.cfg
new file mode 100644 (file)
index 0000000..8dd8dec
--- /dev/null
@@ -0,0 +1,343 @@
+# 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";
+        }
+
+    }
+
+}
index 8a8d707156dc753faa579ec43ce0fb2eb20fdc8d..69d6d0d771ec655b766e2e55a7a78bed6c4ae37f 100644 (file)
@@ -115,14 +115,19 @@ general:
         
     );
 
-    # 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;
index 4127d0cd0c981cc7ec7422b0fb4d14baa114353a..779767f0ab2fbe682f270a767c44ce5c491d0a55 100644 (file)
@@ -91,14 +91,19 @@ general:
 
     );
 
-    # 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;
index ab82796515c0d860c93825ef1c303e9822655d81..c92efae216cf0bcceb471202a357b7d534eca42f 100644 (file)
@@ -114,14 +114,19 @@ general:
         
     );
 
-    # 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;
index 0189357fa5d013bdf587054b9aeaa051abf1fd5c..630fb7ad80409074a96f13970102164c3f1e584b 100644 (file)
                 // +--------------------------------------------------+
                 // | Module                                           |
                 // +--------------------------------------------------+  
-
+                    
                     objs->mod_ssl_object = mod_ssl_construct(cfgs->mod_ssl_config, 
                                                              cfgs->msg_spectra_mics_config,
                                                              cfgs->msg_pots_ssl_config);
-
+                    
                 // +--------------------------------------------------+
                 // | Sinks                                            |
                 // +--------------------------------------------------+  
index 1ca06f90b96bf008ab9578bc3391e5c9ce3ab318..eb0777a99e6337e6e5b3a82418b0c7b69de555e9 100644 (file)
         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                                         |
         // +----------------------------------------------------------+
index 6d4910c869ae46c6dbcac5bdee41a80bd6b6f840..971659f04012cd0becb904ba056d60363639c84f 100644 (file)
     #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
index e1f04d980983da8b09e574c40dad87f23f9ae71d..0ef4b059eb8a563fa78a4d367b7e4442cdc7e214 100644 (file)
@@ -38,9 +38,9 @@
 
     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);
 
index 4df39b9acad902ebdbd2351f24fe0ef202a8e3e5..8cd64548b078635e0693bd0e2b2ff164475e0279 100644 (file)
@@ -42,6 +42,6 @@
     #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
index d27fdce8c6490a1394cb836468d7ac18dfdf3431..231594657c148bf756ba689cb34219c0b116a003 100644 (file)
@@ -92,7 +92,7 @@
         mics_obj * mics;
         samplerate_obj * samplerate;
         soundspeed_obj * soundspeed;
-        spatialfilter_obj * spatialfilter;
+        spatialfilters_obj * spatialfilters;
 
         unsigned int interpRate;
         float epsilon; 
index 4b3d5d04da3e5229ad7988a5b39ef4eeabc22be0..e5a280fadc5ee739dea6d1805f5cbaa89b941acd 100644 (file)
@@ -26,7 +26,6 @@
     #include "../general/mic.h"
     #include "../general/samplerate.h"
     #include "../general/soundspeed.h"
-    #include "../general/spatialfilter.h"
 
     #include "../init/directivity.h"
 
@@ -63,7 +62,6 @@
         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;
@@ -78,7 +76,6 @@
         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;
index 55e425f96cfe31a0715e65d4b3b6a4734e8303ee..e89c2f9e4b12ec173065e20f559e71f55412fb35 100644 (file)
 
     } 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
index edc4332c9bb87445f68c65521c8af6952462e61b..8856ccb6fd5e4c57491bf244315332f0b4a68bf7 100644 (file)
     
     #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);
+        }
 
     }
index 01e4e95d35b05de80e2ea73aea19bad24274c089..147682c5257c0c1e3e90e7d1c567ac2c81d59fab 100644 (file)
 
     }
 
-    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;
 
             }
 
index f1bac15f4162c40edc2a7ef996fdc7240a782230..7d618ba936bf156d40879b61697c842eca0fec23 100644 (file)
 
     #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;        
@@ -40,8 +40,8 @@
         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);
 
@@ -61,8 +61,8 @@
             // 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++) {
 
index eab119ca78fed94219f4973ad2b0c57ff1a4e370..27550c7bef51a7b6f3e1ed8848f68571e71dd759 100644 (file)
@@ -44,7 +44,7 @@
         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++) {
 
index 69fd581850ea2344fef5eb65470f385802460b21..53e5394afab563c5fd0a01e8c0bb545b0f9f8f16 100644 (file)
@@ -41,7 +41,6 @@
         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;
@@ -56,7 +55,6 @@
         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;
@@ -77,9 +75,6 @@
                 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);
@@ -96,8 +91,7 @@
 
                 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);
 
     }
index 827211de290f17a87a71390b6f169fcf8cd1b732..9fbaa55fef3bb4e3515f0bca48ad68c690b1ff37 100644 (file)
@@ -30,7 +30,7 @@
         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')) {
index cd308b144b1cf794c8f81cda8a31a81d517e3beb..c71fe579235157999276231b50f57536a0474350 100644 (file)
@@ -23,7 +23,7 @@
     
     #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;
 
@@ -35,9 +35,6 @@
         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;
 
                 }