From: FrancoisGrondin Date: Wed, 23 Aug 2017 23:04:37 +0000 (-0400) Subject: Separation and post-filtering updated. Now the separated soundstream can be written... X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=c01a3ce96d2fb9705a8b72b592297607465f1315;p=yn%2Fyn-odas.git Separation and post-filtering updated. Now the separated soundstream can be written back to a file. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cc02fc..f0d9d08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ set(SRC src/signal/beampattern.c src/signal/coherence.c src/signal/delta.c + src/signal/env.c src/signal/frame.c src/signal/freq.c src/signal/gain.c @@ -57,10 +58,10 @@ set(SRC src/signal/postprob.c src/signal/pot.c src/signal/scan.c - src/signal/shift.c src/signal/spatialgain.c src/signal/spatialindex.c src/signal/spatialmask.c + src/signal/steer.c src/signal/tau.c src/signal/tdoa.c src/signal/track.c @@ -71,6 +72,7 @@ set(SRC src/system/hop2hop.c src/system/hop2frame.c src/system/frame2freq.c + src/system/freq2env.c src/system/freq2freq.c src/system/freq2frame.c src/system/freq2xcorr.c @@ -81,9 +83,10 @@ set(SRC src/system/mixture2mixture.c src/system/particle2coherence.c src/system/particle2particle.c - src/system/shift2freq.c + src/system/steer2env.c + src/system/steer2freq.c src/system/track2gain.c - src/system/track2shift.c + src/system/track2steer.c src/system/xcorr2aimg.c src/system/xcorr2xcorr.c @@ -94,14 +97,17 @@ set(SRC src/utils/pcm.c src/utils/random.c + src/aconnector/acon_envs.c src/aconnector/acon_hops.c src/aconnector/acon_pots.c src/aconnector/acon_spectra.c src/aconnector/acon_tracks.c + src/amessage/amsg_envs.c src/amessage/amsg_hops.c src/amessage/amsg_pots.c src/amessage/amsg_spectra.c src/amessage/amsg_tracks.c + src/amodule/amod_gain.c src/amodule/amod_istft.c src/amodule/amod_mapping.c src/amodule/amod_resample.c @@ -117,15 +123,18 @@ set(SRC src/asource/asrc_hops.c src/asource/asrc_spectra.c + src/connector/con_envs.c src/connector/con_hops.c src/connector/con_pots.c src/connector/con_spectra.c src/connector/con_tracks.c + src/message/msg_envs.c src/message/msg_hops.c src/message/msg_pots.c src/message/msg_spectra.c src/message/msg_tracks.c src/message/msg_xcorrs.c + src/module/mod_gain.c src/module/mod_istft.c src/module/mod_mapping.c src/module/mod_resample.c @@ -173,3 +182,10 @@ target_link_libraries(core add_executable(server demo/server.c ) + +add_executable(debug + demo/debug.c +) +target_link_libraries(debug + odas +) \ No newline at end of file diff --git a/config/interfaces.ios b/config/interfaces.ios index 78d6cea..28b5ac3 100644 --- a/config/interfaces.ios +++ b/config/interfaces.ios @@ -3,7 +3,7 @@ input: { - raw: { type = "file"; path = "in.raw"; format = "bin16"; } + raw: { type = "file"; path = "meeting_recorded_raw_16.raw"; format = "bin16"; } #raw: { type = "soundcard"; card = 3; device = 0; format = "bin16"; } }; @@ -38,22 +38,34 @@ output: ssl: ( - { type = "file"; path = "potential.bin"; format = "float"; } +# { type = "file"; path = "potential.bin"; format = "float"; }, +# { type = "socket"; ip = "10.51.80.27"; port = 5000; format = "json"; } ); sst: ( - { type = "file"; path = "tracked.bin"; format = "float"; } +# { type = "file"; path = "tracked.bin"; format = "float"; } +# { type = "socket"; ip = "10.51.80.27"; port = 5000; format = "json"; } ); sss: ( - { type = "file"; path = "separated_stft.bin"; format = "float"; } +# { type = "file"; path = "separated_stft.bin"; format = "float"; } ); sspf: ( - { type = "file"; path = "postfiltered_stft.bin"; format = "float"; } +# { type = "file"; path = "postfiltered_stft.bin"; format = "float"; } ); + istft: + ( +# { type = "file"; path = "separated_16.raw"; format = "bin16"; } + ) + + playback: + ( + { type = "file"; path = "playback_16.raw"; format = "bin16"; } + ) + } \ No newline at end of file diff --git a/config/xmos.cfg b/config/xmos.cfg index c79510e..f4e6f02 100644 --- a/config/xmos.cfg +++ b/config/xmos.cfg @@ -7,7 +7,7 @@ version = "2.0"; raw: { - fS = 44100; + fS = 48000; hopSize = 512; nChannels = 8; @@ -152,11 +152,11 @@ sst: # Parameters used by both the Kalman and particle filter active = ( - { weight = 1.0; mu = 0.1; sigma2 = 0.0001 } + { weight = 1.0; mu = 0.3; sigma2 = 0.0025 } ); inactive = ( - { weight = 1.0; mu = 0.07; sigma2 = 0.0001 } + { weight = 1.0; mu = 0.15; sigma2 = 0.0025 } ); sigmaR2_prob = 0.0025; @@ -175,7 +175,7 @@ sst: kalman: { - sigmaQ = 0.01; + sigmaQ = 0.001; } @@ -212,7 +212,16 @@ sss: { sspf: { - nThetas = 181; - gainMin = 0.01; + alpha = 10.0; + beta = 0.95; + Ginterf = 0.01; + +} + +# Playback of separated streams + +playback: { + + volume = 10.0; } \ No newline at end of file diff --git a/demo/configs.c b/demo/configs.c index 87ec20c..3124a6d 100644 --- a/demo/configs.c +++ b/demo/configs.c @@ -32,7 +32,9 @@ cfgs->snk_hops_raw_configs = (snk_hops_cfg **) malloc(sizeof(snk_hops_cfg *) * cfgs->snk_hops_raw_config_count); for (iSink = 0; iSink < cfgs->snk_hops_raw_config_count; iSink++) { + cfgs->snk_hops_raw_configs[iSink] = parameters_snk_hops_raw_config(file_config, file_ios, iSink); + } // +----------------------------------------------------------+ @@ -59,7 +61,9 @@ cfgs->snk_hops_mapping_configs = (snk_hops_cfg **) malloc(sizeof(snk_hops_cfg *) * cfgs->snk_hops_mapping_config_count); for (iSink = 0; iSink < cfgs->snk_hops_mapping_config_count; iSink++) { + cfgs->snk_hops_mapping_configs[iSink] = parameters_snk_hops_mapping_config(file_config, file_ios, iSink); + } // +----------------------------------------------------------+ @@ -86,7 +90,9 @@ cfgs->snk_hops_resample_configs = (snk_hops_cfg **) malloc(sizeof(snk_hops_cfg *) * cfgs->snk_hops_resample_config_count); for (iSink = 0; iSink < cfgs->snk_hops_resample_config_count; iSink++) { + cfgs->snk_hops_resample_configs[iSink] = parameters_snk_hops_resample_config(file_config, file_ios, iSink); + } // +----------------------------------------------------------+ @@ -113,7 +119,9 @@ cfgs->snk_spectra_stft_configs = (snk_spectra_cfg **) malloc(sizeof(snk_spectra_cfg *) * cfgs->snk_spectra_stft_config_count); for (iSink = 0; iSink < cfgs->snk_spectra_stft_config_count; iSink++) { + cfgs->snk_spectra_stft_configs[iSink] = parameters_snk_spectra_stft_config(file_config, file_ios, iSink); + } // +----------------------------------------------------------+ @@ -140,7 +148,9 @@ cfgs->snk_pots_ssl_configs = (snk_pots_cfg **) malloc(sizeof(snk_pots_cfg *) * cfgs->snk_pots_ssl_config_count); for (iSink = 0; iSink < cfgs->snk_pots_ssl_config_count; iSink++) { + cfgs->snk_pots_ssl_configs[iSink] = parameters_snk_pots_ssl_config(file_config, file_ios, iSink); + } // +----------------------------------------------------------+ @@ -167,7 +177,9 @@ cfgs->snk_tracks_sst_configs = (snk_tracks_cfg **) malloc(sizeof(snk_tracks_cfg *) * cfgs->snk_tracks_sst_config_count); for (iSink = 0; iSink < cfgs->snk_tracks_sst_config_count; iSink++) { + cfgs->snk_tracks_sst_configs[iSink] = parameters_snk_tracks_sst_config(file_config, file_ios, iSink); + } // +----------------------------------------------------------+ @@ -185,6 +197,7 @@ // +------------------------------------------------------+ 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 | @@ -194,7 +207,9 @@ 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); + } // +----------------------------------------------------------+ @@ -221,9 +236,69 @@ 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); + + } + + + // +----------------------------------------------------------+ + // | ISTFT | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | 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); + + // +------------------------------------------------------+ + // | 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 | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Module | + // +------------------------------------------------------+ + + cfgs->mod_gain_config = parameters_mod_gain_config(file_config, file_ios); + + // +------------------------------------------------------+ + // | Message | + // +------------------------------------------------------+ + + cfgs->msg_hops_gain_config = parameters_msg_hops_gain_config(file_config, file_ios); + + // +------------------------------------------------------+ + // | 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); + + 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; @@ -254,8 +329,11 @@ // +------------------------------------------------------+ for (iSink = 0; iSink < cfgs->snk_hops_raw_config_count; iSink++) { + snk_hops_cfg_destroy(cfgs->snk_hops_raw_configs[iSink]); + } + free((void *) cfgs->snk_hops_raw_configs); // +----------------------------------------------------------+ @@ -279,8 +357,11 @@ // +------------------------------------------------------+ for (iSink = 0; iSink < cfgs->snk_hops_mapping_config_count; iSink++) { + snk_hops_cfg_destroy(cfgs->snk_hops_mapping_configs[iSink]); + } + free((void *) cfgs->snk_hops_mapping_configs); // +----------------------------------------------------------+ @@ -304,8 +385,11 @@ // +------------------------------------------------------+ for (iSink = 0; iSink < cfgs->snk_hops_resample_config_count; iSink++) { + snk_hops_cfg_destroy(cfgs->snk_hops_resample_configs[iSink]); + } + free((void *) cfgs->snk_hops_resample_configs); // +----------------------------------------------------------+ @@ -329,8 +413,11 @@ // +------------------------------------------------------+ for (iSink = 0; iSink < cfgs->snk_spectra_stft_config_count; iSink++) { + snk_spectra_cfg_destroy(cfgs->snk_spectra_stft_configs[iSink]); + } + free((void *) cfgs->snk_spectra_stft_configs); // +----------------------------------------------------------+ @@ -354,8 +441,11 @@ // +------------------------------------------------------+ for (iSink = 0; iSink < cfgs->snk_pots_ssl_config_count; iSink++) { + snk_pots_cfg_destroy(cfgs->snk_pots_ssl_configs[iSink]); + } + free((void *) cfgs->snk_pots_ssl_configs); // +----------------------------------------------------------+ @@ -379,8 +469,11 @@ // +------------------------------------------------------+ for (iSink = 0; iSink < cfgs->snk_tracks_sst_config_count; iSink++) { + snk_tracks_cfg_destroy(cfgs->snk_tracks_sst_configs[iSink]); + } + free((void *) cfgs->snk_tracks_sst_configs); // +----------------------------------------------------------+ @@ -398,14 +491,18 @@ // +------------------------------------------------------+ 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); // +----------------------------------------------------------+ @@ -429,10 +526,69 @@ // +------------------------------------------------------+ 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 | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | 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); + + // +----------------------------------------------------------+ + // | Gain | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Module | + // +------------------------------------------------------+ + + mod_gain_cfg_destroy(cfgs->mod_gain_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]); + + } + + free((void *) cfgs->snk_hops_gain_configs); + free((void *) cfgs); } diff --git a/demo/configs.h b/demo/configs.h index 35d29da..45eaeca 100644 --- a/demo/configs.h +++ b/demo/configs.h @@ -40,6 +40,7 @@ mod_sss_cfg * mod_sss_config; msg_spectra_cfg * msg_spectra_sss_config; + msg_envs_cfg * msg_envs_sss_config; unsigned int snk_spectra_sss_config_count; snk_spectra_cfg ** snk_spectra_sss_configs; @@ -48,6 +49,16 @@ unsigned int snk_spectra_sspf_config_count; snk_spectra_cfg ** snk_spectra_sspf_configs; + mod_istft_cfg * mod_istft_config; + msg_hops_cfg * msg_hops_istft_config; + unsigned int snk_hops_istft_config_count; + snk_hops_cfg ** snk_hops_istft_configs; + + mod_gain_cfg * mod_gain_config; + msg_hops_cfg * msg_hops_gain_config; + unsigned int snk_hops_gain_config_count; + snk_hops_cfg ** snk_hops_gain_configs; + } configs; configs * configs_construct(const char * file_config, const char * file_ios); diff --git a/demo/debug.c b/demo/debug.c new file mode 100644 index 0000000..fb4b120 --- /dev/null +++ b/demo/debug.c @@ -0,0 +1,13 @@ + #include + #include + #include + + #include + + int main(int argc, char* argv[]) + { + + + return 0; + + } \ No newline at end of file diff --git a/demo/objects.c b/demo/objects.c index 156c1af..bba4c0c 100644 --- a/demo/objects.c +++ b/demo/objects.c @@ -20,7 +20,8 @@ // | Source | // +--------------------------------------------------+ - objs->src_hops_raw_object = src_hops_construct(cfgs->src_hops_raw_config, cfgs->msg_hops_raw_config); + objs->src_hops_raw_object = src_hops_construct(cfgs->src_hops_raw_config, + cfgs->msg_hops_raw_config); // +--------------------------------------------------+ // | Message | @@ -36,7 +37,10 @@ objs->snk_hops_raw_objects = (snk_hops_obj **) malloc(sizeof(snk_hops_obj *) * cfgs->snk_hops_raw_config_count); for (iSink = 0; iSink < objs->snk_hops_raw_object_count; iSink++) { - objs->snk_hops_raw_objects[iSink] = snk_hops_construct(cfgs->snk_hops_raw_configs[iSink], cfgs->msg_hops_raw_config); + + objs->snk_hops_raw_objects[iSink] = snk_hops_construct(cfgs->snk_hops_raw_configs[iSink], + cfgs->msg_hops_raw_config); + } // +------------------------------------------------------+ @@ -47,7 +51,8 @@ // | Module | // +--------------------------------------------------+ - objs->mod_mapping_object = mod_mapping_construct(cfgs->mod_mapping_config, cfgs->msg_hops_mapping_config); + objs->mod_mapping_object = mod_mapping_construct(cfgs->mod_mapping_config, + cfgs->msg_hops_mapping_config); // +--------------------------------------------------+ // | Message | @@ -63,7 +68,10 @@ objs->snk_hops_mapping_objects = (snk_hops_obj **) malloc(sizeof(snk_hops_obj *) * cfgs->snk_hops_mapping_config_count); for (iSink = 0; iSink < objs->snk_hops_mapping_object_count; iSink++) { - objs->snk_hops_mapping_objects[iSink] = snk_hops_construct(cfgs->snk_hops_mapping_configs[iSink], cfgs->msg_hops_mapping_config); + + objs->snk_hops_mapping_objects[iSink] = snk_hops_construct(cfgs->snk_hops_mapping_configs[iSink], + cfgs->msg_hops_mapping_config); + } // +------------------------------------------------------+ @@ -74,7 +82,9 @@ // | Module | // +--------------------------------------------------+ - objs->mod_resample_object = mod_resample_construct(cfgs->mod_resample_config, cfgs->msg_hops_mapping_config, cfgs->msg_hops_resample_config); + objs->mod_resample_object = mod_resample_construct(cfgs->mod_resample_config, + cfgs->msg_hops_mapping_config, + cfgs->msg_hops_resample_config); // +--------------------------------------------------+ // | Message | @@ -90,7 +100,10 @@ objs->snk_hops_resample_objects = (snk_hops_obj **) malloc(sizeof(asnk_hops_obj *) * cfgs->snk_hops_resample_config_count); for (iSink = 0; iSink < objs->snk_hops_resample_object_count; iSink++) { - objs->snk_hops_resample_objects[iSink] = snk_hops_construct(cfgs->snk_hops_resample_configs[iSink], cfgs->msg_hops_resample_config); + + objs->snk_hops_resample_objects[iSink] = snk_hops_construct(cfgs->snk_hops_resample_configs[iSink], + cfgs->msg_hops_resample_config); + } // +------------------------------------------------------+ @@ -101,7 +114,9 @@ // | Module | // +--------------------------------------------------+ - objs->mod_stft_object = mod_stft_construct(cfgs->mod_stft_config, cfgs->msg_hops_resample_config, cfgs->msg_spectra_stft_config); + objs->mod_stft_object = mod_stft_construct(cfgs->mod_stft_config, + cfgs->msg_hops_resample_config, + cfgs->msg_spectra_stft_config); // +--------------------------------------------------+ // | Message | @@ -117,7 +132,10 @@ objs->snk_spectra_stft_objects = (snk_spectra_obj **) malloc(sizeof(snk_spectra_obj *) * cfgs->snk_spectra_stft_config_count); for (iSink = 0; iSink < objs->snk_spectra_stft_object_count; iSink++) { - objs->snk_spectra_stft_objects[iSink] = snk_spectra_construct(cfgs->snk_spectra_stft_configs[iSink], cfgs->msg_spectra_stft_config); + + objs->snk_spectra_stft_objects[iSink] = snk_spectra_construct(cfgs->snk_spectra_stft_configs[iSink], + cfgs->msg_spectra_stft_config); + } // +------------------------------------------------------+ @@ -128,7 +146,9 @@ // | Module | // +--------------------------------------------------+ - objs->mod_ssl_object = mod_ssl_construct(cfgs->mod_ssl_config, cfgs->msg_spectra_stft_config, cfgs->msg_pots_ssl_config); + objs->mod_ssl_object = mod_ssl_construct(cfgs->mod_ssl_config, + cfgs->msg_spectra_stft_config, + cfgs->msg_pots_ssl_config); // +--------------------------------------------------+ // | Message | @@ -144,7 +164,10 @@ objs->snk_pots_ssl_objects = (snk_pots_obj **) malloc(sizeof(snk_pots_obj *) * cfgs->snk_pots_ssl_config_count); for (iSink = 0; iSink < objs->snk_pots_ssl_object_count; iSink++) { - objs->snk_pots_ssl_objects[iSink] = snk_pots_construct(cfgs->snk_pots_ssl_configs[iSink], cfgs->msg_pots_ssl_config); + + objs->snk_pots_ssl_objects[iSink] = snk_pots_construct(cfgs->snk_pots_ssl_configs[iSink], + cfgs->msg_pots_ssl_config); + } // +------------------------------------------------------+ @@ -155,7 +178,10 @@ // | Module | // +--------------------------------------------------+ - objs->mod_sst_object = mod_sst_construct(cfgs->mod_sst_config, cfgs->mod_ssl_config, cfgs->msg_pots_ssl_config, cfgs->msg_tracks_sst_config); + objs->mod_sst_object = mod_sst_construct(cfgs->mod_sst_config, + cfgs->mod_ssl_config, + cfgs->msg_pots_ssl_config, + cfgs->msg_tracks_sst_config); // +--------------------------------------------------+ // | Message | @@ -171,7 +197,10 @@ objs->snk_tracks_sst_objects = (snk_tracks_obj **) malloc(sizeof(snk_tracks_obj *) * cfgs->snk_tracks_sst_config_count); for (iSink = 0; iSink < objs->snk_tracks_sst_object_count; iSink++) { - objs->snk_tracks_sst_objects[iSink] = snk_tracks_construct(cfgs->snk_tracks_sst_configs[iSink], cfgs->msg_tracks_sst_config); + + objs->snk_tracks_sst_objects[iSink] = snk_tracks_construct(cfgs->snk_tracks_sst_configs[iSink], + cfgs->msg_tracks_sst_config); + } // +------------------------------------------------------+ @@ -182,7 +211,10 @@ // | Module | // +--------------------------------------------------+ - objs->mod_sss_object = mod_sss_construct(cfgs->mod_sss_config, cfgs->msg_spectra_sss_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_sss_config, + cfgs->msg_envs_sss_config); // +--------------------------------------------------+ // | Message | @@ -198,7 +230,10 @@ objs->snk_spectra_sss_objects = (snk_spectra_obj **) malloc(sizeof(snk_spectra_obj *) * cfgs->snk_spectra_sss_config_count); for (iSink = 0; iSink < objs->snk_spectra_sss_object_count; iSink++) { - objs->snk_spectra_sss_objects[iSink] = snk_spectra_construct(cfgs->snk_spectra_sss_configs[iSink], cfgs->msg_spectra_sss_config); + + objs->snk_spectra_sss_objects[iSink] = snk_spectra_construct(cfgs->snk_spectra_sss_configs[iSink], + cfgs->msg_spectra_sss_config); + } // +------------------------------------------------------+ @@ -209,7 +244,10 @@ // | Module | // +--------------------------------------------------+ - objs->mod_sspf_object = mod_sspf_construct(cfgs->mod_sspf_config, cfgs->msg_spectra_sspf_config, cfgs->msg_tracks_sst_config); + objs->mod_sspf_object = mod_sspf_construct(cfgs->mod_sspf_config, + cfgs->msg_tracks_sst_config, + cfgs->msg_spectra_sspf_config, + cfgs->msg_envs_sss_config); // +--------------------------------------------------+ // | Message | @@ -225,21 +263,164 @@ objs->snk_spectra_sspf_objects = (snk_spectra_obj **) malloc(sizeof(snk_spectra_obj *) * cfgs->snk_spectra_sspf_config_count); for (iSink = 0; iSink < objs->snk_spectra_sspf_object_count; iSink++) { - objs->snk_spectra_sspf_objects[iSink] = snk_spectra_construct(cfgs->snk_spectra_sspf_configs[iSink], cfgs->msg_spectra_sspf_config); + + objs->snk_spectra_sspf_objects[iSink] = snk_spectra_construct(cfgs->snk_spectra_sspf_configs[iSink], + cfgs->msg_spectra_sspf_config); + + } + + // +------------------------------------------------------+ + // | ISTFT | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + objs->mod_istft_object = mod_istft_construct(cfgs->mod_istft_config, + cfgs->msg_spectra_sspf_config, + cfgs->msg_hops_istft_config); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + objs->msg_hops_istft_object = msg_hops_construct(cfgs->msg_hops_istft_config); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + objs->snk_hops_istft_object_count = cfgs->snk_hops_istft_config_count; + objs->snk_hops_istft_objects = (snk_hops_obj **) malloc(sizeof(snk_hops_obj *) * cfgs->snk_hops_istft_config_count); + + for (iSink = 0; iSink < objs->snk_hops_istft_object_count; iSink++) { + + objs->snk_hops_istft_objects[iSink] = snk_hops_construct(cfgs->snk_hops_istft_configs[iSink], + cfgs->msg_hops_istft_config); + + } + + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + objs->mod_gain_object = mod_gain_construct(cfgs->mod_gain_config, + cfgs->msg_hops_gain_config); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + objs->msg_hops_gain_object = msg_hops_construct(cfgs->msg_hops_gain_config); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + objs->snk_hops_gain_object_count = cfgs->snk_hops_gain_config_count; + objs->snk_hops_gain_objects = (snk_hops_obj **) malloc(sizeof(snk_hops_obj *) * cfgs->snk_hops_gain_config_count); + + for (iSink = 0; iSink < objs->snk_hops_gain_object_count; iSink++) { + + objs->snk_hops_gain_objects[iSink] = snk_hops_construct(cfgs->snk_hops_gain_configs[iSink], + cfgs->msg_hops_gain_config); + } // +----------------------------------------------------------+ // | Connect | // +----------------------------------------------------------+ - objs->con_hops_raw_object = con_hops_construct(objs->snk_hops_raw_object_count+1, cfgs->msg_hops_raw_config); - objs->con_hops_mapping_object = con_hops_construct(objs->snk_hops_mapping_object_count+1, cfgs->msg_hops_mapping_config); - objs->con_hops_resample_object = con_hops_construct(objs->snk_hops_resample_object_count+1, cfgs->msg_hops_resample_config); - objs->con_spectra_stft_object = con_spectra_construct(objs->snk_spectra_stft_object_count+3, cfgs->msg_spectra_stft_config); - objs->con_pots_ssl_object = con_pots_construct(objs->snk_pots_ssl_object_count+1, cfgs->msg_pots_ssl_config); - objs->con_tracks_sst_object = con_tracks_construct(objs->snk_tracks_sst_object_count+2, cfgs->msg_tracks_sst_config); - objs->con_spectra_sss_object = con_spectra_construct(objs->snk_spectra_sss_object_count+1, cfgs->msg_spectra_sss_config); - objs->con_spectra_sspf_object = con_spectra_construct(objs->snk_spectra_sspf_object_count, cfgs->msg_spectra_sspf_config); + // Hops ....... Raw ........ (0): Mapping Hops + // ........ (1): Sink 1 + // ........ (2): Sink 2 + // etc. + // + // Hops ....... Mapping .... (0): Resample Hops + // .... (1): Sink 1 + // .... (2): Sink 2 + // etc. + // + // Hops ....... Resample ... (0): STFT Hops + // ... (1): Sink 1 + // ... (2): Sink 2 + // etc. + // + // Spectra .... STFT ....... (0): SSL + // ....... (1): SSS + // ....... (2): Sink 1 + // ....... (3): Sink 2 + // etc. + // + // Pots ....... SSL ........ (0): SST + // ........ (1): Sink 1 + // ........ (2): Sink 2 + // etc. + // + // Tracks ..... SST ........ (0): SSS + // ........ (1): SSPF + // ........ (2): Sink 1 + // ........ (3): Sink 2 + // etc. + // + // Spectra .... SSS ........ (0): SSPF + // ........ (1): Sink 1 + // ........ (2): Sink 2 + // etc. + // + // Envs ....... SSS ........ (0): SSPF + // + // Spectra .... SSPF ....... (0): ISTFT + // ....... (1): Sink 1 + // ....... (2): Sink 2 + // etc. + // + // Hops ....... ISTFT ...... (0): Gain + // ...... (1): Sink 1 + // ...... (2): Sink 2 + // etc. + // + // Hops ....... Gain ....... (0): Sink 1 + // ....... (1): Sink 2 + // etc. + + objs->con_hops_raw_object = con_hops_construct(objs->snk_hops_raw_object_count + 1, + cfgs->msg_hops_raw_config); + + objs->con_hops_mapping_object = con_hops_construct(objs->snk_hops_mapping_object_count + 1, + cfgs->msg_hops_mapping_config); + + objs->con_hops_resample_object = con_hops_construct(objs->snk_hops_resample_object_count + 1, + cfgs->msg_hops_resample_config); + + objs->con_spectra_stft_object = con_spectra_construct(objs->snk_spectra_stft_object_count + 2, + cfgs->msg_spectra_stft_config); + + objs->con_pots_ssl_object = con_pots_construct(objs->snk_pots_ssl_object_count + 1, + cfgs->msg_pots_ssl_config); + + objs->con_tracks_sst_object = con_tracks_construct(objs->snk_tracks_sst_object_count + 2, + cfgs->msg_tracks_sst_config); + + objs->con_spectra_sss_object = con_spectra_construct(objs->snk_spectra_sss_object_count + 1, + cfgs->msg_spectra_sss_config); + + objs->con_envs_sss_object = con_envs_construct(1, + cfgs->msg_envs_sss_config); + + objs->con_spectra_sspf_object = con_spectra_construct(objs->snk_spectra_sspf_object_count + 1, + cfgs->msg_spectra_sspf_config); + + objs->con_hops_istft_object = con_hops_construct(objs->snk_hops_istft_object_count + 1, + cfgs->msg_hops_istft_config); + + objs->con_hops_gain_object = con_hops_construct(objs->snk_hops_gain_object_count, + cfgs->msg_hops_gain_config); // +------------------------------------------------------+ // | Raw | @@ -259,7 +440,7 @@ for (iSink = 0; iSink < objs->snk_hops_raw_object_count; iSink++) { snk_hops_connect(objs->snk_hops_raw_objects[iSink], - objs->con_hops_raw_object->outs[iSink+1]); + objs->con_hops_raw_object->outs[iSink + 1]); } @@ -282,7 +463,7 @@ for (iSink = 0; iSink < objs->snk_hops_mapping_object_count; iSink++) { snk_hops_connect(objs->snk_hops_mapping_objects[iSink], - objs->con_hops_mapping_object->outs[iSink+1]); + objs->con_hops_mapping_object->outs[iSink + 1]); } @@ -305,7 +486,7 @@ for (iSink = 0; iSink < objs->snk_hops_resample_object_count; iSink++) { snk_hops_connect(objs->snk_hops_resample_objects[iSink], - objs->con_hops_resample_object->outs[iSink+1]); + objs->con_hops_resample_object->outs[iSink + 1]); } @@ -328,7 +509,7 @@ for (iSink = 0; iSink < objs->snk_spectra_stft_object_count; iSink++) { snk_spectra_connect(objs->snk_spectra_stft_objects[iSink], - objs->con_spectra_stft_object->outs[iSink+3]); + objs->con_spectra_stft_object->outs[iSink + 2]); } @@ -351,7 +532,7 @@ for (iSink = 0; iSink < objs->snk_pots_ssl_object_count; iSink++) { snk_pots_connect(objs->snk_pots_ssl_objects[iSink], - objs->con_pots_ssl_object->outs[iSink+1]); + objs->con_pots_ssl_object->outs[iSink + 1]); } @@ -374,7 +555,7 @@ for (iSink = 0; iSink < objs->snk_tracks_sst_object_count; iSink++) { snk_tracks_connect(objs->snk_tracks_sst_objects[iSink], - objs->con_tracks_sst_object->outs[iSink+2]); + objs->con_tracks_sst_object->outs[iSink + 2]); } @@ -389,7 +570,8 @@ mod_sss_connect(objs->mod_sss_object, objs->con_spectra_stft_object->outs[1], objs->con_tracks_sst_object->outs[0], - objs->con_spectra_sss_object->in); + objs->con_spectra_sss_object->in, + objs->con_envs_sss_object->in); // +--------------------------------------------------+ // | Sinks | @@ -398,7 +580,7 @@ for (iSink = 0; iSink < objs->snk_spectra_sss_object_count; iSink++) { snk_spectra_connect(objs->snk_spectra_sss_objects[iSink], - objs->con_spectra_sss_object->outs[iSink+1]); + objs->con_spectra_sss_object->outs[iSink + 1]); } @@ -411,8 +593,8 @@ // +--------------------------------------------------+ mod_sspf_connect(objs->mod_sspf_object, - objs->con_spectra_stft_object->outs[2], objs->con_spectra_sss_object->outs[0], + objs->con_envs_sss_object->outs[0], objs->con_tracks_sst_object->outs[1], objs->con_spectra_sspf_object->in); @@ -423,10 +605,56 @@ for (iSink = 0; iSink < objs->snk_spectra_sspf_object_count; iSink++) { snk_spectra_connect(objs->snk_spectra_sspf_objects[iSink], - objs->con_spectra_sspf_object->outs[iSink]); + objs->con_spectra_sspf_object->outs[iSink + 1]); } + // +------------------------------------------------------+ + // | ISTFT | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + mod_istft_connect(objs->mod_istft_object, + objs->con_spectra_sspf_object->outs[0], + objs->con_hops_istft_object->in); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_istft_object_count; iSink++) { + + snk_hops_connect(objs->snk_hops_istft_objects[iSink], + objs->con_hops_istft_object->outs[iSink + 1]); + + } + + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + mod_gain_connect(objs->mod_gain_object, + objs->con_hops_istft_object->outs[0], + objs->con_hops_gain_object->in); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_gain_object_count; iSink++) { + + snk_hops_connect(objs->snk_hops_gain_objects[iSink], + objs->con_hops_gain_object->outs[iSink]); + + } + return objs; } @@ -460,8 +688,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_hops_raw_object_count; iSink++) { + snk_hops_destroy(objs->snk_hops_raw_objects[iSink]); + } + free((void *) objs->snk_hops_raw_objects); // +--------------------------------------------------+ @@ -491,8 +722,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_hops_mapping_object_count; iSink++) { + snk_hops_destroy(objs->snk_hops_mapping_objects[iSink]); + } + free((void *) objs->snk_hops_mapping_objects); // +--------------------------------------------------+ @@ -522,8 +756,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_hops_resample_object_count; iSink++) { + snk_hops_destroy(objs->snk_hops_resample_objects[iSink]); + } + free((void *) objs->snk_hops_resample_objects); // +--------------------------------------------------+ @@ -553,8 +790,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_spectra_stft_object_count; iSink++) { + snk_spectra_destroy(objs->snk_spectra_stft_objects[iSink]); + } + free((void *) objs->snk_spectra_stft_objects); // +--------------------------------------------------+ @@ -584,8 +824,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_pots_ssl_object_count; iSink++) { + snk_pots_destroy(objs->snk_pots_ssl_objects[iSink]); + } + free((void *) objs->snk_pots_ssl_objects); // +--------------------------------------------------+ @@ -615,8 +858,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_tracks_sst_object_count; iSink++) { + snk_tracks_destroy(objs->snk_tracks_sst_objects[iSink]); + } + free((void *) objs->snk_tracks_sst_objects); // +--------------------------------------------------+ @@ -646,8 +892,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_spectra_sss_object_count; iSink++) { + snk_spectra_destroy(objs->snk_spectra_sss_objects[iSink]); + } + free((void *) objs->snk_spectra_sss_objects); // +--------------------------------------------------+ @@ -655,6 +904,7 @@ // +--------------------------------------------------+ con_spectra_destroy(objs->con_spectra_sss_object); + con_envs_destroy(objs->con_envs_sss_object); // +------------------------------------------------------+ // | SSPF | @@ -677,8 +927,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->snk_spectra_sspf_object_count; iSink++) { + snk_spectra_destroy(objs->snk_spectra_sspf_objects[iSink]); + } + free((void *) objs->snk_spectra_sspf_objects); // +--------------------------------------------------+ @@ -687,6 +940,74 @@ con_spectra_destroy(objs->con_spectra_sspf_object); + // +------------------------------------------------------+ + // | ISTFT | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + mod_istft_destroy(objs->mod_istft_object); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + msg_hops_destroy(objs->msg_hops_istft_object); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_istft_object_count; iSink++) { + + snk_hops_destroy(objs->snk_hops_istft_objects[iSink]); + + } + + free((void *) objs->snk_hops_istft_objects); + + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ + + con_hops_destroy(objs->con_hops_istft_object); + + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + mod_gain_destroy(objs->mod_gain_object); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + msg_hops_destroy(objs->msg_hops_gain_object); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_gain_object_count; iSink++) { + + snk_hops_destroy(objs->snk_hops_gain_objects[iSink]); + + } + + free((void *) objs->snk_hops_gain_objects); + + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ + + con_hops_destroy(objs->con_hops_gain_object); + free((void *) objs); } @@ -712,13 +1033,15 @@ // | Source | // +--------------------------------------------------+ - objs->asrc_hops_raw_object = asrc_hops_construct(cfgs->src_hops_raw_config, cfgs->msg_hops_raw_config); + objs->asrc_hops_raw_object = asrc_hops_construct(cfgs->src_hops_raw_config, + cfgs->msg_hops_raw_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_hops_raw_object = amsg_hops_construct(objs->nMessages, cfgs->msg_hops_raw_config); + objs->amsg_hops_raw_object = amsg_hops_construct(objs->nMessages, + cfgs->msg_hops_raw_config); // +--------------------------------------------------+ // | Sinks | @@ -728,7 +1051,10 @@ objs->asnk_hops_raw_objects = (asnk_hops_obj **) malloc(sizeof(asnk_hops_obj *) * cfgs->snk_hops_raw_config_count); for (iSink = 0; iSink < objs->asnk_hops_raw_object_count; iSink++) { - objs->asnk_hops_raw_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_raw_configs[iSink], cfgs->msg_hops_raw_config); + + objs->asnk_hops_raw_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_raw_configs[iSink], + cfgs->msg_hops_raw_config); + } // +------------------------------------------------------+ @@ -739,13 +1065,15 @@ // | Module | // +--------------------------------------------------+ - objs->amod_mapping_object = amod_mapping_construct(cfgs->mod_mapping_config, cfgs->msg_hops_mapping_config); + objs->amod_mapping_object = amod_mapping_construct(cfgs->mod_mapping_config, + cfgs->msg_hops_mapping_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_hops_mapping_object = amsg_hops_construct(objs->nMessages, cfgs->msg_hops_mapping_config); + objs->amsg_hops_mapping_object = amsg_hops_construct(objs->nMessages, + cfgs->msg_hops_mapping_config); // +--------------------------------------------------+ // | Sinks | @@ -755,7 +1083,10 @@ objs->asnk_hops_mapping_objects = (asnk_hops_obj **) malloc(sizeof(asnk_hops_obj *) * cfgs->snk_hops_mapping_config_count); for (iSink = 0; iSink < objs->asnk_hops_mapping_object_count; iSink++) { - objs->asnk_hops_mapping_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_mapping_configs[iSink], cfgs->msg_hops_mapping_config); + + objs->asnk_hops_mapping_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_mapping_configs[iSink], + cfgs->msg_hops_mapping_config); + } // +------------------------------------------------------+ @@ -766,13 +1097,16 @@ // | Module | // +--------------------------------------------------+ - objs->amod_resample_object = amod_resample_construct(cfgs->mod_resample_config, cfgs->msg_hops_mapping_config, cfgs->msg_hops_resample_config); + objs->amod_resample_object = amod_resample_construct(cfgs->mod_resample_config, + cfgs->msg_hops_mapping_config, + cfgs->msg_hops_resample_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_hops_resample_object = amsg_hops_construct(objs->nMessages, cfgs->msg_hops_resample_config); + objs->amsg_hops_resample_object = amsg_hops_construct(objs->nMessages, + cfgs->msg_hops_resample_config); // +--------------------------------------------------+ // | Sinks | @@ -782,7 +1116,10 @@ objs->asnk_hops_resample_objects = (asnk_hops_obj **) malloc(sizeof(asnk_hops_obj *) * cfgs->snk_hops_resample_config_count); for (iSink = 0; iSink < objs->asnk_hops_resample_object_count; iSink++) { - objs->asnk_hops_resample_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_resample_configs[iSink], cfgs->msg_hops_resample_config); + + objs->asnk_hops_resample_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_resample_configs[iSink], + cfgs->msg_hops_resample_config); + } // +------------------------------------------------------+ @@ -793,13 +1130,16 @@ // | Module | // +--------------------------------------------------+ - objs->amod_stft_object = amod_stft_construct(cfgs->mod_stft_config, cfgs->msg_hops_resample_config, cfgs->msg_spectra_stft_config); + objs->amod_stft_object = amod_stft_construct(cfgs->mod_stft_config, + cfgs->msg_hops_resample_config, + cfgs->msg_spectra_stft_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_spectra_stft_object = amsg_spectra_construct(objs->nMessages, cfgs->msg_spectra_stft_config); + objs->amsg_spectra_stft_object = amsg_spectra_construct(objs->nMessages, + cfgs->msg_spectra_stft_config); // +--------------------------------------------------+ // | Sinks | @@ -809,7 +1149,10 @@ objs->asnk_spectra_stft_objects = (asnk_spectra_obj **) malloc(sizeof(asnk_spectra_obj *) * cfgs->snk_spectra_stft_config_count); for (iSink = 0; iSink < objs->asnk_spectra_stft_object_count; iSink++) { - objs->asnk_spectra_stft_objects[iSink] = asnk_spectra_construct(cfgs->snk_spectra_stft_configs[iSink], cfgs->msg_spectra_stft_config); + + objs->asnk_spectra_stft_objects[iSink] = asnk_spectra_construct(cfgs->snk_spectra_stft_configs[iSink], + cfgs->msg_spectra_stft_config); + } // +------------------------------------------------------+ @@ -820,13 +1163,16 @@ // | Module | // +--------------------------------------------------+ - objs->amod_ssl_object = amod_ssl_construct(cfgs->mod_ssl_config, cfgs->msg_spectra_stft_config, cfgs->msg_pots_ssl_config); + objs->amod_ssl_object = amod_ssl_construct(cfgs->mod_ssl_config, + cfgs->msg_spectra_stft_config, + cfgs->msg_pots_ssl_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_pots_ssl_object = amsg_pots_construct(objs->nMessages, cfgs->msg_pots_ssl_config); + objs->amsg_pots_ssl_object = amsg_pots_construct(objs->nMessages, + cfgs->msg_pots_ssl_config); // +--------------------------------------------------+ // | Sinks | @@ -836,7 +1182,10 @@ objs->asnk_pots_ssl_objects = (asnk_pots_obj **) malloc(sizeof(asnk_pots_obj *) * cfgs->snk_pots_ssl_config_count); for (iSink = 0; iSink < objs->asnk_pots_ssl_object_count; iSink++) { - objs->asnk_pots_ssl_objects[iSink] = asnk_pots_construct(cfgs->snk_pots_ssl_configs[iSink], cfgs->msg_pots_ssl_config); + + objs->asnk_pots_ssl_objects[iSink] = asnk_pots_construct(cfgs->snk_pots_ssl_configs[iSink], + cfgs->msg_pots_ssl_config); + } // +------------------------------------------------------+ @@ -847,13 +1196,17 @@ // | Module | // +--------------------------------------------------+ - objs->amod_sst_object = amod_sst_construct(cfgs->mod_sst_config, cfgs->mod_ssl_config, cfgs->msg_pots_ssl_config, cfgs->msg_tracks_sst_config); + objs->amod_sst_object = amod_sst_construct(cfgs->mod_sst_config, + cfgs->mod_ssl_config, + cfgs->msg_pots_ssl_config, + cfgs->msg_tracks_sst_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_tracks_sst_object = amsg_tracks_construct(objs->nMessages, cfgs->msg_tracks_sst_config); + objs->amsg_tracks_sst_object = amsg_tracks_construct(objs->nMessages, + cfgs->msg_tracks_sst_config); // +--------------------------------------------------+ // | Sinks | @@ -863,7 +1216,10 @@ objs->asnk_tracks_sst_objects = (asnk_tracks_obj **) malloc(sizeof(asnk_tracks_obj *) * cfgs->snk_tracks_sst_config_count); for (iSink = 0; iSink < objs->asnk_tracks_sst_object_count; iSink++) { - objs->asnk_tracks_sst_objects[iSink] = asnk_tracks_construct(cfgs->snk_tracks_sst_configs[iSink], cfgs->msg_tracks_sst_config); + + objs->asnk_tracks_sst_objects[iSink] = asnk_tracks_construct(cfgs->snk_tracks_sst_configs[iSink], + cfgs->msg_tracks_sst_config); + } // +------------------------------------------------------+ @@ -874,13 +1230,17 @@ // | Module | // +--------------------------------------------------+ - objs->amod_sss_object = amod_sss_construct(cfgs->mod_sss_config, cfgs->msg_spectra_sss_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_sss_config, + cfgs->msg_envs_sss_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_spectra_sss_object = amsg_spectra_construct(objs->nMessages, cfgs->msg_spectra_sss_config); + objs->amsg_spectra_sss_object = amsg_spectra_construct(objs->nMessages, + cfgs->msg_spectra_sss_config); // +--------------------------------------------------+ // | Sinks | @@ -890,7 +1250,10 @@ objs->asnk_spectra_sss_objects = (asnk_spectra_obj **) malloc(sizeof(asnk_spectra_obj *) * cfgs->snk_spectra_sss_config_count); for (iSink = 0; iSink < objs->asnk_spectra_sss_object_count; iSink++) { - objs->asnk_spectra_sss_objects[iSink] = asnk_spectra_construct(cfgs->snk_spectra_sss_configs[iSink], cfgs->msg_spectra_sss_config); + + objs->asnk_spectra_sss_objects[iSink] = asnk_spectra_construct(cfgs->snk_spectra_sss_configs[iSink], + cfgs->msg_spectra_sss_config); + } // +------------------------------------------------------+ @@ -901,13 +1264,17 @@ // | Module | // +--------------------------------------------------+ - objs->amod_sspf_object = amod_sspf_construct(cfgs->mod_sspf_config, cfgs->msg_spectra_sspf_config, cfgs->msg_tracks_sst_config); + objs->amod_sspf_object = amod_sspf_construct(cfgs->mod_sspf_config, + cfgs->msg_tracks_sst_config, + cfgs->msg_spectra_sspf_config, + cfgs->msg_envs_sss_config); // +--------------------------------------------------+ // | Message | // +--------------------------------------------------+ - objs->amsg_spectra_sspf_object = amsg_spectra_construct(objs->nMessages, cfgs->msg_spectra_sspf_config); + objs->amsg_spectra_sspf_object = amsg_spectra_construct(objs->nMessages, + cfgs->msg_spectra_sspf_config); // +--------------------------------------------------+ // | Sinks | @@ -917,21 +1284,178 @@ objs->asnk_spectra_sspf_objects = (asnk_spectra_obj **) malloc(sizeof(asnk_spectra_obj *) * cfgs->snk_spectra_sspf_config_count); for (iSink = 0; iSink < objs->asnk_spectra_sspf_object_count; iSink++) { - objs->asnk_spectra_sspf_objects[iSink] = asnk_spectra_construct(cfgs->snk_spectra_sspf_configs[iSink], cfgs->msg_spectra_sspf_config); + + objs->asnk_spectra_sspf_objects[iSink] = asnk_spectra_construct(cfgs->snk_spectra_sspf_configs[iSink], + cfgs->msg_spectra_sspf_config); + + } + + + // +------------------------------------------------------+ + // | ISTFT | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + objs->amod_istft_object = amod_istft_construct(cfgs->mod_istft_config, + cfgs->msg_spectra_sspf_config, + cfgs->msg_hops_istft_config); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + objs->amsg_hops_istft_object = amsg_hops_construct(objs->nMessages, + cfgs->msg_hops_istft_config); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + objs->asnk_hops_istft_object_count = cfgs->snk_hops_istft_config_count; + objs->asnk_hops_istft_objects = (asnk_hops_obj **) malloc(sizeof(asnk_hops_obj *) * cfgs->snk_hops_istft_config_count); + + for (iSink = 0; iSink < objs->asnk_hops_istft_object_count; iSink++) { + + objs->asnk_hops_istft_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_istft_configs[iSink], + cfgs->msg_hops_istft_config); + } + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + objs->amod_gain_object = amod_gain_construct(cfgs->mod_gain_config, + cfgs->msg_hops_gain_config); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + objs->amsg_hops_gain_object = amsg_hops_construct(objs->nMessages, + cfgs->msg_hops_gain_config); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + objs->asnk_hops_gain_object_count = cfgs->snk_hops_gain_config_count; + objs->asnk_hops_gain_objects = (asnk_hops_obj **) malloc(sizeof(asnk_hops_obj *) * cfgs->snk_hops_gain_config_count); + + for (iSink = 0; iSink < objs->asnk_hops_gain_object_count; iSink++) { + + objs->asnk_hops_gain_objects[iSink] = asnk_hops_construct(cfgs->snk_hops_gain_configs[iSink], + cfgs->msg_hops_gain_config); + + } + // +----------------------------------------------------------+ // | Connect | // +----------------------------------------------------------+ - objs->acon_hops_raw_object = acon_hops_construct(objs->asnk_hops_raw_object_count+1, objs->nMessages, cfgs->msg_hops_raw_config); - objs->acon_hops_mapping_object = acon_hops_construct(objs->asnk_hops_mapping_object_count+1, objs->nMessages, cfgs->msg_hops_mapping_config); - objs->acon_hops_resample_object = acon_hops_construct(objs->asnk_hops_resample_object_count+1, objs->nMessages, cfgs->msg_hops_resample_config); - objs->acon_spectra_stft_object = acon_spectra_construct(objs->asnk_spectra_stft_object_count+3, objs->nMessages, cfgs->msg_spectra_stft_config); - objs->acon_pots_ssl_object = acon_pots_construct(objs->asnk_pots_ssl_object_count+1, objs->nMessages, cfgs->msg_pots_ssl_config); - objs->acon_tracks_sst_object = acon_tracks_construct(objs->asnk_tracks_sst_object_count+2, objs->nMessages, cfgs->msg_tracks_sst_config); - objs->acon_spectra_sss_object = acon_spectra_construct(objs->asnk_spectra_sss_object_count+1, objs->nMessages, cfgs->msg_spectra_sss_config); - objs->acon_spectra_sspf_object = acon_spectra_construct(objs->asnk_spectra_sspf_object_count, objs->nMessages, cfgs->msg_spectra_sspf_config); + // Hops ....... Raw ........ (0): Mapping Hops + // ........ (1): Sink 1 + // ........ (2): Sink 2 + // etc. + // + // Hops ....... Mapping .... (0): Resample Hops + // .... (1): Sink 1 + // .... (2): Sink 2 + // etc. + // + // Hops ....... Resample ... (0): STFT Hops + // ... (1): Sink 1 + // ... (2): Sink 2 + // etc. + // + // Spectra .... STFT ....... (0): SSL + // ....... (1): SSS + // ....... (2): Sink 1 + // ....... (3): Sink 2 + // etc. + // + // Pots ....... SSL ........ (0): SST + // ........ (1): Sink 1 + // ........ (2): Sink 2 + // etc. + // + // Tracks ..... SST ........ (0): SSS + // ........ (1): SSPF + // ........ (2): Sink 1 + // ........ (3): Sink 2 + // etc. + // + // Spectra .... SSS ........ (0): SSPF + // ........ (1): Sink 1 + // ........ (2): Sink 2 + // etc. + // + // Envs ....... SSS ........ (0): SSPF + // + // Spectra .... SSPF ....... (0): ISTFT + // ....... (1): Sink 1 + // ....... (2): Sink 2 + // etc. + // + // Hops ...... ISTFT ....... (0): Gain + // ....... (1): Sink 1 + // ....... (2): Sink 2 + // etc. + // + // Hops ....... Gain ....... (0): Sink 1 + // ....... (1): Sink 2 + // etc. + + objs->acon_hops_raw_object = acon_hops_construct(objs->asnk_hops_raw_object_count + 1, + objs->nMessages, + cfgs->msg_hops_raw_config); + + objs->acon_hops_mapping_object = acon_hops_construct(objs->asnk_hops_mapping_object_count + 1, + objs->nMessages, + cfgs->msg_hops_mapping_config); + + objs->acon_hops_resample_object = acon_hops_construct(objs->asnk_hops_resample_object_count + 1, + objs->nMessages, + cfgs->msg_hops_resample_config); + + objs->acon_spectra_stft_object = acon_spectra_construct(objs->asnk_spectra_stft_object_count + 2, + objs->nMessages, + cfgs->msg_spectra_stft_config); + + objs->acon_pots_ssl_object = acon_pots_construct(objs->asnk_pots_ssl_object_count + 1, + objs->nMessages, + cfgs->msg_pots_ssl_config); + + objs->acon_tracks_sst_object = acon_tracks_construct(objs->asnk_tracks_sst_object_count + 2, + objs->nMessages, + cfgs->msg_tracks_sst_config); + + objs->acon_spectra_sss_object = acon_spectra_construct(objs->asnk_spectra_sss_object_count + 1, + objs->nMessages, + cfgs->msg_spectra_sss_config); + + objs->acon_envs_sss_object = acon_envs_construct(1, + objs->nMessages, + cfgs->msg_envs_sss_config); + + objs->acon_spectra_sspf_object = acon_spectra_construct(objs->asnk_spectra_sspf_object_count + 1, + objs->nMessages, + cfgs->msg_spectra_sspf_config); + + objs->acon_hops_istft_object = acon_hops_construct(objs->asnk_hops_istft_object_count + 1, + objs->nMessages, + cfgs->msg_hops_istft_config); + + objs->acon_hops_gain_object = acon_hops_construct(objs->asnk_hops_gain_object_count, + objs->nMessages, + cfgs->msg_hops_gain_config); // +------------------------------------------------------+ // | Raw | @@ -951,7 +1475,7 @@ for (iSink = 0; iSink < objs->asnk_hops_raw_object_count; iSink++) { asnk_hops_connect(objs->asnk_hops_raw_objects[iSink], - objs->acon_hops_raw_object->outs[iSink+1]); + objs->acon_hops_raw_object->outs[iSink + 1]); } @@ -974,7 +1498,7 @@ for (iSink = 0; iSink < objs->asnk_hops_mapping_object_count; iSink++) { asnk_hops_connect(objs->asnk_hops_mapping_objects[iSink], - objs->acon_hops_mapping_object->outs[iSink+1]); + objs->acon_hops_mapping_object->outs[iSink + 1]); } @@ -997,7 +1521,7 @@ for (iSink = 0; iSink < objs->asnk_hops_resample_object_count; iSink++) { asnk_hops_connect(objs->asnk_hops_resample_objects[iSink], - objs->acon_hops_resample_object->outs[iSink+1]); + objs->acon_hops_resample_object->outs[iSink + 1]); } @@ -1020,7 +1544,7 @@ for (iSink = 0; iSink < objs->asnk_spectra_stft_object_count; iSink++) { asnk_spectra_connect(objs->asnk_spectra_stft_objects[iSink], - objs->acon_spectra_stft_object->outs[iSink+3]); + objs->acon_spectra_stft_object->outs[iSink + 2]); } @@ -1043,7 +1567,7 @@ for (iSink = 0; iSink < objs->asnk_pots_ssl_object_count; iSink++) { asnk_pots_connect(objs->asnk_pots_ssl_objects[iSink], - objs->acon_pots_ssl_object->outs[iSink+1]); + objs->acon_pots_ssl_object->outs[iSink + 1]); } @@ -1066,7 +1590,7 @@ for (iSink = 0; iSink < objs->asnk_tracks_sst_object_count; iSink++) { asnk_tracks_connect(objs->asnk_tracks_sst_objects[iSink], - objs->acon_tracks_sst_object->outs[iSink+2]); + objs->acon_tracks_sst_object->outs[iSink + 2]); } @@ -1081,7 +1605,8 @@ amod_sss_connect(objs->amod_sss_object, objs->acon_spectra_stft_object->outs[1], objs->acon_tracks_sst_object->outs[0], - objs->acon_spectra_sss_object->in); + objs->acon_spectra_sss_object->in, + objs->acon_envs_sss_object->in); // +--------------------------------------------------+ // | Sinks | @@ -1090,7 +1615,7 @@ for (iSink = 0; iSink < objs->asnk_spectra_sss_object_count; iSink++) { asnk_spectra_connect(objs->asnk_spectra_sss_objects[iSink], - objs->acon_spectra_sss_object->outs[iSink+1]); + objs->acon_spectra_sss_object->outs[iSink + 1]); } @@ -1103,8 +1628,8 @@ // +--------------------------------------------------+ amod_sspf_connect(objs->amod_sspf_object, - objs->acon_spectra_stft_object->outs[2], objs->acon_spectra_sss_object->outs[0], + objs->acon_envs_sss_object->outs[0], objs->acon_tracks_sst_object->outs[1], objs->acon_spectra_sspf_object->in); @@ -1115,9 +1640,55 @@ for (iSink = 0; iSink < objs->asnk_spectra_sspf_object_count; iSink++) { asnk_spectra_connect(objs->asnk_spectra_sspf_objects[iSink], - objs->acon_spectra_sspf_object->outs[iSink]); + objs->acon_spectra_sspf_object->outs[iSink + 1]); - } + } + + // +------------------------------------------------------+ + // | ISTFT | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + amod_istft_connect(objs->amod_istft_object, + objs->acon_spectra_sspf_object->outs[0], + objs->acon_hops_istft_object->in); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->asnk_hops_istft_object_count; iSink++) { + + asnk_hops_connect(objs->asnk_hops_istft_objects[iSink], + objs->acon_hops_istft_object->outs[iSink + 1]); + + } + + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + amod_gain_connect(objs->amod_gain_object, + objs->acon_hops_istft_object->outs[0], + objs->acon_hops_gain_object->in); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->asnk_hops_gain_object_count; iSink++) { + + asnk_hops_connect(objs->asnk_hops_gain_objects[iSink], + objs->acon_hops_gain_object->outs[iSink]); + + } return objs; @@ -1152,8 +1723,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_hops_raw_object_count; iSink++) { + asnk_hops_destroy(objs->asnk_hops_raw_objects[iSink]); + } + free((void *) objs->asnk_hops_raw_objects); // +--------------------------------------------------+ @@ -1183,8 +1757,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_hops_mapping_object_count; iSink++) { + asnk_hops_destroy(objs->asnk_hops_mapping_objects[iSink]); + } + free((void *) objs->asnk_hops_mapping_objects); // +--------------------------------------------------+ @@ -1214,8 +1791,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_hops_resample_object_count; iSink++) { + asnk_hops_destroy(objs->asnk_hops_resample_objects[iSink]); + } + free((void *) objs->asnk_hops_resample_objects); // +--------------------------------------------------+ @@ -1245,8 +1825,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_spectra_stft_object_count; iSink++) { + asnk_spectra_destroy(objs->asnk_spectra_stft_objects[iSink]); + } + free((void *) objs->asnk_spectra_stft_objects); // +--------------------------------------------------+ @@ -1276,8 +1859,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_pots_ssl_object_count; iSink++) { + asnk_pots_destroy(objs->asnk_pots_ssl_objects[iSink]); + } + free((void *) objs->asnk_pots_ssl_objects); // +--------------------------------------------------+ @@ -1307,8 +1893,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_tracks_sst_object_count; iSink++) { + asnk_tracks_destroy(objs->asnk_tracks_sst_objects[iSink]); + } + free((void *) objs->asnk_tracks_sst_objects); // +--------------------------------------------------+ @@ -1338,8 +1927,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_spectra_sss_object_count; iSink++) { + asnk_spectra_destroy(objs->asnk_spectra_sss_objects[iSink]); + } + free((void *) objs->asnk_spectra_sss_objects); // +--------------------------------------------------+ @@ -1347,6 +1939,7 @@ // +--------------------------------------------------+ acon_spectra_destroy(objs->acon_spectra_sss_object); + acon_envs_destroy(objs->acon_envs_sss_object); // +------------------------------------------------------+ // | SSPF | @@ -1369,8 +1962,11 @@ // +--------------------------------------------------+ for (iSink = 0; iSink < objs->asnk_spectra_sspf_object_count; iSink++) { + asnk_spectra_destroy(objs->asnk_spectra_sspf_objects[iSink]); + } + free((void *) objs->asnk_spectra_sspf_objects); // +--------------------------------------------------+ @@ -1379,6 +1975,74 @@ acon_spectra_destroy(objs->acon_spectra_sspf_object); + // +------------------------------------------------------+ + // | ISTFT | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + amod_istft_destroy(objs->amod_istft_object); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + amsg_hops_destroy(objs->amsg_hops_istft_object); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->asnk_hops_istft_object_count; iSink++) { + + asnk_hops_destroy(objs->asnk_hops_istft_objects[iSink]); + + } + + free((void *) objs->asnk_hops_istft_objects); + + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ + + acon_hops_destroy(objs->acon_hops_istft_object); + + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + amod_gain_destroy(objs->amod_gain_object); + + // +--------------------------------------------------+ + // | Message | + // +--------------------------------------------------+ + + amsg_hops_destroy(objs->amsg_hops_gain_object); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + for (iSink = 0; iSink < objs->asnk_hops_gain_object_count; iSink++) { + + asnk_hops_destroy(objs->asnk_hops_gain_objects[iSink]); + + } + + free((void *) objs->asnk_hops_gain_objects); + + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ + + acon_hops_destroy(objs->acon_hops_gain_object); + free((void *) objs); } \ No newline at end of file diff --git a/demo/objects.h b/demo/objects.h index 8309eaf..ebd7805 100644 --- a/demo/objects.h +++ b/demo/objects.h @@ -50,6 +50,7 @@ unsigned int snk_spectra_sss_object_count; snk_spectra_obj ** snk_spectra_sss_objects; con_spectra_obj * con_spectra_sss_object; + con_envs_obj * con_envs_sss_object; mod_sspf_obj * mod_sspf_object; msg_spectra_obj * msg_spectra_sspf_object; @@ -57,6 +58,18 @@ snk_spectra_obj ** snk_spectra_sspf_objects; con_spectra_obj * con_spectra_sspf_object; + mod_istft_obj * mod_istft_object; + msg_hops_obj * msg_hops_istft_object; + unsigned int snk_hops_istft_object_count; + snk_hops_obj ** snk_hops_istft_objects; + con_hops_obj * con_hops_istft_object; + + mod_gain_obj * mod_gain_object; + msg_hops_obj * msg_hops_gain_object; + unsigned int snk_hops_gain_object_count; + snk_hops_obj ** snk_hops_gain_objects; + con_hops_obj * con_hops_gain_object; + } objects; typedef struct aobjects { @@ -104,6 +117,7 @@ unsigned int asnk_spectra_sss_object_count; asnk_spectra_obj ** asnk_spectra_sss_objects; acon_spectra_obj * acon_spectra_sss_object; + acon_envs_obj * acon_envs_sss_object; amod_sspf_obj * amod_sspf_object; amsg_spectra_obj * amsg_spectra_sspf_object; @@ -111,6 +125,18 @@ asnk_spectra_obj ** asnk_spectra_sspf_objects; acon_spectra_obj * acon_spectra_sspf_object; + amod_istft_obj * amod_istft_object; + amsg_hops_obj * amsg_hops_istft_object; + unsigned int asnk_hops_istft_object_count; + asnk_hops_obj ** asnk_hops_istft_objects; + acon_hops_obj * acon_hops_istft_object; + + amod_gain_obj * amod_gain_object; + amsg_hops_obj * amsg_hops_gain_object; + unsigned int asnk_hops_gain_object_count; + asnk_hops_obj ** asnk_hops_gain_objects; + acon_hops_obj * acon_hops_gain_object; + } aobjects; objects * objects_construct(const configs * cfgs); diff --git a/demo/parameters.c b/demo/parameters.c index a32aea2..ec6f913 100644 --- a/demo/parameters.c +++ b/demo/parameters.c @@ -1296,6 +1296,7 @@ free((void *) tmpLabel); if (strcmp(tmpStr1, "json") == 0) { cfg->format = format_construct_json(); } + else if (strcmp(tmpStr1, "float") == 0) { cfg->format = format_construct_float(); } else { printf("Sink tracks: Invalid format\n"); exit(EXIT_FAILURE); } free((void *) tmpStr1); @@ -1486,7 +1487,7 @@ cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu"); // +----------------------------------------------------------+ - // | Hop size | + // | Half Frame Size | // +----------------------------------------------------------+ cfg->halfFrameSize = parameters_lookup_int(fileConfig, "general.size.frameSize") / 2 + 1; @@ -1502,6 +1503,38 @@ } + msg_envs_cfg * parameters_msg_envs_sss_config(const char * fileConfig, const char * fileIOs) { + + msg_envs_cfg * cfg; + + unsigned int halfFrameSize; + unsigned int nChannels; + unsigned int fS; + + cfg = msg_envs_cfg_construct(); + + // +----------------------------------------------------------+ + // | Sample rate | + // +----------------------------------------------------------+ + + cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu"); + + // +----------------------------------------------------------+ + // | Half Frame 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; + + } + unsigned int parameters_snk_spectra_sss_count(const char * fileConfig, const char * fileIOs) { return parameters_count(fileIOs, "output.sss"); @@ -1602,94 +1635,30 @@ cfg = mod_sspf_cfg_construct(); // +----------------------------------------------------------+ - // | Number of channels | + // | alpha | // +----------------------------------------------------------+ - 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); - - } + cfg->alpha = parameters_lookup_float(fileConfig, "sspf.alpha"); // +----------------------------------------------------------+ - // | Epsilon | + // | beta | // +----------------------------------------------------------+ - cfg->epsilon = parameters_lookup_float(fileConfig, "general.epsilon"); + cfg->beta = parameters_lookup_float(fileConfig, "sspf.beta"); // +----------------------------------------------------------+ - // | Spatial filter | + // | Ginterf | // +----------------------------------------------------------+ - 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]"); + cfg->Ginterf = parameters_lookup_float(fileConfig, "sspf.Ginterf"); // +----------------------------------------------------------+ - // | Directivity | + // | Epsilon | // +----------------------------------------------------------+ - cfg->nThetas = parameters_lookup_int(fileConfig, "sspf.nThetas"); - cfg->gainMin = parameters_lookup_float(fileConfig, "sspf.gainMin"); + cfg->epsilon = parameters_lookup_float(fileConfig, "general.epsilon"); + + return cfg; @@ -1811,4 +1780,294 @@ return cfg; + } + + mod_istft_cfg * parameters_mod_istft_config(const char * fileConfig, const char * fileIOs) { + + mod_istft_cfg * cfg; + + cfg = mod_istft_cfg_construct(); + + return cfg; + + } + + msg_hops_cfg * parameters_msg_hops_istft_config(const char * fileConfig, const char * fileIOs) { + + 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; + + } + + unsigned int parameters_snk_hops_istft_count(const char * fileConfig, const char * fileIOs) { + + return parameters_count(fileIOs, "output.istft"); + + } + + snk_hops_cfg * parameters_snk_hops_istft_config(const char * fileConfig, const char * fileIOs, const unsigned int iSink) { + + snk_hops_cfg * cfg; + char * tmpStr1; + char * tmpStr2; + char * tmpLabel; + unsigned int tmpInt1; + unsigned int tmpInt2; + + cfg = snk_hops_cfg_construct(); + + // +------------------------------------------------------+ + // | Sample rate | + // +------------------------------------------------------+ + + cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu"); + + // +------------------------------------------------------+ + // | Format | + // +------------------------------------------------------+ + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.istft.[%u].format", iSink); + tmpStr1 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + if (strcmp(tmpStr1, "bin08") == 0) { cfg->format = format_construct_bin(8); } + else if (strcmp(tmpStr1, "bin16") == 0) { cfg->format = format_construct_bin(16); } + else if (strcmp(tmpStr1, "bin24") == 0) { cfg->format = format_construct_bin(24); } + else if (strcmp(tmpStr1, "bin32") == 0) { cfg->format = format_construct_bin(32); } + else { printf("Sink hops ISTFT: Invalid format\n"); exit(EXIT_FAILURE); } + + free((void *) tmpStr1); + + // +------------------------------------------------------+ + // | Type | + // +------------------------------------------------------+ + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.istft.[%u].type", iSink); + tmpStr1 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + if (strcmp(tmpStr1, "file") == 0) { + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.istft.[%u].path", iSink); + tmpStr2 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + cfg->interface = interface_construct_file(tmpStr2); + free((void *) tmpStr2); + + } + else if (strcmp(tmpStr1, "socket") == 0) { + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.istft.[%u].ip", iSink); + tmpStr2 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.istft.[%u].port", iSink); + tmpInt1 = parameters_lookup_int(fileIOs, tmpLabel); + free((void *) tmpLabel); + + cfg->interface = interface_construct_socket(tmpStr2, tmpInt1); + free((void *) tmpStr2); + + } + else if (strcmp(tmpStr1, "soundcard") == 0) { + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.istft.[%u].device", iSink); + tmpInt1 = parameters_lookup_int(fileIOs, tmpLabel); + free((void *) tmpLabel); + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.istft.[%u].subdevice", iSink); + tmpInt2 = parameters_lookup_int(fileIOs, tmpLabel); + free((void *) tmpLabel); + + cfg->interface = interface_construct_soundcard(tmpInt1, tmpInt2); + + } + else { + + printf("Invalid type\n"); + exit(EXIT_FAILURE); + + } + + free((void *) tmpStr1); + + return cfg; + + } + + mod_gain_cfg * parameters_mod_gain_config(const char * fileConfig, const char * fileIOs) { + + mod_gain_cfg * cfg; + + cfg = mod_gain_cfg_construct(); + + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + cfg->gain = parameters_lookup_float(fileConfig, "playback.volume"); + + return cfg; + + } + + msg_hops_cfg * parameters_msg_hops_gain_config(const char * fileConfig, const char * fileIOs) { + + 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; + + } + + unsigned int parameters_snk_hops_gain_count(const char * fileConfig, const char * fileIOs) { + + return parameters_count(fileIOs, "output.playback"); + + } + + snk_hops_cfg * parameters_snk_hops_gain_config(const char * fileConfig, const char * fileIOs, const unsigned int iSink) { + + snk_hops_cfg * cfg; + char * tmpStr1; + char * tmpStr2; + char * tmpLabel; + unsigned int tmpInt1; + unsigned int tmpInt2; + + cfg = snk_hops_cfg_construct(); + + // +------------------------------------------------------+ + // | Sample rate | + // +------------------------------------------------------+ + + cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu"); + + // +------------------------------------------------------+ + // | Format | + // +------------------------------------------------------+ + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.playback.[%u].format", iSink); + tmpStr1 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + if (strcmp(tmpStr1, "bin08") == 0) { cfg->format = format_construct_bin(8); } + else if (strcmp(tmpStr1, "bin16") == 0) { cfg->format = format_construct_bin(16); } + else if (strcmp(tmpStr1, "bin24") == 0) { cfg->format = format_construct_bin(24); } + else if (strcmp(tmpStr1, "bin32") == 0) { cfg->format = format_construct_bin(32); } + else { printf("Sink hops ISTFT: Invalid format\n"); exit(EXIT_FAILURE); } + + free((void *) tmpStr1); + + // +------------------------------------------------------+ + // | Type | + // +------------------------------------------------------+ + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.playback.[%u].type", iSink); + tmpStr1 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + if (strcmp(tmpStr1, "file") == 0) { + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.playback.[%u].path", iSink); + tmpStr2 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + cfg->interface = interface_construct_file(tmpStr2); + free((void *) tmpStr2); + + } + else if (strcmp(tmpStr1, "socket") == 0) { + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.playback.[%u].ip", iSink); + tmpStr2 = parameters_lookup_string(fileIOs, tmpLabel); + free((void *) tmpLabel); + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.playback.[%u].port", iSink); + tmpInt1 = parameters_lookup_int(fileIOs, tmpLabel); + free((void *) tmpLabel); + + cfg->interface = interface_construct_socket(tmpStr2, tmpInt1); + free((void *) tmpStr2); + + } + else if (strcmp(tmpStr1, "soundcard") == 0) { + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.playback.[%u].device", iSink); + tmpInt1 = parameters_lookup_int(fileIOs, tmpLabel); + free((void *) tmpLabel); + + tmpLabel = (char *) malloc(sizeof(char) * 1024); + sprintf(tmpLabel, "output.playback.[%u].subdevice", iSink); + tmpInt2 = parameters_lookup_int(fileIOs, tmpLabel); + free((void *) tmpLabel); + + cfg->interface = interface_construct_soundcard(tmpInt1, tmpInt2); + + } + else { + + printf("Invalid type\n"); + exit(EXIT_FAILURE); + + } + + free((void *) tmpStr1); + + return cfg; + } \ No newline at end of file diff --git a/demo/parameters.h b/demo/parameters.h index 827d665..cccfff8 100644 --- a/demo/parameters.h +++ b/demo/parameters.h @@ -71,6 +71,8 @@ msg_spectra_cfg * parameters_msg_spectra_sss_config(const char * fileConfig, const char * fileIOs); + msg_envs_cfg * parameters_msg_envs_sss_config(const char * fileConfig, const char * fileIOs); + unsigned int parameters_snk_spectra_sss_count(const char * fileConfig, const char * fileIOs); snk_spectra_cfg * parameters_snk_spectra_sss_config(const char * fileConfig, const char * fileIOs, const unsigned int iSink); @@ -85,4 +87,21 @@ snk_spectra_cfg * parameters_snk_spectra_sspf_config(const char * fileConfig, const char * fileIOs, const unsigned int iSink); + mod_istft_cfg * parameters_mod_istft_config(const char * fileConfig, const char * fileIOs); + + msg_hops_cfg * parameters_msg_hops_istft_config(const char * fileConfig, const char * fileIOs); + + unsigned int parameters_snk_hops_istft_count(const char * fileConfig, const char * fileIOs); + + snk_hops_cfg * parameters_snk_hops_istft_config(const char * fileConfig, const char * fileIOs, const unsigned int iSink); + + + mod_gain_cfg * parameters_mod_gain_config(const char * fileConfig, const char * fileIOs); + + msg_hops_cfg * parameters_msg_hops_gain_config(const char * fileConfig, const char * fileIOs); + + unsigned int parameters_snk_hops_gain_count(const char * fileConfig, const char * fileIOs); + + snk_hops_cfg * parameters_snk_hops_gain_config(const char * fileConfig, const char * fileIOs, const unsigned int iSink); + #endif \ No newline at end of file diff --git a/demo/profiler.c b/demo/profiler.c index 5182d97..fe821f9 100644 --- a/demo/profiler.c +++ b/demo/profiler.c @@ -35,12 +35,21 @@ prf->mod_sss_prf = 0.0f; prf->con_spectra_sss_prf = 0.0f; + prf->con_envs_sss_prf = 0.0f; prf->snk_spectra_sss_prf = 0.0f; prf->mod_sspf_prf = 0.0f; prf->con_spectra_sspf_prf = 0.0f; prf->snk_spectra_sspf_prf = 0.0f; + prf->mod_istft_prf = 0.0f; + prf->con_hops_istft_prf = 0.0f; + prf->snk_hops_istft_prf = 0.0f; + + prf->mod_gain_prf = 0.0f; + prf->con_hops_gain_prf = 0.0f; + prf->snk_hops_gain_prf = 0.0f; + return prf; } @@ -65,7 +74,9 @@ prf->snk_pots_ssl_prf + prf->snk_tracks_sst_prf + prf->snk_spectra_sss_prf + - prf->snk_spectra_sspf_prf; + prf->snk_spectra_sspf_prf + + prf->snk_hops_istft_prf + + prf->snk_hops_gain_prf; module = prf->mod_mapping_prf + prf->mod_resample_prf + @@ -73,7 +84,9 @@ prf->mod_ssl_prf + prf->mod_sst_prf + prf->mod_sss_prf + - prf->mod_sspf_prf; + prf->mod_sspf_prf + + prf->mod_istft_prf + + prf->mod_gain_prf; connector = prf->con_hops_raw_prf + prf->con_hops_mapping_prf + @@ -82,7 +95,10 @@ prf->con_pots_ssl_prf + prf->con_tracks_sst_prf + prf->con_spectra_sss_prf + - prf->con_spectra_sspf_prf; + prf->con_envs_sss_prf + + prf->con_spectra_sspf_prf + + prf->con_hops_istft_prf + + prf->con_hops_gain_prf; total = source + sink + module + connector; @@ -121,6 +137,14 @@ printf("| - Module.......... %07.3f (%06.2f%%) |\n",prf->mod_sspf_prf,roundf(10000.0f * prf->mod_sspf_prf / prf->duration) / 100.0f); printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_spectra_sspf_prf,roundf(10000.0f * prf->con_spectra_sspf_prf / prf->duration) / 100.0f); printf("| - Sink............ %07.3f (%06.2f%%) |\n",prf->snk_spectra_sspf_prf,roundf(10000.0f * prf->snk_spectra_sspf_prf / prf->duration) / 100.0f); + printf("| + ISTFT |\n"); + printf("| - Module.......... %07.3f (%06.2f%%) |\n",prf->mod_istft_prf,roundf(10000.0f * prf->mod_istft_prf / prf->duration) / 100.0f); + printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_hops_istft_prf,roundf(10000.0f * prf->con_hops_istft_prf / prf->duration) / 100.0f); + printf("| - Sink............ %07.3f (%06.2f%%) |\n",prf->snk_hops_istft_prf,roundf(10000.0f * prf->snk_hops_istft_prf / prf->duration) / 100.0f); + printf("| + Playback |\n"); + printf("| - Module.......... %07.3f (%06.2f%%) |\n",prf->mod_gain_prf,roundf(10000.0f * prf->mod_gain_prf / prf->duration) / 100.0f); + printf("| - Connector....... %07.3f (%06.2f%%) |\n",prf->con_hops_gain_prf,roundf(10000.0f * prf->con_hops_gain_prf / prf->duration) / 100.0f); + printf("| - Sink............ %07.3f (%06.2f%%) |\n",prf->snk_hops_gain_prf,roundf(10000.0f * prf->snk_hops_gain_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); diff --git a/demo/profiler.h b/demo/profiler.h index 5ca62ef..b273aa1 100644 --- a/demo/profiler.h +++ b/demo/profiler.h @@ -35,12 +35,21 @@ float mod_sss_prf; float con_spectra_sss_prf; + float con_envs_sss_prf; float snk_spectra_sss_prf; float mod_sspf_prf; float con_spectra_sspf_prf; float snk_spectra_sspf_prf; + float mod_istft_prf; + float con_hops_istft_prf; + float snk_hops_istft_prf; + + float mod_gain_prf; + float con_hops_gain_prf; + float snk_hops_gain_prf; + } profiler; profiler * profiler_construct(void); diff --git a/demo/threads.c b/demo/threads.c index 37259a1..67ac100 100644 --- a/demo/threads.c +++ b/demo/threads.c @@ -172,6 +172,7 @@ // +------------------------------------------------------+ thread_start(aobjs->acon_spectra_sss_object->thread); + thread_start(aobjs->acon_envs_sss_object->thread); // +----------------------------------------------------------+ // | SSPF | @@ -197,6 +198,54 @@ thread_start(aobjs->acon_spectra_sspf_object->thread); + // +----------------------------------------------------------+ + // | ISTFT | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Module | + // +------------------------------------------------------+ + + thread_start(aobjs->amod_istft_object->thread); + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < aobjs->asnk_hops_istft_object_count; iSink++) { + thread_start(aobjs->asnk_hops_istft_objects[iSink]->thread); + } + + // +------------------------------------------------------+ + // | Connector | + // +------------------------------------------------------+ + + thread_start(aobjs->acon_hops_istft_object->thread); + + // +----------------------------------------------------------+ + // | Gain | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Module | + // +------------------------------------------------------+ + + thread_start(aobjs->amod_gain_object->thread); + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < aobjs->asnk_hops_gain_object_count; iSink++) { + thread_start(aobjs->asnk_hops_gain_objects[iSink]->thread); + } + + // +------------------------------------------------------+ + // | Connector | + // +------------------------------------------------------+ + + thread_start(aobjs->acon_hops_gain_object->thread); + } void threads_multiple_stop(aobjects * aobjs) { @@ -388,6 +437,7 @@ // +------------------------------------------------------+ thread_join(aobjs->acon_spectra_sss_object->thread); + thread_join(aobjs->acon_envs_sss_object->thread); // +----------------------------------------------------------+ // | SSPF | @@ -413,6 +463,54 @@ thread_join(aobjs->acon_spectra_sspf_object->thread); + // +----------------------------------------------------------+ + // | ISTFT | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Module | + // +------------------------------------------------------+ + + thread_join(aobjs->amod_istft_object->thread); + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < aobjs->asnk_hops_istft_object_count; iSink++) { + thread_join(aobjs->asnk_hops_istft_objects[iSink]->thread); + } + + // +------------------------------------------------------+ + // | Connector | + // +------------------------------------------------------+ + + thread_join(aobjs->acon_hops_istft_object->thread); + + // +----------------------------------------------------------+ + // | Gain | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Module | + // +------------------------------------------------------+ + + thread_join(aobjs->amod_gain_object->thread); + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < aobjs->asnk_hops_gain_object_count; iSink++) { + thread_join(aobjs->asnk_hops_gain_objects[iSink]->thread); + } + + // +------------------------------------------------------+ + // | Connector | + // +------------------------------------------------------+ + + thread_join(aobjs->acon_hops_gain_object->thread); + } void threads_single_open(objects * objs) { @@ -521,6 +619,30 @@ snk_spectra_open(objs->snk_spectra_sspf_objects[iSink]); } + // +----------------------------------------------------------+ + // | ISTFT | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_istft_object_count; iSink++) { + snk_hops_open(objs->snk_hops_istft_objects[iSink]); + } + + // +----------------------------------------------------------+ + // | Gain | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_gain_object_count; iSink++) { + snk_hops_open(objs->snk_hops_gain_objects[iSink]); + } + } void threads_single_close(objects * objs) { @@ -629,6 +751,30 @@ snk_spectra_close(objs->snk_spectra_sspf_objects[iSink]); } + // +----------------------------------------------------------+ + // | ISTFT | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_istft_object_count; iSink++) { + snk_hops_close(objs->snk_hops_istft_objects[iSink]); + } + + // +----------------------------------------------------------+ + // | Gain | + // +----------------------------------------------------------+ + + // +------------------------------------------------------+ + // | Sinks | + // +------------------------------------------------------+ + + for (iSink = 0; iSink < objs->snk_hops_gain_object_count; iSink++) { + snk_hops_close(objs->snk_hops_gain_objects[iSink]); + } + } int threads_single_process(objects * objs, profiler * prf) { @@ -892,6 +1038,11 @@ end = clock(); prf->con_spectra_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + begin = clock(); + con_envs_process(objs->con_envs_sss_object); + end = clock(); + prf->con_envs_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ // | Sinks | // +--------------------------------------------------+ @@ -929,13 +1080,79 @@ // | Sinks | // +--------------------------------------------------+ - begin = clock(); + begin = clock(); for (iSink = 0; iSink < objs->snk_spectra_sspf_object_count; iSink++) { snk_spectra_process(objs->snk_spectra_sspf_objects[iSink]); } end = clock(); prf->snk_spectra_sspf_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +------------------------------------------------------+ + // | ISTFT | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + begin = clock(); + mod_istft_process(objs->mod_istft_object); + end = clock(); + prf->mod_istft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ + + begin = clock(); + con_hops_process(objs->con_hops_istft_object); + end = clock(); + prf->con_hops_istft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + begin = clock(); + for (iSink = 0; iSink < objs->snk_hops_istft_object_count; iSink++) { + snk_hops_process(objs->snk_hops_istft_objects[iSink]); + } + end = clock(); + prf->snk_hops_istft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + + // +------------------------------------------------------+ + // | Gain | + // +------------------------------------------------------+ + + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + begin = clock(); + mod_gain_process(objs->mod_gain_object); + end = clock(); + prf->mod_gain_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ + + begin = clock(); + con_hops_process(objs->con_hops_gain_object); + end = clock(); + prf->con_hops_gain_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + begin = clock(); + for (iSink = 0; iSink < objs->snk_hops_gain_object_count; iSink++) { + snk_hops_process(objs->snk_hops_gain_objects[iSink]); + } + end = clock(); + prf->snk_hops_gain_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + } return rtnValue; diff --git a/include/odas/odas.h b/include/odas/odas.h index b088b7a..2ff8197 100644 --- a/include/odas/odas.h +++ b/include/odas/odas.h @@ -1,12 +1,16 @@ + #include "../../src/connector/con_envs.h" #include "../../src/connector/con_hops.h" #include "../../src/connector/con_pots.h" #include "../../src/connector/con_spectra.h" #include "../../src/connector/con_tracks.h" + #include "../../src/message/msg_envs.h" #include "../../src/message/msg_hops.h" #include "../../src/message/msg_pots.h" #include "../../src/message/msg_spectra.h" #include "../../src/message/msg_tracks.h" + #include "../../src/module/mod_gain.h" + #include "../../src/module/mod_istft.h" #include "../../src/module/mod_mapping.h" #include "../../src/module/mod_resample.h" #include "../../src/module/mod_ssl.h" @@ -20,14 +24,18 @@ #include "../../src/sink/snk_tracks.h" #include "../../src/source/src_hops.h" + #include "../../src/aconnector/acon_envs.h" #include "../../src/aconnector/acon_hops.h" #include "../../src/aconnector/acon_pots.h" #include "../../src/aconnector/acon_spectra.h" #include "../../src/aconnector/acon_tracks.h" + #include "../../src/amessage/amsg_envs.h" #include "../../src/amessage/amsg_hops.h" #include "../../src/amessage/amsg_pots.h" #include "../../src/amessage/amsg_spectra.h" #include "../../src/amessage/amsg_tracks.h" + #include "../../src/amodule/amod_gain.h" + #include "../../src/amodule/amod_istft.h" #include "../../src/amodule/amod_mapping.h" #include "../../src/amodule/amod_resample.h" #include "../../src/amodule/amod_ssl.h" diff --git a/src/aconnector/acon_envs.c b/src/aconnector/acon_envs.c new file mode 100644 index 0000000..95bce71 --- /dev/null +++ b/src/aconnector/acon_envs.c @@ -0,0 +1,85 @@ + + #include "acon_envs.h" + + acon_envs_obj * acon_envs_construct(const unsigned int nOuts, const unsigned int nMessages, const msg_envs_cfg * msg_envs_config) { + + acon_envs_obj * obj; + unsigned int iOut; + + obj = (acon_envs_obj *) malloc(sizeof(acon_envs_obj)); + + obj->in = amsg_envs_construct(nMessages, msg_envs_config); + + obj->outs = (amsg_envs_obj **) malloc(sizeof(amsg_envs_obj *) * nOuts); + for (iOut = 0; iOut < nOuts; iOut++) { + obj->outs[iOut] = amsg_envs_construct(nMessages, msg_envs_config); + } + + obj->con_envs = con_envs_construct(nOuts, msg_envs_config); + + obj->thread = thread_construct(&acon_envs_thread, (void *) obj); + + return obj; + + } + + void acon_envs_destroy(acon_envs_obj * obj) { + + unsigned int iOut; + unsigned int nOuts; + + nOuts = obj->con_envs->nOuts; + + thread_destroy(obj->thread); + + con_envs_destroy(obj->con_envs); + + for (iOut = 0; iOut < nOuts; iOut++) { + amsg_envs_destroy(obj->outs[iOut]); + } + free((void *) obj->outs); + + amsg_envs_destroy(obj->in); + + free((void *) obj); + + + } + + void * acon_envs_thread(void * ptr) { + + msg_envs_obj * msg_envs_in; + msg_envs_obj * msg_envs_out; + + acon_envs_obj * obj; + unsigned int iOut; + unsigned int nOuts; + int rtnValue; + + obj = (acon_envs_obj *) ptr; + + nOuts = obj->con_envs->nOuts; + + while(1) { + + msg_envs_in = amsg_envs_filled_pop(obj->in); + msg_envs_copy(obj->con_envs->in, msg_envs_in); + amsg_envs_empty_push(obj->in, msg_envs_in); + + rtnValue = con_envs_process(obj->con_envs); + + for (iOut = 0; iOut < nOuts; iOut++) { + + msg_envs_out = amsg_envs_empty_pop(obj->outs[iOut]); + msg_envs_copy(msg_envs_out, obj->con_envs->outs[iOut]); + amsg_envs_filled_push(obj->outs[iOut], msg_envs_out); + + } + + if (rtnValue == -1) { + break; + } + + } + + } \ No newline at end of file diff --git a/src/aconnector/acon_envs.h b/src/aconnector/acon_envs.h new file mode 100644 index 0000000..3cf076c --- /dev/null +++ b/src/aconnector/acon_envs.h @@ -0,0 +1,27 @@ +#ifndef __ODAS_ACONNECTOR_ENVS +#define __ODAS_ACONNECTOR_ENVS + + #include "../connector/con_envs.h" + #include "../amessage/amsg_envs.h" + #include "../message/msg_envs.h" + #include "../general/thread.h" + + #include + #include + + typedef struct acon_envs_obj { + + amsg_envs_obj * in; + amsg_envs_obj ** outs; + con_envs_obj * con_envs; + thread_obj * thread; + + } acon_envs_obj; + + acon_envs_obj * acon_envs_construct(const unsigned int nOuts, const unsigned int nMessages, const msg_envs_cfg * msg_envs_config); + + void acon_envs_destroy(acon_envs_obj * obj); + + void * acon_envs_thread(void * ptr); + +#endif \ No newline at end of file diff --git a/src/amessage/amsg_envs.c b/src/amessage/amsg_envs.c new file mode 100644 index 0000000..96f1747 --- /dev/null +++ b/src/amessage/amsg_envs.c @@ -0,0 +1,64 @@ + + #include "amsg_envs.h" + + amsg_envs_obj * amsg_envs_construct(const unsigned int nMessages, const msg_envs_cfg * msg_envs_config) { + + amsg_envs_obj * obj; + unsigned int iMessage; + + obj = (amsg_envs_obj *) malloc(sizeof(amsg_envs_obj)); + + obj->nMessages = nMessages; + obj->filled = fifo_construct_zero(nMessages); + obj->empty = fifo_construct_zero(nMessages); + + for (iMessage = 0; iMessage < nMessages; iMessage++) { + + fifo_push(obj->empty, (void *) msg_envs_construct(msg_envs_config)); + + } + + return obj; + + } + + void amsg_envs_destroy(amsg_envs_obj * obj) { + + while(fifo_nElements(obj->filled) > 0) { + msg_envs_destroy((void *) fifo_pop(obj->filled)); + } + + while(fifo_nElements(obj->empty) > 0) { + msg_envs_destroy((void *) fifo_pop(obj->empty)); + } + + fifo_destroy(obj->filled); + fifo_destroy(obj->empty); + + free((void *) obj); + + } + + msg_envs_obj * amsg_envs_filled_pop(amsg_envs_obj * obj) { + + return ((msg_envs_obj *) fifo_pop(obj->filled)); + + } + + void amsg_envs_filled_push(amsg_envs_obj * obj, msg_envs_obj * msg_envs) { + + fifo_push(obj->filled, (void *) msg_envs); + + } + + msg_envs_obj * amsg_envs_empty_pop(amsg_envs_obj * obj) { + + return ((msg_envs_obj *) fifo_pop(obj->empty)); + + } + + void amsg_envs_empty_push(amsg_envs_obj * obj, msg_envs_obj * msg_envs) { + + fifo_push(obj->empty, (void *) msg_envs); + + } \ No newline at end of file diff --git a/src/amessage/amsg_envs.h b/src/amessage/amsg_envs.h new file mode 100644 index 0000000..686a3ff --- /dev/null +++ b/src/amessage/amsg_envs.h @@ -0,0 +1,29 @@ +#ifndef __ODAS_AMESSAGE_ENVS +#define __ODAS_AMESSAGE_ENVS + + #include + + #include "../message/msg_envs.h" + #include "../utils/fifo.h" + + typedef struct amsg_envs_obj { + + unsigned int nMessages; + fifo_obj * filled; + fifo_obj * empty; + + } amsg_envs_obj; + + amsg_envs_obj * amsg_envs_construct(const unsigned int nMessages, const msg_envs_cfg * msg_envs_config); + + void amsg_envs_destroy(amsg_envs_obj * obj); + + msg_envs_obj * amsg_envs_filled_pop(amsg_envs_obj * obj); + + void amsg_envs_filled_push(amsg_envs_obj * obj, msg_envs_obj * msg_envs); + + msg_envs_obj * amsg_envs_empty_pop(amsg_envs_obj * obj); + + void amsg_envs_empty_push(amsg_envs_obj * obj, msg_envs_obj * msg_envs); + +#endif \ No newline at end of file diff --git a/src/amodule/amod_gain.c b/src/amodule/amod_gain.c new file mode 100644 index 0000000..34bd1a7 --- /dev/null +++ b/src/amodule/amod_gain.c @@ -0,0 +1,70 @@ + + #include "amod_gain.h" + + amod_gain_obj * amod_gain_construct(const mod_gain_cfg * mod_gain_config, const msg_hops_cfg * msg_hops_config) { + + amod_gain_obj * obj; + + obj = (amod_gain_obj *) malloc(sizeof(amod_gain_obj)); + + obj->mod_gain = mod_gain_construct(mod_gain_config, msg_hops_config); + obj->in = (amsg_hops_obj *) NULL; + obj->out = (amsg_hops_obj *) NULL; + + obj->thread = thread_construct(&amod_gain_thread, (void *) obj); + + return obj; + + } + + void amod_gain_destroy(amod_gain_obj * obj) { + + mod_gain_destroy(obj->mod_gain); + thread_destroy(obj->thread); + + free((void *) obj); + + } + + void amod_gain_connect(amod_gain_obj * obj, amsg_hops_obj * in, amsg_hops_obj * out) { + + obj->in = in; + obj->out = out; + + } + + void amod_gain_disconnect(amod_gain_obj * obj) { + + obj->in = (amsg_hops_obj *) NULL; + obj->out = (amsg_hops_obj *) NULL; + + } + + void * amod_gain_thread(void * ptr) { + + amod_gain_obj * obj; + msg_hops_obj * msg_hops_in; + msg_hops_obj * msg_hops_out; + int rtnValue; + + obj = (amod_gain_obj *) ptr; + + while(1) { + + // Pop a message, process, and push back + msg_hops_in = amsg_hops_filled_pop(obj->in); + msg_hops_out = amsg_hops_empty_pop(obj->out); + mod_gain_connect(obj->mod_gain, msg_hops_in, msg_hops_out); + rtnValue = mod_gain_process(obj->mod_gain); + mod_gain_disconnect(obj->mod_gain); + amsg_hops_empty_push(obj->in, msg_hops_in); + amsg_hops_filled_push(obj->out, msg_hops_out); + + // If this is the last frame, rtnValue = -1 + if (rtnValue == -1) { + break; + } + + } + + } \ No newline at end of file diff --git a/src/amodule/amod_gain.h b/src/amodule/amod_gain.h new file mode 100644 index 0000000..a8315fe --- /dev/null +++ b/src/amodule/amod_gain.h @@ -0,0 +1,27 @@ +#ifndef __ODAS_AMODULE_GAIN +#define __ODAS_AMODULE_GAIN + + #include "../module/mod_gain.h" + #include "../amessage/amsg_hops.h" + #include "../general/thread.h" + + typedef struct amod_gain_obj { + + mod_gain_obj * mod_gain; + amsg_hops_obj * in; + amsg_hops_obj * out; + thread_obj * thread; + + } amod_gain_obj; + + amod_gain_obj * amod_gain_construct(const mod_gain_cfg * mod_gain_config, const msg_hops_cfg * msg_hops_config); + + void amod_gain_destroy(amod_gain_obj * obj); + + void amod_gain_connect(amod_gain_obj * obj, amsg_hops_obj * in, amsg_hops_obj * out); + + void amod_gain_disconnect(amod_gain_obj * obj); + + void * amod_gain_thread(void * ptr); + +#endif \ No newline at end of file diff --git a/src/amodule/amod_sspf.c b/src/amodule/amod_sspf.c index eb58316..ae1202b 100644 --- a/src/amodule/amod_sspf.c +++ b/src/amodule/amod_sspf.c @@ -1,16 +1,16 @@ #include "amod_sspf.h" - amod_sspf_obj * amod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config) { + amod_sspf_obj * amod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config) { amod_sspf_obj * obj; obj = (amod_sspf_obj *) malloc(sizeof(amod_sspf_obj)); - - obj->mod_sspf = mod_sspf_construct(mod_sspf_config, msg_spectra_config, msg_tracks_config); - + + obj->mod_sspf = mod_sspf_construct(mod_sspf_config, msg_tracks_config, msg_spectra_config, msg_envs_config); + obj->in1 = (amsg_spectra_obj *) NULL; - obj->in2 = (amsg_spectra_obj *) NULL; + obj->in2 = (amsg_envs_obj *) NULL; obj->in3 = (amsg_tracks_obj *) NULL; obj->out = (amsg_spectra_obj *) NULL; @@ -29,7 +29,7 @@ } - void amod_sspf_connect(amod_sspf_obj * obj, amsg_spectra_obj * in1, amsg_spectra_obj * in2, amsg_tracks_obj * in3, amsg_spectra_obj * out) { + void amod_sspf_connect(amod_sspf_obj * obj, amsg_spectra_obj * in1, amsg_envs_obj * in2, amsg_tracks_obj * in3, amsg_spectra_obj * out) { obj->in1 = in1; obj->in2 = in2; @@ -41,7 +41,7 @@ void amod_sspf_disconnect(amod_sspf_obj * obj) { obj->in1 = (amsg_spectra_obj *) NULL; - obj->in2 = (amsg_spectra_obj *) NULL; + obj->in2 = (amsg_envs_obj *) NULL; obj->in3 = (amsg_tracks_obj *) NULL; obj->out = (amsg_spectra_obj *) NULL; @@ -50,8 +50,8 @@ void * amod_sspf_thread(void * ptr) { amod_sspf_obj * obj; - msg_spectra_obj * msg_spectra_in1; - msg_spectra_obj * msg_spectra_in2; + msg_spectra_obj * msg_spectra_in; + msg_envs_obj * msg_envs_in; msg_tracks_obj * msg_tracks_in; msg_spectra_obj * msg_spectra_out; int rtnValue; @@ -61,15 +61,15 @@ while(1) { // Pop a message, process, and push back - msg_spectra_in1 = amsg_spectra_filled_pop(obj->in1); - msg_spectra_in2 = amsg_spectra_filled_pop(obj->in2); + msg_spectra_in = amsg_spectra_filled_pop(obj->in1); + msg_envs_in = amsg_envs_filled_pop(obj->in2); msg_tracks_in = amsg_tracks_filled_pop(obj->in3); msg_spectra_out = amsg_spectra_empty_pop(obj->out); - mod_sspf_connect(obj->mod_sspf, msg_spectra_in1, msg_spectra_in2, msg_tracks_in, msg_spectra_out); + mod_sspf_connect(obj->mod_sspf, msg_spectra_in, msg_envs_in, msg_tracks_in, msg_spectra_out); rtnValue = mod_sspf_process(obj->mod_sspf); mod_sspf_disconnect(obj->mod_sspf); - amsg_spectra_empty_push(obj->in1, msg_spectra_in1); - amsg_spectra_empty_push(obj->in2, msg_spectra_in2); + amsg_spectra_empty_push(obj->in1, msg_spectra_in); + amsg_envs_empty_push(obj->in2, msg_envs_in); amsg_tracks_empty_push(obj->in3, msg_tracks_in); amsg_spectra_filled_push(obj->out, msg_spectra_out); diff --git a/src/amodule/amod_sspf.h b/src/amodule/amod_sspf.h index d773337..df079ce 100644 --- a/src/amodule/amod_sspf.h +++ b/src/amodule/amod_sspf.h @@ -2,6 +2,7 @@ #define __ODAS_AMODULE_SSPF #include "../module/mod_sspf.h" + #include "../amessage/amsg_envs.h" #include "../amessage/amsg_tracks.h" #include "../amessage/amsg_spectra.h" #include "../general/thread.h" @@ -10,18 +11,18 @@ mod_sspf_obj * mod_sspf; amsg_spectra_obj * in1; - amsg_spectra_obj * in2; + amsg_envs_obj * in2; amsg_tracks_obj * in3; amsg_spectra_obj * out; thread_obj * thread; } amod_sspf_obj; - amod_sspf_obj * amod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config); + amod_sspf_obj * amod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config); void amod_sspf_destroy(amod_sspf_obj * obj); - void amod_sspf_connect(amod_sspf_obj * obj, amsg_spectra_obj * in1, amsg_spectra_obj * in2, amsg_tracks_obj * in3, amsg_spectra_obj * out); + void amod_sspf_connect(amod_sspf_obj * obj, amsg_spectra_obj * in1, amsg_envs_obj * in2, amsg_tracks_obj * in3, amsg_spectra_obj * out); void amod_sspf_disconnect(amod_sspf_obj * obj); diff --git a/src/amodule/amod_sss.c b/src/amodule/amod_sss.c index 5de1bdb..215cabd 100644 --- a/src/amodule/amod_sss.c +++ b/src/amodule/amod_sss.c @@ -1,17 +1,18 @@ #include "amod_sss.h" - amod_sss_obj * amod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config) { + amod_sss_obj * amod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config) { amod_sss_obj * obj; obj = (amod_sss_obj *) malloc(sizeof(amod_sss_obj)); - obj->mod_sss = mod_sss_construct(mod_sss_config, msg_spectra_config, msg_tracks_config); + obj->mod_sss = mod_sss_construct(mod_sss_config, msg_tracks_config, msg_spectra_config, msg_envs_config); obj->in1 = (amsg_spectra_obj *) NULL; obj->in2 = (amsg_tracks_obj *) NULL; - obj->out = (amsg_spectra_obj *) NULL; + obj->out1 = (amsg_spectra_obj *) NULL; + obj->out2 = (amsg_envs_obj *) NULL; obj->thread = thread_construct(&amod_sss_thread, (void *) obj); @@ -28,11 +29,12 @@ } - void amod_sss_connect(amod_sss_obj * obj, amsg_spectra_obj * in1, amsg_tracks_obj * in2, amsg_spectra_obj * out) { + void amod_sss_connect(amod_sss_obj * obj, amsg_spectra_obj * in1, amsg_tracks_obj * in2, amsg_spectra_obj * out1, amsg_envs_obj * out2) { obj->in1 = in1; obj->in2 = in2; - obj->out = out; + obj->out1 = out1; + obj->out2 = out2; } @@ -40,7 +42,8 @@ obj->in1 = (amsg_spectra_obj *) NULL; obj->in2 = (amsg_tracks_obj *) NULL; - obj->out = (amsg_spectra_obj *) NULL; + obj->out1 = (amsg_spectra_obj *) NULL; + obj->out2 = (amsg_envs_obj *) NULL; } @@ -50,6 +53,7 @@ msg_spectra_obj * msg_spectra_in; msg_tracks_obj * msg_tracks_in; msg_spectra_obj * msg_spectra_out; + msg_envs_obj * msg_envs_out; int rtnValue; obj = (amod_sss_obj *) ptr; @@ -59,13 +63,15 @@ // Pop a message, process, and push back msg_spectra_in = amsg_spectra_filled_pop(obj->in1); msg_tracks_in = amsg_tracks_filled_pop(obj->in2); - msg_spectra_out = amsg_spectra_empty_pop(obj->out); - mod_sss_connect(obj->mod_sss, msg_spectra_in, msg_tracks_in, msg_spectra_out); + msg_spectra_out = amsg_spectra_empty_pop(obj->out1); + msg_envs_out = amsg_envs_empty_pop(obj->out2); + mod_sss_connect(obj->mod_sss, msg_spectra_in, msg_tracks_in, msg_spectra_out, msg_envs_out); rtnValue = mod_sss_process(obj->mod_sss); mod_sss_disconnect(obj->mod_sss); amsg_spectra_empty_push(obj->in1, msg_spectra_in); amsg_tracks_empty_push(obj->in2, msg_tracks_in); - amsg_spectra_filled_push(obj->out, msg_spectra_out); + amsg_spectra_filled_push(obj->out1, msg_spectra_out); + amsg_envs_filled_push(obj->out2, msg_envs_out); // If this is the last frame, rtnValue = -1 if (rtnValue == -1) { diff --git a/src/amodule/amod_sss.h b/src/amodule/amod_sss.h index 596a613..a68bf1f 100644 --- a/src/amodule/amod_sss.h +++ b/src/amodule/amod_sss.h @@ -2,6 +2,7 @@ #define __ODAS_AMODULE_SSS #include "../module/mod_sss.h" + #include "../amessage/amsg_envs.h" #include "../amessage/amsg_tracks.h" #include "../amessage/amsg_spectra.h" #include "../general/thread.h" @@ -11,16 +12,17 @@ mod_sss_obj * mod_sss; amsg_spectra_obj * in1; amsg_tracks_obj * in2; - amsg_spectra_obj * out; + amsg_spectra_obj * out1; + amsg_envs_obj * out2; thread_obj * thread; } amod_sss_obj; - amod_sss_obj * amod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config); + amod_sss_obj * amod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config); void amod_sss_destroy(amod_sss_obj * obj); - void amod_sss_connect(amod_sss_obj * obj, amsg_spectra_obj * in1, amsg_tracks_obj * in2, amsg_spectra_obj * out); + void amod_sss_connect(amod_sss_obj * obj, amsg_spectra_obj * in1, amsg_tracks_obj * in2, amsg_spectra_obj * out1, amsg_envs_obj * out2); void amod_sss_disconnect(amod_sss_obj * obj); diff --git a/src/connector/con_envs.c b/src/connector/con_envs.c new file mode 100644 index 0000000..7c69e0b --- /dev/null +++ b/src/connector/con_envs.c @@ -0,0 +1,57 @@ + + #include "con_envs.h" + + con_envs_obj * con_envs_construct(const unsigned int nOuts, const msg_envs_cfg * msg_envs_config) { + + con_envs_obj * obj; + unsigned int iOut; + + obj = (con_envs_obj *) malloc(sizeof(con_envs_obj)); + + obj->nOuts = nOuts; + + obj->in = msg_envs_construct(msg_envs_config); + + obj->outs = (msg_envs_obj **) malloc(sizeof(msg_envs_obj *) * nOuts); + for (iOut = 0; iOut < obj->nOuts; iOut++) { + obj->outs[iOut] = msg_envs_construct(msg_envs_config); + } + + return obj; + + } + + void con_envs_destroy(con_envs_obj * obj) { + + unsigned int iOut; + + for (iOut = 0; iOut < obj->nOuts; iOut++) { + msg_envs_destroy(obj->outs[iOut]); + } + free((void *) obj->outs); + + msg_envs_destroy(obj->in); + + free((void *) obj); + + } + + int con_envs_process(con_envs_obj * obj) { + + unsigned int iOut; + int rtnValue; + + for (iOut = 0; iOut < obj->nOuts; iOut++) { + msg_envs_copy(obj->outs[iOut], obj->in); + } + + if (msg_envs_isZero(obj->in) == 1) { + rtnValue = -1; + } + else { + rtnValue = 0; + } + + return rtnValue; + + } \ No newline at end of file diff --git a/src/connector/con_envs.h b/src/connector/con_envs.h new file mode 100644 index 0000000..ea6fa27 --- /dev/null +++ b/src/connector/con_envs.h @@ -0,0 +1,24 @@ +#ifndef __ODAS_CONNECTOR_ENVS +#define __ODAS_CONNECTOR_ENVS + + #include "../message/msg_envs.h" + + #include + #include + + typedef struct con_envs_obj { + + msg_envs_obj * in; + msg_envs_obj ** outs; + + unsigned int nOuts; + + } con_envs_obj; + + con_envs_obj * con_envs_construct(const unsigned int nOuts, const msg_envs_cfg * msg_envs_config); + + void con_envs_destroy(con_envs_obj * obj); + + int con_envs_process(con_envs_obj * obj); + +#endif \ No newline at end of file diff --git a/src/message/msg_envs.c b/src/message/msg_envs.c new file mode 100644 index 0000000..9ac4e44 --- /dev/null +++ b/src/message/msg_envs.c @@ -0,0 +1,91 @@ + + #include "msg_envs.h" + + msg_envs_obj * msg_envs_construct(const msg_envs_cfg * msg_envs_config) { + + msg_envs_obj * obj; + + obj = (msg_envs_obj *) malloc(sizeof(msg_envs_obj)); + + obj->timeStamp = 0; + obj->fS = msg_envs_config->fS; + obj->envs = envs_construct_zero(msg_envs_config->nChannels, msg_envs_config->halfFrameSize); + + return obj; + + } + + void msg_envs_destroy(msg_envs_obj * obj) { + + free((void *) obj->envs); + free((void *) obj); + + } + + void msg_envs_copy(msg_envs_obj * dest, const msg_envs_obj * src) { + + dest->timeStamp = src->timeStamp; + dest->fS = src->fS; + envs_copy(dest->envs, src->envs); + + } + + void msg_envs_zero(msg_envs_obj * obj) { + + obj->timeStamp = 0; + obj->fS = 0; + envs_zero(obj->envs); + + } + + unsigned int msg_envs_isZero(const msg_envs_obj * obj) { + + unsigned int rtnValue; + + if (obj->timeStamp == 0) { + rtnValue = 1; + } + else { + rtnValue = 0; + } + + return rtnValue; + + } + + msg_envs_cfg * msg_envs_cfg_construct(void) { + + msg_envs_cfg * cfg; + + cfg = (msg_envs_cfg *) malloc(sizeof(msg_envs_cfg)); + + cfg->halfFrameSize = 0; + cfg->nChannels = 0; + cfg->fS = 0; + + return cfg; + + } + + void msg_envs_cfg_destroy(msg_envs_cfg * msg_envs_config) { + + free((void *) msg_envs_config); + + } + + void msg_envs_cfg_printf(const msg_envs_cfg * msg_envs_config) { + + if (msg_envs_config != NULL) { + + printf("halfFrameSize = %u\n", msg_envs_config->halfFrameSize); + printf("nChannels = %u\n", msg_envs_config->nChannels); + printf("fS = %u\n", msg_envs_config->fS); + + } + else { + + printf("(null)\n"); + + } + + } \ No newline at end of file diff --git a/src/message/msg_envs.h b/src/message/msg_envs.h new file mode 100644 index 0000000..da4c128 --- /dev/null +++ b/src/message/msg_envs.h @@ -0,0 +1,40 @@ +#ifndef __ODAS_MESSAGE_ENVS +#define __ODAS_MESSAGE_ENVS + + #include + + #include "../signal/env.h" + + typedef struct msg_envs_obj { + + unsigned long long timeStamp; + unsigned int fS; + envs_obj * envs; + + } msg_envs_obj; + + typedef struct msg_envs_cfg { + + unsigned int halfFrameSize; + unsigned int nChannels; + unsigned int fS; + + } msg_envs_cfg; + + msg_envs_obj * msg_envs_construct(const msg_envs_cfg * msg_envs_config); + + void msg_envs_destroy(msg_envs_obj * obj); + + void msg_envs_copy(msg_envs_obj * dest, const msg_envs_obj * src); + + void msg_envs_zero(msg_envs_obj * obj); + + unsigned int msg_envs_isZero(const msg_envs_obj * obj); + + msg_envs_cfg * msg_envs_cfg_construct(void); + + void msg_envs_cfg_destroy(msg_envs_cfg * msg_envs_config); + + void msg_envs_cfg_printf(const msg_envs_cfg * msg_envs_config); + +#endif \ No newline at end of file diff --git a/src/module/mod_gain.c b/src/module/mod_gain.c new file mode 100644 index 0000000..b781360 --- /dev/null +++ b/src/module/mod_gain.c @@ -0,0 +1,85 @@ + + #include "mod_gain.h" + + mod_gain_obj * mod_gain_construct(const mod_gain_cfg * mod_gain_config, const msg_hops_cfg * msg_hops_config) { + + mod_gain_obj * obj; + + obj = (mod_gain_obj *) malloc(sizeof(mod_gain_obj)); + + obj->hop2hop_gain = hop2hop_gain_construct_zero(msg_hops_config->hopSize, mod_gain_config->gain); + + obj->in = (msg_hops_obj *) NULL; + obj->out = (msg_hops_obj *) NULL; + + return obj; + + } + + void mod_gain_destroy(mod_gain_obj * obj) { + + hop2hop_gain_destroy(obj->hop2hop_gain); + free((void *) obj); + + } + + int mod_gain_process(mod_gain_obj * obj) { + + int rtnValue; + + if (msg_hops_isZero(obj->in) == 0) { + + hop2hop_gain_process(obj->hop2hop_gain, obj->in->hops, obj->out->hops); + + obj->out->timeStamp = obj->in->timeStamp; + + rtnValue = 0; + + } + else { + + msg_hops_zero(obj->out); + + rtnValue = -1; + + } + + return rtnValue; + + } + + void mod_gain_connect(mod_gain_obj * obj, msg_hops_obj * in, msg_hops_obj * out) { + + obj->in = in; + obj->out = out; + + } + + void mod_gain_disconnect(mod_gain_obj * obj) { + + obj->in = (msg_hops_obj *) NULL; + obj->out = (msg_hops_obj *) NULL; + + } + + mod_gain_cfg * mod_gain_cfg_construct(void) { + + mod_gain_cfg * cfg; + + cfg = (mod_gain_cfg *) malloc(sizeof(mod_gain_cfg)); + + cfg->gain = 0.0f; + + return cfg; + + } + + void mod_gain_cfg_destroy(mod_gain_cfg * cfg) { + + free((void *) cfg); + + } + + void mod_gain_cfg_printf(const mod_gain_cfg * cfg) { + + } \ No newline at end of file diff --git a/src/module/mod_gain.h b/src/module/mod_gain.h new file mode 100644 index 0000000..24039de --- /dev/null +++ b/src/module/mod_gain.h @@ -0,0 +1,38 @@ +#ifndef __ODAS_MODULE_GAIN +#define __ODAS_MODULE_GAIN + + #include "../system/hop2hop.h" + #include "../message/msg_hops.h" + + typedef struct mod_gain_obj { + + hop2hop_gain_obj * hop2hop_gain; + + msg_hops_obj * in; + msg_hops_obj * out; + + } mod_gain_obj; + + typedef struct mod_gain_cfg { + + float gain; + + } mod_gain_cfg; + + mod_gain_obj * mod_gain_construct(const mod_gain_cfg * mod_gain_config, const msg_hops_cfg * msg_hops_config); + + void mod_gain_destroy(mod_gain_obj * obj); + + int mod_gain_process(mod_gain_obj * obj); + + void mod_gain_connect(mod_gain_obj * obj, msg_hops_obj * in, msg_hops_obj * out); + + void mod_gain_disconnect(mod_gain_obj * obj); + + mod_gain_cfg * mod_gain_cfg_construct(void); + + void mod_gain_cfg_destroy(mod_gain_cfg * cfg); + + void mod_gain_cfg_printf(const mod_gain_cfg * cfg); + +#endif \ No newline at end of file diff --git a/src/module/mod_resample.c b/src/module/mod_resample.c index 0d05a34..bb8dcd7 100644 --- a/src/module/mod_resample.c +++ b/src/module/mod_resample.c @@ -41,7 +41,7 @@ obj->framesAnalysis = frames_construct_zero(obj->nChannels, obj->frameSize); obj->frame2freq = frame2freq_construct_zero(obj->frameSize, obj->halfFrameSize); obj->freqsAnalysis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); - obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, obj-> lowPassCut, 0.0f); + obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, obj-> lowPassCut, 0.0f, 0.0f, 0.0f, 0.0f); obj->freqsSynthesis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); obj->freq2frame = freq2frame_construct_zero(obj->frameSize, obj->halfFrameSize); obj->framesSynthesis = frames_construct_zero(obj->nChannels, obj->frameSize); @@ -62,7 +62,7 @@ obj->framesAnalysis = frames_construct_zero(obj->nChannels, obj->frameSize); obj->frame2freq = frame2freq_construct_zero(obj->frameSize, obj->halfFrameSize); obj->freqsAnalysis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); - obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, obj-> lowPassCut, 0.0f); + obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, obj-> lowPassCut, 0.0f, 0.0f, 0.0f, 0.0f); obj->freqsSynthesis = freqs_construct_zero(obj->nChannels, obj->halfFrameSize); obj->freq2frame = freq2frame_construct_zero(obj->frameSize, obj->halfFrameSize); obj->framesSynthesis = frames_construct_zero(obj->nChannels, obj->frameSize); diff --git a/src/module/mod_ssl.c b/src/module/mod_ssl.c index 32582d8..36582ed 100644 --- a/src/module/mod_ssl.c +++ b/src/module/mod_ssl.c @@ -38,7 +38,10 @@ obj->freq2freq = freq2freq_construct_zero(msg_spectra_config->halfFrameSize, 0, - mod_ssl_config->epsilon); + mod_ssl_config->epsilon, + 0.0f, + 0.0f, + 0.0f); obj->phasors = freqs_construct_zero(mod_ssl_config->mics->nChannels, msg_spectra_config->halfFrameSize); diff --git a/src/module/mod_sspf.c b/src/module/mod_sspf.c index 30f472e..231ef3a 100644 --- a/src/module/mod_sspf.c +++ b/src/module/mod_sspf.c @@ -1,41 +1,28 @@ #include "mod_sspf.h" - mod_sspf_obj * mod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config) { + mod_sspf_obj * mod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config) { mod_sspf_obj * obj; obj = (mod_sspf_obj *) malloc(sizeof(mod_sspf_obj)); - obj->nChannels = mod_sspf_config->mics->nChannels; - obj->nSeps = msg_tracks_config->nTracks; + obj->nSeps = msg_spectra_config->nChannels; + obj->halfFrameSize = msg_spectra_config->halfFrameSize; - obj->beampatterns_mics = directivity_beampattern_mics(mod_sspf_config->mics, mod_sspf_config->nThetas); - obj->beampatterns_spatialfilter = directivity_beampattern_spatialfilter(mod_sspf_config->spatialfilter, mod_sspf_config->nThetas); + obj->alpha = mod_sspf_config->alpha; + obj->beta = mod_sspf_config->beta; + obj->Ginterf = mod_sspf_config->Ginterf; + obj->epsilon = mod_sspf_config->epsilon; - obj->track2gain = track2gain_construct_zero(obj->nSeps, - obj->nChannels, - mod_sspf_config->mics->direction, - mod_sspf_config->spatialfilter->direction); - - obj->gains = gains_construct_zero(obj->nSeps, - obj->nChannels); - - obj->gain2mask = gain2mask_construct_zero(obj->nSeps, - obj->nChannels, - mod_sspf_config->gainMin); - - obj->masks = masks_construct_zero(obj->nSeps, - obj->nChannels); - - obj->freq2freq = freq2freq_construct_zero(msg_spectra_config->halfFrameSize, - 0, - mod_sspf_config->epsilon); + obj->freq2env = freq2env_construct_zero(obj->halfFrameSize, obj->nSeps); + obj->envs = envs_construct_zero(obj->nSeps, obj->halfFrameSize); + obj->freq2freq = freq2freq_construct_zero(obj->halfFrameSize, 0, obj->epsilon, obj->alpha, obj->beta, obj->Ginterf); obj->in1 = (msg_spectra_obj *) NULL; - obj->in2 = (msg_spectra_obj *) NULL; + obj->in2 = (msg_envs_obj *) NULL; obj->in3 = (msg_tracks_obj *) NULL; - obj->out = (msg_spectra_obj *) NULL; + obj->out = (msg_spectra_obj *) NULL; return obj; @@ -43,13 +30,8 @@ void mod_sspf_destroy(mod_sspf_obj * obj) { - beampatterns_destroy(obj->beampatterns_mics); - beampatterns_destroy(obj->beampatterns_spatialfilter); - - track2gain_destroy(obj->track2gain); - gains_destroy(obj->gains); - gain2mask_destroy(obj->gain2mask); - masks_destroy(obj->masks); + freq2env_destroy(obj->freq2env); + envs_destroy(obj->envs); freq2freq_destroy(obj->freq2freq); free((void *) obj); @@ -60,29 +42,15 @@ int rtnValue; - if ((msg_spectra_isZero(obj->in1) == 0) && (msg_spectra_isZero(obj->in2) == 0) && (msg_tracks_isZero(obj->in3) == 0)) { + if ((msg_spectra_isZero(obj->in1) == 0) && (msg_envs_isZero(obj->in2) == 0) && (msg_tracks_isZero(obj->in3) == 0)) { if ((obj->in1->timeStamp != obj->in2->timeStamp) || (obj->in1->timeStamp != obj->in3->timeStamp)) { printf("Time stamp mismatch.\n"); exit(EXIT_FAILURE); } - track2gain_process(obj->track2gain, - obj->beampatterns_mics, - obj->beampatterns_spatialfilter, - obj->in3->tracks, - obj->gains); - - gain2mask_process(obj->gain2mask, - obj->gains, - obj->masks); - - freq2freq_process_postfilter(obj->freq2freq, - obj->in1->freqs, - obj->in2->freqs, - obj->gains, - obj->masks, - obj->out->freqs); + freq2env_process(obj->freq2env, obj->in1->freqs, obj->envs); + freq2freq_process_postfilter(obj->freq2freq, obj->in3->tracks, obj->in1->freqs, obj->envs, obj->in2->envs, obj->out->freqs); obj->out->timeStamp = obj->in1->timeStamp; @@ -93,7 +61,7 @@ msg_spectra_zero(obj->out); - rtnValue = -1; + rtnValue = -1; } @@ -101,7 +69,7 @@ } - void mod_sspf_connect(mod_sspf_obj * obj, msg_spectra_obj * in1, msg_spectra_obj * in2, msg_tracks_obj * in3, msg_spectra_obj * out) { + void mod_sspf_connect(mod_sspf_obj * obj, msg_spectra_obj * in1, msg_envs_obj * in2, msg_tracks_obj * in3, msg_spectra_obj * out) { obj->in1 = in1; obj->in2 = in2; @@ -113,9 +81,9 @@ void mod_sspf_disconnect(mod_sspf_obj * obj) { obj->in1 = (msg_spectra_obj *) NULL; - obj->in2 = (msg_spectra_obj *) NULL; + obj->in2 = (msg_envs_obj *) NULL; obj->in3 = (msg_tracks_obj *) NULL; - obj->out = (msg_spectra_obj *) NULL; + obj->out = (msg_spectra_obj *) NULL; } @@ -125,32 +93,21 @@ cfg = (mod_sspf_cfg *) malloc(sizeof(mod_sspf_cfg)); - cfg->mics = (mics_obj *) NULL; - cfg->spatialfilter = (spatialfilter_obj *) NULL; - + cfg->alpha = 0.0f; + cfg->beta = 0.0f; + cfg->Ginterf = 0.0f; cfg->epsilon = 0.0f; - cfg->nThetas = 0; - cfg->gainMin = 0.0f; - return cfg; } void mod_sspf_cfg_destroy(mod_sspf_cfg * cfg) { - if (cfg->mics != NULL) { - mics_destroy(cfg->mics); - } - - if (cfg->spatialfilter != NULL) { - spatialfilter_destroy(cfg->spatialfilter); - } - free((void *) cfg); } void mod_sspf_cfg_printf(const mod_sspf_cfg * cfg) { - } + } \ No newline at end of file diff --git a/src/module/mod_sspf.h b/src/module/mod_sspf.h index 43d8f60..ee31703 100644 --- a/src/module/mod_sspf.h +++ b/src/module/mod_sspf.h @@ -1,43 +1,32 @@ #ifndef __ODAS_MODULE_SSPF #define __ODAS_MODULE_SSPF - #include "../signal/beampattern.h" - #include "../signal/freq.h" - #include "../signal/gain.h" - #include "../signal/mask.h" - - #include "../system/gain2mask.h" - #include "../system/track2gain.h" - #include "../system/freq2freq.h" - - #include "../general/mic.h" - #include "../general/samplerate.h" - #include "../general/soundspeed.h" - #include "../general/spatialfilter.h" - - #include "../init/directivity.h" - + #include "../message/msg_envs.h" #include "../message/msg_spectra.h" #include "../message/msg_tracks.h" + #include "../system/freq2env.h" + #include "../signal/env.h" + #include "../system/freq2freq.h" + #include typedef struct mod_sspf_obj { - unsigned int nChannels; unsigned int nSeps; + unsigned int halfFrameSize; - beampatterns_obj * beampatterns_mics; - beampatterns_obj * beampatterns_spatialfilter; + float alpha; + float beta; + float Ginterf; + float epsilon; - track2gain_obj * track2gain; - gains_obj * gains; - gain2mask_obj * gain2mask; - masks_obj * masks; + freq2env_obj * freq2env; + envs_obj * envs; freq2freq_obj * freq2freq; msg_spectra_obj * in1; - msg_spectra_obj * in2; + msg_envs_obj * in2; msg_tracks_obj * in3; msg_spectra_obj * out; @@ -45,23 +34,20 @@ typedef struct mod_sspf_cfg { - mics_obj * mics; - spatialfilter_obj * spatialfilter; - + float alpha; + float beta; + float Ginterf; float epsilon; - unsigned int nThetas; - float gainMin; - } mod_sspf_cfg; - mod_sspf_obj * mod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config); + mod_sspf_obj * mod_sspf_construct(const mod_sspf_cfg * mod_sspf_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config); void mod_sspf_destroy(mod_sspf_obj * obj); int mod_sspf_process(mod_sspf_obj * obj); - void mod_sspf_connect(mod_sspf_obj * obj, msg_spectra_obj * in1, msg_spectra_obj * in2, msg_tracks_obj * in3, msg_spectra_obj * out); + void mod_sspf_connect(mod_sspf_obj * obj, msg_spectra_obj * in1, msg_envs_obj * in2, msg_tracks_obj * in3, msg_spectra_obj * out); void mod_sspf_disconnect(mod_sspf_obj * obj); diff --git a/src/module/mod_sss.c b/src/module/mod_sss.c index cf84e58..8f91ef7 100644 --- a/src/module/mod_sss.c +++ b/src/module/mod_sss.c @@ -1,7 +1,7 @@ #include "mod_sss.h" - mod_sss_obj * mod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config) { + mod_sss_obj * mod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config) { mod_sss_obj * obj; @@ -13,15 +13,6 @@ 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->track2shift = track2shift_construct_zero(obj->nSeps, - obj->nChannels, - mod_sss_config->samplerate->mu, - mod_sss_config->soundspeed->mu, - mod_sss_config->mics->mu); - - obj->shifts = shifts_construct_zero(obj->nSeps, - obj->nChannels); - obj->track2gain = track2gain_construct_zero(obj->nSeps, obj->nChannels, mod_sss_config->mics->direction, @@ -37,13 +28,32 @@ obj->masks = masks_construct_zero(obj->nSeps, obj->nChannels); - obj->freq2freq = freq2freq_construct_zero(msg_spectra_config->halfFrameSize, - 0, - 0.0f); + obj->track2steer = track2steer_construct_zero(obj->nSeps, + obj->nChannels, + msg_spectra_config->halfFrameSize, + mod_sss_config->soundspeed->mu, + mod_sss_config->samplerate->mu, + mod_sss_config->mics->mu); + + obj->W = steers_construct_zero(msg_spectra_config->halfFrameSize, + obj->nSeps, + obj->nChannels); + + obj->steer2freq = steer2freq_construct_zero(obj->nSeps, + obj->nChannels, + msg_spectra_config->halfFrameSize); + + obj->steer2env = steer2env_construct_zero(obj->nSeps, + obj->nChannels, + msg_envs_config->halfFrameSize); + + obj->ids = (unsigned long long *) malloc(sizeof(unsigned long long) * obj->nSeps); + memset(obj->ids, 0x00, sizeof(unsigned long long) * obj->nSeps); obj->in1 = (msg_spectra_obj *) NULL; obj->in2 = (msg_tracks_obj *) NULL; - obj->out = (msg_spectra_obj *) NULL; + obj->out1 = (msg_spectra_obj *) NULL; + obj->out2 = (msg_envs_obj *) NULL; return obj; @@ -54,13 +64,15 @@ beampatterns_destroy(obj->beampatterns_mics); beampatterns_destroy(obj->beampatterns_spatialfilter); - track2shift_destroy(obj->track2shift); - shifts_destroy(obj->shifts); track2gain_destroy(obj->track2gain); gains_destroy(obj->gains); gain2mask_destroy(obj->gain2mask); masks_destroy(obj->masks); - freq2freq_destroy(obj->freq2freq); + + track2steer_destroy(obj->track2steer); + steers_destroy(obj->W); + steer2freq_destroy(obj->steer2freq); + steer2env_destroy(obj->steer2env); free((void *) obj); @@ -69,6 +81,7 @@ int mod_sss_process(mod_sss_obj * obj) { int rtnValue; + unsigned int iSep; if ((msg_spectra_isZero(obj->in1) == 0) && (msg_tracks_isZero(obj->in2) == 0)) { @@ -77,35 +90,51 @@ exit(EXIT_FAILURE); } - track2shift_process(obj->track2shift, - obj->in2->tracks, - obj->shifts); - + // Generate the gain according to each source direction track2gain_process(obj->track2gain, obj->beampatterns_mics, obj->beampatterns_spatialfilter, obj->in2->tracks, obj->gains); + // Generate masks from gains gain2mask_process(obj->gain2mask, obj->gains, obj->masks); - - freq2freq_process_delaysum(obj->freq2freq, - obj->in1->freqs, - obj->shifts, - obj->gains, - obj->masks, - obj->out->freqs); - - obj->out->timeStamp = obj->in1->timeStamp; + + // Generate the demixing matrix W with gains + track2steer_process_demixing(obj->track2steer, + obj->in2->tracks, + obj->gains, + obj->masks, + obj->W); + + // Apply W to get separated spectra + steer2freq_process(obj->steer2freq, + obj->in2->tracks, + obj->W, + obj->masks, + obj->in1->freqs, + obj->out1->freqs); + + // Apply W to get separated envelope + steer2env_process(obj->steer2env, + obj->in2->tracks, + obj->W, + obj->masks, + obj->in1->freqs, + obj->out2->envs); + + obj->out1->timeStamp = obj->in1->timeStamp; + obj->out2->timeStamp = obj->in1->timeStamp; rtnValue = 0; } else { - msg_spectra_zero(obj->out); + msg_spectra_zero(obj->out1); + msg_envs_zero(obj->out2); rtnValue = -1; @@ -115,11 +144,12 @@ } - void mod_sss_connect(mod_sss_obj * obj, msg_spectra_obj * in1, msg_tracks_obj * in2, msg_spectra_obj * out) { + void mod_sss_connect(mod_sss_obj * obj, msg_spectra_obj * in1, msg_tracks_obj * in2, msg_spectra_obj * out1, msg_envs_obj * out2) { obj->in1 = in1; obj->in2 = in2; - obj->out = out; + obj->out1 = out1; + obj->out2 = out2; } @@ -127,7 +157,8 @@ obj->in1 = (msg_spectra_obj *) NULL; obj->in2 = (msg_tracks_obj *) NULL; - obj->out = (msg_spectra_obj *) NULL; + obj->out1 = (msg_spectra_obj *) NULL; + obj->out2 = (msg_envs_obj *) NULL; } diff --git a/src/module/mod_sss.h b/src/module/mod_sss.h index 0868863..c638611 100644 --- a/src/module/mod_sss.h +++ b/src/module/mod_sss.h @@ -5,12 +5,13 @@ #include "../signal/freq.h" #include "../signal/gain.h" #include "../signal/mask.h" - #include "../signal/shift.h" #include "../system/gain2mask.h" #include "../system/track2gain.h" - #include "../system/track2shift.h" #include "../system/freq2freq.h" + #include "../system/track2steer.h" + #include "../system/steer2env.h" + #include "../system/steer2freq.h" #include "../general/mic.h" #include "../general/samplerate.h" @@ -19,6 +20,7 @@ #include "../init/directivity.h" + #include "../message/msg_envs.h" #include "../message/msg_spectra.h" #include "../message/msg_tracks.h" @@ -26,23 +28,29 @@ typedef struct mod_sss_obj { + unsigned int halfFrameSize; unsigned int nChannels; unsigned int nSeps; beampatterns_obj * beampatterns_mics; beampatterns_obj * beampatterns_spatialfilter; - track2shift_obj * track2shift; - shifts_obj * shifts; track2gain_obj * track2gain; gains_obj * gains; gain2mask_obj * gain2mask; masks_obj * masks; - freq2freq_obj * freq2freq; + + track2steer_obj * track2steer; + steers_obj * W; + steer2freq_obj * steer2freq; + steer2env_obj * steer2env; msg_spectra_obj * in1; msg_tracks_obj * in2; - msg_spectra_obj * out; + msg_spectra_obj * out1; + msg_envs_obj * out2; + + unsigned long long * ids; } mod_sss_obj; @@ -54,17 +62,17 @@ spatialfilter_obj * spatialfilter; unsigned int nThetas; - float gainMin; + float gainMin; } mod_sss_cfg; - mod_sss_obj * mod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_spectra_cfg * msg_spectra_config, const msg_tracks_cfg * msg_tracks_config); + mod_sss_obj * mod_sss_construct(const mod_sss_cfg * mod_sss_config, const msg_tracks_cfg * msg_tracks_config, const msg_spectra_cfg * msg_spectra_config, const msg_envs_cfg * msg_envs_config); void mod_sss_destroy(mod_sss_obj * obj); int mod_sss_process(mod_sss_obj * obj); - void mod_sss_connect(mod_sss_obj * obj, msg_spectra_obj * in1, msg_tracks_obj * in2, msg_spectra_obj * out); + void mod_sss_connect(mod_sss_obj * obj, msg_spectra_obj * in1, msg_tracks_obj * in2, msg_spectra_obj * out1, msg_envs_obj * out2); void mod_sss_disconnect(mod_sss_obj * obj); diff --git a/src/signal/env.c b/src/signal/env.c new file mode 100644 index 0000000..134b6cd --- /dev/null +++ b/src/signal/env.c @@ -0,0 +1,100 @@ + + #include "env.h" + + envs_obj * envs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize) { + + envs_obj * obj; + unsigned int iSignal; + + obj = (envs_obj *) malloc(sizeof(envs_obj)); + + obj->nSignals = nSignals; + obj->halfFrameSize = halfFrameSize; + + obj->array = (float **) malloc(sizeof(float *) * nSignals); + for (iSignal = 0; iSignal < nSignals; iSignal++) { + obj->array[iSignal] = (float *) malloc(sizeof(float) * halfFrameSize); + memset(obj->array[iSignal], 0x00, halfFrameSize * sizeof(float)); + } + + return obj; + + } + + envs_obj * envs_clone(const envs_obj * obj) { + + envs_obj * clone; + unsigned int iSignal; + + clone = (envs_obj *) malloc(sizeof(envs_obj)); + + clone->nSignals = obj->nSignals; + clone->halfFrameSize = obj->halfFrameSize; + + clone->array = (float **) malloc(sizeof(float *) * obj->nSignals); + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + clone->array[iSignal] = (float *) malloc(sizeof(float) * obj->halfFrameSize); + memcpy(clone->array[iSignal], obj->array[iSignal], obj->halfFrameSize * sizeof(float)); + } + + return clone; + + } + + void envs_copy(envs_obj * dest, const envs_obj * src) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < src->nSignals; iSignal++) { + memcpy(dest->array[iSignal], src->array[iSignal], src->halfFrameSize * sizeof(float)); + } + + } + + void envs_zero(envs_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + memset(obj->array[iSignal], 0x00, obj->halfFrameSize * sizeof(float)); + } + + } + + void envs_destroy(envs_obj * obj) { + + unsigned int iSignal; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + free((void *) obj->array[iSignal]); + } + free((void *) obj->array); + + free((void *) obj); + + } + + void envs_printf(const envs_obj * obj) { + + unsigned int iSignal; + unsigned int iSample; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + + printf("(%04u): ",iSignal); + + for (iSample = 0; iSample < obj->halfFrameSize; iSample++) { + + printf("%+1.5f ", obj->array[iSignal][iSample]); + + if ((((iSample+1) % 16) == 0) && ((iSample+1)!=obj->halfFrameSize)) { + printf("\n "); + } + + } + + printf("\n"); + + } + + } \ No newline at end of file diff --git a/src/signal/env.h b/src/signal/env.h new file mode 100644 index 0000000..7803ec2 --- /dev/null +++ b/src/signal/env.h @@ -0,0 +1,28 @@ +#ifndef __ODAS_SIGNAL_ENV +#define __ODAS_SIGNAL_ENV + + #include + #include + #include + + typedef struct envs_obj { + + unsigned int nSignals; + unsigned int halfFrameSize; + float ** array; + + } envs_obj; + + envs_obj * envs_construct_zero(const unsigned int nSignals, const unsigned int halfFrameSize); + + envs_obj * envs_clone(const envs_obj * obj); + + void envs_copy(envs_obj * dest, const envs_obj * src); + + void envs_zero(envs_obj * obj); + + void envs_destroy(envs_obj * obj); + + void envs_printf(const envs_obj * obj); + +#endif \ No newline at end of file diff --git a/src/signal/shift.c b/src/signal/shift.c deleted file mode 100644 index 1e61c34..0000000 --- a/src/signal/shift.c +++ /dev/null @@ -1,47 +0,0 @@ - - #include "shift.h" - - shifts_obj * shifts_construct_zero(const unsigned int nSeps, const unsigned int nChannels) { - - shifts_obj * obj; - unsigned int iChannel; - - obj = (shifts_obj *) malloc(sizeof(shifts_obj)); - - obj->nSeps = nSeps; - obj->nChannels = nChannels; - - obj->array = (float *) malloc(sizeof(float) * nSeps * nChannels); - memset(obj->array, 0x00, sizeof(float) * nSeps * nChannels); - - return obj; - - } - - void shifts_destroy(shifts_obj * obj) { - - free((void *) obj->array); - free((void *) obj); - - } - - void shifts_printf(const shifts_obj * obj) { - - unsigned int iSep; - unsigned int iChannel; - - for (iSep = 0; iSep < obj->nSeps; iSep++) { - - printf("(%02u): ",iSep); - - for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - - printf("%+1.3f ",obj->array[iChannel]); - - } - - printf("\n"); - - } - - } \ No newline at end of file diff --git a/src/signal/shift.h b/src/signal/shift.h deleted file mode 100644 index 3613121..0000000 --- a/src/signal/shift.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __ODAS_SIGNAL_SHIFT -#define __ODAS_SIGNAL_SHIFT - - #include - #include - #include - - typedef struct shifts_obj { - - unsigned int nSeps; - unsigned int nChannels; - float * array; - - } shifts_obj; - - shifts_obj * shifts_construct_zero(const unsigned int nSeps, const unsigned int nChannels); - - void shifts_destroy(shifts_obj * obj); - - void shifts_printf(const shifts_obj * obj); - -#endif \ No newline at end of file diff --git a/src/signal/steer.c b/src/signal/steer.c new file mode 100644 index 0000000..50394af --- /dev/null +++ b/src/signal/steer.c @@ -0,0 +1,85 @@ + + #include "steer.h" + + steers_obj * steers_construct_zero(const unsigned int halfFrameSize, const unsigned int nSeps, const unsigned int nChannels) { + + steers_obj * obj; + unsigned int iSep; + + obj = (steers_obj *) malloc(sizeof(steers_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 steers_destroy(steers_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 steers_copy(steers_obj * dest, const steers_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 steers_printf(const steers_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 diff --git a/src/signal/steer.h b/src/signal/steer.h new file mode 100644 index 0000000..8fab923 --- /dev/null +++ b/src/signal/steer.h @@ -0,0 +1,26 @@ +#ifndef __ODAS_SIGNAL_STEER +#define __ODAS_SIGNAL_STEER + + #include + #include + #include + + typedef struct steers_obj { + + unsigned int nSeps; + unsigned int nChannels; + unsigned int halfFrameSize; + + float ** array; + + } steers_obj; + + steers_obj * steers_construct_zero(const unsigned int halfFrameSize, const unsigned int nSeps, const unsigned int nChannels); + + void steers_destroy(steers_obj * obj); + + void steers_copy(steers_obj * dest, const steers_obj * src); + + void steers_printf(const steers_obj * obj); + +#endif \ No newline at end of file diff --git a/src/sink/snk_tracks.c b/src/sink/snk_tracks.c index 9b850ad..6d18229 100644 --- a/src/sink/snk_tracks.c +++ b/src/sink/snk_tracks.c @@ -18,6 +18,7 @@ switch (obj->format->type) { case format_json: break; + case format_float: break; default: printf("Invalid format.\n"); diff --git a/src/system/freq2env.c b/src/system/freq2env.c new file mode 100644 index 0000000..295af65 --- /dev/null +++ b/src/system/freq2env.c @@ -0,0 +1,47 @@ + + #include "freq2env.h" + + freq2env_obj * freq2env_construct_zero(const unsigned int halfFrameSize, const unsigned int nSignals) { + + freq2env_obj * obj; + + obj = (freq2env_obj *) malloc(sizeof(freq2env_obj)); + + obj->halfFrameSize = halfFrameSize; + obj->nSignals = nSignals; + + return obj; + + } + + void freq2env_destroy(freq2env_obj * obj) { + + free((void *) obj); + + } + + void freq2env_process(freq2env_obj * obj, const freqs_obj * freqs, envs_obj * envs) { + + unsigned int iSignal; + unsigned int iSample; + + float real; + float imag; + float env; + + for (iSignal = 0; iSignal < obj->nSignals; iSignal++) { + + for (iSample = 0; iSample < obj->halfFrameSize; iSample++) { + + real = freqs->array[iSignal][iSample * 2 + 0]; + imag = freqs->array[iSignal][iSample * 2 + 1]; + + env = real * real + imag * imag; + + envs->array[iSignal][iSample] = sqrtf(env); + + } + + } + + } \ No newline at end of file diff --git a/src/system/freq2env.h b/src/system/freq2env.h new file mode 100644 index 0000000..aff3e63 --- /dev/null +++ b/src/system/freq2env.h @@ -0,0 +1,23 @@ +#ifndef __ODAS_SYSTEM_FREQ2ENV +#define __ODAS_SYSTEM_FREQ2ENV + + #include + #include + + #include "../signal/freq.h" + #include "../signal/env.h" + + typedef struct freq2env_obj { + + unsigned int nSignals; + unsigned int halfFrameSize; + + } freq2env_obj; + + freq2env_obj * freq2env_construct_zero(const unsigned int halfFrameSize, const unsigned int nSignals); + + void freq2env_destroy(freq2env_obj * obj); + + void freq2env_process(freq2env_obj * obj, const freqs_obj * freqs, envs_obj * envs); + +#endif \ No newline at end of file diff --git a/src/system/freq2freq.c b/src/system/freq2freq.c index 2aa0280..ce9c16b 100644 --- a/src/system/freq2freq.c +++ b/src/system/freq2freq.c @@ -1,7 +1,7 @@ #include "freq2freq.h" - freq2freq_obj * freq2freq_construct_zero(const unsigned int halfFrameSize, const unsigned int lowPassCut, const float epsilon) { + freq2freq_obj * freq2freq_construct_zero(const unsigned int halfFrameSize, const unsigned int lowPassCut, const float epsilon, const float alpha, const float beta, const float Ginterf) { freq2freq_obj * obj; @@ -11,6 +11,10 @@ obj->lowPassCut = lowPassCut; obj->epsilon = epsilon; + obj->alpha = alpha; + obj->beta = beta; + obj->Ginterf = Ginterf; + return obj; } @@ -94,163 +98,38 @@ } - void freq2freq_process_delaysum(freq2freq_obj * obj, const freqs_obj * freqsChannels, const shifts_obj * shifts, const gains_obj * gains, const masks_obj * masks, freqs_obj * freqsSeps) { + void freq2freq_process_postfilter(freq2freq_obj * obj, const tracks_obj * tracks, const freqs_obj * freqsSeps, const envs_obj * envsSeps, const envs_obj * envsDiffuse, freqs_obj * freqsPosts) { - unsigned int iSep; - unsigned int iChannel; + unsigned int iSignal; unsigned int iSample; - unsigned int nSeps; - unsigned int nChannels; - unsigned int nSamples; - float N; - - float channelReal; - float channelImag; - - float gainTotal; + float ratio; float gain; - float tau; - float phase; - - float shiftReal; - float shiftImag; - - float sepReal; - float sepImag; - - nSeps = freqsSeps->nSignals; - nChannels = freqsChannels->nSignals; - nSamples = freqsChannels->halfFrameSize; - - N = (float) (2 * (freqsChannels->halfFrameSize-1)); - - for (iSep = 0; iSep < nSeps; iSep++) { - - memset(freqsSeps->array[iSep], 0x00, sizeof(float) * nSamples * 2); - - gainTotal = 0.0f; - - for (iChannel = 0; iChannel < nChannels; iChannel++) { - - if (masks->array[iSep * nChannels + iChannel] == 0x01) { - - gainTotal += gains->array[iSep * nChannels + iChannel]; - - } + float real; + float imag; - } - - for (iChannel = 0; iChannel < nChannels; iChannel++) { - - if (masks->array[iSep * nChannels + iChannel] == 0x01) { - - gain = gains->array[iSep * nChannels + iChannel] / gainTotal; - tau = shifts->array[iSep * nChannels + iChannel]; + for (iSignal = 0; iSignal < freqsSeps->nSignals; iSignal++) { - for (iSample = 0; iSample < freqsChannels->halfFrameSize; iSample++) { + if (tracks->ids[iSignal] != 0) { - phase = 2.0f * M_PI * tau * ((float) iSample) / N; + for (iSample = 0; iSample < obj->halfFrameSize; iSample++) { - shiftReal = gain * cosf(phase); - shiftImag = gain * sinf(phase); + ratio = envsSeps->array[iSignal][iSample] / (envsDiffuse->array[iSignal][iSample] + obj->epsilon); - channelReal = freqsChannels->array[iChannel][iSample * 2 + 0]; - channelImag = freqsChannels->array[iChannel][iSample * 2 + 1]; + gain = (1.0f - obj->Ginterf) / (1.0f + expf(-1.0f * obj->alpha * (ratio - obj->beta))) + obj->Ginterf; - sepReal = channelReal * shiftReal - channelImag * shiftImag; - sepImag = channelImag * shiftReal + channelReal * shiftImag; + real = freqsSeps->array[iSignal][iSample * 2 + 0]; + imag = freqsSeps->array[iSignal][iSample * 2 + 1]; - freqsSeps->array[iSep][iSample * 2 + 0] += sepReal; - freqsSeps->array[iSep][iSample * 2 + 1] += sepImag; - - } + freqsPosts->array[iSignal][iSample * 2 + 0] = gain * real; + freqsPosts->array[iSignal][iSample * 2 + 1] = gain * imag; } } + else { - } - - } - - void freq2freq_process_postfilter(freq2freq_obj * obj, const freqs_obj * freqsChannels, const freqs_obj * freqsSeps, const gains_obj * gains, const masks_obj * masks, freqs_obj * freqsPosts) { - - unsigned int iSep; - unsigned int iChannel; - unsigned int iSample; - - unsigned int nSeps; - unsigned int nChannels; - unsigned int nSamples; - - float sepReal; - float sepImag; - float sepPwr; - - float gain; - float gainTotal; - float gainTotal2; - - float channelReal; - float channelImag; - float channelPwr; - float channelsPwr; - - float ratio; - float factor; - - nSeps = freqsSeps->nSignals; - nChannels = freqsChannels->nSignals; - nSamples = freqsChannels->halfFrameSize; - - for (iSample = 0; iSample < nSamples; iSample++) { - - for (iSep = 0; iSep < nSeps; iSep++) { - - sepReal = freqsSeps->array[iSep][iSample * 2 + 0]; - sepImag = freqsSeps->array[iSep][iSample * 2 + 1]; - sepPwr = sepReal * sepReal + sepImag * sepImag; - - gainTotal = 0.0f; - gainTotal2 = 0.0f; - - for (iChannel = 0; iChannel < nChannels; iChannel++) { - - if (masks->array[iSep * nChannels + iChannel] == 0x01) { - - gain = gains->array[iSep * nChannels + iChannel]; - gainTotal += gain; - gainTotal2 += gain * gain; - - } - - } - - channelsPwr = 0.0f; - - for (iChannel = 0; iChannel < nChannels; iChannel++) { - - if (masks->array[iSep * nChannels + iChannel] == 0x01) { - - gain = gains->array[iSep * nChannels + iChannel] / gainTotal; - - channelReal = gain * freqsChannels->array[iChannel][iSample * 2 + 0]; - channelImag = gain * freqsChannels->array[iChannel][iSample * 2 + 1]; - channelPwr = channelReal * channelReal + channelImag * channelImag; - - channelsPwr += channelPwr; - - } - - } - - ratio = sepPwr / (channelsPwr * gainTotal2 + obj->epsilon); - - factor = 0.9f / (1.0f + expf(-20.0f * (ratio-0.5f))) + 0.1f; - - freqsPosts->array[iSep][iSample * 2 + 0] = factor * freqsSeps->array[iSep][iSample * 2 + 0]; - freqsPosts->array[iSep][iSample * 2 + 1] = factor * freqsSeps->array[iSep][iSample * 2 + 1]; + memset(freqsPosts->array[iSignal], 0x00, sizeof(float) * obj->halfFrameSize * 2); } diff --git a/src/system/freq2freq.h b/src/system/freq2freq.h index 1115a9c..2b6098c 100644 --- a/src/system/freq2freq.h +++ b/src/system/freq2freq.h @@ -4,21 +4,25 @@ #include #include + #include "../signal/env.h" #include "../signal/freq.h" #include "../signal/gain.h" #include "../signal/mask.h" #include "../signal/pair.h" - #include "../signal/shift.h" + #include "../signal/track.h" typedef struct freq2freq_obj { unsigned int halfFrameSize; unsigned int lowPassCut; float epsilon; + float alpha; + float beta; + float Ginterf; } freq2freq_obj; - freq2freq_obj * freq2freq_construct_zero(const unsigned int halfFrameSize, const unsigned int lowPassCut, const float epsilon); + freq2freq_obj * freq2freq_construct_zero(const unsigned int halfFrameSize, const unsigned int lowPassCut, const float epsilon, const float alpha, const float beta, const float Ginterf); void freq2freq_destroy(freq2freq_obj * obj); @@ -28,8 +32,6 @@ void freq2freq_process_lowpass(freq2freq_obj * obj, const freqs_obj * freqsAllPass, freqs_obj * freqsLowPass); - void freq2freq_process_delaysum(freq2freq_obj * obj, const freqs_obj * freqsChannels, const shifts_obj * shifts, const gains_obj * gains, const masks_obj * masks, freqs_obj * freqsSeps); - - void freq2freq_process_postfilter(freq2freq_obj * obj, const freqs_obj * freqsChannels, const freqs_obj * freqsSeps, const gains_obj * gains, const masks_obj * masks, freqs_obj * freqsPosts); + void freq2freq_process_postfilter(freq2freq_obj * obj, const tracks_obj * tracks, const freqs_obj * freqsSeps, const envs_obj * envsSeps, const envs_obj * envsDiffuse, freqs_obj * freqsPosts); #endif \ No newline at end of file diff --git a/src/system/hop2hop.c b/src/system/hop2hop.c index 943f518..f4a3ba3 100644 --- a/src/system/hop2hop.c +++ b/src/system/hop2hop.c @@ -229,4 +229,40 @@ return rtnValue; + } + + hop2hop_gain_obj * hop2hop_gain_construct_zero(const unsigned int hopSize, const float gain) { + + hop2hop_gain_obj * obj; + + obj = (hop2hop_gain_obj *) malloc(sizeof(hop2hop_gain_obj)); + + obj->hopSize = hopSize; + obj->gain = gain; + + return obj; + + } + + void hop2hop_gain_destroy(hop2hop_gain_obj * obj) { + + free((void *) obj); + + } + + void hop2hop_gain_process(hop2hop_gain_obj * obj, const hops_obj * src, hops_obj * dest) { + + unsigned int iSignal; + unsigned int iSample; + + for (iSignal = 0; iSignal < src->nSignals; iSignal++) { + + for (iSample = 0; iSample < src->hopSize; iSample++) { + + dest->array[iSignal][iSample] = obj->gain * src->array[iSignal][iSample]; + + } + + } + } \ No newline at end of file diff --git a/src/system/hop2hop.h b/src/system/hop2hop.h index dae23c2..78ab649 100644 --- a/src/system/hop2hop.h +++ b/src/system/hop2hop.h @@ -33,6 +33,13 @@ } hop2hop_buffer_obj; + typedef struct hop2hop_gain_obj { + + unsigned int hopSize; + float gain; + + } hop2hop_gain_obj; + hop2hop_multiplex_obj * hop2hop_multiplex_construct_zero(const unsigned int hopSize); void hop2hop_multiplex_destroy(hop2hop_multiplex_obj * obj); @@ -51,4 +58,10 @@ char hop2hop_buffer_isEmpty(hop2hop_buffer_obj * obj); + hop2hop_gain_obj * hop2hop_gain_construct_zero(const unsigned int hopSize, const float gain); + + void hop2hop_gain_destroy(hop2hop_gain_obj * obj); + + void hop2hop_gain_process(hop2hop_gain_obj * obj, const hops_obj * src, hops_obj * dest); + #endif \ No newline at end of file diff --git a/src/system/shift2freq.c b/src/system/shift2freq.c deleted file mode 100644 index 9cc1692..0000000 --- a/src/system/shift2freq.c +++ /dev/null @@ -1,68 +0,0 @@ - - #include "shift2freq.h" - - shift2freq_obj * shift2freq_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize) { - - shift2freq_obj * obj; - unsigned int iSample; - - obj = (shift2freq_obj *) malloc(sizeof(shift2freq_obj)); - - obj->nChannels = nChannels; - obj->halfFrameSize = halfFrameSize; - - obj->array = (float *) malloc(sizeof(float) * halfFrameSize); - - for (iSample = 0; iSample < halfFrameSize; iSample++) { - - obj->array[iSample] = 2.0f * M_PI * ((float) iSample) / ((float) ((halfFrameSize-1)*2)); - - } - - return obj; - - } - - void shift2freq_destroy(shift2freq_obj * obj) { - - free((void *) obj); - - } - - void shift2freq_process(shift2freq_obj * obj, const shifts_obj * shifts, const gains_obj * gains, const masks_obj * masks, freqs_obj * freqs) { - - unsigned int iChannel; - unsigned int iSample; - float gainTotal; - float normalize; - - gainTotal = 0.0f; - - for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - - if (masks->array[iChannel] == 0x01) { - - gainTotal += gains->array[iChannel]; - - } - - } - - normalize = 1.0f / (gainTotal); - - for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - - if (masks->array[iChannel] == 0x01) { - - for (iSample = 0; iSample < obj->halfFrameSize; iSample++) { - - freqs->array[iChannel][iSample*2+0] = normalize * gains->array[iChannel] * cosf(obj->array[iSample] * shifts->array[iChannel]); - freqs->array[iChannel][iSample*2+1] = normalize * gains->array[iChannel] * sinf(obj->array[iSample] * shifts->array[iChannel]); - - } - - } - - } - - } \ No newline at end of file diff --git a/src/system/shift2freq.h b/src/system/shift2freq.h deleted file mode 100644 index 5e64de3..0000000 --- a/src/system/shift2freq.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __ODAS_SYSTEM_SHIFT2FREQ -#define __ODAS_SYSTEM_SHIFT2FREQ - - #include "../signal/gain.h" - #include "../signal/mask.h" - #include "../signal/shift.h" - #include "../signal/freq.h" - - #include - #include - #include - - typedef struct shift2freq_obj { - - unsigned int nChannels; - unsigned int halfFrameSize; - - float * array; - - } shift2freq_obj; - - shift2freq_obj * shift2freq_construct_zero(const unsigned int nChannels, const unsigned int halfFrameSize); - - void shift2freq_destroy(shift2freq_obj * obj); - - void shift2freq_process(shift2freq_obj * obj, const shifts_obj * shifts, const gains_obj * gains, const masks_obj * masks, freqs_obj * freqs); - -#endif \ No newline at end of file diff --git a/src/system/steer2env.c b/src/system/steer2env.c new file mode 100644 index 0000000..57de3e4 --- /dev/null +++ b/src/system/steer2env.c @@ -0,0 +1,84 @@ + + #include "steer2env.h" + + steer2env_obj * steer2env_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize) { + + steer2env_obj * obj; + + obj = (steer2env_obj *) malloc(sizeof(steer2env_obj)); + + obj->nSeps = nSeps; + obj->nChannels = nChannels; + obj->halfFrameSize = halfFrameSize; + + return obj; + + } + + void steer2env_destroy(steer2env_obj * obj) { + + free((void *) obj); + + } + + void steer2env_process(steer2env_obj * obj, const tracks_obj * tracks, const steers_obj * demixing, const masks_obj * masks, const freqs_obj * freqs, envs_obj * envs) { + + 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(envs->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize); + + 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 = freqs->array[iChannel][iSampleB * 2 + 0]; + Ximag = freqs->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; + + envs->array[iSep][iSampleB] += sqrtf(Yreal*Yreal + Yimag*Yimag); + + } + + } + + } + + } + else { + + memset(envs->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize); + + } + + } + + } diff --git a/src/system/steer2env.h b/src/system/steer2env.h new file mode 100644 index 0000000..61e1f2d --- /dev/null +++ b/src/system/steer2env.h @@ -0,0 +1,29 @@ +#ifndef __ODAS_SYSTEM_STEER2ENV +#define __ODAS_SYSTEM_STEER2ENV + + #include + #include + #include + #include + + #include "../signal/env.h" + #include "../signal/freq.h" + #include "../signal/mask.h" + #include "../signal/steer.h" + #include "../signal/track.h" + + typedef struct steer2env_obj { + + unsigned int nSeps; + unsigned int nChannels; + unsigned int halfFrameSize; + + } steer2env_obj; + + steer2env_obj * steer2env_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize); + + void steer2env_destroy(steer2env_obj * obj); + + void steer2env_process(steer2env_obj * obj, const tracks_obj * tracks, const steers_obj * demixing, const masks_obj * masks, const freqs_obj * freqs, envs_obj * envs); + +#endif \ No newline at end of file diff --git a/src/system/steer2freq.c b/src/system/steer2freq.c new file mode 100644 index 0000000..2cd750c --- /dev/null +++ b/src/system/steer2freq.c @@ -0,0 +1,85 @@ + + #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 diff --git a/src/system/steer2freq.h b/src/system/steer2freq.h new file mode 100644 index 0000000..ffe5dfd --- /dev/null +++ b/src/system/steer2freq.h @@ -0,0 +1,28 @@ +#ifndef __ODAS_SYSTEM_STEER2FREQ +#define __ODAS_SYSTEM_STEER2FREQ + + #include + #include + #include + #include + + #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 diff --git a/src/system/track2shift.c b/src/system/track2shift.c deleted file mode 100644 index 8e1c4b9..0000000 --- a/src/system/track2shift.c +++ /dev/null @@ -1,58 +0,0 @@ - - #include "track2shift.h" - - track2shift_obj * track2shift_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int fS, const unsigned int c, const float * mics) { - - track2shift_obj * obj; - - obj = (track2shift_obj *) malloc(sizeof(track2shift_obj)); - - obj->nSeps = nSeps; - obj->nChannels = nChannels; - obj->fS = fS; - obj->c = c; - - obj->mics = (float *) malloc(sizeof(float) * nChannels * 3); - memcpy(obj->mics, mics, sizeof(float) * nChannels * 3); - - return obj; - - } - - void track2shift_destroy(track2shift_obj * obj) { - - free((void *) obj->mics); - free((void *) obj); - - } - - void track2shift_process(track2shift_obj * obj, const tracks_obj * tracks, shifts_obj * shifts) { - - unsigned int iSep; - unsigned int iChannel; - float dist; - - for (iSep = 0; iSep < obj->nSeps; iSep++) { - - if (tracks->ids[iSep] != 0) { - - for (iChannel = 0; iChannel < obj->nChannels; iChannel++) { - - dist = tracks->array[iSep * 3 + 0] * obj->mics[iChannel * 3 + 0] + - tracks->array[iSep * 3 + 1] * obj->mics[iChannel * 3 + 1] + - tracks->array[iSep * 3 + 2] * obj->mics[iChannel * 3 + 2]; - - shifts->array[iSep * obj->nChannels + iChannel] = -1.0f * (((float) obj->fS) / obj->c) * dist; - - } - - } - else { - - memset(&(shifts->array[iSep * obj->nChannels]), 0x00, sizeof(float) * obj->nChannels); - - } - - } - - } \ No newline at end of file diff --git a/src/system/track2shift.h b/src/system/track2shift.h deleted file mode 100644 index 111797f..0000000 --- a/src/system/track2shift.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ODAS_SYSTEM_TRACK2SHIFT -#define __ODAS_SYSTEM_TRACK2SHIFT - - #include "../signal/track.h" - #include "../signal/shift.h" - - typedef struct track2shift_obj { - - unsigned int nSeps; - unsigned int nChannels; - unsigned int fS; - float c; - float * mics; - - } track2shift_obj; - - track2shift_obj * track2shift_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int fS, const unsigned int c, const float * mics); - - void track2shift_destroy(track2shift_obj * obj); - - void track2shift_process(track2shift_obj * obj, const tracks_obj * tracks, shifts_obj * shifts); - -#endif \ No newline at end of file diff --git a/src/system/track2steer.c b/src/system/track2steer.c new file mode 100644 index 0000000..578657f --- /dev/null +++ b/src/system/track2steer.c @@ -0,0 +1,123 @@ + + #include "track2steer.h" + + track2steer_obj * track2steer_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float c, const unsigned int fS, const float * mics) { + + track2steer_obj * obj; + unsigned int iBin; + + obj = (track2steer_obj *) malloc(sizeof(track2steer_obj)); + + obj->nSeps = nSeps; + obj->nChannels = nChannels; + obj->halfFrameSize = halfFrameSize; + obj->c = c; + obj->fS = fS; + + obj->mics = (float *) malloc(sizeof(float) * nChannels * 3); + memcpy(obj->mics, mics, sizeof(float) * nChannels * 3); + + obj->factor = (float *) malloc(sizeof(float) * halfFrameSize); + + for (iBin = 0; iBin < halfFrameSize; iBin++) { + + obj->factor[iBin] = -2.0f * M_PI * ((float) iBin) / ((float) ((halfFrameSize-1) * 2)); + + } + + obj->speed = ((float) obj->fS) / obj->c; + + return obj; + + } + + void track2steer_destroy(track2steer_obj * obj) { + + unsigned int iBin; + + free((void *) obj->factor); + free((void *) obj->mics); + + free((void *) obj); + + } + + void track2steer_process_demixing(track2steer_obj * obj, const tracks_obj * tracks, const gains_obj * gains, const masks_obj * masks, steers_obj * steers) { + + unsigned int iSep; + unsigned int iBin; + unsigned int iChannel; + + float dist; + float delay; + float gain; + float gainTotal; + char mask; + + float Wreal; + float Wimag; + + unsigned int iSampleSC; + unsigned int iSampleBC; + + for (iSep = 0; iSep < obj->nSeps; iSep++) { + + 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; + mask = masks->array[iSampleSC]; + + if (mask == 1) { + + dist = tracks->array[iSep * 3 + 0] * obj->mics[iChannel * 3 + 0] + + tracks->array[iSep * 3 + 1] * obj->mics[iChannel * 3 + 1] + + tracks->array[iSep * 3 + 2] * obj->mics[iChannel * 3 + 2]; + + delay = -1.0f * obj->speed * dist; + + gain = gains->array[iSampleSC] / gainTotal; + + 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); + + steers->array[iSep][iSampleBC * 2 + 0] = Wreal; + steers->array[iSep][iSampleBC * 2 + 1] = Wimag; + + } + + } + + } + + } + else { + + memset(steers->array[iSep], 0x00, sizeof(float) * obj->halfFrameSize * obj->nChannels * 2); + + } + + } + + } \ No newline at end of file diff --git a/src/system/track2steer.h b/src/system/track2steer.h new file mode 100644 index 0000000..b49e61d --- /dev/null +++ b/src/system/track2steer.h @@ -0,0 +1,34 @@ +#ifndef __ODAS_SYSTEM_TRACK2STEER +#define __ODAS_SYSTEM_TRACK2STEER + + #include + #include + #include + #include + + #include "../signal/gain.h" + #include "../signal/mask.h" + #include "../signal/track.h" + #include "../signal/steer.h" + + typedef struct track2steer_obj { + + unsigned int nSeps; + unsigned int nChannels; + unsigned int halfFrameSize; + float c; + unsigned int fS; + float * mics; + + float * factor; + float speed; + + } track2steer_obj; + + track2steer_obj * track2steer_construct_zero(const unsigned int nSeps, const unsigned int nChannels, const unsigned int halfFrameSize, const float c, const unsigned int fS, const float * mics); + + 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); + +#endif \ No newline at end of file