src/signal/beampattern.c
src/signal/coherence.c
src/signal/delta.c
+ src/signal/demixing.c
src/signal/frame.c
src/signal/freq.c
src/signal/gain.c
src/signal/window.c
src/signal/xcorr.c
+ src/system/demixing2freq.c
src/system/hop2hop.c
src/system/hop2frame.c
src/system/frame2freq.c
src/system/mixture2mixture.c
src/system/particle2coherence.c
src/system/particle2particle.c
- src/system/steer2freq.c
+ src/system/steer2demixing.c
src/system/track2gain.c
src/system/track2steer.c
src/system/xcorr2aimg.c
src/system/xcorr2xcorr.c
+ src/utils/cmatrix.c
src/utils/fft.c
src/utils/fifo.c
src/utils/gaussian.c
+ src/utils/gaussjordan.c
+ src/utils/inverse.c
src/utils/matrix.c
src/utils/pcm.c
src/utils/random.c
odas
)
+add_executable(debug
+ demo/debug.c
+)
+target_link_libraries(debug
+ odas
+)
+
install(TARGETS odas DESTINATION lib)
--- /dev/null
+# Configuration file for ReSpeaker circular sound card
+
+version = "2.1";
+
+# Raw
+
+raw:
+{
+
+ fS = 16000;
+ hopSize = 128;
+ nBits = 16;
+ nChannels = 16;
+
+ # Input with raw signal from microphones
+ interface: {
+ type = "file";
+ path = "input.raw";
+ }
+
+}
+
+# Mapping
+
+mapping:
+{
+
+ map: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+
+}
+
+# General
+
+general:
+{
+
+ epsilon = 1E-20;
+
+ size:
+ {
+ hopSize = 128;
+ frameSize = 256;
+ };
+
+ samplerate:
+ {
+ mu = 16000;
+ sigma2 = 0.01;
+ };
+
+ speedofsound:
+ {
+ mu = 343.0;
+ sigma2 = 25.0;
+ };
+
+ mics = (
+
+ # Microphone 1
+ {
+ mu = ( +0.1250, -0.0725, +0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 2
+ {
+ mu = ( +0.1250, +0.0725, +0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 3
+ {
+ mu = ( +0.1250, -0.0725, -0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 4
+ {
+ mu = ( +0.1250, +0.0725, -0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 5
+ {
+ mu = ( +0.0725, +0.1250, +0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, +1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 6
+ {
+ mu = ( -0.0725, +0.1250, +0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, +1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 7
+ {
+ mu = ( +0.0725, +0.1250, -0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, +1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 8
+ {
+ mu = ( -0.0725, +0.1250, -0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, +1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 9
+ {
+ mu = ( -0.1250, +0.0725, +0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( -1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 10
+ {
+ mu = ( -0.1250, -0.0725, +0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( -1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 11
+ {
+ mu = ( -0.1250, +0.0725, -0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( -1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 12
+ {
+ mu = ( -0.1250, -0.0725, -0.0725 );
+ sigma2 = ( 0.0, 0.0, 0.0, 0.0, +1E-6, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( -1.000, +0.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 13
+ {
+ mu = ( -0.0725, -0.1250, +0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, -1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 14
+ {
+ mu = ( +0.0725, -0.1250, +0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, -1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 15
+ {
+ mu = ( -0.0725, -0.1250, -0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, -1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ },
+
+ # Microphone 16
+ {
+ mu = ( +0.0725, -0.1250, -0.0725 );
+ sigma2 = ( +1E-6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, +1E-6 );
+ direction = ( +0.000, -1.000, +0.000 );
+ angle = ( 80.0, 100.0 );
+ }
+
+ );
+
+ # Spatial filter to include only a range of direction if required
+ # (may be useful to remove false detections from the floor)
+ spatialfilter: {
+
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ };
+
+ nThetas = 181;
+ gainMin = 0.25;
+
+};
+
+# Sound Source Localization
+
+ssl:
+{
+
+ nPots = 4;
+ nMatches = 10;
+ probMin = 0.3;
+ nRefinedLevels = 1;
+ interpRate = 1;
+
+ # Number of scans: level is the resolution of the sphere
+ # and delta is the size of the maximum sliding window
+ # (delta = -1 means the size is automatically computed)
+ scans = (
+ { level = 2; delta = -1; },
+ { level = 4; delta = -1; }
+ );
+
+ # Output to export potential sources
+ potential: {
+
+ format = "json";
+
+ interface: {
+ type = "blackhole";
+ };
+
+ };
+
+};
+
+# Sound Source Tracking
+
+sst:
+{
+
+ # Mode is either "kalman" or "particle"
+
+ mode = "kalman";
+
+ # Parameters used by both the Kalman and particle filter
+
+ active = (
+ { weight = 1.0; mu = 0.3; sigma2 = 0.0025 }
+ );
+
+ inactive = (
+ { weight = 1.0; mu = 0.15; sigma2 = 0.0025 }
+ );
+
+ sigmaR2_prob = 0.0025;
+ sigmaR2_active = 0.0225;
+ Pfalse = 0.1;
+ Pnew = 0.1;
+ Ptrack = 0.8;
+
+ theta_new = 0.9;
+ N_prob = 5;
+ theta_prob = 0.8;
+ N_inactive = ( 150, 200, 250, 250 );
+ theta_inactive = 0.9;
+
+ # Parameters used by the Kalman filter only
+
+ kalman: {
+
+ sigmaQ = 0.001;
+
+ };
+
+ # Parameters used by the particle filter only
+
+ particle: {
+
+ nParticles = 1000;
+ st_alpha = 2.0;
+ st_beta = 0.04;
+ st_ratio = 0.5;
+ ve_alpha = 0.05;
+ ve_beta = 0.2;
+ ve_ratio = 0.3;
+ ac_alpha = 0.5;
+ ac_beta = 0.2;
+ ac_ratio = 0.2;
+ Nmin = 0.7;
+
+ };
+
+ # Output to export tracked sources
+ tracked: {
+
+ format = "json";
+
+ interface: {
+ type = "blackhole";
+ };
+
+ };
+
+}
+
+sss:
+{
+
+ # Mode is either "dds", "dgss" or "dmvdr"
+
+ mode_sep = "dds";
+ mode_pf = "ms";
+
+ dds: {
+
+ };
+
+ dgss: {
+
+ };
+
+ dmvdr: {
+
+ };
+
+ ms: {
+
+ };
+
+ separated: {
+
+ fS = 44100;
+ hopSize = 512;
+ nBits = 16;
+
+ interface: {
+ type = "file";
+ path = "separated.raw";
+ }
+
+ };
+
+ postfiltered: {
+
+ fS = 44100;
+ hopSize = 512;
+ nBits = 16;
+
+ interface: {
+ type = "file";
+ path = "postfiltered.raw";
+ }
+
+ };
+
+}
sss:
{
- # Mode is either "ds", "gss" or "mvdr"
+ # Mode is either "dds", "dgss" or "dmvdr"
- mode = "ds";
+ mode_sep = "dds";
+ mode_pf = "ms";
- ds: {
+ dds: {
};
- gss: {
+ dgss: {
};
- mvdr: {
+ dmvdr: {
+
+ };
+
+ ms: {
};
};
-}
+ postfiltered: {
+
+ fS = 44100;
+ hopSize = 512;
+ nBits = 16;
+
+ interface: {
+ type = "file";
+ path = "postfiltered.raw";
+ }
+
+ };
+
+}
\ No newline at end of file
sss:
{
- # Mode is either "ds", "gss" or "mvdr"
+ # Mode is either "dds", "dgss" or "dmvdr"
- mode = "ds";
+ mode_sep = "dds";
+ mode_pf = "ms";
- ds: {
+ dds: {
};
- gss: {
+ dgss: {
};
- mvdr: {
+ dmvdr: {
+
+ };
+
+ ms: {
};
};
-}
+ postfiltered: {
+
+ fS = 44100;
+ hopSize = 512;
+ nBits = 16;
+
+ interface: {
+ type = "file";
+ path = "postfiltered.raw";
+ }
+
+ };
+
+}
\ No newline at end of file
cfgs->msg_spectra_mics_config = parameters_msg_spectra_mics_config(file_config);
-
// +----------------------------------------------------------+
// | SSL |
// +----------------------------------------------------------+
cfgs->snk_pots_ssl_config = parameters_snk_pots_ssl_config(file_config);
-
// +----------------------------------------------------------+
// | SST |
// +----------------------------------------------------------+
cfgs->snk_tracks_sst_config = parameters_snk_tracks_sst_config(file_config);
-/*
// +----------------------------------------------------------+
// | SSS |
// +----------------------------------------------------------+
// | Module |
// +------------------------------------------------------+
- cfgs->mod_sss_config = parameters_mod_sss_config(file_config, file_ios);
+ cfgs->mod_sss_config = parameters_mod_sss_config(file_config);
// +------------------------------------------------------+
// | Message |
// +------------------------------------------------------+
- cfgs->msg_spectra_sss_config = parameters_msg_spectra_sss_config(file_config, file_ios);
- cfgs->msg_envs_sss_config = parameters_msg_envs_sss_config(file_config, file_ios);
-
- // +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
-
- cfgs->snk_spectra_sss_config_count = parameters_snk_spectra_sss_count(file_config, file_ios);
- cfgs->snk_spectra_sss_configs = (snk_spectra_cfg **) malloc(sizeof(snk_spectra_cfg *) * cfgs->snk_spectra_sss_config_count);
-
- for (iSink = 0; iSink < cfgs->snk_spectra_sss_config_count; iSink++) {
-
- cfgs->snk_spectra_sss_configs[iSink] = parameters_snk_spectra_sss_config(file_config, file_ios, iSink);
-
- }
+ cfgs->msg_spectra_seps_config = parameters_msg_spectra_seps_config(file_config);
+ cfgs->msg_spectra_pfs_config = parameters_msg_spectra_pfs_config(file_config);
// +----------------------------------------------------------+
- // | SSPF |
- // +----------------------------------------------------------+
+ // | ISTFT |
+ // +----------------------------------------------------------+
// +------------------------------------------------------+
// | Module |
- // +------------------------------------------------------+
+ // +------------------------------------------------------+
- cfgs->mod_sspf_config = parameters_mod_sspf_config(file_config, file_ios);
+ cfgs->mod_istft_seps_config = parameters_mod_istft_seps_config(file_config);
+ cfgs->mod_istft_pfs_config = parameters_mod_istft_pfs_config(file_config);
// +------------------------------------------------------+
// | Message |
- // +------------------------------------------------------+
-
- cfgs->msg_spectra_sspf_config = parameters_msg_spectra_sspf_config(file_config, file_ios);
-
// +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
-
- cfgs->snk_spectra_sspf_config_count = parameters_snk_spectra_sspf_count(file_config, file_ios);
- cfgs->snk_spectra_sspf_configs = (snk_spectra_cfg **) malloc(sizeof(snk_spectra_cfg *) * cfgs->snk_spectra_sspf_config_count);
-
- for (iSink = 0; iSink < cfgs->snk_spectra_sspf_config_count; iSink++) {
-
- cfgs->snk_spectra_sspf_configs[iSink] = parameters_snk_spectra_sspf_config(file_config, file_ios, iSink);
-
- }
+ cfgs->msg_hops_seps_config = parameters_msg_hops_seps_config(file_config);
+ cfgs->msg_hops_pfs_config = parameters_msg_hops_pfs_config(file_config);
// +----------------------------------------------------------+
- // | ISTFT |
- // +----------------------------------------------------------+
+ // | Resample |
+ // +----------------------------------------------------------+
// +------------------------------------------------------+
// | Module |
- // +------------------------------------------------------+
-
- cfgs->mod_istft_config = parameters_mod_istft_config(file_config, file_ios);
-
// +------------------------------------------------------+
- // | Message |
- // +------------------------------------------------------+
- cfgs->msg_hops_istft_config = parameters_msg_hops_istft_config(file_config, file_ios);
+ cfgs->mod_resample_seps_config = parameters_mod_resample_seps_config(file_config);
+ cfgs->mod_resample_pfs_config = parameters_mod_resample_pfs_config(file_config);
// +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
-
- cfgs->snk_hops_istft_config_count = parameters_snk_hops_istft_count(file_config, file_ios);
- cfgs->snk_hops_istft_configs = (snk_hops_cfg **) malloc(sizeof(snk_hops_cfg *) * cfgs->snk_hops_istft_config_count);
-
- for (iSink = 0; iSink < cfgs->snk_hops_istft_config_count; iSink++) {
-
- cfgs->snk_hops_istft_configs[iSink] = parameters_snk_hops_istft_config(file_config, file_ios, iSink);
-
- }
-
- // +----------------------------------------------------------+
- // | Gain |
- // +----------------------------------------------------------+
-
+ // | Message |
// +------------------------------------------------------+
- // | Module |
- // +------------------------------------------------------+
- cfgs->mod_gain_config = parameters_mod_gain_config(file_config, file_ios);
+ cfgs->msg_hops_seps_rs_config = parameters_msg_hops_seps_rs_config(file_config);
+ cfgs->msg_hops_pfs_rs_config = parameters_msg_hops_pfs_rs_config(file_config);
// +------------------------------------------------------+
- // | Message |
- // +------------------------------------------------------+
-
- cfgs->msg_hops_gain_config = parameters_msg_hops_gain_config(file_config, file_ios);
-
+ // | Sink |
// +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
- cfgs->snk_hops_gain_config_count = parameters_snk_hops_gain_count(file_config, file_ios);
- cfgs->snk_hops_gain_configs = (snk_hops_cfg **) malloc(sizeof(snk_hops_cfg *) * cfgs->snk_hops_gain_config_count);
+ cfgs->snk_hops_seps_rs_config = parameters_snk_hops_seps_rs_config(file_config);
+ cfgs->snk_hops_pfs_rs_config = parameters_snk_hops_pfs_rs_config(file_config);
- for (iSink = 0; iSink < cfgs->snk_hops_gain_config_count; iSink++) {
-
- cfgs->snk_hops_gain_configs[iSink] = parameters_snk_hops_gain_config(file_config, file_ios, iSink);
-
- }
-*/
return cfgs;
}
msg_hops_cfg_destroy(cfgs->msg_hops_mics_map_config);
// +----------------------------------------------------------+
- // | Mapping |
+ // | Resample |
// +----------------------------------------------------------+
// +------------------------------------------------------+
// | Message |
// +------------------------------------------------------+
- msg_spectra_cfg_destroy(cfgs->msg_spectra_sss_config);
- msg_envs_cfg_destroy(cfgs->msg_envs_sss_config);
-
- // +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
-
- for (iSink = 0; iSink < cfgs->snk_spectra_sss_config_count; iSink++) {
-
- snk_spectra_cfg_destroy(cfgs->snk_spectra_sss_configs[iSink]);
-
- }
-
- free((void *) cfgs->snk_spectra_sss_configs);
+ msg_spectra_cfg_destroy(cfgs->msg_spectra_sss_seps_config);
+ msg_spectra_cfg_destroy(cfgs->msg_spectra_sss_pfs_config);
// +----------------------------------------------------------+
- // | SSPF |
- // +----------------------------------------------------------+
+ // | ISTFT |
+ // +----------------------------------------------------------+
// +------------------------------------------------------+
// | Module |
- // +------------------------------------------------------+
-
- mod_sspf_cfg_destroy(cfgs->mod_sspf_config);
-
// +------------------------------------------------------+
- // | Message |
- // +------------------------------------------------------+
-
- msg_spectra_cfg_destroy(cfgs->msg_spectra_sspf_config);
-
- // +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
-
- for (iSink = 0; iSink < cfgs->snk_spectra_sspf_config_count; iSink++) {
- snk_spectra_cfg_destroy(cfgs->snk_spectra_sspf_configs[iSink]);
-
- }
-
- free((void *) cfgs->snk_spectra_sspf_configs);
-
- // +----------------------------------------------------------+
- // | ISTFT |
- // +----------------------------------------------------------+
+ mod_istft_cfg_destroy(cfgs->mod_istft_seps_config);
+ mod_istft_cfg_destroy(cfgs->mod_istft_pfs_config);
- // +------------------------------------------------------+
- // | Module |
- // +------------------------------------------------------+
-
- mod_istft_cfg_destroy(cfgs->mod_istft_config);
-
// +------------------------------------------------------+
// | Message |
- // +------------------------------------------------------+
-
- msg_hops_cfg_destroy(cfgs->msg_hops_istft_config);
-
// +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
-
- for (iSink = 0; iSink < cfgs->snk_hops_istft_config_count; iSink++) {
-
- snk_hops_cfg_destroy(cfgs->snk_hops_istft_configs[iSink]);
- }
-
- free((void *) cfgs->snk_hops_istft_configs);
+ msg_hops_cfg_destroy(cfgs->msg_hops_seps_config);
+ msg_hops_cfg_destroy(cfgs->msg_hops_pfs_config);
// +----------------------------------------------------------+
- // | Gain |
- // +----------------------------------------------------------+
+ // | Resample |
+ // +----------------------------------------------------------+
// +------------------------------------------------------+
// | Module |
- // +------------------------------------------------------+
+ // +------------------------------------------------------+
- mod_gain_cfg_destroy(cfgs->mod_gain_config);
+ mod_resample_cfg_destroy(cfgs->mod_resample_seps_config);
+ mod_resample_cfg_destroy(cfgs->mod_resample_pfs_config);
// +------------------------------------------------------+
// | Message |
- // +------------------------------------------------------+
-
- msg_hops_cfg_destroy(cfgs->msg_hops_gain_config);
-
// +------------------------------------------------------+
- // | Sinks |
- // +------------------------------------------------------+
-
- for (iSink = 0; iSink < cfgs->snk_hops_gain_config_count; iSink++) {
- snk_hops_cfg_destroy(cfgs->snk_hops_gain_configs[iSink]);
+ msg_hops_cfg_destroy(cfgs->msg_hops_seps_rs_config);
+ msg_hops_cfg_destroy(cfgs->msg_hops_pfs_rs_config);
- }
+ // +------------------------------------------------------+
+ // | Sink |
+ // +------------------------------------------------------+
- free((void *) cfgs->snk_hops_gain_configs);
+ snk_hops_cfg_destroy(cfgs->snk_hops_seps_rs_config);
+ snk_hops_cfg_destroy(cfgs->snk_hops_pfs_rs_config);
*/
free((void *) cfgs);
msg_tracks_cfg * msg_tracks_sst_config;
snk_tracks_cfg * snk_tracks_sst_config;
+ mod_sss_cfg * mod_sss_config;
+ msg_spectra_cfg * msg_spectra_seps_config;
+ msg_spectra_cfg * msg_spectra_pfs_config;
+
+ mod_istft_cfg * mod_istft_seps_config;
+ mod_istft_cfg * mod_istft_pfs_config;
+ msg_hops_cfg * msg_hops_seps_config;
+ msg_hops_cfg * msg_hops_pfs_config;
+
+ mod_resample_cfg * mod_resample_seps_config;
+ mod_resample_cfg * mod_resample_pfs_config;
+ msg_hops_cfg * msg_hops_seps_rs_config;
+ msg_hops_cfg * msg_hops_pfs_rs_config;
+ snk_hops_cfg * snk_hops_seps_rs_config;
+ snk_hops_cfg * snk_hops_pfs_rs_config;
+
} configs;
configs * configs_construct(const char * file_config);
--- /dev/null
+
+ #include <odas/odas.h>
+
+ #include <time.h>
+ #include <stdlib.h>
+
+ #include "../src/utils/inverse.h"
+
+ int main(int argc, char * argv[]) {
+
+ cmatrix_obj * cmatrix1;
+ cmatrix_obj * cmatrix2;
+ inverse_complex_obj * inverse_complex;
+
+ unsigned int iRow;
+ unsigned int iCol;
+ unsigned int iIteration;
+ unsigned int nIterations;
+
+ nIterations = 100000;
+
+ cmatrix1 = cmatrix_construct_zero(16,16);
+ cmatrix2 = cmatrix_construct_zero(16,16);
+ inverse_complex = inverse_complex_construct_zero(16,1E-20);
+
+ srand(time(NULL));
+
+ for (iRow = 0; iRow < 16; iRow++) {
+
+ for (iCol = 0; iCol < 16; iCol++) {
+
+ cmatrix1->real[iRow * 16 + iCol] = ((float) rand()) / ((float) RAND_MAX);
+ cmatrix1->imag[iRow * 16 + iCol] = ((float) rand()) / ((float) RAND_MAX);
+
+ }
+
+ }
+
+ for (iIteration = 0; iIteration < nIterations; iIteration++) {
+
+ inverse_complex_process(inverse_complex, cmatrix1, cmatrix2);
+
+ }
+
+ }
\ No newline at end of file
case 'h':
+ printf("+----------------------------------------------------+\n");
+ printf("| ODAS (Open embeddeD Audition System) |\n");
+ printf("+----------------------------------------------------+\n");
+ printf("| Author: Francois Grondin |\n");
+ printf("| Email: francois.grondin2@usherbrooke.ca |\n");
+ printf("| Website: introlab.3it.usherbrooke.ca |\n");
+ printf("| Version: 1.0 |\n");
+ printf("+----------------------------------------------------+\n");
+ printf("| -c Configuration file (.cfg) |\n");
+ printf("| -h Help |\n");
+ printf("| -s Process sequentially (no multithread) |\n");
+ printf("| -v Verbose |\n");
+ printf("+----------------------------------------------------+\n");
+
exit(EXIT_SUCCESS);
break;
// | Configure |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Initializing configurations...... "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Initializing configurations...... "); fflush(stdout);
cfgs = configs_construct(file_config);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Construct |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Initializing objects............. "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Initializing objects............. "); fflush(stdout);
objs = objects_construct(cfgs);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Processing |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Processing....................... "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Processing....................... "); fflush(stdout);
threads_single_open(objs);
stopProcess = 0;
while((threads_single_process(objs, prf) == 0) && (stopProcess == 0));
threads_single_close(objs);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Free memory |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Free memory...................... "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Free memory...................... "); fflush(stdout);
- objects_destroy(objs);
+ objects_destroy(objs);
configs_destroy(cfgs);
free((void *) file_config);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Results |
// | Configure |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Initializing configurations...... "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Initializing configurations...... "); fflush(stdout);
cfgs = configs_construct(file_config);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Construct |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Initializing objects............. "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Initializing objects............. "); fflush(stdout);
aobjs = aobjects_construct(cfgs);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Launch threads |
signal(SIGINT, sighandler);
- if (verbose == 0x01) printf(" + Launch threads................... "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Launch threads................... "); fflush(stdout);
threads_multiple_start(aobjs);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Wait |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Threads running.................. "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Threads running.................. "); fflush(stdout);
threads_multiple_join(aobjs);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
// +--------------------------------------------------+
// | Free memory |
// +--------------------------------------------------+
- if (verbose == 0x01) printf(" + Free memory...................... "); fflush(stdout);
+ if (verbose == 0x01) printf("| + Free memory...................... "); fflush(stdout);
aobjects_destroy(aobjs);
configs_destroy(cfgs);
free((void *) file_config);
- if (verbose == 0x01) printf("[Done]\n");
+ if (verbose == 0x01) printf("[Done] |\n");
+
+ if (verbose == 0x01) printf("+--------------------------------------------+\n");
}
cfgs->msg_hops_mics_raw_config);
// +--------------------------------------------------+
- // | Message |
+ // | Connector |
// +--------------------------------------------------+
- objs->msg_hops_mics_raw_object = msg_hops_construct(cfgs->msg_hops_mics_raw_config);
+ objs->con_hops_mics_raw_object = con_hops_construct(1, cfgs->msg_hops_mics_raw_config);
// +------------------------------------------------------+
// | Mapping |
cfgs->msg_hops_mics_map_config);
// +--------------------------------------------------+
- // | Message |
+ // | Connector |
// +--------------------------------------------------+
- objs->msg_hops_mics_map_object = msg_hops_construct(cfgs->msg_hops_mics_map_config);
+ objs->con_hops_mics_map_object = con_hops_construct(1, cfgs->msg_hops_mics_map_config);
// +------------------------------------------------------+
// | Resample |
cfgs->msg_hops_mics_rs_config);
// +--------------------------------------------------+
- // | Message |
+ // | Connector |
// +--------------------------------------------------+
- objs->msg_hops_mics_rs_object = msg_hops_construct(cfgs->msg_hops_mics_rs_config);
+ objs->con_hops_mics_rs_object = con_hops_construct(1, cfgs->msg_hops_mics_rs_config);
// +------------------------------------------------------+
// | STFT |
cfgs->msg_spectra_mics_config);
// +--------------------------------------------------+
- // | Message |
+ // | Connector |
// +--------------------------------------------------+
- objs->msg_spectra_mics_object = msg_spectra_construct(cfgs->msg_spectra_mics_config);
+ objs->con_spectra_mics_object = con_spectra_construct(2, cfgs->msg_spectra_mics_config);
// +------------------------------------------------------+
// | SSL |
cfgs->msg_spectra_mics_config,
cfgs->msg_pots_ssl_config);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- objs->msg_pots_ssl_object = msg_pots_construct(cfgs->msg_pots_ssl_config);
-
// +--------------------------------------------------+
// | Sinks |
// +--------------------------------------------------+
objs->snk_pots_ssl_object = snk_pots_construct(cfgs->snk_pots_ssl_config,
cfgs->msg_pots_ssl_config);
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ objs->con_pots_ssl_object = con_pots_construct(2, cfgs->msg_pots_ssl_config);
// +------------------------------------------------------+
// | SST |
cfgs->msg_tracks_sst_config);
// +--------------------------------------------------+
- // | Message |
+ // | Sinks |
// +--------------------------------------------------+
- objs->msg_tracks_sst_object = msg_tracks_construct(cfgs->msg_tracks_sst_config);
+ objs->snk_tracks_sst_object = snk_tracks_construct(cfgs->snk_tracks_sst_config,
+ cfgs->msg_tracks_sst_config);
// +--------------------------------------------------+
- // | Sinks |
+ // | Connector |
+ // +--------------------------------------------------+
+
+ objs->con_tracks_sst_object = con_tracks_construct(2, cfgs->msg_tracks_sst_config);
+
+ // +------------------------------------------------------+
+ // | SSS |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
// +--------------------------------------------------+
- objs->snk_tracks_sst_object = snk_tracks_construct(cfgs->snk_tracks_sst_config,
- cfgs->msg_tracks_sst_config);
+ objs->mod_sss_object = mod_sss_construct(cfgs->mod_sss_config,
+ cfgs->msg_tracks_sst_config,
+ cfgs->msg_spectra_mics_config);
- // +----------------------------------------------------------+
- // | Connect |
- // +----------------------------------------------------------+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
- objs->con_hops_mics_raw_object = con_hops_construct(1, cfgs->msg_hops_mics_raw_config);
+ objs->con_spectra_seps_object = con_spectra_construct(1, cfgs->msg_spectra_seps_config);
+ objs->con_spectra_pfs_object = con_spectra_construct(1, cfgs->msg_spectra_pfs_config);
- objs->con_hops_mics_map_object = con_hops_construct(1, cfgs->msg_hops_mics_map_config);
+ // +------------------------------------------------------+
+ // | ISTFT |
+ // +------------------------------------------------------+
- objs->con_hops_mics_rs_object = con_hops_construct(1, cfgs->msg_hops_mics_rs_config);
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
- objs->con_spectra_mics_object = con_spectra_construct(1, cfgs->msg_spectra_mics_config);
+ objs->mod_istft_seps_object = mod_istft_construct(cfgs->mod_istft_seps_config,
+ cfgs->msg_spectra_seps_config,
+ cfgs->msg_hops_seps_config);
- objs->con_pots_ssl_object = con_pots_construct(2, cfgs->msg_pots_ssl_config);
+ objs->mod_istft_pfs_object = mod_istft_construct(cfgs->mod_istft_pfs_config,
+ cfgs->msg_spectra_pfs_config,
+ cfgs->msg_hops_pfs_config);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
- objs->con_tracks_sst_object = con_tracks_construct(1, cfgs->msg_tracks_sst_config);
+ objs->con_hops_seps_object = con_hops_construct(1, cfgs->msg_hops_seps_config);
+ objs->con_hops_pfs_object = con_hops_construct(1, cfgs->msg_hops_pfs_config);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ objs->mod_resample_seps_object = mod_resample_construct(cfgs->mod_resample_seps_config,
+ cfgs->msg_hops_seps_config,
+ cfgs->msg_hops_seps_rs_config);
+
+ objs->mod_resample_pfs_object = mod_resample_construct(cfgs->mod_resample_pfs_config,
+ cfgs->msg_hops_pfs_config,
+ cfgs->msg_hops_pfs_rs_config);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ objs->con_hops_seps_rs_object = con_hops_construct(1, cfgs->msg_hops_seps_rs_config);
+
+ objs->con_hops_pfs_rs_object = con_hops_construct(1, cfgs->msg_hops_pfs_rs_config);
+
+ // +--------------------------------------------------+
+ // | Sink |
+ // +--------------------------------------------------+
+
+ objs->snk_hops_seps_rs_object = snk_hops_construct(cfgs->snk_hops_seps_rs_config,
+ cfgs->msg_hops_seps_rs_config);
+
+ objs->snk_hops_pfs_rs_object = snk_hops_construct(cfgs->snk_hops_pfs_rs_config,
+ cfgs->msg_hops_pfs_rs_config);
+
+
+ // +----------------------------------------------------------+
+ // | Connect |
+ // +----------------------------------------------------------+
// +------------------------------------------------------+
// | Raw |
// +--------------------------------------------------+
snk_tracks_connect(objs->snk_tracks_sst_object,
- objs->con_tracks_sst_object->outs[0]);
+ objs->con_tracks_sst_object->outs[1]);
+
+ // +------------------------------------------------------+
+ // | SSS |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ mod_sss_connect(objs->mod_sss_object,
+ objs->con_spectra_mics_object->outs[1],
+ objs->con_tracks_sst_object->outs[0],
+ objs->con_spectra_seps_object->in,
+ objs->con_spectra_pfs_object->in);
+
+ // +------------------------------------------------------+
+ // | ISTFT |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ mod_istft_connect(objs->mod_istft_seps_object,
+ objs->con_spectra_seps_object->outs[0],
+ objs->con_hops_seps_object->in);
+
+ mod_istft_connect(objs->mod_istft_pfs_object,
+ objs->con_spectra_pfs_object->outs[0],
+ objs->con_hops_pfs_object->in);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ mod_resample_connect(objs->mod_resample_seps_object,
+ objs->con_hops_seps_object->outs[0],
+ objs->con_hops_seps_rs_object->in);
+
+ mod_resample_connect(objs->mod_resample_pfs_object,
+ objs->con_hops_pfs_object->outs[0],
+ objs->con_hops_pfs_rs_object->in);
+
+ // +--------------------------------------------------+
+ // | Sink |
+ // +--------------------------------------------------+
+
+ snk_hops_connect(objs->snk_hops_seps_rs_object,
+ objs->con_hops_seps_rs_object->outs[0]);
+
+ snk_hops_connect(objs->snk_hops_pfs_rs_object,
+ objs->con_hops_pfs_rs_object->outs[0]);
return objs;
src_hops_destroy(objs->src_hops_mics_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- msg_hops_destroy(objs->msg_hops_mics_raw_object);
-
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
mod_mapping_destroy(objs->mod_mapping_mics_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- msg_hops_destroy(objs->msg_hops_mics_map_object);
-
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
- con_hops_destroy(objs->con_hops_mics_map_object);
+ con_hops_destroy(objs->con_hops_mics_map_object);
// +------------------------------------------------------+
// | Resample |
// +--------------------------------------------------+
mod_resample_destroy(objs->mod_resample_mics_object);
-
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- msg_hops_destroy(objs->msg_hops_mics_rs_object);
-
+
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
- con_hops_destroy(objs->con_hops_mics_rs_object);
+ con_hops_destroy(objs->con_hops_mics_rs_object);
// +------------------------------------------------------+
// | STFT |
// +--------------------------------------------------+
mod_stft_destroy(objs->mod_stft_mics_object);
-
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- msg_spectra_destroy(objs->msg_spectra_mics_object);
-
+
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
- con_spectra_destroy(objs->con_spectra_mics_object);
+ con_spectra_destroy(objs->con_spectra_mics_object);
// +------------------------------------------------------+
// | SSL |
// +--------------------------------------------------+
mod_ssl_destroy(objs->mod_ssl_object);
-
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- msg_pots_destroy(objs->msg_pots_ssl_object);
-
+
// +--------------------------------------------------+
// | Sinks |
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
- con_pots_destroy(objs->con_pots_ssl_object);
+ con_pots_destroy(objs->con_pots_ssl_object);
// +------------------------------------------------------+
// | SST |
// +--------------------------------------------------+
mod_sst_destroy(objs->mod_sst_object);
-
+
// +--------------------------------------------------+
- // | Message |
+ // | Sinks |
// +--------------------------------------------------+
- msg_tracks_destroy(objs->msg_tracks_sst_object);
-
+ snk_tracks_destroy(objs->snk_tracks_sst_object);
+
// +--------------------------------------------------+
- // | Sinks |
+ // | Connector |
// +--------------------------------------------------+
- snk_tracks_destroy(objs->snk_tracks_sst_object);
+ con_tracks_destroy(objs->con_tracks_sst_object);
+
+ // +------------------------------------------------------+
+ // | SSS |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ mod_sss_destroy(objs->mod_sss_object);
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
- con_tracks_destroy(objs->con_tracks_sst_object);
+ con_spectra_destroy(objs->con_spectra_seps_object);
+ con_spectra_destroy(objs->con_spectra_pfs_object);
+
+ // +------------------------------------------------------+
+ // | ISTFT |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ mod_istft_destroy(objs->mod_istft_seps_object);
+ mod_istft_destroy(objs->mod_istft_pfs_object);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ con_hops_destroy(objs->con_hops_seps_object);
+ con_hops_destroy(objs->con_hops_pfs_object);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ mod_resample_destroy(objs->mod_resample_seps_object);
+ mod_resample_destroy(objs->mod_resample_pfs_object);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ con_hops_destroy(objs->con_hops_seps_rs_object);
+ con_hops_destroy(objs->con_hops_pfs_rs_object);
+
+ // +--------------------------------------------------+
+ // | Sink |
+ // +--------------------------------------------------+
+
+ snk_hops_destroy(objs->snk_hops_seps_rs_object);
+ snk_hops_destroy(objs->snk_hops_pfs_rs_object);
free((void *) objs);
cfgs->msg_hops_mics_raw_config);
// +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
- objs->amsg_hops_mics_raw_object = amsg_hops_construct(objs->nMessages,
- cfgs->msg_hops_mics_raw_config);
+ objs->acon_hops_mics_raw_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_mics_raw_config);
// +------------------------------------------------------+
// | Mapping |
cfgs->msg_hops_mics_map_config);
// +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
- objs->amsg_hops_mics_map_object = amsg_hops_construct(objs->nMessages,
- cfgs->msg_hops_mics_map_config);
+ objs->acon_hops_mics_map_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_mics_map_config);
// +------------------------------------------------------+
// | Resample |
cfgs->msg_hops_mics_rs_config);
// +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
- objs->amsg_hops_mics_rs_object = amsg_hops_construct(objs->nMessages,
- cfgs->msg_hops_mics_rs_config);
+ objs->acon_hops_mics_rs_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_mics_rs_config);
// +------------------------------------------------------+
// | STFT |
cfgs->msg_spectra_mics_config);
// +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- objs->amsg_spectra_mics_object = amsg_spectra_construct(objs->nMessages,
- cfgs->msg_spectra_mics_config);
+ // | Connector |
+ // +--------------------------------------------------+
+
+ objs->acon_spectra_mics_object = acon_spectra_construct(2, objs->nMessages, cfgs->msg_spectra_mics_config);
// +------------------------------------------------------+
// | SSL |
cfgs->msg_pots_ssl_config);
// +--------------------------------------------------+
- // | Message |
+ // | Sinks |
// +--------------------------------------------------+
- objs->amsg_pots_ssl_object = amsg_pots_construct(objs->nMessages,
+ objs->asnk_pots_ssl_object = asnk_pots_construct(cfgs->snk_pots_ssl_config,
cfgs->msg_pots_ssl_config);
// +--------------------------------------------------+
- // | Sinks |
- // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
- objs->asnk_pots_ssl_object = asnk_pots_construct(cfgs->snk_pots_ssl_config,
- cfgs->msg_pots_ssl_config);
+ objs->acon_pots_ssl_object = acon_pots_construct(2, objs->nMessages, cfgs->msg_pots_ssl_config);
// +------------------------------------------------------+
// | SST |
cfgs->msg_tracks_sst_config);
// +--------------------------------------------------+
- // | Message |
+ // | Sinks |
// +--------------------------------------------------+
- objs->amsg_tracks_sst_object = amsg_tracks_construct(objs->nMessages,
+ objs->asnk_tracks_sst_object = asnk_tracks_construct(cfgs->snk_tracks_sst_config,
cfgs->msg_tracks_sst_config);
// +--------------------------------------------------+
- // | Sinks |
+ // | Connector |
+ // +--------------------------------------------------+
+
+ objs->acon_tracks_sst_object = acon_tracks_construct(2, objs->nMessages, cfgs->msg_tracks_sst_config);
+
+ // +------------------------------------------------------+
+ // | SSS |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
// +--------------------------------------------------+
- objs->asnk_tracks_sst_object = asnk_tracks_construct(cfgs->snk_tracks_sst_config,
- cfgs->msg_tracks_sst_config);
+ objs->amod_sss_object = amod_sss_construct(cfgs->mod_sss_config,
+ cfgs->msg_tracks_sst_config,
+ cfgs->msg_spectra_mics_config);
- // +----------------------------------------------------------+
- // | Connect |
- // +----------------------------------------------------------+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
- objs->acon_hops_mics_raw_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_mics_raw_config);
+ objs->acon_spectra_seps_object = acon_spectra_construct(1, objs->nMessages, cfgs->msg_spectra_seps_config);
+ objs->acon_spectra_pfs_object = acon_spectra_construct(1, objs->nMessages, cfgs->msg_spectra_pfs_config);
- objs->acon_hops_mics_map_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_mics_map_config);
+ // +------------------------------------------------------+
+ // | ISTFT |
+ // +------------------------------------------------------+
- objs->acon_hops_mics_rs_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_mics_rs_config);
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
- objs->acon_spectra_mics_object = acon_spectra_construct(1, objs->nMessages, cfgs->msg_spectra_mics_config);
+ objs->amod_istft_seps_object = amod_istft_construct(cfgs->mod_istft_seps_config,
+ cfgs->msg_spectra_seps_config,
+ cfgs->msg_hops_seps_config);
- objs->acon_pots_ssl_object = acon_pots_construct(2, objs->nMessages, cfgs->msg_pots_ssl_config);
+ objs->amod_istft_pfs_object = amod_istft_construct(cfgs->mod_istft_pfs_config,
+ cfgs->msg_spectra_pfs_config,
+ cfgs->msg_hops_pfs_config);
- objs->acon_tracks_sst_object = acon_tracks_construct(1, objs->nMessages, cfgs->msg_tracks_sst_config);
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ objs->acon_hops_seps_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_seps_config);
+ objs->acon_hops_pfs_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_pfs_config);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ objs->amod_resample_seps_object = amod_resample_construct(cfgs->mod_resample_seps_config,
+ cfgs->msg_hops_seps_config,
+ cfgs->msg_hops_seps_rs_config);
+
+ objs->amod_resample_pfs_object = amod_resample_construct(cfgs->mod_resample_pfs_config,
+ cfgs->msg_hops_pfs_config,
+ cfgs->msg_hops_pfs_rs_config);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ objs->acon_hops_seps_rs_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_seps_rs_config);
+
+ objs->acon_hops_pfs_rs_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_pfs_rs_config);
+
+ // +--------------------------------------------------+
+ // | Sink |
+ // +--------------------------------------------------+
+
+ objs->asnk_hops_seps_rs_object = asnk_hops_construct(cfgs->snk_hops_seps_rs_config,
+ cfgs->msg_hops_seps_rs_config);
+
+ objs->asnk_hops_pfs_rs_object = asnk_hops_construct(cfgs->snk_hops_pfs_rs_config,
+ cfgs->msg_hops_pfs_rs_config);
+
+ // +----------------------------------------------------------+
+ // | Connect |
+ // +----------------------------------------------------------+
// +------------------------------------------------------+
// | Raw |
// +--------------------------------------------------+
asnk_tracks_connect(objs->asnk_tracks_sst_object,
- objs->acon_tracks_sst_object->outs[0]);
+ objs->acon_tracks_sst_object->outs[1]);
+
+ // +------------------------------------------------------+
+ // | SSS |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ amod_sss_connect(objs->amod_sss_object,
+ objs->acon_spectra_mics_object->outs[1],
+ objs->acon_tracks_sst_object->outs[0],
+ objs->acon_spectra_seps_object->in,
+ objs->acon_spectra_pfs_object->in);
+
+ // +------------------------------------------------------+
+ // | ISTFT |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ amod_istft_connect(objs->amod_istft_seps_object,
+ objs->acon_spectra_seps_object->outs[0],
+ objs->acon_hops_seps_object->in);
+
+ amod_istft_connect(objs->amod_istft_pfs_object,
+ objs->acon_spectra_pfs_object->outs[0],
+ objs->acon_hops_pfs_object->in);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ amod_resample_connect(objs->amod_resample_seps_object,
+ objs->acon_hops_seps_object->outs[0],
+ objs->acon_hops_seps_rs_object->in);
+
+ amod_resample_connect(objs->amod_resample_pfs_object,
+ objs->acon_hops_pfs_object->outs[0],
+ objs->acon_hops_pfs_rs_object->in);
+
+ // +--------------------------------------------------+
+ // | Sink |
+ // +--------------------------------------------------+
+
+ asnk_hops_connect(objs->asnk_hops_seps_rs_object,
+ objs->acon_hops_seps_rs_object->outs[0]);
+
+ asnk_hops_connect(objs->asnk_hops_pfs_rs_object,
+ objs->acon_hops_pfs_rs_object->outs[0]);
return objs;
asrc_hops_destroy(objs->asrc_hops_mics_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- amsg_hops_destroy(objs->amsg_hops_mics_raw_object);
-
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
amod_mapping_destroy(objs->amod_mapping_mics_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- amsg_hops_destroy(objs->amsg_hops_mics_map_object);
-
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
amod_resample_destroy(objs->amod_resample_mics_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- amsg_hops_destroy(objs->amsg_hops_mics_rs_object);
-
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
amod_stft_destroy(objs->amod_stft_mics_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- amsg_spectra_destroy(objs->amsg_spectra_mics_object);
-
// +--------------------------------------------------+
// | Connector |
// +--------------------------------------------------+
amod_ssl_destroy(objs->amod_ssl_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- amsg_pots_destroy(objs->amsg_pots_ssl_object);
-
// +--------------------------------------------------+
// | Sinks |
// +--------------------------------------------------+
amod_sst_destroy(objs->amod_sst_object);
- // +--------------------------------------------------+
- // | Message |
- // +--------------------------------------------------+
-
- amsg_tracks_destroy(objs->amsg_tracks_sst_object);
-
// +--------------------------------------------------+
// | Sinks |
// +--------------------------------------------------+
acon_tracks_destroy(objs->acon_tracks_sst_object);
+ // +------------------------------------------------------+
+ // | SSS |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ amod_sss_destroy(objs->amod_sss_object);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ acon_spectra_destroy(objs->acon_spectra_seps_object);
+ acon_spectra_destroy(objs->acon_spectra_pfs_object);
+
+ // +------------------------------------------------------+
+ // | ISTFT |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ amod_istft_destroy(objs->amod_istft_seps_object);
+ amod_istft_destroy(objs->amod_istft_pfs_object);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ acon_hops_destroy(objs->acon_hops_seps_object);
+ acon_hops_destroy(objs->acon_hops_pfs_object);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ amod_resample_destroy(objs->amod_resample_seps_object);
+ amod_resample_destroy(objs->amod_resample_pfs_object);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ acon_hops_destroy(objs->acon_hops_seps_rs_object);
+ acon_hops_destroy(objs->acon_hops_pfs_rs_object);
+
+ // +--------------------------------------------------+
+ // | Sink |
+ // +--------------------------------------------------+
+
+ asnk_hops_destroy(objs->asnk_hops_seps_rs_object);
+ asnk_hops_destroy(objs->asnk_hops_pfs_rs_object);
+
free((void *) objs);
}
\ No newline at end of file
typedef struct objects {
src_hops_obj * src_hops_mics_object;
- msg_hops_obj * msg_hops_mics_raw_object;
snk_hops_obj * snk_hops_mics_raw_object;
con_hops_obj * con_hops_mics_raw_object;
mod_mapping_obj * mod_mapping_mics_object;
- msg_hops_obj * msg_hops_mics_map_object;
snk_hops_obj * snk_hops_mics_map_object;
con_hops_obj * con_hops_mics_map_object;
mod_resample_obj * mod_resample_mics_object;
- msg_hops_obj * msg_hops_mics_rs_object;
snk_hops_obj * snk_hops_mics_rs_object;
con_hops_obj * con_hops_mics_rs_object;
mod_stft_obj * mod_stft_mics_object;
- msg_spectra_obj * msg_spectra_mics_object;
snk_spectra_obj * snk_spectra_mics_object;
con_spectra_obj * con_spectra_mics_object;
mod_ssl_obj * mod_ssl_object;
- msg_pots_obj * msg_pots_ssl_object;
snk_pots_obj * snk_pots_ssl_object;
con_pots_obj * con_pots_ssl_object;
mod_sst_obj * mod_sst_object;
- msg_tracks_obj * msg_tracks_sst_object;
snk_tracks_obj * snk_tracks_sst_object;
con_tracks_obj * con_tracks_sst_object;
+ mod_sss_obj * mod_sss_object;
+ con_spectra_obj * con_spectra_seps_object;
+ con_spectra_obj * con_spectra_pfs_object;
+
+ mod_istft_obj * mod_istft_seps_object;
+ con_hops_obj * con_hops_seps_object;
+ mod_resample_obj * mod_resample_seps_object;
+ con_hops_obj * con_hops_seps_rs_object;
+ snk_hops_obj * snk_hops_seps_rs_object;
+
+ mod_istft_obj * mod_istft_pfs_object;
+ con_hops_obj * con_hops_pfs_object;
+ mod_resample_obj * mod_resample_pfs_object;
+ con_hops_obj * con_hops_pfs_rs_object;
+ snk_hops_obj * snk_hops_pfs_rs_object;
+
} objects;
typedef struct aobjects {
unsigned int nMessages;
asrc_hops_obj * asrc_hops_mics_object;
- amsg_hops_obj * amsg_hops_mics_raw_object;
asnk_hops_obj * asnk_hops_mics_raw_object;
acon_hops_obj * acon_hops_mics_raw_object;
amod_mapping_obj * amod_mapping_mics_object;
- amsg_hops_obj * amsg_hops_mics_map_object;
asnk_hops_obj * asnk_hops_mics_map_objects;
acon_hops_obj * acon_hops_mics_map_object;
amod_resample_obj * amod_resample_mics_object;
- amsg_hops_obj * amsg_hops_mics_rs_object;
asnk_hops_obj * asnk_hops_mics_rs_object;
acon_hops_obj * acon_hops_mics_rs_object;
amod_stft_obj * amod_stft_mics_object;
- amsg_spectra_obj * amsg_spectra_mics_object;
asnk_spectra_obj * asnk_spectra_mics_object;
acon_spectra_obj * acon_spectra_mics_object;
amod_ssl_obj * amod_ssl_object;
- amsg_pots_obj * amsg_pots_ssl_object;
asnk_pots_obj * asnk_pots_ssl_object;
acon_pots_obj * acon_pots_ssl_object;
amod_sst_obj * amod_sst_object;
- amsg_tracks_obj * amsg_tracks_sst_object;
asnk_tracks_obj * asnk_tracks_sst_object;
acon_tracks_obj * acon_tracks_sst_object;
+ amod_sss_obj * amod_sss_object;
+ acon_spectra_obj * acon_spectra_seps_object;
+ acon_spectra_obj * acon_spectra_pfs_object;
+
+ amod_istft_obj * amod_istft_seps_object;
+ amod_istft_obj * amod_istft_pfs_object;
+ acon_hops_obj * acon_hops_seps_object;
+ acon_hops_obj * acon_hops_pfs_object;
+
+ amod_resample_obj * amod_resample_seps_object;
+ amod_resample_obj * amod_resample_pfs_object;
+ acon_hops_obj * acon_hops_seps_rs_object;
+ acon_hops_obj * acon_hops_pfs_rs_object;
+ asnk_hops_obj * asnk_hops_seps_rs_object;
+ asnk_hops_obj * asnk_hops_pfs_rs_object;
+
} aobjects;
objects * objects_construct(const configs * cfgs);
}
-
\ No newline at end of file
+ mod_sss_cfg * parameters_mod_sss_config(const char * fileConfig) {
+
+ mod_sss_cfg * cfg;
+
+ unsigned int nChannels;
+ unsigned int iChannel;
+ unsigned int iSample;
+
+ char * tmpStr1;
+ char * tmpLabel;
+
+ cfg = mod_sss_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Mode |
+ // +----------------------------------------------------------+
+
+ tmpStr1 = parameters_lookup_string(fileConfig, "sss.mode_sep");
+
+ if (strcmp(tmpStr1, "dds") == 0) {
+ cfg->mode_sep = 'd';
+ }
+ else if (strcmp(tmpStr1, "dgss") == 0) {
+ cfg->mode_sep = 'g';
+ }
+ else if (strcmp(tmpStr1, "dmvdr") == 0) {
+ cfg->mode_sep = 'm';
+ }
+ else {
+ printf("sss.mode_sep: Invalid separation method.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ tmpStr1 = parameters_lookup_string(fileConfig, "sss.mode_pf");
+
+ if (strcmp(tmpStr1, "ms") == 0) {
+ cfg->mode_pf = 'm';
+ }
+ else {
+ printf("sss.mode_pf: Invalid post-filtering method.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ free((void *) tmpStr1);
+
+ // +----------------------------------------------------------+
+ // | Number of channels |
+ // +----------------------------------------------------------+
+
+ nChannels = parameters_count(fileConfig, "general.mics");
+
+ cfg->mics = mics_construct_zero(nChannels);
+
+ for (iChannel = 0; iChannel < nChannels; iChannel++) {
+
+ // +--------------------------------------------------+
+ // | Mu |
+ // +--------------------------------------------------+
+
+ for (iSample = 0; iSample < 3; iSample++) {
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.mics.[%u].mu.[%u]", iChannel, iSample);
+ cfg->mics->mu[iChannel * 3 + iSample] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ }
+
+ // +--------------------------------------------------+
+ // | Sigma2 |
+ // +--------------------------------------------------+
+
+ for (iSample = 0; iSample < 9; iSample++) {
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.mics.[%u].sigma2.[%u]", iChannel, iSample);
+ cfg->mics->sigma2[iChannel * 9 + iSample] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ }
+
+ // +--------------------------------------------------+
+ // | Direction |
+ // +--------------------------------------------------+
+
+ for (iSample = 0; iSample < 3; iSample++) {
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.mics.[%u].direction.[%u]", iChannel, iSample);
+ cfg->mics->direction[iChannel * 3 + iSample] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ }
+
+ // +--------------------------------------------------+
+ // | Angle |
+ // +--------------------------------------------------+
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.mics.[%u].angle.[%u]", iChannel, 0);
+ cfg->mics->thetaAllPass[iChannel] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ tmpLabel = (char *) malloc(sizeof(char) * 1024);
+ sprintf(tmpLabel, "general.mics.[%u].angle.[%u]", iChannel, 1);
+ cfg->mics->thetaNoPass[iChannel] = parameters_lookup_float(fileConfig, tmpLabel);
+ free((void *) tmpLabel);
+
+ }
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->samplerate = samplerate_construct_zero();
+
+ cfg->samplerate->mu = parameters_lookup_int(fileConfig, "general.samplerate.mu");
+ cfg->samplerate->sigma2 = parameters_lookup_float(fileConfig, "general.samplerate.sigma2");
+
+ // +----------------------------------------------------------+
+ // | Sound speed |
+ // +----------------------------------------------------------+
+
+ cfg->soundspeed = soundspeed_construct_zero();
+
+ 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 |
+ // +----------------------------------------------------------+
+
+ cfg->nThetas = parameters_lookup_int(fileConfig, "general.nThetas");
+
+ // +----------------------------------------------------------+
+ // | Number of thetas |
+ // +----------------------------------------------------------+
+
+ cfg->gainMin = parameters_lookup_float(fileConfig, "general.gainMin");
+
+ return cfg;
+
+ }
+
+ msg_spectra_cfg * parameters_msg_spectra_seps_config(const char * fileConfig) {
+
+ msg_spectra_cfg * cfg;
+
+ unsigned int halfFrameSize;
+ unsigned int nChannels;
+ unsigned int fS;
+
+ cfg = msg_spectra_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu");
+
+ // +----------------------------------------------------------+
+ // | Hop size |
+ // +----------------------------------------------------------+
+
+ cfg->halfFrameSize = parameters_lookup_int(fileConfig, "general.size.frameSize") / 2 + 1;
+
+ // +----------------------------------------------------------+
+ // | Number of channels |
+ // +----------------------------------------------------------+
+
+ cfg->nChannels = parameters_count(fileConfig, "sst.N_inactive");
+
+ return cfg;
+
+ }
+
+ msg_spectra_cfg * parameters_msg_spectra_pfs_config(const char * fileConfig) {
+
+ msg_spectra_cfg * cfg;
+
+ unsigned int halfFrameSize;
+ unsigned int nChannels;
+ unsigned int fS;
+
+ cfg = msg_spectra_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu");
+
+ // +----------------------------------------------------------+
+ // | Hop size |
+ // +----------------------------------------------------------+
+
+ cfg->halfFrameSize = parameters_lookup_int(fileConfig, "general.size.frameSize") / 2 + 1;
+
+ // +----------------------------------------------------------+
+ // | Number of channels |
+ // +----------------------------------------------------------+
+
+ cfg->nChannels = parameters_count(fileConfig, "sst.N_inactive");
+
+ return cfg;
+
+ }
+
+ mod_istft_cfg * parameters_mod_istft_seps_config(const char * fileConfig) {
+
+ mod_istft_cfg * cfg;
+
+ cfg = mod_istft_cfg_construct();
+
+ return cfg;
+
+ }
+
+ mod_istft_cfg * parameters_mod_istft_pfs_config(const char * fileConfig) {
+
+ mod_istft_cfg * cfg;
+
+ cfg = mod_istft_cfg_construct();
+
+ return cfg;
+
+ }
+
+ msg_hops_cfg * parameters_msg_hops_seps_config(const char * fileConfig) {
+
+ msg_hops_cfg * cfg;
+
+ cfg = msg_hops_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu");
+
+ // +----------------------------------------------------------+
+ // | Hop size |
+ // +----------------------------------------------------------+
+
+ cfg->hopSize = parameters_lookup_int(fileConfig, "general.size.hopSize");
+
+ // +----------------------------------------------------------+
+ // | Number of channels |
+ // +----------------------------------------------------------+
+
+ cfg->nChannels = parameters_count(fileConfig, "sst.N_inactive");
+
+ return cfg;
+
+ }
+
+ msg_hops_cfg * parameters_msg_hops_pfs_config(const char * fileConfig) {
+
+ msg_hops_cfg * cfg;
+
+ cfg = msg_hops_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu");
+
+ // +----------------------------------------------------------+
+ // | Hop size |
+ // +----------------------------------------------------------+
+
+ cfg->hopSize = parameters_lookup_int(fileConfig, "general.size.hopSize");
+
+ // +----------------------------------------------------------+
+ // | Number of channels |
+ // +----------------------------------------------------------+
+
+ cfg->nChannels = parameters_count(fileConfig, "sst.N_inactive");
+
+ return cfg;
+
+ }
+
+ mod_resample_cfg * parameters_mod_resample_seps_config(const char * fileConfig) {
+
+ mod_resample_cfg * cfg;
+
+ unsigned int tmpInt1;
+ unsigned int tmpInt2;
+
+ cfg = mod_resample_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rates |
+ // +----------------------------------------------------------+
+
+ tmpInt1 = parameters_lookup_int(fileConfig, "general.samplerate.mu");
+ tmpInt2 = parameters_lookup_int(fileConfig, "sss.separated.fS");
+
+ cfg->fSin = tmpInt1;
+ cfg->fSout = tmpInt2;
+
+ return cfg;
+
+ }
+
+ mod_resample_cfg * parameters_mod_resample_pfs_config(const char * fileConfig) {
+
+ mod_resample_cfg * cfg;
+
+ unsigned int tmpInt1;
+ unsigned int tmpInt2;
+
+ cfg = mod_resample_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rates |
+ // +----------------------------------------------------------+
+
+ tmpInt1 = parameters_lookup_int(fileConfig, "general.samplerate.mu");
+ tmpInt2 = parameters_lookup_int(fileConfig, "sss.postfiltered.fS");
+
+ cfg->fSin = tmpInt1;
+ cfg->fSout = tmpInt2;
+
+ return cfg;
+
+ }
+
+ msg_hops_cfg * parameters_msg_hops_seps_rs_config(const char * fileConfig) {
+
+ msg_hops_cfg * cfg;
+
+ cfg = msg_hops_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "sss.separated.fS");
+
+ // +----------------------------------------------------------+
+ // | Hop size |
+ // +----------------------------------------------------------+
+
+ cfg->hopSize = parameters_lookup_int(fileConfig, "sss.separated.hopSize");
+
+ // +----------------------------------------------------------+
+ // | Number of channels |
+ // +----------------------------------------------------------+
+
+ cfg->nChannels = parameters_count(fileConfig, "sst.N_inactive");
+
+ return cfg;
+
+ }
+
+ msg_hops_cfg * parameters_msg_hops_pfs_rs_config(const char * fileConfig) {
+
+ msg_hops_cfg * cfg;
+
+ cfg = msg_hops_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "sss.postfiltered.fS");
+
+ // +----------------------------------------------------------+
+ // | Hop size |
+ // +----------------------------------------------------------+
+
+ cfg->hopSize = parameters_lookup_int(fileConfig, "sss.postfiltered.hopSize");
+
+ // +----------------------------------------------------------+
+ // | Number of channels |
+ // +----------------------------------------------------------+
+
+ cfg->nChannels = parameters_count(fileConfig, "sst.N_inactive");
+
+ return cfg;
+
+ }
+
+ snk_hops_cfg * parameters_snk_hops_seps_rs_config(const char * fileConfig) {
+
+ snk_hops_cfg * cfg;
+ unsigned int tmpInt1;
+ char * tmpStr1;
+ char * tmpStr2;
+
+ cfg = snk_hops_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "sss.separated.fS");
+
+
+ // +----------------------------------------------------------+
+ // | Format |
+ // +----------------------------------------------------------+
+
+ tmpInt1 = parameters_lookup_int(fileConfig, "raw.nBits");
+
+ if ((tmpInt1 == 8) || (tmpInt1 == 16) || (tmpInt1 == 24) || (tmpInt1 == 32)) {
+ cfg->format = format_construct_binary_int(tmpInt1);
+ }
+ else {
+ printf("raw.nBits: Invalid number of bits\n");
+ exit(EXIT_FAILURE);
+ }
+
+ // +----------------------------------------------------------+
+ // | Type |
+ // +----------------------------------------------------------+
+
+ tmpStr1 = parameters_lookup_string(fileConfig, "sss.separated.interface.type");
+
+ if (strcmp(tmpStr1, "blackhole") == 0) {
+
+ cfg->interface = interface_construct_blackhole();
+
+ }
+ else if (strcmp(tmpStr1, "file") == 0) {
+
+ tmpStr2 = parameters_lookup_string(fileConfig, "sss.separated.interface.path");
+ cfg->interface = interface_construct_file(tmpStr2);
+ free((void *) tmpStr2);
+
+ }
+ else if (strcmp(tmpStr1, "socket") == 0) {
+
+ tmpStr2 = parameters_lookup_string(fileConfig, "sss.separated.interface.ip");
+ tmpInt1 = parameters_lookup_int(fileConfig, "sss.separated.interface.port");
+
+ cfg->interface = interface_construct_socket(tmpStr2, tmpInt1);
+ free((void *) tmpStr2);
+
+ }
+ else if (strcmp(tmpStr1, "terminal") == 0) {
+
+ cfg->interface = interface_construct_terminal();
+
+ }
+ else {
+
+ printf("sss.separated.interface.type: Invalid type\n");
+ exit(EXIT_FAILURE);
+
+ }
+
+ free((void *) tmpStr1);
+
+ return cfg;
+
+ }
+
+ snk_hops_cfg * parameters_snk_hops_pfs_rs_config(const char * fileConfig) {
+
+ snk_hops_cfg * cfg;
+ unsigned int tmpInt1;
+ char * tmpStr1;
+ char * tmpStr2;
+
+ cfg = snk_hops_cfg_construct();
+
+ // +----------------------------------------------------------+
+ // | Sample rate |
+ // +----------------------------------------------------------+
+
+ cfg->fS = parameters_lookup_int(fileConfig, "sss.postfiltered.fS");
+
+
+ // +----------------------------------------------------------+
+ // | Format |
+ // +----------------------------------------------------------+
+
+ tmpInt1 = parameters_lookup_int(fileConfig, "raw.nBits");
+
+ if ((tmpInt1 == 8) || (tmpInt1 == 16) || (tmpInt1 == 24) || (tmpInt1 == 32)) {
+ cfg->format = format_construct_binary_int(tmpInt1);
+ }
+ else {
+ printf("raw.nBits: Invalid number of bits\n");
+ exit(EXIT_FAILURE);
+ }
+
+ // +----------------------------------------------------------+
+ // | Type |
+ // +----------------------------------------------------------+
+
+ tmpStr1 = parameters_lookup_string(fileConfig, "sss.postfiltered.interface.type");
+
+ if (strcmp(tmpStr1, "blackhole") == 0) {
+
+ cfg->interface = interface_construct_blackhole();
+
+ }
+ else if (strcmp(tmpStr1, "file") == 0) {
+
+ tmpStr2 = parameters_lookup_string(fileConfig, "sss.postfiltered.interface.path");
+ cfg->interface = interface_construct_file(tmpStr2);
+ free((void *) tmpStr2);
+
+ }
+ else if (strcmp(tmpStr1, "socket") == 0) {
+
+ tmpStr2 = parameters_lookup_string(fileConfig, "sss.postfiltered.interface.ip");
+ tmpInt1 = parameters_lookup_int(fileConfig, "sss.postfiltered.interface.port");
+
+ cfg->interface = interface_construct_socket(tmpStr2, tmpInt1);
+ free((void *) tmpStr2);
+
+ }
+ else if (strcmp(tmpStr1, "terminal") == 0) {
+
+ cfg->interface = interface_construct_terminal();
+
+ }
+ else {
+
+ printf("sss.postfiltered.interface.type: Invalid type\n");
+ exit(EXIT_FAILURE);
+
+ }
+
+ free((void *) tmpStr1);
+
+ return cfg;
+
+ }
snk_tracks_cfg * parameters_snk_tracks_sst_config(const char * fileConfig);
+
+ mod_sss_cfg * parameters_mod_sss_config(const char * fileConfig);
+
+ msg_spectra_cfg * parameters_msg_spectra_seps_config(const char * fileConfig);
+
+ msg_spectra_cfg * parameters_msg_spectra_pfs_config(const char * fileConfig);
+
+
+ mod_istft_cfg * parameters_mod_istft_seps_config(const char * fileConfig);
+
+ mod_istft_cfg * parameters_mod_istft_pfs_config(const char * fileConfig);
+
+ msg_hops_cfg * parameters_msg_hops_seps_config(const char * fileConfig);
+
+ msg_hops_cfg * parameters_msg_hops_pfs_config(const char * fileConfig);
+
+
+ mod_resample_cfg * parameters_mod_resample_seps_config(const char * fileConfig);
+
+ mod_resample_cfg * parameters_mod_resample_pfs_config(const char * fileConfig);
+
+ msg_hops_cfg * parameters_msg_hops_seps_rs_config(const char * fileConfig);
+
+ msg_hops_cfg * parameters_msg_hops_pfs_rs_config(const char * fileConfig);
+
+ snk_hops_cfg * parameters_snk_hops_seps_rs_config(const char * fileConfig);
+
+ snk_hops_cfg * parameters_snk_hops_pfs_rs_config(const char * fileConfig);
+
+
#endif
\ No newline at end of file
prf->con_tracks_sst_prf = 0.0f;
prf->snk_tracks_sst_prf = 0.0f;
+ prf->mod_sss_prf = 0.0f;
+ prf->con_spectra_seps_prf = 0.0f;
+ prf->con_spectra_pfs_prf = 0.0f;
+
+ prf->mod_istft_seps_prf = 0.0f;;
+ prf->mod_istft_pfs_prf = 0.0f;;
+ prf->con_hops_seps_prf = 0.0f;
+ prf->con_hops_pfs_prf = 0.0f;
+
+ prf->mod_resample_seps_prf = 0.0f;
+ prf->mod_resample_pfs_prf = 0.0f;
+ prf->con_hops_seps_rs_prf = 0.0f;
+ prf->con_hops_pfs_rs_prf = 0.0f;
+ prf->snk_hops_seps_rs_prf = 0.0f;
+ prf->snk_hops_pfs_rs_prf = 0.0f;
+
return prf;
}
source = prf->src_hops_mics_prf;
sink = prf->snk_pots_ssl_prf +
- prf->snk_tracks_sst_prf;
+ prf->snk_tracks_sst_prf +
+ prf->snk_hops_seps_rs_prf +
+ prf->snk_hops_pfs_rs_prf;
module = prf->mod_mapping_mics_prf +
prf->mod_resample_mics_prf +
prf->mod_stft_mics_prf +
prf->mod_ssl_prf +
- prf->mod_sst_prf;
+ prf->mod_sst_prf +
+ prf->mod_sss_prf +
+ prf->mod_istft_seps_prf +
+ prf->mod_istft_pfs_prf +
+ prf->mod_resample_seps_prf +
+ prf->mod_resample_pfs_prf;
connector = prf->con_hops_mics_raw_prf +
prf->con_hops_mics_map_prf +
prf->con_hops_mics_rs_prf +
prf->con_spectra_mics_prf +
prf->con_pots_ssl_prf +
- prf->con_tracks_sst_prf;
+ prf->con_tracks_sst_prf +
+ prf->con_spectra_seps_prf +
+ prf->con_spectra_pfs_prf +
+ prf->con_hops_seps_prf +
+ prf->con_hops_pfs_prf +
+ prf->con_hops_seps_rs_prf +
+ prf->con_hops_pfs_rs_prf;
total = source + sink + module + connector;
printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_hops_mics_map_prf,roundf(10000.0f * prf->con_hops_mics_map_prf / prf->duration) / 100.0f);
printf("| + Resample |\n");
printf("| - Module.......... %07.3f (%06.2f%%) |\n",prf->mod_resample_mics_prf,roundf(10000.0f * prf->mod_resample_mics_prf / prf->duration) / 100.0f);
- printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_hops_mics_rs_prf,roundf(10000.0f * prf->con_hops_mics_rs_prf / prf->duration));
+ printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_hops_mics_rs_prf,roundf(10000.0f * prf->con_hops_mics_rs_prf / prf->duration) / 100.0f);
printf("| + STFT |\n");
printf("| - Module.......... %07.3f (%06.2f%%) |\n",prf->mod_stft_mics_prf,roundf(10000.0f * prf->mod_stft_mics_prf / prf->duration) / 100.0f);
printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_spectra_mics_prf,roundf(10000.0f * prf->con_spectra_mics_prf / prf->duration) / 100.0f);
printf("| + SST |\n");
printf("| - Module.......... %07.3f (%06.2f%%) |\n",prf->mod_sst_prf,roundf(10000.0f * prf->mod_sst_prf / prf->duration) / 100.0f);
printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_tracks_sst_prf,roundf(10000.0f * prf->con_tracks_sst_prf / prf->duration) / 100.0f);
- printf("| - Sink............ %07.3f (%06.2f%%) |\n",prf->snk_tracks_sst_prf,roundf(10000.0f * prf->snk_tracks_sst_prf / prf->duration) / 100.0f);
+ printf("| - Sink............ %07.3f (%06.2f%%) |\n",prf->snk_tracks_sst_prf,roundf(10000.0f * prf->snk_tracks_sst_prf / prf->duration) / 100.0f);
+ printf("| + SSS |\n");
+ printf("| - Module.......... %07.3f (%06.2f%%) |\n",prf->mod_sss_prf,roundf(10000.0f * prf->mod_sss_prf / prf->duration) / 100.0f);
+ printf("| - Connector....... %07.3f (%06.2f%%) |\n",(prf->con_spectra_seps_prf+prf->con_spectra_pfs_prf),roundf(10000.0f * (prf->con_spectra_seps_prf+prf->con_spectra_pfs_prf) / 100.0f));
+ printf("| + ISTFT |\n");
+ printf("| - Module.......... %07.3f (%06.2f%%) |\n",(prf->mod_istft_seps_prf+prf->mod_istft_pfs_prf),roundf(10000.0f * (prf->mod_istft_seps_prf+prf->mod_istft_pfs_prf) / prf->duration) / 100.0f);
+ printf("| - Connector....... %07.3f (%06.2f%%) |\n",(prf->con_hops_seps_prf+prf->con_hops_pfs_prf),roundf(10000.0f * (prf->con_hops_seps_prf+prf->con_hops_pfs_prf) / prf->duration) / 100.0f);
+ printf("| + Resample |\n");
+ printf("| - Module.......... %07.3f (%06.2f%%) |\n",(prf->mod_resample_seps_prf+prf->mod_resample_pfs_prf),roundf(10000.0f * (prf->mod_resample_seps_prf+prf->mod_resample_pfs_prf) / prf->duration) / 100.0f);
+ printf("| - Connector....... %07.3f (%06.2f%%) |\n",(prf->con_hops_seps_rs_prf+prf->con_hops_pfs_rs_prf),roundf(10000.0f * (prf->con_hops_seps_rs_prf+prf->con_hops_pfs_rs_prf) / prf->duration) / 100.0f);
+ printf("| - Sink............ %07.3f (%06.2f%%) |\n",(prf->snk_hops_seps_rs_prf+prf->snk_hops_pfs_rs_prf),roundf(10000.0f * (prf->snk_hops_seps_rs_prf+prf->snk_hops_pfs_rs_prf) / prf->duration) / 100.0f);
printf("+--------------------------------------------+\n");
printf("| + TOTAL.............. %07.3f (%06.2f%%) |\n",total,roundf(10000.0f * total / prf->duration) / 100.0f);
printf("| - Module.......... %07.3f (%06.2f%%) |\n",module,roundf(10000.0f * module / prf->duration) / 100.0f);
float con_tracks_sst_prf;
float snk_tracks_sst_prf;
+ float mod_sss_prf;
+ float con_spectra_seps_prf;
+ float con_spectra_pfs_prf;
+
+ float mod_istft_seps_prf;
+ float mod_istft_pfs_prf;
+ float con_hops_seps_prf;
+ float con_hops_pfs_prf;
+
+ float mod_resample_seps_prf;
+ float mod_resample_pfs_prf;
+ float con_hops_seps_rs_prf;
+ float con_hops_pfs_rs_prf;
+ float snk_hops_seps_rs_prf;
+ float snk_hops_pfs_rs_prf;
+
} profiler;
profiler * profiler_construct(void);
thread_start(aobjs->acon_tracks_sst_object->thread);
+ // +----------------------------------------------------------+
+ // | SSS |
+ // +----------------------------------------------------------+
+
+ // +------------------------------------------------------+
+ // | Module |
+ // +------------------------------------------------------+
+
+ thread_start(aobjs->amod_sss_object->thread);
+
+ // +------------------------------------------------------+
+ // | Connector |
+ // +------------------------------------------------------+
+
+ thread_start(aobjs->acon_spectra_seps_object->thread);
+ thread_start(aobjs->acon_spectra_pfs_object->thread);
+
+ // +----------------------------------------------------------+
+ // | ISTFT |
+ // +----------------------------------------------------------+
+
+ // +------------------------------------------------------+
+ // | Module |
+ // +------------------------------------------------------+
+
+ thread_start(aobjs->amod_istft_seps_object->thread);
+ thread_start(aobjs->amod_istft_pfs_object->thread);
+
+ // +------------------------------------------------------+
+ // | Connector |
+ // +------------------------------------------------------+
+
+ thread_start(aobjs->acon_hops_seps_object->thread);
+ thread_start(aobjs->acon_hops_pfs_object->thread);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ thread_start(aobjs->amod_resample_seps_object->thread);
+ thread_start(aobjs->amod_resample_pfs_object->thread);
+
+ // +--------------------------------------------------+
+ // | Sinks |
+ // +--------------------------------------------------+
+
+ thread_start(aobjs->asnk_hops_seps_rs_object->thread);
+ thread_start(aobjs->asnk_hops_pfs_rs_object->thread);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ thread_start(aobjs->acon_hops_seps_rs_object->thread);
+ thread_start(aobjs->acon_hops_pfs_rs_object->thread);
+
}
void threads_multiple_stop(aobjects * aobjs) {
thread_join(aobjs->acon_tracks_sst_object->thread);
+ // +----------------------------------------------------------+
+ // | SSS |
+ // +----------------------------------------------------------+
+
+ // +------------------------------------------------------+
+ // | Module |
+ // +------------------------------------------------------+
+
+ thread_join(aobjs->amod_sss_object->thread);
+
+ // +------------------------------------------------------+
+ // | Connector |
+ // +------------------------------------------------------+
+
+ thread_join(aobjs->acon_spectra_seps_object->thread);
+ thread_join(aobjs->acon_spectra_pfs_object->thread);
+
+ // +----------------------------------------------------------+
+ // | ISTFT |
+ // +----------------------------------------------------------+
+
+ // +------------------------------------------------------+
+ // | Module |
+ // +------------------------------------------------------+
+
+ thread_join(aobjs->amod_istft_seps_object->thread);
+ thread_join(aobjs->amod_istft_pfs_object->thread);
+
+ // +------------------------------------------------------+
+ // | Connector |
+ // +------------------------------------------------------+
+
+ thread_join(aobjs->acon_hops_seps_object->thread);
+ thread_join(aobjs->acon_hops_pfs_object->thread);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ thread_join(aobjs->amod_resample_seps_object->thread);
+ thread_join(aobjs->amod_resample_pfs_object->thread);
+
+ // +--------------------------------------------------+
+ // | Sinks |
+ // +--------------------------------------------------+
+
+ thread_join(aobjs->asnk_hops_seps_rs_object->thread);
+ thread_join(aobjs->asnk_hops_pfs_rs_object->thread);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ thread_join(aobjs->acon_hops_seps_rs_object->thread);
+ thread_join(aobjs->acon_hops_pfs_rs_object->thread);
+
}
void threads_single_open(objects * objs) {
snk_tracks_open(objs->snk_tracks_sst_object);
+ // +----------------------------------------------------------+
+ // | Resample |
+ // +----------------------------------------------------------+
+
+ // +------------------------------------------------------+
+ // | Sinks |
+ // +------------------------------------------------------+
+
+ snk_hops_open(objs->snk_hops_seps_rs_object);
+ snk_hops_open(objs->snk_hops_pfs_rs_object);
+
}
void threads_single_close(objects * objs) {
snk_tracks_close(objs->snk_tracks_sst_object);
+ // +----------------------------------------------------------+
+ // | Resample |
+ // +----------------------------------------------------------+
+
+ // +------------------------------------------------------+
+ // | Sinks |
+ // +------------------------------------------------------+
+
+ snk_hops_close(objs->snk_hops_seps_rs_object);
+ snk_hops_close(objs->snk_hops_pfs_rs_object);
+
}
int threads_single_process(objects * objs, profiler * prf) {
end = clock();
prf->snk_tracks_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+ // +------------------------------------------------------+
+ // | SSS |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ begin = clock();
+ mod_sss_process(objs->mod_sss_object);
+ end = clock();
+ prf->mod_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ begin = clock();
+ con_spectra_process(objs->con_spectra_seps_object);
+ end = clock();
+ prf->con_spectra_seps_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ begin = clock();
+ con_spectra_process(objs->con_spectra_pfs_object);
+ end = clock();
+ prf->con_spectra_pfs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // +------------------------------------------------------+
+ // | ISTFT |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ begin = clock();
+ mod_istft_process(objs->mod_istft_seps_object);
+ end = clock();
+ prf->mod_istft_seps_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ begin = clock();
+ mod_istft_process(objs->mod_istft_pfs_object);
+ end = clock();
+ prf->mod_istft_pfs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // +--------------------------------------------------+
+ // | Connector |
+ // +--------------------------------------------------+
+
+ begin = clock();
+ con_hops_process(objs->con_hops_seps_object);
+ end = clock();
+ prf->con_hops_seps_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ begin = clock();
+ con_hops_process(objs->con_hops_pfs_object);
+ end = clock();
+ prf->con_hops_pfs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // +------------------------------------------------------+
+ // | Resample |
+ // +------------------------------------------------------+
+
+ // +--------------------------------------------------+
+ // | Module |
+ // +--------------------------------------------------+
+
+ begin = clock();
+ mod_resample_process_push(objs->mod_resample_seps_object);
+ end = clock();
+ prf->mod_resample_seps_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ begin = clock();
+ mod_resample_process_push(objs->mod_resample_pfs_object);
+ end = clock();
+ prf->mod_resample_pfs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // +------------------------------------------------------+
+ // | SECTION III |
+ // +------------------------------------------------------+
+
+ while(1) {
+
+ // +----------------------------------------------+
+ // | Module |
+ // +----------------------------------------------+
+
+ begin = clock();
+ rtnResample = mod_resample_process_pop(objs->mod_resample_seps_object);
+ end = clock();
+ prf->mod_resample_seps_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // If there is no frames to process, stop
+ if (rtnResample == -1) {
+ break;
+ }
+
+ // +----------------------------------------------+
+ // | Connector |
+ // +----------------------------------------------+
+
+ begin = clock();
+ con_hops_process(objs->con_hops_seps_rs_object);
+ end = clock();
+ prf->con_hops_seps_rs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // +----------------------------------------------+
+ // | Sink |
+ // +----------------------------------------------+
+
+ begin = clock();
+ snk_hops_process(objs->snk_hops_seps_rs_object);
+ end = clock();
+ prf->snk_hops_seps_rs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ }
+
+
+ while(1) {
+
+ // +----------------------------------------------+
+ // | Module |
+ // +----------------------------------------------+
+
+ begin = clock();
+ rtnResample = mod_resample_process_pop(objs->mod_resample_pfs_object);
+ end = clock();
+ prf->mod_resample_pfs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // If there is no frames to process, stop
+ if (rtnResample == -1) {
+ break;
+ }
+
+ // +----------------------------------------------+
+ // | Connector |
+ // +----------------------------------------------+
+
+ begin = clock();
+ con_hops_process(objs->con_hops_pfs_rs_object);
+ end = clock();
+ prf->con_hops_pfs_rs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ // +----------------------------------------------+
+ // | Sink |
+ // +----------------------------------------------+
+
+ begin = clock();
+ snk_hops_process(objs->snk_hops_pfs_rs_object);
+ end = clock();
+ prf->snk_hops_pfs_rs_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+ }
+
}
return rtnValue;
#include "../../src/module/mod_resample.h"
#include "../../src/module/mod_ssl.h"
#include "../../src/module/mod_sst.h"
+ #include "../../src/module/mod_sss.h"
#include "../../src/module/mod_stft.h"
#include "../../src/sink/snk_hops.h"
#include "../../src/sink/snk_pots.h"
#include "../../src/amodule/amod_resample.h"
#include "../../src/amodule/amod_ssl.h"
#include "../../src/amodule/amod_sst.h"
+ #include "../../src/amodule/amod_sss.h"
#include "../../src/amodule/amod_stft.h"
#include "../../src/asink/asnk_hops.h"
#include "../../src/asink/asnk_pots.h"
obj->nSeps = msg_tracks_config->nTracks;
obj->nChannels = msg_spectra_config->nChannels;
obj->halfFrameSize = msg_spectra_config->halfFrameSize;
+ obj->mode_sep = mod_sss_config->mode_sep;
+ obj->mode_pf = mod_sss_config->mode_pf;
+
+ obj->beampatterns_mics = directivity_beampattern_mics(mod_sss_config->mics,
+ mod_sss_config->nThetas);
+
+ obj->beampatterns_spatialfilter = directivity_beampattern_spatialfilter(mod_sss_config->spatialfilter,
+ mod_sss_config->nThetas);
+
+ obj->steers = steers_construct_zero(msg_spectra_config->halfFrameSize,
+ msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels);
+
+ obj->gains = gains_construct_zero(msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels);
+
+ obj->masks = masks_construct_zero(msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels);
+
+ obj->track2gain = track2gain_construct_zero(msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels,
+ mod_sss_config->mics->direction,
+ mod_sss_config->spatialfilter->direction);
+
+ obj->gain2mask = gain2mask_construct_zero(msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels,
+ mod_sss_config->gainMin);
+
+ obj->track2steer = track2steer_construct_zero(msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels,
+ msg_spectra_config->halfFrameSize,
+ mod_sss_config->soundspeed->mu,
+ mod_sss_config->samplerate->mu,
+ mod_sss_config->mics->mu);
switch(obj->mode_sep) {
case 'd':
+ obj->steer2demixing_ds = steer2demixing_ds_construct_zero(msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels,
+ msg_spectra_config->halfFrameSize,
+ mod_sss_config->epsilon);
+ obj->steer2demixing_gss = (steer2demixing_gss_obj *) NULL;
+ obj->steer2demixing_mvdr = (steer2demixing_mvdr_obj *) NULL;
+
+ break;
+
break;
case 'g':
+ printf("GSS not implemented yet.\n");
+ exit(EXIT_FAILURE);
+
break;
case 'm':
+ printf("MVDR not implemented yet.\n");
+ exit(EXIT_FAILURE);
+
break;
default:
case 'm':
+ //printf("Multiple source post-filtering.\n");
+ //exit(EXIT_FAILURE);
+
break;
default:
}
+ obj->demixingsPrev = demixings_construct_zero(msg_spectra_config->halfFrameSize,
+ msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels);
+
+ obj->demixingsNow = demixings_construct_zero(msg_spectra_config->halfFrameSize,
+ msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels);
+
+ obj->demixing2freq = demixing2freq_construct_zero(msg_tracks_config->nTracks,
+ msg_spectra_config->nChannels,
+ msg_spectra_config->halfFrameSize);
return obj;
int mod_sss_process(mod_sss_obj * obj) {
+ int rtnValue1;
+ int rtnValue2;
int rtnValue;
+ switch(obj->mode_sep) {
+
+ case 'd':
+
+ rtnValue1 = mod_sss_process_dds(obj);
+
+ break;
+
+ case 'g':
+
+ rtnValue1 = mod_sss_process_dgss(obj);
+
+ break;
+
+ case 'm':
+
+ rtnValue1 = mod_sss_process_dmvdr(obj);
+
+ break;
+
+ default:
+
+ printf("Invalid separation method.\n");
+ exit(EXIT_FAILURE);
+
+ break;
+
+ }
+
+ switch(obj->mode_pf) {
+
+ case 'm':
+
+ rtnValue2 = mod_sss_process_mspf(obj);
+
+ break;
+
+ default:
+
+ printf("Invalid post-filtering method.\n");
+ exit(EXIT_FAILURE);
+
+ break;
+
+ }
+
+ if (rtnValue1 != rtnValue2) {
+ printf("Return value mismatch.\n");
+ exit(EXIT_FAILURE);
+ }
+ else {
+ rtnValue = rtnValue1;
+ }
return rtnValue;
int mod_sss_process_dds(mod_sss_obj * obj) {
+ int rtnValue;
+
+ if (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in2)) {
+
+ printf("Time stamp mismatch.\n");
+ exit(EXIT_FAILURE);
+
+ }
+
+ if (msg_spectra_isZero(obj->in1) == 0) {
+
+ track2gain_process(obj->track2gain,
+ obj->beampatterns_mics,
+ obj->beampatterns_spatialfilter,
+ obj->in2->tracks,
+ obj->gains);
+
+ gain2mask_process(obj->gain2mask,
+ obj->gains,
+ obj->masks);
+
+ track2steer_process(obj->track2steer,
+ obj->in2->tracks,
+ obj->gains,
+ obj->masks,
+ obj->steers);
+
+ demixings_copy(obj->demixingsPrev,
+ obj->demixingsNow);
+
+ steer2demixing_ds_process(obj->steer2demixing_ds,
+ obj->in2->tracks,
+ obj->steers,
+ obj->masks,
+ obj->demixingsNow);
+
+ demixing2freq_process(obj->demixing2freq,
+ obj->in2->tracks,
+ obj->demixingsNow,
+ obj->masks,
+ obj->in1->freqs,
+ obj->out1->freqs);
+
+ msg_spectra_zero(obj->out2);
+
+ obj->out1->timeStamp = obj->in1->timeStamp;
+ obj->out2->timeStamp = obj->in1->timeStamp;
+
+ rtnValue = 0;
+
+ }
+ else {
+
+ msg_spectra_zero(obj->out1);
+ msg_spectra_zero(obj->out2);
+
+ rtnValue = -1;
+
+ }
+
+ return rtnValue;
+
}
int mod_sss_process_dgss(mod_sss_obj * obj) {
+ int rtnValue;
+
+ if (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in2)) {
+
+ printf("Time stamp mismatch.\n");
+ exit(EXIT_FAILURE);
+
+ }
+
+ if (msg_spectra_isZero(obj->in1) == 0) {
+
+ track2gain_process(obj->track2gain,
+ obj->beampatterns_mics,
+ obj->beampatterns_spatialfilter,
+ obj->in2->tracks,
+ obj->gains);
+
+ gain2mask_process(obj->gain2mask,
+ obj->gains,
+ obj->masks);
+
+ track2steer_process(obj->track2steer,
+ obj->in2->tracks,
+ obj->gains,
+ obj->masks,
+ obj->steers);
+
+ demixings_copy(obj->demixingsPrev,
+ obj->demixingsNow);
+
+ demixing2freq_process(obj->demixing2freq,
+ obj->in2->tracks,
+ obj->demixingsNow,
+ obj->masks,
+ obj->in1->freqs,
+ obj->out1->freqs);
+
+ }
+ else {
+
+ msg_spectra_zero(obj->out1);
+ msg_spectra_zero(obj->out2);
+
+ rtnValue = -1;
+
+ }
+
+ return rtnValue;
+
}
int mod_sss_process_dmvdr(mod_sss_obj * obj) {
+ int rtnValue;
+
+ if (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in2)) {
+
+ printf("Time stamp mismatch.\n");
+ exit(EXIT_FAILURE);
+
+ }
+
+ if (msg_spectra_isZero(obj->in1) == 0) {
+
+ track2gain_process(obj->track2gain,
+ obj->beampatterns_mics,
+ obj->beampatterns_spatialfilter,
+ obj->in2->tracks,
+ obj->gains);
+
+ gain2mask_process(obj->gain2mask,
+ obj->gains,
+ obj->masks);
+
+ track2steer_process(obj->track2steer,
+ obj->in2->tracks,
+ obj->gains,
+ obj->masks,
+ obj->steers);
+
+ }
+ else {
+
+ msg_spectra_zero(obj->out1);
+ msg_spectra_zero(obj->out2);
+
+ rtnValue = -1;
+
+ }
+
+ return rtnValue;
+
+ }
+
+ int mod_sss_process_mspf(mod_sss_obj * obj) {
+
+ // Empty
+
}
void mod_sss_connect(mod_sss_obj * obj, msg_spectra_obj * in1, msg_tracks_obj * in2, msg_spectra_obj * out1, msg_spectra_obj * out2) {
+ obj->in1 = in1;
+ obj->in2 = in2;
+ obj->out1 = out1;
+ obj->out2 = out2;
+
}
void mod_sss_disconnect(mod_sss_obj * obj) {
+ obj->in1 = (msg_spectra_obj *) NULL;
+ obj->in2 = (msg_tracks_obj *) NULL;
+ obj->out1 = (msg_spectra_obj *) NULL;
+ obj->out2 = (msg_spectra_obj *) NULL;
+
}
mod_sss_cfg * mod_sss_cfg_construct(void) {
+ mod_sss_cfg * cfg;
+
+ cfg = (mod_sss_cfg *) malloc(sizeof(mod_sss_cfg));
+
+ cfg->mode_sep = 0x00;
+ cfg->mode_pf = 0x00;
+
+ cfg->nThetas = 0;
+ cfg->gainMin = 0.0f;
+
+ cfg->mics = (mics_obj *) NULL;
+ cfg->samplerate = (samplerate_obj *) NULL;
+ cfg->soundspeed = (soundspeed_obj *) NULL;
+ cfg->spatialfilter = (spatialfilter_obj *) NULL;
+
+ return cfg;
+
}
void mod_sss_cfg_destroy(mod_sss_cfg * cfg) {
+ if (cfg->mics != NULL) {
+ mics_destroy(cfg->mics);
+ }
+
+ if (cfg->samplerate != NULL) {
+ samplerate_destroy(cfg->samplerate);
+ }
+
+ if (cfg->soundspeed != NULL) {
+ soundspeed_destroy(cfg->soundspeed);
+ }
+
+ if (cfg->spatialfilter != NULL) {
+ spatialfilter_destroy(cfg->spatialfilter);
+ }
+
+ free((void *) cfg);
+
}
void mod_sss_cfg_printf(const mod_sss_cfg * cfg) {
+ // Empty
+
}
\ No newline at end of file
#include "../general/soundspeed.h"
#include "../general/spatialfilter.h"
+ #include "../init/directivity.h"
+
#include "../message/msg_spectra.h"
#include "../message/msg_tracks.h"
+ #include "../signal/beampattern.h"
+ #include "../signal/steer.h"
+ #include "../signal/gain.h"
+ #include "../signal/demixing.h"
+
+ #include "../system/demixing2freq.h"
+ #include "../system/gain2mask.h"
#include "../system/track2steer.h"
+ #include "../system/track2gain.h"
+ #include "../system/steer2demixing.h"
#include <stdlib.h>
#include <string.h>
char mode_sep;
char mode_pf;
- track2steer_obj * dds_track2steer;
+ beampatterns_obj * beampatterns_mics;
+ beampatterns_obj * beampatterns_spatialfilter;
+ steers_obj * steers;
+ gains_obj * gains;
+ masks_obj * masks;
+
+ track2gain_obj * track2gain;
+ gain2mask_obj * gain2mask;
+ track2steer_obj * track2steer;
+
+ steer2demixing_ds_obj * steer2demixing_ds;
+ steer2demixing_gss_obj * steer2demixing_gss;
+ steer2demixing_mvdr_obj * steer2demixing_mvdr;
+
+ demixings_obj * demixingsPrev;
+ demixings_obj * demixingsNow;
+
+ demixing2freq_obj * demixing2freq;
+
+ msg_spectra_obj * in1;
+ msg_tracks_obj * in2;
+ msg_spectra_obj * out1;
+ msg_spectra_obj * out2;
} mod_sss_obj;
char mode_sep;
char mode_pf;
+ unsigned int nThetas;
+ float gainMin;
+
+ float epsilon;
+
mics_obj * mics;
samplerate_obj * samplerate;
soundspeed_obj * soundspeed;
int mod_sss_process_dmvdr(mod_sss_obj * obj);
+ int mod_sss_process_mspf(mod_sss_obj * obj);
+
void mod_sss_connect(mod_sss_obj * obj, msg_spectra_obj * in1, msg_tracks_obj * in2, msg_spectra_obj * out1, msg_spectra_obj * out2);
void mod_sss_disconnect(mod_sss_obj * obj);
--- /dev/null
+
+ #include "demixing.h"
+
+ demixings_obj * demixings_construct_zero(const unsigned int halfFrameSize, const unsigned int nSeps, const unsigned int nChannels) {
+
+ demixings_obj * obj;
+ unsigned int iSep;
+
+ obj = (demixings_obj *) malloc(sizeof(demixings_obj));
+
+ obj->nSeps = nSeps;
+ obj->nChannels = nChannels;
+ obj->halfFrameSize = halfFrameSize;
+
+ obj->array = (float **) malloc(sizeof(float *) * obj->nSeps);
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ obj->array[iSep] = (float *) malloc(sizeof(float) * obj->halfFrameSize * obj->nChannels * 2);
+ memset(obj->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize * obj->nChannels * 2);
+
+ }
+
+ return obj;
+
+ }
+
+ void demixings_destroy(demixings_obj * obj) {
+
+ unsigned int iSep;
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ free((void *) obj->array[iSep]);
+
+ }
+
+ free((void *) obj->array);
+ free((void *) obj);
+
+ }
+
+ void demixings_copy(demixings_obj * dest, const demixings_obj * src) {
+
+ unsigned int iSep;
+
+ for (iSep = 0; iSep < src->nSeps; iSep++) {
+ memcpy(dest->array[iSep], src->array[iSep], src->halfFrameSize * src->nChannels * 2 * sizeof(float));
+ }
+
+ }
+
+ void demixings_printf(const demixings_obj * obj) {
+
+ unsigned int iBin;
+ unsigned int iSep;
+ unsigned int iChannel;
+
+ float real;
+ float imag;
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ printf("\nSource index: %u\n",iSep);
+
+ for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
+
+ printf("(%03u): ",iBin);
+
+ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+ real = obj->array[iSep][iBin * obj->nChannels * 2 + iChannel * 2 + 0];
+ imag = obj->array[iSep][iBin * obj->nChannels * 2 + iChannel * 2 + 1];
+
+ printf("(%+1.2f + %1.2fi) ", real, imag);
+
+ }
+
+ printf("\n");
+
+ }
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SIGNAL_DEMIXING
+#define __ODAS_SIGNAL_DEMIXING
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+
+ typedef struct demixings_obj {
+
+ unsigned int nSeps;
+ unsigned int nChannels;
+ unsigned int halfFrameSize;
+
+ float ** array;
+
+ } demixings_obj;
+
+ demixings_obj * demixings_construct_zero(const unsigned int halfFrameSize, const unsigned int nSeps, const unsigned int nChannels);
+
+ void demixings_destroy(demixings_obj * obj);
+
+ void demixings_copy(demixings_obj * dest, const demixings_obj * src);
+
+ void demixings_printf(const demixings_obj * obj);
+
+#endif
\ No newline at end of file
for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
- printf("%+1.3f ",obj->array[iChannel]);
+ printf("%+1.3f ",obj->array[iSep * obj->nChannels + iChannel]);
}
for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
- printf("%d ",obj->array[iChannel]);
+ printf("%d ",obj->array[iSep * obj->nChannels + iChannel]);
}
--- /dev/null
+
+ #include "demixing2freq.h"
+
+ demixing2freq_obj * demixing2freq_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize) {
+
+ demixing2freq_obj * obj;
+
+ obj = (demixing2freq_obj *) malloc(sizeof(demixing2freq_obj));
+
+ obj->nSeps = nSeps;
+ obj->nChannels = nChannels;
+ obj->halfFrameSize = halfFrameSize;
+
+ return obj;
+
+ }
+
+ void demixing2freq_destroy(demixing2freq_obj * obj) {
+
+ free((void *) obj);
+
+ }
+
+ void demixing2freq_process(demixing2freq_obj * obj, const tracks_obj * tracks, const demixings_obj * demixings, const masks_obj * masks, const freqs_obj * freqsChannel, freqs_obj * freqsSeparated) {
+
+ unsigned int iSep;
+ unsigned int iChannel;
+ unsigned int iBin;
+
+ unsigned int iSampleSC;
+ unsigned int iSampleBC;
+ unsigned int iSampleB;
+
+ float Xreal;
+ float Ximag;
+ float Wreal;
+ float Wimag;
+ float Yreal;
+ float Yimag;
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ if (tracks->ids[iSep] != 0) {
+
+ memset(freqsSeparated->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize * 2);
+
+ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+ iSampleSC = iSep * obj->nChannels + iChannel;
+
+ if (masks->array[iSampleSC] == 1) {
+
+ for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
+
+ iSampleBC = iBin * obj->nChannels + iChannel;
+ iSampleB = iBin;
+
+ Xreal = freqsChannel->array[iChannel][iSampleB * 2 + 0];
+ Ximag = freqsChannel->array[iChannel][iSampleB * 2 + 1];
+
+ Wreal = demixings->array[iSep][iSampleBC * 2 + 0];
+ Wimag = demixings->array[iSep][iSampleBC * 2 + 1];
+
+ Yreal = Wreal * Xreal - Wimag * Ximag;
+ Yimag = Wreal * Ximag + Wimag * Xreal;
+
+ freqsSeparated->array[iSep][iSampleB * 2 + 0] += Yreal;
+ freqsSeparated->array[iSep][iSampleB * 2 + 1] += Yimag;
+
+ }
+
+ }
+
+ }
+
+ }
+ else {
+
+ memset(freqsSeparated->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize * 2);
+
+ }
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SYSTEM_DEMIXING2FREQ
+#define __ODAS_SYSTEM_DEMIXING2FREQ
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+ #include <math.h>
+
+ #include "../signal/demixing.h"
+ #include "../signal/freq.h"
+ #include "../signal/mask.h"
+ #include "../signal/track.h"
+
+ typedef struct demixing2freq_obj {
+
+ unsigned int nSeps;
+ unsigned int nChannels;
+ unsigned int halfFrameSize;
+
+ } demixing2freq_obj;
+
+ demixing2freq_obj * demixing2freq_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize);
+
+ void demixing2freq_destroy(demixing2freq_obj * obj);
+
+ void demixing2freq_process(demixing2freq_obj * obj, const tracks_obj * tracks, const demixings_obj * demixings, const masks_obj * masks, const freqs_obj * freqsChannel, freqs_obj * freqsSeparated);
+
+#endif
\ No newline at end of file
obj->epsilon = epsilon;
obj->H = matrix_construct_zero(3,6);
- obj->H->array[0][0] = 1.0f;
- obj->H->array[1][1] = 1.0f;
- obj->H->array[2][2] = 1.0f;
+ obj->H->array[0*obj->H->nCols+0] = 1.0f;
+ obj->H->array[1*obj->H->nCols+1] = 1.0f;
+ obj->H->array[2*obj->H->nCols+2] = 1.0f;
obj->Ht = matrix_construct_zero(6,3);
- obj->Ht->array[0][0] = 1.0f;
- obj->Ht->array[1][1] = 1.0f;
- obj->Ht->array[2][2] = 1.0f;
+ obj->Ht->array[0*obj->Ht->nCols+0] = 1.0f;
+ obj->Ht->array[1*obj->Ht->nCols+1] = 1.0f;
+ obj->Ht->array[2*obj->Ht->nCols+2] = 1.0f;
obj->mu_t = matrix_construct_zero(3,1);
obj->mu_t_t = matrix_construct_zero(1,3);
obj->sigma_t_inv_mu_t_sigma_s_inv_mu_s = matrix_construct_zero(3,1);
- obj->sigma_s->array[0][0] = sigmaR*sigmaR;
- obj->sigma_s->array[1][1] = sigmaR*sigmaR;
- obj->sigma_s->array[2][2] = sigmaR*sigmaR;
+ obj->sigma_s->array[0*obj->sigma_s->nCols+0] = sigmaR*sigmaR;
+ obj->sigma_s->array[1*obj->sigma_s->nCols+1] = sigmaR*sigmaR;
+ obj->sigma_s->array[2*obj->sigma_s->nCols+2] = sigmaR*sigmaR;
- obj->sigma_epsilon->array[0][0] = epsilon;
- obj->sigma_epsilon->array[1][1] = epsilon;
- obj->sigma_epsilon->array[2][2] = epsilon;
+ obj->sigma_epsilon->array[0*obj->sigma_epsilon->nCols+0] = epsilon;
+ obj->sigma_epsilon->array[1*obj->sigma_epsilon->nCols+1] = epsilon;
+ obj->sigma_epsilon->array[2*obj->sigma_epsilon->nCols+2] = epsilon;
matrix_inv(obj->sigma_s_inv, obj->sigma_s);
// Compute B3
matrix_mul(obj->mu_t_t_sigma_t_inv_mu_t, obj->mu_t_t, obj->sigma_t_inv_mu_t);
- B3 = obj->mu_t_t_sigma_t_inv_mu_t->array[0][0];
+ B3 = obj->mu_t_t_sigma_t_inv_mu_t->array[0*(obj->mu_t_t_sigma_t_inv_mu_t->nCols)+0];
for (iPot = 0; iPot < pots->nPots; iPot++) {
// Compute mu_s
- obj->mu_s->array[0][0] = pots->array[iPot*4+0];
- obj->mu_s->array[1][0] = pots->array[iPot*4+1];
- obj->mu_s->array[2][0] = pots->array[iPot*4+2];
+ obj->mu_s->array[0*(obj->mu_s->nCols)+0] = pots->array[iPot*4+0];
+ obj->mu_s->array[1*(obj->mu_s->nCols)+0] = pots->array[iPot*4+1];
+ obj->mu_s->array[2*(obj->mu_s->nCols)+0] = pots->array[iPot*4+2];
matrix_transpose(obj->mu_s_t, obj->mu_s);
// Compute sigma_st^-1
// Compute B2
matrix_mul(obj->sigma_st_inv_mu_st, obj->sigma_st_inv, obj->mu_st);
matrix_mul(obj->mu_st_t_sigma_st_inv_mu_st, obj->mu_st_t, obj->sigma_st_inv_mu_st);
- B2 = obj->mu_st_t_sigma_st_inv_mu_st->array[0][0];
+ B2 = obj->mu_st_t_sigma_st_inv_mu_st->array[0*(obj->mu_st_t_sigma_st_inv_mu_st->nCols)+0];
// Compute B4
matrix_mul(obj->mu_s_t_sigma_s_inv_mu_s, obj->mu_s_t, obj->sigma_s_inv_mu_s);
- B4 = obj->mu_s_t_sigma_s_inv_mu_s->array[0][0];
+ B4 = obj->mu_s_t_sigma_s_inv_mu_s->array[0*(obj->mu_s_t_sigma_s_inv_mu_s->nCols)+0];
// Compute weight
weight = expf(0.5f * (B1+B2-B3-B4));
obj->Ht = matrix_construct_zero(6,3);
obj->R = matrix_construct_zero(3,3);
- obj->F->array[0][0] = 1.0f;
- obj->F->array[0][3] = deltaT;
- obj->F->array[1][1] = 1.0f;
- obj->F->array[1][4] = deltaT;
- obj->F->array[2][2] = 1.0f;
- obj->F->array[2][5] = deltaT;
- obj->F->array[3][3] = 1.0f;
- obj->F->array[4][4] = 1.0f;
- obj->F->array[5][5] = 1.0f;
-
- obj->Ft->array[0][0] = 1.0f;
- obj->Ft->array[3][0] = deltaT;
- obj->Ft->array[1][1] = 1.0f;
- obj->Ft->array[4][1] = deltaT;
- obj->Ft->array[2][2] = 1.0f;
- obj->Ft->array[5][2] = deltaT;
- obj->Ft->array[3][3] = 1.0f;
- obj->Ft->array[4][4] = 1.0f;
- obj->Ft->array[5][5] = 1.0f;
-
- obj->Q->array[3][3] = sigmaQ*sigmaQ;
- obj->Q->array[4][4] = sigmaQ*sigmaQ;
- obj->Q->array[5][5] = sigmaQ*sigmaQ;
-
- obj->H->array[0][0] = 1.0f;
- obj->H->array[1][1] = 1.0f;
- obj->H->array[2][2] = 1.0f;
-
- obj->Ht->array[0][0] = 1.0f;
- obj->Ht->array[1][1] = 1.0f;
- obj->Ht->array[2][2] = 1.0f;
-
- obj->R->array[0][0] = sigmaR*sigmaR;
- obj->R->array[1][1] = sigmaR*sigmaR;
- obj->R->array[2][2] = sigmaR*sigmaR;
+ obj->F->array[0*(obj->F->nCols)+0] = 1.0f;
+ obj->F->array[0*(obj->F->nCols)+3] = deltaT;
+ obj->F->array[1*(obj->F->nCols)+1] = 1.0f;
+ obj->F->array[1*(obj->F->nCols)+4] = deltaT;
+ obj->F->array[2*(obj->F->nCols)+2] = 1.0f;
+ obj->F->array[2*(obj->F->nCols)+5] = deltaT;
+ obj->F->array[3*(obj->F->nCols)+3] = 1.0f;
+ obj->F->array[4*(obj->F->nCols)+4] = 1.0f;
+ obj->F->array[5*(obj->F->nCols)+5] = 1.0f;
+
+ obj->Ft->array[0*(obj->Ft->nCols)+0] = 1.0f;
+ obj->Ft->array[3*(obj->Ft->nCols)+0] = deltaT;
+ obj->Ft->array[1*(obj->Ft->nCols)+1] = 1.0f;
+ obj->Ft->array[4*(obj->Ft->nCols)+1] = deltaT;
+ obj->Ft->array[2*(obj->Ft->nCols)+2] = 1.0f;
+ obj->Ft->array[5*(obj->Ft->nCols)+2] = deltaT;
+ obj->Ft->array[3*(obj->Ft->nCols)+3] = 1.0f;
+ obj->Ft->array[4*(obj->Ft->nCols)+4] = 1.0f;
+ obj->Ft->array[5*(obj->Ft->nCols)+5] = 1.0f;
+
+ obj->Q->array[3*(obj->Q->nCols)+3] = sigmaQ*sigmaQ;
+ obj->Q->array[4*(obj->Q->nCols)+4] = sigmaQ*sigmaQ;
+ obj->Q->array[5*(obj->Q->nCols)+5] = sigmaQ*sigmaQ;
+
+ obj->H->array[0*(obj->H->nCols)+0] = 1.0f;
+ obj->H->array[1*(obj->H->nCols)+1] = 1.0f;
+ obj->H->array[2*(obj->H->nCols)+2] = 1.0f;
+
+ obj->Ht->array[0*(obj->Ht->nCols)+0] = 1.0f;
+ obj->Ht->array[1*(obj->Ht->nCols)+1] = 1.0f;
+ obj->Ht->array[2*(obj->Ht->nCols)+2] = 1.0f;
+
+ obj->R->array[0*(obj->R->nCols)+0] = sigmaR*sigmaR;
+ obj->R->array[1*(obj->R->nCols)+1] = sigmaR*sigmaR;
+ obj->R->array[2*(obj->R->nCols)+2] = sigmaR*sigmaR;
obj->FP = matrix_construct_zero(6,6);
obj->FPFt = matrix_construct_zero(6,6);
matrix_copy_zero(kalman->P_llm1);
matrix_copy_zero(kalman->P_lm1lm1);
- kalman->P_lm1lm1->array[0][0] = obj->sigmaQ * obj->sigmaQ;
- kalman->P_lm1lm1->array[1][1] = obj->sigmaQ * obj->sigmaQ;
- kalman->P_lm1lm1->array[2][2] = obj->sigmaQ * obj->sigmaQ;
- kalman->P_lm1lm1->array[3][3] = obj->sigmaQ * obj->sigmaQ;
- kalman->P_lm1lm1->array[4][4] = obj->sigmaQ * obj->sigmaQ;
- kalman->P_lm1lm1->array[5][5] = obj->sigmaQ * obj->sigmaQ;
+ kalman->P_lm1lm1->array[0*(kalman->P_lm1lm1->nCols)+0] = obj->sigmaQ * obj->sigmaQ;
+ kalman->P_lm1lm1->array[1*(kalman->P_lm1lm1->nCols)+1] = obj->sigmaQ * obj->sigmaQ;
+ kalman->P_lm1lm1->array[2*(kalman->P_lm1lm1->nCols)+2] = obj->sigmaQ * obj->sigmaQ;
+ kalman->P_lm1lm1->array[3*(kalman->P_lm1lm1->nCols)+3] = obj->sigmaQ * obj->sigmaQ;
+ kalman->P_lm1lm1->array[4*(kalman->P_lm1lm1->nCols)+4] = obj->sigmaQ * obj->sigmaQ;
+ kalman->P_lm1lm1->array[5*(kalman->P_lm1lm1->nCols)+5] = obj->sigmaQ * obj->sigmaQ;
- kalman->x_lm1lm1->array[0][0] = pots->array[iPot * 4 + 0];
- kalman->x_lm1lm1->array[1][0] = pots->array[iPot * 4 + 1];
- kalman->x_lm1lm1->array[2][0] = pots->array[iPot * 4 + 2];
+ kalman->x_lm1lm1->array[0*(kalman->x_lm1lm1->nCols)+0] = pots->array[iPot * 4 + 0];
+ kalman->x_lm1lm1->array[1*(kalman->x_lm1lm1->nCols)+0] = pots->array[iPot * 4 + 1];
+ kalman->x_lm1lm1->array[2*(kalman->x_lm1lm1->nCols)+0] = pots->array[iPot * 4 + 2];
}
matrix_mul(obj->FPFt, obj->FP, obj->Ft);
matrix_add(kalman->P_llm1, obj->FPFt, obj->Q);
- xx = kalman->x_llm1->array[0][0];
- xy = kalman->x_llm1->array[1][0];
- xz = kalman->x_llm1->array[2][0];
- vx = kalman->x_llm1->array[3][0];
- vy = kalman->x_llm1->array[4][0];
- vz = kalman->x_llm1->array[5][0];
+ xx = kalman->x_llm1->array[0*(kalman->x_llm1->nCols)+0];
+ xy = kalman->x_llm1->array[1*(kalman->x_llm1->nCols)+0];
+ xz = kalman->x_llm1->array[2*(kalman->x_llm1->nCols)+0];
+ vx = kalman->x_llm1->array[3*(kalman->x_llm1->nCols)+0];
+ vy = kalman->x_llm1->array[4*(kalman->x_llm1->nCols)+0];
+ vz = kalman->x_llm1->array[5*(kalman->x_llm1->nCols)+0];
norm2 = xx*xx + xy*xy + xz*xz;
norm = sqrtf(norm2);
proj = xx*vx + xy*vy + xz*vz;
- kalman->x_llm1->array[0][0] = xx / (norm + obj->epsilon);
- kalman->x_llm1->array[1][0] = xy / (norm + obj->epsilon);
- kalman->x_llm1->array[2][0] = xz / (norm + obj->epsilon);
- kalman->x_llm1->array[3][0] = vx - xx * proj / (norm2 + obj->epsilon);
- kalman->x_llm1->array[4][0] = vy - xy * proj / (norm2 + obj->epsilon);
- kalman->x_llm1->array[5][0] = vz - xz * proj / (norm2 + obj->epsilon);
+ kalman->x_llm1->array[0*(kalman->x_llm1->nCols)+0] = xx / (norm + obj->epsilon);
+ kalman->x_llm1->array[1*(kalman->x_llm1->nCols)+0] = xy / (norm + obj->epsilon);
+ kalman->x_llm1->array[2*(kalman->x_llm1->nCols)+0] = xz / (norm + obj->epsilon);
+ kalman->x_llm1->array[3*(kalman->x_llm1->nCols)+0] = vx - xx * proj / (norm2 + obj->epsilon);
+ kalman->x_llm1->array[4*(kalman->x_llm1->nCols)+0] = vy - xy * proj / (norm2 + obj->epsilon);
+ kalman->x_llm1->array[5*(kalman->x_llm1->nCols)+0] = vz - xz * proj / (norm2 + obj->epsilon);
}
}
- obj->z->array[0][0] = pots->array[maxIndex * 4 + 0];
- obj->z->array[1][0] = pots->array[maxIndex * 4 + 1];
- obj->z->array[2][0] = pots->array[maxIndex * 4 + 2];
+ obj->z->array[0*(obj->z->nCols)+0] = pots->array[maxIndex * 4 + 0];
+ obj->z->array[1*(obj->z->nCols)+0] = pots->array[maxIndex * 4 + 1];
+ obj->z->array[2*(obj->z->nCols)+0] = pots->array[maxIndex * 4 + 2];
// Compute K
matrix_mul(obj->HP, obj->H, kalman->P_llm1);
void kalman2kalman_estimate(kalman2kalman_obj * obj, const kalman_obj * kalman, float * x, float * y, float * z) {
- *x = kalman->x_lm1lm1->array[0][0];
- *y = kalman->x_lm1lm1->array[1][0];
- *z = kalman->x_lm1lm1->array[2][0];
+ *x = kalman->x_lm1lm1->array[0*(kalman->x_lm1lm1->nCols)+0];
+ *y = kalman->x_lm1lm1->array[1*(kalman->x_lm1lm1->nCols)+0];
+ *z = kalman->x_lm1lm1->array[2*(kalman->x_lm1lm1->nCols)+0];
}
\ No newline at end of file
--- /dev/null
+
+ #include "steer2demixing.h"
+
+ steer2demixing_ds_obj * steer2demixing_ds_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float epsilon) {
+
+ steer2demixing_ds_obj * obj;
+
+ obj = (steer2demixing_ds_obj *) malloc(sizeof(steer2demixing_ds_obj));
+
+ obj->nSeps = nSeps;
+ obj->nChannels = nChannels;
+ obj->halfFrameSize = halfFrameSize;
+ obj->epsilon = epsilon;
+
+ obj->gains2 = (float *) malloc(sizeof(float) * halfFrameSize);
+ memset(obj->gains2, 0x00, sizeof(float) * halfFrameSize);
+
+ return obj;
+
+ }
+
+ void steer2demixing_ds_destroy(steer2demixing_ds_obj * obj) {
+
+ free((void *) obj->gains2);
+ free((void *) obj);
+
+ }
+
+ void steer2demixing_ds_process(steer2demixing_ds_obj * obj, const tracks_obj * tracks, const steers_obj * steers, const masks_obj * masks, demixings_obj * demixings) {
+
+ unsigned int iSep;
+ unsigned int iChannel;
+ unsigned int iBin;
+ unsigned int iSampleSC;
+ unsigned int iSampleBC;
+
+ char mask;
+ float Areal;
+ float Aimag;
+ float gain2;
+ float Wreal;
+ float Wimag;
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ if (tracks->ids[iSep] != 0) {
+
+ memset(obj->gains2, 0x00, sizeof(float) * obj->halfFrameSize);
+
+ for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
+
+ obj->gains2[iBin] = obj->epsilon;
+
+ }
+
+ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+ iSampleSC = iSep * obj->nChannels + iChannel;
+ mask = masks->array[iSampleSC];
+
+ if (mask == 1) {
+
+ for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
+
+ iSampleBC = iBin * obj->nChannels + iChannel;
+
+ Areal = steers->array[iSep][iSampleBC * 2 + 0];
+ Aimag = steers->array[iSep][iSampleBC * 2 + 1];
+
+ gain2 = Areal * Areal + Aimag * Aimag;
+
+ obj->gains2[iBin] += gain2;
+
+ }
+
+ }
+
+ }
+
+ for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+ iSampleSC = iSep * obj->nChannels + iChannel;
+ mask = masks->array[iSampleSC];
+
+ if (mask == 1) {
+
+ for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
+
+ iSampleBC = iBin * obj->nChannels + iChannel;
+
+ Areal = steers->array[iSep][iSampleBC * 2 + 0];
+ Aimag = steers->array[iSep][iSampleBC * 2 + 1];
+
+ Wreal = Areal / obj->gains2[iBin];
+ Wimag = Aimag / obj->gains2[iBin];
+
+ demixings->array[iSep][iSampleBC * 2 + 0] = Wreal;
+ demixings->array[iSep][iSampleBC * 2 + 1] = Wimag;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ steer2demixing_gss_obj * steer2demixing_gss_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float mu, const float lambda) {
+
+ steer2demixing_gss_obj * obj;
+ unsigned int iSep;
+
+ obj = (steer2demixing_gss_obj *) malloc(sizeof(steer2demixing_gss_obj));
+
+ obj->nSeps = nSeps;
+ obj->nChannels = nChannels;
+ obj->halfFrameSize = halfFrameSize;
+
+ obj->mu = mu;
+ obj->lambda = lambda;
+
+ obj->X = cmatrix_construct_zero(nChannels, 1);
+ obj->XH = cmatrix_construct_zero(1, nChannels);
+
+ obj->Y = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->YH = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->Ryy = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->E = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->A = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->AH = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->Wn = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->Wnp1 = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->dJ1 = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+ obj->dJ2 = (cmatrix_obj **) malloc(sizeof(cmatrix_obj *) * nSeps);
+
+ for (iSep = 0; iSep < nSeps; iSep++) {
+
+ obj->Y[iSep] = cmatrix_construct_zero((iSep+1), 1);
+ obj->YH[iSep] = cmatrix_construct_zero(1, (iSep+1));
+ obj->Ryy[iSep] = cmatrix_construct_zero((iSep+1), (iSep+1));
+ obj->E[iSep] = cmatrix_construct_zero((iSep+1), (iSep+1));
+ obj->A[iSep] = cmatrix_construct_zero(nChannels, (iSep+1));
+ obj->AH[iSep] = cmatrix_construct_zero((iSep+1), nChannels);
+ obj->Wn[iSep] = cmatrix_construct_zero((iSep+1), nChannels);
+ obj->Wnp1[iSep] = cmatrix_construct_zero((iSep+1), nChannels);
+ obj->dJ1[iSep] = cmatrix_construct_zero((iSep+1), nChannels);
+ obj->dJ2[iSep] = cmatrix_construct_zero((iSep+1), nChannels);
+
+ }
+
+ return obj;
+
+ }
+
+ void steer2demixing_gss_destroy(steer2demixing_gss_obj * obj) {
+
+ unsigned int iSep;
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ cmatrix_destroy(obj->Y[iSep]);
+ cmatrix_destroy(obj->YH[iSep]);
+ cmatrix_destroy(obj->Ryy[iSep]);
+ cmatrix_destroy(obj->E[iSep]);
+ cmatrix_destroy(obj->A[iSep]);
+ cmatrix_destroy(obj->AH[iSep]);
+ cmatrix_destroy(obj->Wn[iSep]);
+ cmatrix_destroy(obj->Wnp1[iSep]);
+ cmatrix_destroy(obj->dJ1[iSep]);
+ cmatrix_destroy(obj->dJ2[iSep]);
+
+ }
+
+ free((void *) obj->Y);
+ free((void *) obj->YH);
+ free((void *) obj->Ryy);
+ free((void *) obj->E);
+ free((void *) obj->A);
+ free((void *) obj->AH);
+ free((void *) obj->Wn);
+ free((void *) obj->Wnp1);
+ free((void *) obj->dJ1);
+ free((void *) obj->dJ2);
+
+ cmatrix_destroy(obj->XH);
+ cmatrix_destroy(obj->X);
+
+ free((void *) obj);
+
+ }
+
+ void steer2demixing_gss_process(steer2demixing_gss_obj * obj, const tracks_obj * tracks, const steers_obj * steers, const masks_obj * masks, const freqs_obj * freqs, demixings_obj * demixings) {
+
+ unsigned int nActiveSeps;
+ unsigned int iSep;
+ unsigned int iBin;
+ unsigned int iChannel;
+
+ nActiveSeps = 0;
+
+ for (iSep = 0; iSep < obj->nSeps; iSep++) {
+
+ nActiveSeps++;
+
+ }
+
+
+ }
+
+ steer2demixing_mvdr_obj * steer2demixing_mvdr_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float sigma) {
+
+ }
+
+ void steer2demixing_mvdr_process(steer2demixing_mvdr_obj * obj, const tracks_obj * tracks, const steers_obj * steers, const masks_obj * masks, const freqs_obj * freqs, demixings_obj * demixings) {
+
+ }
+
+ void steer2demixing_mvdr_destroy(steer2demixing_mvdr_obj * obj) {
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_SYSTEM_STEER2DEMIXING
+#define __ODAS_SYSTEM_STEER2DEMIXING
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+ #include <math.h>
+
+ #include "../signal/demixing.h"
+ #include "../signal/freq.h"
+ #include "../signal/mask.h"
+ #include "../signal/steer.h"
+ #include "../signal/track.h"
+
+ #include "../utils/cmatrix.h"
+
+ typedef struct steer2demixing_ds_obj {
+
+ unsigned int nSeps;
+ unsigned int nChannels;
+ unsigned int halfFrameSize;
+ float epsilon;
+
+ float * gains2;
+
+ } steer2demixing_ds_obj;
+
+ typedef struct steer2demixing_gss_obj {
+
+ unsigned int nSeps;
+ unsigned int nChannels;
+ unsigned int halfFrameSize;
+
+ float mu;
+ float lambda;
+
+ cmatrix_obj * X;
+ cmatrix_obj * XH;
+
+ cmatrix_obj ** Y;
+ cmatrix_obj ** YH;
+ cmatrix_obj ** Ryy;
+ cmatrix_obj ** E;
+ cmatrix_obj ** A;
+ cmatrix_obj ** AH;
+ cmatrix_obj ** Wn;
+ cmatrix_obj ** Wnp1;
+ cmatrix_obj ** dJ1;
+ cmatrix_obj ** dJ2;
+
+ } steer2demixing_gss_obj;
+
+ typedef struct steer2demixing_mvdr_obj {
+
+ unsigned int nSeps;
+ unsigned int nChannels;
+ unsigned int halfFrameSize;
+
+ float sigma;
+
+ } steer2demixing_mvdr_obj;
+
+
+ steer2demixing_ds_obj * steer2demixing_ds_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float epsilon);
+
+ void steer2demixing_ds_destroy(steer2demixing_ds_obj * obj);
+
+ void steer2demixing_ds_process(steer2demixing_ds_obj * obj, const tracks_obj * tracks, const steers_obj * steers, const masks_obj * masks, demixings_obj * demixings);
+
+
+ steer2demixing_gss_obj * steer2demixing_gss_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float mu, const float lambda);
+
+ void steer2demixing_gss_destroy(steer2demixing_gss_obj * obj);
+
+ void steer2demixing_gss_process(steer2demixing_gss_obj * obj, const tracks_obj * tracks, const steers_obj * steers, const masks_obj * masks, const freqs_obj * freqs, demixings_obj * demixings);
+
+
+ steer2demixing_mvdr_obj * steer2demixing_mvdr_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float sigma);
+
+ void steer2demixing_mvdr_process(steer2demixing_mvdr_obj * obj, const tracks_obj * tracks, const steers_obj * steers, const masks_obj * masks, const freqs_obj * freqs, demixings_obj * demixings);
+
+ void steer2demixing_mvdr_destroy(steer2demixing_mvdr_obj * obj);
+
+#endif
\ No newline at end of file
+++ /dev/null
-
- #include "steer2freq.h"
-
- steer2freq_obj * steer2freq_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize) {
-
- steer2freq_obj * obj;
-
- obj = (steer2freq_obj *) malloc(sizeof(steer2freq_obj));
-
- obj->nSeps = nSeps;
- obj->nChannels = nChannels;
- obj->halfFrameSize = halfFrameSize;
-
- return obj;
-
- }
-
- void steer2freq_destroy(steer2freq_obj * obj) {
-
- free((void *) obj);
-
- }
-
- void steer2freq_process(steer2freq_obj * obj, const tracks_obj * tracks, const steers_obj * demixing, const masks_obj * masks, const freqs_obj * freqsChannel, freqs_obj * freqsSeparated) {
-
- unsigned int iSep;
- unsigned int iChannel;
- unsigned int iBin;
-
- unsigned int iSampleSC;
- unsigned int iSampleBC;
- unsigned int iSampleB;
-
- float Xreal;
- float Ximag;
- float Wreal;
- float Wimag;
- float Yreal;
- float Yimag;
-
- for (iSep = 0; iSep < obj->nSeps; iSep++) {
-
- if (tracks->ids[iSep] != 0) {
-
- memset(freqsSeparated->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize * 2);
-
- for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
-
- iSampleSC = iSep * obj->nChannels + iChannel;
-
- if (masks->array[iSampleSC] == 1) {
-
- for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
-
- iSampleBC = iBin * obj->nChannels + iChannel;
- iSampleB = iBin;
-
- Xreal = freqsChannel->array[iChannel][iSampleB * 2 + 0];
- Ximag = freqsChannel->array[iChannel][iSampleB * 2 + 1];
-
- Wreal = demixing->array[iSep][iSampleBC * 2 + 0];
- Wimag = demixing->array[iSep][iSampleBC * 2 + 1];
-
- Yreal = Wreal * Xreal - Wimag * Ximag;
- Yimag = Wreal * Ximag + Wimag * Xreal;
-
- freqsSeparated->array[iSep][iSampleB * 2 + 0] += Yreal;
- freqsSeparated->array[iSep][iSampleB * 2 + 1] += Yimag;
-
- }
-
- }
-
- }
-
- }
- else {
-
- memset(freqsSeparated->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize * 2);
-
- }
-
- }
-
- }
\ No newline at end of file
+++ /dev/null
-#ifndef __ODAS_SYSTEM_STEER2FREQ
-#define __ODAS_SYSTEM_STEER2FREQ
-
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <math.h>
-
- #include "../signal/freq.h"
- #include "../signal/mask.h"
- #include "../signal/steer.h"
- #include "../signal/track.h"
-
- typedef struct steer2freq_obj {
-
- unsigned int nSeps;
- unsigned int nChannels;
- unsigned int halfFrameSize;
-
- } steer2freq_obj;
-
- steer2freq_obj * steer2freq_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize);
-
- void steer2freq_destroy(steer2freq_obj * obj);
-
- void steer2freq_process(steer2freq_obj * obj, const tracks_obj * tracks, const steers_obj * demixing, const masks_obj * masks, const freqs_obj * freqsChannel, freqs_obj * freqsSeparated);
-
-#endif
\ No newline at end of file
}
- void track2steer_process_demixing(track2steer_obj * obj, const tracks_obj * tracks, const gains_obj * gains, const masks_obj * masks, steers_obj * steers) {
+ void track2steer_process(track2steer_obj * obj, const tracks_obj * tracks, const gains_obj * gains, const masks_obj * masks, steers_obj * steers) {
unsigned int iSep;
unsigned int iBin;
float dist;
float delay;
float gain;
- float gainTotal;
char mask;
- float Wreal;
- float Wimag;
+ float Areal;
+ float Aimag;
unsigned int iSampleSC;
unsigned int iSampleBC;
if (tracks->ids[iSep] != 0) {
- gainTotal = 0.0f;
-
- for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
-
- iSampleSC = iSep * obj->nChannels + iChannel;
- mask = masks->array[iSampleSC];
-
- if (mask == 1) {
-
- gain = gains->array[iSampleSC];
- gainTotal += gain * gain;
-
- }
-
- }
-
for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
iSampleSC = iSep * obj->nChannels + iChannel;
delay = -1.0f * obj->speed * dist;
- gain = gains->array[iSampleSC] / gainTotal;
+ gain = gains->array[iSampleSC];
for (iBin = 0; iBin < obj->halfFrameSize; iBin++) {
iSampleBC = iBin * obj->nChannels + iChannel;
- Wreal = gain * cosf(obj->factor[iBin] * -1.0f * delay);
- Wimag = gain * sinf(obj->factor[iBin] * -1.0f * delay);
+ Areal = gain * cosf(obj->factor[iBin] * delay);
+ Aimag = gain * sinf(obj->factor[iBin] * delay);
- steers->array[iSep][iSampleBC * 2 + 0] = Wreal;
- steers->array[iSep][iSampleBC * 2 + 1] = Wimag;
+ steers->array[iSep][iSampleBC * 2 + 0] = Areal;
+ steers->array[iSep][iSampleBC * 2 + 1] = Aimag;
}
void track2steer_destroy(track2steer_obj * obj);
- void track2steer_process_demixing(track2steer_obj * obj, const tracks_obj * tracks, const gains_obj * gains, const masks_obj * masks, steers_obj * steers);
+ void track2steer_process(track2steer_obj * obj, const tracks_obj * tracks, const gains_obj * gains, const masks_obj * masks, steers_obj * steers);
#endif
\ No newline at end of file
--- /dev/null
+
+ #include "cmatrix.h"
+
+ cmatrix_obj * cmatrix_construct_zero(const unsigned int nRows, const unsigned int nCols) {
+
+ cmatrix_obj * obj;
+
+ obj = (cmatrix_obj *) malloc(sizeof(cmatrix_obj));
+
+ obj->nRows = nRows;
+ obj->nCols = nCols;
+
+ obj->real = (float *) malloc(sizeof(float) * nRows * nCols);
+ obj->imag = (float *) malloc(sizeof(float) * nRows * nCols);
+
+ return obj;
+
+ }
+
+ cmatrix_obj * cmatrix_construct_matrix(const cmatrix_obj * cmatrix) {
+
+ cmatrix_obj * obj;
+
+ obj = (cmatrix_obj *) malloc(sizeof(cmatrix_obj));
+
+ obj->nRows = cmatrix->nRows;
+ obj->nCols = cmatrix->nCols;
+
+ memcpy(obj->real, cmatrix->real, sizeof(float) * cmatrix->nRows * cmatrix->nCols);
+ memcpy(obj->imag, cmatrix->imag, sizeof(float) * cmatrix->nRows * cmatrix->nCols);
+
+ return obj;
+
+ }
+
+ void cmatrix_copy_zero(cmatrix_obj * obj) {
+
+ memset(obj->real, 0x00, sizeof(float) * obj->nRows * obj->nCols);
+ memset(obj->imag, 0x00, sizeof(float) * obj->nRows * obj->nCols);
+
+ }
+
+ void cmatrix_copy_cmatrix(cmatrix_obj * obj, const cmatrix_obj * cmatrix) {
+
+ memcpy(obj->real, cmatrix->real, sizeof(float) * cmatrix->nRows * cmatrix->nCols);
+ memcpy(obj->imag, cmatrix->imag, sizeof(float) * cmatrix->nRows * cmatrix->nCols);
+
+ }
+
+ void cmatrix_destroy(cmatrix_obj * obj) {
+
+ free((void *) obj->real);
+ free((void *) obj->imag);
+ free((void *) obj);
+
+ }
+
+ void cmatrix_transpose(cmatrix_obj * obj, const cmatrix_obj * src) {
+
+ unsigned int iRow;
+ unsigned int iCol;
+
+ for (iRow = 0; iRow < obj->nRows; iRow++) {
+
+ for (iCol = 0; iCol < obj->nCols; iCol++) {
+
+ obj->real[iRow * obj->nRows + iCol] = src->real[iCol * obj->nRows + iRow];
+ obj->imag[iRow * obj->nRows + iCol] = src->imag[iCol * obj->nRows + iRow];
+
+ }
+
+ }
+
+ }
+
+ void cmatrix_hermitian(cmatrix_obj * obj, const cmatrix_obj * src) {
+
+ unsigned int iRow;
+ unsigned int iCol;
+
+ for (iRow = 0; iRow < obj->nRows; iRow++) {
+
+ for (iCol = 0; iCol < obj->nCols; iCol++) {
+
+ obj->real[iRow * obj->nRows + iCol] = src->real[iCol * obj->nRows + iRow];
+ obj->imag[iRow * obj->nRows + iCol] = -1.0f * src->imag[iCol * obj->nRows + iRow];
+
+ }
+
+ }
+
+ }
+
+ void cmatrix_add(cmatrix_obj * obj, const cmatrix_obj * src1, const cmatrix_obj * src2) {
+
+ unsigned int iRow;
+ unsigned int iCol;
+
+ for (iRow = 0; iRow < obj->nRows; iRow++) {
+
+ for (iCol = 0; iCol < obj->nCols; iCol++) {
+
+ obj->real[iRow * obj->nRows + iCol] = src1->real[iRow * obj->nRows + iCol] + src2->real[iRow * obj->nRows + iCol];
+
+ }
+
+ }
+
+ }
+
+ void cmatrix_sub(cmatrix_obj * obj, const cmatrix_obj * src1, const cmatrix_obj * src2) {
+
+ unsigned int iRow;
+ unsigned int iCol;
+
+ for (iRow = 0; iRow < obj->nRows; iRow++) {
+
+ for (iCol = 0; iCol < obj->nCols; iCol++) {
+
+ obj->real[iRow * obj->nRows + iCol] = src1->real[iRow * obj->nRows + iCol] - src2->real[iRow * obj->nRows + iCol];
+
+ }
+
+ }
+
+ }
+
+ void cmatrix_mul(cmatrix_obj * obj, const cmatrix_obj * src1, const cmatrix_obj * src2) {
+
+ unsigned int iRow;
+ unsigned int iCol;
+ unsigned int iElement;
+
+ float real1, imag1;
+ float real2, imag2;
+ float real12, imag12;
+
+ for (iRow = 0; iRow < src1->nRows; iRow++) {
+
+ for (iCol = 0; iCol < src2->nCols; iCol++) {
+
+ obj->real[iRow*obj->nRows+iCol] = 0.0f;
+ obj->imag[iRow*obj->nRows+iCol] = 0.0f;
+
+ for (iElement = 0; iElement < src1->nCols; iElement++) {
+
+ real1 = src1->real[iRow*obj->nRows+iElement];
+ imag1 = src1->imag[iRow*obj->nRows+iElement];
+ real2 = src2->real[iElement*obj->nRows+iCol];
+ imag2 = src2->imag[iElement*obj->nRows+iCol];
+
+ real12 = real1 * real2 - imag1 * imag2;
+ imag12 = real1 * imag2 + imag1 * real2;
+
+ obj->real[iRow*obj->nRows+iCol] += real12;
+ obj->imag[iRow*obj->nRows+iCol] += imag12;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ void cmatrix_scale(cmatrix_obj * obj, const cmatrix_obj * src, const float scale) {
+
+ unsigned int iRow;
+ unsigned int iCol;
+
+ for (iRow = 0; iRow < src->nRows; iRow++) {
+
+ for (iCol = 0; iCol < src->nCols; iCol++) {
+
+ obj->real[iRow * obj->nRows + iCol] = scale * src->real[iRow * obj->nRows + iCol];
+ obj->imag[iRow * obj->nRows + iCol] = scale * src->imag[iRow * obj->nRows + iCol];
+
+ }
+
+ }
+
+ }
+
+ void cmatrix_printf(const cmatrix_obj * obj) {
+
+ unsigned int iRow;
+ unsigned int iCol;
+
+ for (iRow = 0; iRow < obj->nRows; iRow++) {
+
+ for (iCol = 0; iCol < obj->nCols; iCol++) {
+
+ printf("(%+1.5f + %+1.5fj) ",obj->real[iRow*obj->nRows+iCol],obj->imag[iRow*obj->nRows+iCol]);
+
+ }
+
+ printf("\n");
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_UTILS_CMATRIX
+#define __ODAS_UTILS_CMATRIX
+
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <math.h>
+
+ typedef struct cmatrix_obj {
+
+ float * real;
+ float * imag;
+ unsigned int nRows;
+ unsigned int nCols;
+
+ } cmatrix_obj;
+
+ cmatrix_obj * cmatrix_construct_zero(const unsigned int nRows, const unsigned int nCols);
+
+ cmatrix_obj * cmatrix_construct_matrix(const cmatrix_obj * cmatrix);
+
+ void cmatrix_copy_zero(cmatrix_obj * obj);
+
+ void cmatrix_copy_cmatrix(cmatrix_obj * obj, const cmatrix_obj * cmatrix);
+
+ void cmatrix_destroy(cmatrix_obj * obj);
+
+ void cmatrix_transpose(cmatrix_obj * obj, const cmatrix_obj * src);
+
+ void cmatrix_hermitian(cmatrix_obj * obj, const cmatrix_obj * src);
+
+ void cmatrix_add(cmatrix_obj * obj, const cmatrix_obj * src1, const cmatrix_obj * src2);
+
+ void cmatrix_sub(cmatrix_obj * obj, const cmatrix_obj * src1, const cmatrix_obj * src2);
+
+ void cmatrix_mul(cmatrix_obj * obj, const cmatrix_obj * src1, const cmatrix_obj * src2);
+
+ void cmatrix_scale(cmatrix_obj * obj, const cmatrix_obj * src, const float scale);
+
+ void cmatrix_printf(const cmatrix_obj * obj);
+
+#endif
\ No newline at end of file
-#ifndef __ODAS_SIGNAL_GAUSSIAN
-#define __ODAS_SIGNAL_GAUSSIAN
+#ifndef __ODAS_UTILS_GAUSSIAN
+#define __ODAS_UTILS_GAUSSIAN
#include <stdlib.h>
#include <stdio.h>
--- /dev/null
+
+ #include "gaussjordan.h"
+
+ gaussjordan_obj * gaussjordan_construct_zero(const unsigned int nRowsCols, const float epsilon) {
+
+ gaussjordan_obj * obj;
+
+ obj = (gaussjordan_obj *) malloc(sizeof(gaussjordan_obj));
+
+ obj->nRowsCols = nRowsCols;
+ obj->epsilon = epsilon;
+
+ obj->array = (float *) malloc(sizeof(float) * nRowsCols * nRowsCols);
+ memset(obj->array, 0x00, sizeof(float) * nRowsCols * nRowsCols);
+
+ return obj;
+
+ }
+
+ void gaussjordan_destroy(gaussjordan_obj * obj) {
+
+ free((void *) obj->array);
+ free((void *) obj);
+
+ }
+
+ void gaussjordan_process(gaussjordan_obj * obj, const float * src, float * dest) {
+
+ unsigned int nRows;
+ unsigned int nCols;
+
+ signed int iRow;
+ signed int iRowUnder;
+ signed int iRowOther;
+ signed int iCol;
+
+ float epsilon;
+ char nonZero;
+ char singular;
+
+ float element1;
+ float element2;
+ float gain;
+
+ epsilon = 1E-20f;
+
+ nRows = obj->nRowsCols;
+ nCols = obj->nRowsCols;
+
+ // Copy source
+
+ memcpy(obj->array, src, sizeof(float) * nRows * nCols);
+
+ // Create identity matrix
+
+ memset(dest, 0x00, sizeof(float) * nRows * nCols);
+
+ for (iRow = 0; iRow < nRows; iRow++) {
+
+ dest[iRow * nRows + iRow] = 1.0f;
+
+ }
+
+ // Invert
+
+ singular = 0x00;
+
+ for (iRow = 0; iRow < nRows; iRow++) {
+
+ // Check if the leading number is zero
+
+ nonZero = 0x00;
+
+ for (iRowUnder = iRow; iRowUnder < nRows; iRowUnder++) {
+
+ if (fabs(obj->array[iRowUnder * nRows + iRow]) > epsilon) {
+
+ nonZero = 0x01;
+ break;
+
+ }
+
+ }
+
+ // If all following terms are zero, then cannot invert matrix
+
+ if (nonZero == 0x00) {
+
+ singular = 0x01;
+ break;
+
+ }
+
+ // If the leading number is zero, then swap rows in both matrices
+
+ if (iRow != iRowUnder) {
+
+ // Swap memory
+
+ for (iCol = 0; iCol < nCols; iCol++) {
+
+ element1 = obj->array[iRow * nRows + iCol];
+ element2 = obj->array[iRowUnder * nRows + iCol];
+
+ obj->array[iRow * nRows + iCol] = element2;
+ obj->array[iRowUnder * nRows + iCol] = element1;
+
+ element1 = dest[iRow * nRows + iCol];
+ element2 = dest[iRowUnder * nRows + iCol];
+
+ dest[iRow * nRows + iCol] = element2;
+ dest[iRowUnder * nRows + iCol] = element1;
+
+ }
+
+ }
+
+ // Normalize to generate a leading 1
+
+ gain = 1.0f / obj->array[iRow * nRows + iRow];
+
+ for (iCol = iRow; iCol < nCols; iCol++) {
+
+ obj->array[iRow * nRows + iCol] *= gain;
+
+ }
+
+ for (iCol = 0; iCol < nCols; iCol++) {
+
+ dest[iRow * nRows + iCol] *= gain;
+
+ }
+
+ // Subtract from all rows
+
+ for (iRowOther = 0; iRowOther < nRows; iRowOther++) {
+
+ if (iRowOther != iRow) {
+
+ gain = obj->array[iRowOther * nRows + iRow];
+
+ for (iCol = 0; iCol < nCols; iCol++) {
+
+ obj->array[iRowOther * nRows + iCol] -= (obj->array[iRow * nRows + iCol] * gain);
+ dest[iRowOther * nRows + iCol] -= (dest[iRow * nRows + iCol] * gain);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ if (singular != 0x00) {
+
+ for (iRow = 0; iRow < nRows; iRow++) {
+
+ for (iCol = 0; iCol < nCols; iCol++) {
+
+ dest[iRow * nRows + iCol] = +INFINITY;
+
+ }
+
+ }
+
+ }
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_UTILS_GAUSSJORDAN
+#define __ODAS_UTILS_GAUSSJORDAN
+
+ #include <stdlib.h>
+ #include <string.h>
+ #include <math.h>
+
+ typedef struct gaussjordan_obj {
+
+ unsigned int nRowsCols;
+ float * array;
+ float epsilon;
+
+ } gaussjordan_obj;
+
+ gaussjordan_obj * gaussjordan_construct_zero(const unsigned int nRowsCols, const float epsilon);
+
+ void gaussjordan_destroy(gaussjordan_obj * obj);
+
+ void gaussjordan_process(gaussjordan_obj * obj, const float * src, float * dest);
+
+#endif
\ No newline at end of file
--- /dev/null
+
+ #include "inverse.h"
+
+ inverse_real_obj * inverse_real_construct_zero(const unsigned int nRowsCols, const float epsilon) {
+
+ inverse_real_obj * obj;
+
+ obj = (inverse_real_obj *) malloc(sizeof(inverse_real_obj));
+
+ obj->nRowsCols = nRowsCols;
+ obj->gaussjordan = gaussjordan_construct_zero(nRowsCols, epsilon);
+
+ return obj;
+
+ }
+
+ void inverse_real_destroy(inverse_real_obj * obj) {
+
+ gaussjordan_destroy(obj->gaussjordan);
+ free((void *) obj);
+
+ }
+
+ void inverse_real_process(inverse_real_obj * obj, const matrix_obj * src, matrix_obj * dest) {
+
+ gaussjordan_process(obj->gaussjordan, src->array, dest->array);
+
+ }
+
+ inverse_complex_obj * inverse_complex_construct_zero(const unsigned int nRowsCols, const float epsilon) {
+
+ inverse_complex_obj * obj;
+
+ obj = (inverse_complex_obj *) malloc(sizeof(inverse_complex_obj));
+
+ obj->nRowsCols = nRowsCols;
+ obj->gaussjordan = gaussjordan_construct_zero(nRowsCols, epsilon);
+
+ obj->A = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->B = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->Ainv = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->Binv = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->BAinv = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->ABinv = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->BAinvB = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->ABinvA = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->ApBAinvB = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->BpABinvA = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->ApBAinvB_inv = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->BpABinvA_inv = matrix_construct_zero(nRowsCols,nRowsCols);
+ obj->mBpABinvA_inv = matrix_construct_zero(nRowsCols,nRowsCols);
+
+ return obj;
+
+ }
+
+ void inverse_complex_destroy(inverse_complex_obj * obj) {
+
+ matrix_destroy(obj->A);
+ matrix_destroy(obj->B);
+ matrix_destroy(obj->Ainv);
+ matrix_destroy(obj->Binv);
+ matrix_destroy(obj->BAinv);
+ matrix_destroy(obj->ABinv);
+ matrix_destroy(obj->BAinvB);
+ matrix_destroy(obj->ABinvA);
+ matrix_destroy(obj->ApBAinvB);
+ matrix_destroy(obj->BpABinvA);
+ matrix_destroy(obj->ApBAinvB_inv);
+ matrix_destroy(obj->BpABinvA_inv);
+ matrix_destroy(obj->mBpABinvA_inv);
+
+ }
+
+ void inverse_complex_process(inverse_complex_obj * obj, const cmatrix_obj * src, cmatrix_obj * dest) {
+
+ memcpy(obj->A->array, src->real, sizeof(float) * obj->nRowsCols * obj->nRowsCols);
+ memcpy(obj->B->array, src->imag, sizeof(float) * obj->nRowsCols * obj->nRowsCols);
+
+ gaussjordan_process(obj->gaussjordan, obj->A->array, obj->Ainv->array);
+ gaussjordan_process(obj->gaussjordan, obj->B->array, obj->Binv->array);
+
+ matrix_mul(obj->BAinv, obj->B, obj->Ainv);
+ matrix_mul(obj->ABinv, obj->A, obj->Binv);
+ matrix_mul(obj->BAinvB, obj->BAinv, obj->B);
+ matrix_mul(obj->ABinvA, obj->ABinv, obj->A);
+ matrix_add(obj->ApBAinvB, obj->A, obj->BAinvB);
+ matrix_add(obj->BpABinvA, obj->B, obj->ABinvA);
+
+ gaussjordan_process(obj->gaussjordan, obj->ApBAinvB->array, obj->ApBAinvB_inv->array);
+ gaussjordan_process(obj->gaussjordan, obj->BpABinvA->array, obj->BpABinvA_inv->array);
+
+ matrix_scale(obj->mBpABinvA_inv, obj->BpABinvA_inv, -1.0f);
+
+ memcpy(dest->real, obj->ApBAinvB_inv->array, sizeof(float) * obj->nRowsCols * obj->nRowsCols);
+ memcpy(dest->imag, obj->mBpABinvA_inv->array, sizeof(float) * obj->nRowsCols * obj->nRowsCols);
+
+ }
\ No newline at end of file
--- /dev/null
+#ifndef __ODAS_UTILS_INVERSE
+#define __ODAS_UTILS_INVERSE
+
+ #include "gaussjordan.h"
+ #include "matrix.h"
+ #include "cmatrix.h"
+
+ typedef struct inverse_real_obj {
+
+ unsigned int nRowsCols;
+
+ gaussjordan_obj * gaussjordan;
+
+ } inverse_real_obj;
+
+ typedef struct inverse_complex_obj {
+
+ unsigned int nRowsCols;
+
+ gaussjordan_obj * gaussjordan;
+
+ matrix_obj * A;
+ matrix_obj * B;
+
+ matrix_obj * Ainv;
+ matrix_obj * Binv;
+
+ matrix_obj * BAinv;
+ matrix_obj * ABinv;
+
+ matrix_obj * BAinvB;
+ matrix_obj * ABinvA;
+
+ matrix_obj * ApBAinvB;
+ matrix_obj * BpABinvA;
+
+ matrix_obj * ApBAinvB_inv;
+ matrix_obj * BpABinvA_inv;
+
+ matrix_obj * mBpABinvA_inv;
+
+ } inverse_complex_obj;
+
+ inverse_real_obj * inverse_real_construct_zero(const unsigned int nRowsCols, const float epsilon);
+
+ void inverse_real_destroy(inverse_real_obj * obj);
+
+ void inverse_real_process(inverse_real_obj * obj, const matrix_obj * src, matrix_obj * dest);
+
+ inverse_complex_obj * inverse_complex_construct_zero(const unsigned int nRowsCols, const float epsilon);
+
+ void inverse_complex_destroy(inverse_complex_obj * obj);
+
+ void inverse_complex_process(inverse_complex_obj * obj, const cmatrix_obj * src, cmatrix_obj * dest);
+
+#endif
\ No newline at end of file
obj->nRows = nRows;
obj->nCols = nCols;
- obj->array = (float **) malloc(sizeof(float *) * nRows);
+ obj->array = (float *) malloc(sizeof(float) * nRows * nCols);
- for (iRow = 0; iRow < nRows; iRow++) {
-
- obj->array[iRow] = (float *) malloc(sizeof(float) * nCols);
-
- for (iCol = 0; iCol < nCols; iCol++) {
-
- obj->array[iRow][iCol] = 0.0f;
-
- }
-
- }
+ memset(obj->array, 0x00, sizeof(float) * nRows * nCols);
return obj;
obj->nRows = matrix->nRows;
obj->nCols = matrix->nCols;
- obj->array = (float **) malloc(sizeof(float *) * matrix->nRows);
-
- for (iRow = 0; iRow < matrix->nRows; iRow++) {
-
- obj->array[iRow] = (float *) malloc(sizeof(float) * matrix->nCols);
-
- for (iCol = 0; iCol < matrix->nCols; iCol++) {
+ obj->array = (float *) malloc(sizeof(float) * matrix->nRows * matrix->nCols);
- obj->array[iRow][iCol] = matrix->array[iRow][iCol];
-
- }
-
- }
+ memcpy(obj->array, matrix->array, sizeof(float) * matrix->nRows * matrix->nCols);
return obj;
unsigned int iRow;
unsigned int iCol;
- for (iRow = 0; iRow < obj->nRows; iRow++) {
-
- for (iCol = 0; iCol < obj->nCols; iCol++) {
-
- obj->array[iRow][iCol] = 0.0f;
-
- }
-
- }
+ memset(obj->array, 0x00, sizeof(float) * obj->nRows * obj->nCols);
}
unsigned int iRow;
unsigned int iCol;
- for (iRow = 0; iRow < matrix->nRows; iRow++) {
-
- obj->array[iRow] = (float *) malloc(sizeof(float) * matrix->nCols);
-
- for (iCol = 0; iCol < matrix->nCols; iCol++) {
-
- obj->array[iRow][iCol] = matrix->array[iRow][iCol];
-
- }
-
- }
+ memcpy(obj->array, matrix->array, sizeof(float) * matrix->nRows * matrix->nCols);
}
void matrix_destroy(matrix_obj * obj) {
- unsigned int iRow;
-
- for (iRow = 0; iRow < obj->nRows; iRow++) {
-
- free((void *) obj->array[iRow]);
-
- }
-
free((void *) obj->array);
free((void *) obj);
for (iCol = 0; iCol < obj->nCols; iCol++) {
- obj->array[iRow][iCol] = src->array[iCol][iRow];
+ obj->array[iRow*obj->nCols+iCol] = src->array[iCol*src->nCols+iRow];
}
for (iCol = 0; iCol < obj->nCols; iCol++) {
- obj->array[iRow][iCol] = src1->array[iRow][iCol] + src2->array[iRow][iCol];
+ obj->array[iRow*obj->nCols+iCol] = src1->array[iRow*src1->nCols+iCol] + src2->array[iRow*src2->nCols+iCol];
}
for (iCol = 0; iCol < obj->nCols; iCol++) {
- obj->array[iRow][iCol] = src1->array[iRow][iCol] - src2->array[iRow][iCol];
+ obj->array[iRow*obj->nCols+iCol] = src1->array[iRow*src1->nCols+iCol] - src2->array[iRow*src2->nCols+iCol];
}
for (iCol = 0; iCol < src2->nCols; iCol++) {
- obj->array[iRow][iCol] = 0.0f;
+ obj->array[iRow*obj->nCols+iCol] = 0.0f;
for (iElement = 0; iElement < src1->nCols; iElement++) {
- obj->array[iRow][iCol] += (src1->array[iRow][iElement] * src2->array[iElement][iCol]);
+ obj->array[iRow*obj->nCols+iCol] += (src1->array[iRow*src1->nCols+iElement] * src2->array[iElement*src2->nCols+iCol]);
}
if ((src->nRows == 2) && (src->nCols == 2)) {
- a00 = src->array[0][0];
- a01 = src->array[0][1];
- a10 = src->array[1][0];
- a11 = src->array[1][1];
+ a00 = src->array[0*src->nRows+0];
+ a01 = src->array[0*src->nRows+1];
+ a10 = src->array[1*src->nRows+0];
+ a11 = src->array[1*src->nRows+1];
det = a00*a11 - a01*a10;
- obj->array[0][0] = +a11 / det;
- obj->array[0][1] = -a01 / det;
- obj->array[1][0] = -a10 / det;
- obj->array[1][1] = +a00 / det;
+ obj->array[0*obj->nRows+0] = +a11 / det;
+ obj->array[0*obj->nRows+1] = -a01 / det;
+ obj->array[1*obj->nRows+0] = -a10 / det;
+ obj->array[1*obj->nRows+1] = +a00 / det;
}
if ((src->nRows == 3) && (src->nCols == 3)) {
- a00 = src->array[0][0];
- a01 = src->array[0][1];
- a02 = src->array[0][2];
- a10 = src->array[1][0];
- a11 = src->array[1][1];
- a12 = src->array[1][2];
- a20 = src->array[2][0];
- a21 = src->array[2][1];
- a22 = src->array[2][2];
+ a00 = src->array[0*src->nRows+0];
+ a01 = src->array[0*src->nRows+1];
+ a02 = src->array[0*src->nRows+2];
+ a10 = src->array[1*src->nRows+0];
+ a11 = src->array[1*src->nRows+1];
+ a12 = src->array[1*src->nRows+2];
+ a20 = src->array[2*src->nRows+0];
+ a21 = src->array[2*src->nRows+1];
+ a22 = src->array[2*src->nRows+2];
det = a00*a11*a22 - a00*a12*a21 - a01*a10*a22 + a01*a12*a20 + a02*a10*a21 - a02*a11*a20;
- obj->array[0][0] = +(a11*a22 - a12*a21) / det;
- obj->array[0][1] = -(a01*a22 - a02*a21) / det;
- obj->array[0][2] = +(a01*a12 - a02*a11) / det;
- obj->array[1][0] = -(a10*a22 - a12*a20) / det;
- obj->array[1][1] = +(a00*a22 - a02*a20) / det;
- obj->array[1][2] = -(a00*a12 - a02*a10) / det;
- obj->array[2][0] = +(a10*a21 - a11*a20) / det;
- obj->array[2][1] = -(a00*a21 - a01*a20) / det;
- obj->array[2][2] = +(a00*a11 - a01*a10) / det;
+ obj->array[0*obj->nRows+0] = +(a11*a22 - a12*a21) / det;
+ obj->array[0*obj->nRows+1] = -(a01*a22 - a02*a21) / det;
+ obj->array[0*obj->nRows+2] = +(a01*a12 - a02*a11) / det;
+ obj->array[1*obj->nRows+0] = -(a10*a22 - a12*a20) / det;
+ obj->array[1*obj->nRows+1] = +(a00*a22 - a02*a20) / det;
+ obj->array[1*obj->nRows+2] = -(a00*a12 - a02*a10) / det;
+ obj->array[2*obj->nRows+0] = +(a10*a21 - a11*a20) / det;
+ obj->array[2*obj->nRows+1] = -(a00*a21 - a01*a20) / det;
+ obj->array[2*obj->nRows+2] = +(a00*a11 - a01*a10) / det;
}
if ((obj->nRows == 3) && (obj->nCols == 3)) {
- a00 = obj->array[0][0];
- a01 = obj->array[0][1];
- a10 = obj->array[1][0];
- a11 = obj->array[1][1];
+ a00 = obj->array[0*obj->nRows+0];
+ a01 = obj->array[0*obj->nRows+1];
+ a10 = obj->array[1*obj->nRows+0];
+ a11 = obj->array[1*obj->nRows+1];
det = a00*a11 - a01*a10;
if ((obj->nRows == 3) && (obj->nCols == 3)) {
- a00 = obj->array[0][0];
- a01 = obj->array[0][1];
- a02 = obj->array[0][2];
- a10 = obj->array[1][0];
- a11 = obj->array[1][1];
- a12 = obj->array[1][2];
- a20 = obj->array[2][0];
- a21 = obj->array[2][1];
- a22 = obj->array[2][2];
+ a00 = obj->array[0*obj->nRows+0];
+ a01 = obj->array[0*obj->nRows+1];
+ a02 = obj->array[0*obj->nRows+2];
+ a10 = obj->array[1*obj->nRows+0];
+ a11 = obj->array[1*obj->nRows+1];
+ a12 = obj->array[1*obj->nRows+2];
+ a20 = obj->array[2*obj->nRows+0];
+ a21 = obj->array[2*obj->nRows+1];
+ a22 = obj->array[2*obj->nRows+2];
det = a00*a11*a22 - a00*a12*a21 - a01*a10*a22 + a01*a12*a20 + a02*a10*a21 - a02*a11*a20;
for (iCol = 0; iCol < src->nCols; iCol++) {
- obj->array[iRow][iCol] = scale * src->array[iRow][iCol];
+ obj->array[iRow*obj->nCols+iCol] = scale * src->array[iRow*src->nCols+iCol];
}
for (iCol = 0; iCol < obj->nCols; iCol++) {
- printf("%+1.5f ",obj->array[iRow][iCol]);
+ printf("%+1.5f ",obj->array[iRow*obj->nCols+iCol]);
}
-#ifndef __ODAS_SIGNAL_MATRIX
-#define __ODAS_SIGNAL_MATRIX
+#ifndef __ODAS_UTILS_MATRIX
+#define __ODAS_UTILS_MATRIX
#include <stdlib.h>
#include <stdio.h>
+ #include <string.h>
+ #include <math.h>
//! Matrix
typedef struct matrix_obj {
- float ** array; ///< Array of elements in the matrix.
+ float * array; ///< Array of elements in the matrix.
unsigned int nRows; ///< Number of rows.
unsigned int nCols; ///< Number of columns.