From: FrancoisGrondin Date: Sat, 24 Mar 2018 23:43:23 +0000 (-0400) Subject: Multiple spatial filters added to restrict the search space for linear arrays X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=a92568e828021dae72b7d5f111ef8d226863a80f;p=yn%2Fyn-odas.git Multiple spatial filters added to restrict the search space for linear arrays --- diff --git a/config/beam.cfg b/config/beam.cfg index a74c175..af93715 100644 --- a/config/beam.cfg +++ b/config/beam.cfg @@ -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; diff --git a/config/matrix_voice.cfg b/config/matrix_voice.cfg index fae1d2a..a592921 100644 --- a/config/matrix_voice.cfg +++ b/config/matrix_voice.cfg @@ -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; diff --git a/config/minidsp.cfg b/config/minidsp.cfg index 06ec989..d47d321 100644 --- a/config/minidsp.cfg +++ b/config/minidsp.cfg @@ -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; diff --git a/config/pepper.cfg b/config/pepper.cfg index be59be1..f24e100 100644 --- a/config/pepper.cfg +++ b/config/pepper.cfg @@ -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 index 0000000..8dd8dec --- /dev/null +++ b/config/pseye.cfg @@ -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"; + } + + } + +} diff --git a/config/respeaker.cfg b/config/respeaker.cfg index 8a8d707..69d6d0d 100644 --- a/config/respeaker.cfg +++ b/config/respeaker.cfg @@ -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; diff --git a/config/respeaker_4_mic_array.cfg b/config/respeaker_4_mic_array.cfg index 4127d0c..779767f 100644 --- a/config/respeaker_4_mic_array.cfg +++ b/config/respeaker_4_mic_array.cfg @@ -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; diff --git a/config/xmos.cfg b/config/xmos.cfg index ab82796..c92efae 100644 --- a/config/xmos.cfg +++ b/config/xmos.cfg @@ -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; diff --git a/demo/objects.c b/demo/objects.c index 0189357..630fb7a 100644 --- a/demo/objects.c +++ b/demo/objects.c @@ -107,11 +107,11 @@ // +--------------------------------------------------+ // | Module | // +--------------------------------------------------+ - + objs->mod_ssl_object = mod_ssl_construct(cfgs->mod_ssl_config, cfgs->msg_spectra_mics_config, cfgs->msg_pots_ssl_config); - + // +--------------------------------------------------+ // | Sinks | // +--------------------------------------------------+ diff --git a/demo/parameters.c b/demo/parameters.c index 1ca06f9..eb0777a 100644 --- a/demo/parameters.c +++ b/demo/parameters.c @@ -477,7 +477,9 @@ mod_ssl_cfg * cfg; unsigned int nChannels; + unsigned int nFilters; unsigned int iChannel; + unsigned int iFilter; unsigned int iSample; unsigned int iLevel; @@ -638,13 +640,44 @@ // | 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; @@ -1261,18 +1294,6 @@ 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 | // +----------------------------------------------------------+ diff --git a/include/odas/general/spatialfilter.h b/include/odas/general/spatialfilter.h index 6d4910c..971659f 100644 --- a/include/odas/general/spatialfilter.h +++ b/include/odas/general/spatialfilter.h @@ -27,20 +27,21 @@ #include #include - 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 diff --git a/include/odas/init/directivity.h b/include/odas/init/directivity.h index e1f04d9..0ef4b05 100644 --- a/include/odas/init/directivity.h +++ b/include/odas/init/directivity.h @@ -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); diff --git a/include/odas/init/scanning.h b/include/odas/init/scanning.h index 4df39b9..8cd6454 100644 --- a/include/odas/init/scanning.h +++ b/include/odas/init/scanning.h @@ -42,6 +42,6 @@ #include #include - 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 diff --git a/include/odas/module/mod_ssl.h b/include/odas/module/mod_ssl.h index d27fdce..2315946 100644 --- a/include/odas/module/mod_ssl.h +++ b/include/odas/module/mod_ssl.h @@ -92,7 +92,7 @@ mics_obj * mics; samplerate_obj * samplerate; soundspeed_obj * soundspeed; - spatialfilter_obj * spatialfilter; + spatialfilters_obj * spatialfilters; unsigned int interpRate; float epsilon; diff --git a/include/odas/module/mod_sss.h b/include/odas/module/mod_sss.h index 4b3d5d0..e5a280f 100644 --- a/include/odas/module/mod_sss.h +++ b/include/odas/module/mod_sss.h @@ -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; @@ -146,7 +143,6 @@ mics_obj * mics; samplerate_obj * samplerate; soundspeed_obj * soundspeed; - spatialfilter_obj * spatialfilter; float sep_gss_lambda; float sep_gss_mu; diff --git a/include/odas/system/track2gain.h b/include/odas/system/track2gain.h index 55e425f..e89c2f9 100644 --- a/include/odas/system/track2gain.h +++ b/include/odas/system/track2gain.h @@ -40,11 +40,11 @@ } 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 diff --git a/src/general/spatialfilter.c b/src/general/spatialfilter.c index edc4332..8856ccb 100644 --- a/src/general/spatialfilter.c +++ b/src/general/spatialfilter.c @@ -23,49 +23,66 @@ #include - 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); + } } diff --git a/src/init/directivity.c b/src/init/directivity.c index 01e4e95..147682c 100644 --- a/src/init/directivity.c +++ b/src/init/directivity.c @@ -78,44 +78,52 @@ } - 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))); + + } } @@ -125,10 +133,12 @@ } - 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; @@ -145,9 +155,11 @@ 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; @@ -155,55 +167,63 @@ 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; } diff --git a/src/init/scanning.c b/src/init/scanning.c index f1bac15..7d618ba 100644 --- a/src/init/scanning.c +++ b/src/init/scanning.c @@ -23,13 +23,13 @@ #include - 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 @@ -111,7 +111,7 @@ } beampatterns_destroy(beampatterns_mics); - beampatterns_destroy(beampatterns_spatialfilter); + beampatterns_destroy(beampatterns_spatialfilters); for (iLevel = 0; iLevel < obj->nLevels; iLevel++) { diff --git a/src/module/mod_ssl.c b/src/module/mod_ssl.c index eab119c..27550c7 100644 --- a/src/module/mod_ssl.c +++ b/src/module/mod_ssl.c @@ -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, @@ -107,8 +107,6 @@ obj->in = (msg_spectra_obj *) NULL; obj->out = (msg_pots_obj *) NULL; - //obj->tmpFile = fopen("weights.bin","wb"); - return obj; } @@ -118,8 +116,6 @@ unsigned int iLevel; unsigned int iPot; - //fclose(obj->tmpFile); - scans_destroy(obj->scans); freq2freq_phasor_destroy(obj->freq2freq_phasor); @@ -279,7 +275,7 @@ 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; @@ -308,8 +304,8 @@ soundspeed_destroy(cfg->soundspeed); } - if (cfg->spatialfilter != NULL) { - spatialfilter_destroy(cfg->spatialfilter); + if (cfg->spatialfilters != NULL) { + spatialfilters_destroy(cfg->spatialfilters); } if (cfg->levels != NULL) { @@ -331,7 +327,7 @@ 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++) { diff --git a/src/module/mod_sss.c b/src/module/mod_sss.c index 69fd581..53e5394 100644 --- a/src/module/mod_sss.c +++ b/src/module/mod_sss.c @@ -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, @@ -134,9 +128,6 @@ 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); @@ -153,8 +144,7 @@ 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, @@ -368,7 +358,6 @@ 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); @@ -387,7 +376,6 @@ 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); @@ -552,7 +540,6 @@ track2gain_process(obj->sep_ds_track2gain, obj->sep_ds_beampatterns_mics, - obj->sep_ds_beampatterns_spatialfilter, obj->sep_ds_tracksNow, obj->sep_ds_gains); @@ -626,8 +613,7 @@ 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); @@ -857,7 +843,6 @@ cfg->mics = (mics_obj *) NULL; cfg->samplerate = (samplerate_obj *) NULL; cfg->soundspeed = (soundspeed_obj *) NULL; - cfg->spatialfilter = (spatialfilter_obj *) NULL; return cfg; @@ -877,10 +862,6 @@ soundspeed_destroy(cfg->soundspeed); } - if (cfg->spatialfilter != NULL) { - spatialfilter_destroy(cfg->spatialfilter); - } - free((void *) cfg); } diff --git a/src/module/mod_sst.c b/src/module/mod_sst.c index 827211d..9fbaa55 100644 --- a/src/module/mod_sst.c +++ b/src/module/mod_sst.c @@ -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; @@ -135,8 +135,8 @@ 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); @@ -154,7 +154,7 @@ points_destroy(points); beampatterns_destroy(beampatterns_mics); - beampatterns_destroy(beampatterns_spatialfilter); + beampatterns_destroy(beampatterns_spatialfilters); spatialgains_destroy(spatialgains); spatialmasks_destroy(spatialmasks); spatialindexes_destroy(spatialindexes); @@ -1094,9 +1094,12 @@ 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')) { diff --git a/src/system/track2gain.c b/src/system/track2gain.c index cd308b1..c71fe57 100644 --- a/src/system/track2gain.c +++ b/src/system/track2gain.c @@ -23,7 +23,7 @@ #include - 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; } @@ -45,12 +42,11 @@ 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; @@ -62,15 +58,10 @@ 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++) { @@ -82,12 +73,6 @@ 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]; @@ -97,13 +82,8 @@ 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; @@ -112,17 +92,9 @@ 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; }