From: FrancoisGrondin Date: Fri, 28 Jul 2017 16:18:22 +0000 (-0400) Subject: Bug fixed with resampling for sequential processing X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=edc8ebd1aea1248996f9deba39976bab5ff1a1d3;p=yn%2Fyn-odas.git Bug fixed with resampling for sequential processing --- diff --git a/config/azimut3_close.cfg b/config/azimut3_close.cfg new file mode 100644 index 0000000..0fc2403 --- /dev/null +++ b/config/azimut3_close.cfg @@ -0,0 +1,281 @@ +# Configuration file for Azimut 3 - Open Microphone Array Configuration + +version = "2.0"; + +# Raw + +raw: +{ + + fS = 48000; + hopSize = 512; + nChannels = 16; + +} + +# Mapping + +mapping: +{ + + map: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); + +} + +# General + +general: +{ + + epsilon = 1E-20; + + size: + { + hopSize = 512; + frameSize = 1024; + }; + + samplerate: + { + mu = 48000; + sigma2 = 0.01; + }; + + speedofsound: + { + mu = 343.0; + sigma2 = 25.0; + }; + + mics = ( + + # Microphone 1 + { + mu = ( +0.120, -0.090, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 2 + { + mu = ( +0.120, +0.090, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 3 + { + mu = ( +0.120, -0.090, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 4 + { + mu = ( +0.120, +0.090, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 5 + { + mu = ( +0.090, +0.120, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, +1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 6 + { + mu = ( -0.090, +0.120, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, +1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 7 + { + mu = ( +0.090, +0.120, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, +1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 8 + { + mu = ( -0.090, +0.120, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, +1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 9 + { + mu = ( -0.120, +0.090, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( -1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 10 + { + mu = ( -0.120, -0.090, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( -1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 11 + { + mu = ( -0.120, +0.090, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( -1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 12 + { + mu = ( -0.120, -0.090, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( -1.000, +0.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 13 + { + mu = ( -0.090, -0.120, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, -1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 14 + { + mu = ( +0.090, -0.120, +0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, -1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 15 + { + mu = ( -0.090, -0.120, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, -1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + }, + + # Microphone 16 + { + mu = ( +0.090, -0.120, -0.090 ); + sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 ); + direction = ( +0.000, -1.000, +0.000 ); + angle = ( 80.0, 90.0 ); + } + + ); + +}; + +# Sound Source Localization + +ssl: +{ + + nPots = 4; + nMatches = 10; + probMin = 0.5; + nRefinedLevels = 1; + gainMin = 0.25; + nThetas = 181; + + # Number of scans: level is the resolution of the sphere + # and delta is the size of the maximum sliding window + # (delta = -1 means the size is automatically computed) + scans = ( + { level = 2; delta = -1; }, + { level = 4; delta = -1; } + ); + +}; + +# Sound Source Tracking + +sst: +{ + + # Mode is either "kalman" or "particle" + + mode = "kalman"; + + # Parameters used by both the Kalman and particle filter + + active = ( + { weight = 1.0; mu = 0.30; sigma2 = 0.0025 } + ); + + inactive = ( + { weight = 1.0; mu = 0.10; sigma2 = 0.0025 } + ); + + sigmaR2_prob = 0.0025; + sigmaR2_active = 0.0225; + Pfalse = 0.1; + Pnew = 0.1; + Ptrack = 0.8; + + theta_new = 0.9; + N_prob = 5; + theta_prob = 0.8; + N_inactive = ( 150, 200, 250, 250 ); + theta_inactive = 0.9; + + # Parameters used by the Kalman filter only + + kalman: { + + sigmaQ = 0.01; + + } + + # Parameters used by the particle filter only + + particle: { + + nParticles = 1000; + st_alpha = 2.0; + st_beta = 0.04; + st_ratio = 0.5; + ve_alpha = 0.05; + ve_beta = 0.2; + ve_ratio = 0.3; + ac_alpha = 0.5; + ac_beta = 0.2; + ac_ratio = 0.2; + Nmin = 0.7; + + } + +} + +# Sound source separation + +sss: { + + nThetas = 181; + gainMin = 0.01; + +} + +# Sound source post-filtering + +sspf: { + + nThetas = 181; + gainMin = 0.01; + +} \ No newline at end of file diff --git a/config/azimut3_open.cfg b/config/azimut3_open.cfg index 78af4f8..92d0d88 100644 --- a/config/azimut3_open.cfg +++ b/config/azimut3_open.cfg @@ -222,14 +222,14 @@ sst: { weight = 1.0; mu = 0.10; sigma2 = 0.0025 } ); - sigmaR2_prob = 0.0025; + sigmaR2_prob = 0.01; sigmaR2_active = 0.0225; Pfalse = 0.1; Pnew = 0.1; Ptrack = 0.8; theta_new = 0.9; - N_prob = 5; + N_prob = 10; theta_prob = 0.8; N_inactive = ( 150, 200, 250, 250 ); theta_inactive = 0.9; @@ -238,7 +238,7 @@ sst: kalman: { - sigmaQ = 0.01; + sigmaQ = 0.001; } @@ -278,4 +278,4 @@ sspf: { nThetas = 181; gainMin = 0.01; -} \ No newline at end of file +} diff --git a/config/interfaces.ios b/config/interfaces.ios index 7196a9d..dee4bf8 100644 --- a/config/interfaces.ios +++ b/config/interfaces.ios @@ -3,8 +3,8 @@ input: { - raw: { type = "file"; path = "in.raw"; format = "bin16"; } - #raw: { type = "soundcard"; card = 2; device = 0; format = "bin16"; } + raw: { type = "file"; path = "recorded_7ch_44100.raw"; format = "bin16"; } + #raw: { type = "soundcard"; card = 3; device = 0; format = "bin16"; } }; @@ -21,13 +21,13 @@ output: mapping: ( -# { type = "file"; path = "recorded_mapping_16.raw"; format = "bin16"; } + { type = "file"; path = "recorded_mapping_16.raw"; format = "bin16"; } # { type = "file"; path = "recorded_mapping_32.raw"; format = "bin32"; } ); resample: ( -# { type = "file"; path = "recorded_resample_16.raw"; format = "bin16"; }, + { type = "file"; path = "recorded_resample_16.raw"; format = "bin16"; } # { type = "file"; path = "recorded_resample_32.raw"; format = "bin32"; } ); @@ -38,22 +38,22 @@ output: ssl: ( - { type = "file"; path = "potential.bin"; format = "float"; } +# { type = "file"; path = "potential.bin"; format = "float"; } ); sst: ( - { type = "file"; path = "tracked.bin"; format = "float"; } - ) +# { type = "file"; path = "tracked.bin"; format = "float"; } + ); 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"; } + ); } \ No newline at end of file diff --git a/config/xmos.cfg b/config/xmos.cfg index 531b18d..99d69ae 100644 --- a/config/xmos.cfg +++ b/config/xmos.cfg @@ -7,9 +7,9 @@ version = "2.0"; raw: { - fS = 48000; + fS = 44100; hopSize = 512; - nChannels = 8; + nChannels = 7; } @@ -31,13 +31,13 @@ general: size: { - hopSize = 512; - frameSize = 1024; + hopSize = 128; + frameSize = 256; }; samplerate: { - mu = 48000; + mu = 16000; sigma2 = 0.01; }; @@ -138,7 +138,7 @@ sst: # Mode is either "kalman" or "particle" - mode = "particle"; + mode = "kalman"; # Parameters used by both the Kalman and particle filter diff --git a/demo/threads.c b/demo/threads.c index 6999fea..37259a1 100644 --- a/demo/threads.c +++ b/demo/threads.c @@ -634,6 +634,7 @@ int threads_single_process(objects * objs, profiler * prf) { int rtnValue; + int rtnResample; unsigned int iSink; clock_t begin, end; @@ -641,270 +642,301 @@ prf->duration += ((float) (objs->src_hops_raw_object->hopSize)) / ((float) (objs->src_hops_raw_object->fS)); // +----------------------------------------------------------+ - // | Raw | - // +----------------------------------------------------------+ + // | SECTION I | + // +----------------------------------------------------------- // +------------------------------------------------------+ - // | Source | + // | Raw | // +------------------------------------------------------+ - begin = clock(); - rtnValue = src_hops_process(objs->src_hops_raw_object); - end = clock(); - prf->src_hops_raw_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Source | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + rtnValue = src_hops_process(objs->src_hops_raw_object); + end = clock(); + prf->src_hops_raw_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_hops_process(objs->con_hops_raw_object); - end = clock(); - prf->con_hops_raw_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + begin = clock(); + con_hops_process(objs->con_hops_raw_object); + end = clock(); + prf->con_hops_raw_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - for (iSink = 0; iSink < objs->snk_hops_raw_object_count; iSink++) { + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ - snk_hops_process(objs->snk_hops_raw_objects[iSink]); + begin = clock(); + for (iSink = 0; iSink < objs->snk_hops_raw_object_count; iSink++) { - } - end = clock(); - prf->snk_hops_raw_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + snk_hops_process(objs->snk_hops_raw_objects[iSink]); - // +----------------------------------------------------------+ - // | Mapping | - // +----------------------------------------------------------+ + } + end = clock(); + prf->snk_hops_raw_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +------------------------------------------------------+ - // | Module | + // | Mapping | // +------------------------------------------------------+ - begin = clock(); - mod_mapping_process(objs->mod_mapping_object); - end = clock(); - prf->mod_mapping_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + mod_mapping_process(objs->mod_mapping_object); + end = clock(); + prf->mod_mapping_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ + + begin = clock(); + con_hops_process(objs->con_hops_mapping_object); + end = clock(); + prf->con_hops_mapping_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_hops_process(objs->con_hops_mapping_object); - end = clock(); - prf->con_hops_mapping_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + begin = clock(); + for (iSink = 0; iSink < objs->snk_hops_mapping_object_count; iSink++) { + snk_hops_process(objs->snk_hops_mapping_objects[iSink]); + } + end = clock(); + prf->snk_hops_mapping_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + // | Resample | + // +------------------------------------------------------+ - begin = clock(); - for (iSink = 0; iSink < objs->snk_hops_mapping_object_count; iSink++) { - snk_hops_process(objs->snk_hops_mapping_objects[iSink]); - } - end = clock(); - prf->snk_hops_mapping_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ + + begin = clock(); + mod_resample_process_push(objs->mod_resample_object); + end = clock(); + prf->mod_resample_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +----------------------------------------------------------+ - // | Resample | - // +----------------------------------------------------------+ + // | SECTION II | + // +----------------------------------------------------------- + + // Loop through section II as long as there are frames to process from the resample module + while(1) { // +------------------------------------------------------+ - // | Module | + // | Resample | // +------------------------------------------------------+ - begin = clock(); - mod_resample_process(objs->mod_resample_object); - end = clock(); - prf->mod_resample_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + rtnResample = mod_resample_process_pop(objs->mod_resample_object); + end = clock(); + prf->mod_resample_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_hops_process(objs->con_hops_resample_object); - end = clock(); - prf->con_hops_resample_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // If there is no frames to process, stop + if (rtnResample == -1) { + break; + } - // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ - begin = clock(); - for (iSink = 0; iSink < objs->snk_hops_resample_object_count; iSink++) { - snk_hops_process(objs->snk_hops_resample_objects[iSink]); - } - end = clock(); - prf->snk_hops_resample_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + begin = clock(); + con_hops_process(objs->con_hops_resample_object); + end = clock(); + prf->con_hops_resample_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - // +----------------------------------------------------------+ - // | STFT | - // +----------------------------------------------------------+ + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + begin = clock(); + for (iSink = 0; iSink < objs->snk_hops_resample_object_count; iSink++) { + snk_hops_process(objs->snk_hops_resample_objects[iSink]); + } + end = clock(); + prf->snk_hops_resample_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +------------------------------------------------------+ - // | Module | + // | STFT | // +------------------------------------------------------+ - begin = clock(); - mod_stft_process(objs->mod_stft_object); - end = clock(); - prf->mod_stft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + mod_stft_process(objs->mod_stft_object); + end = clock(); + prf->mod_stft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_spectra_process(objs->con_spectra_stft_object); - end = clock(); - prf->con_spectra_stft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + begin = clock(); + con_spectra_process(objs->con_spectra_stft_object); + end = clock(); + prf->con_spectra_stft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - for (iSink = 0; iSink < objs->snk_spectra_stft_object_count; iSink++) { - snk_spectra_process(objs->snk_spectra_stft_objects[iSink]); - } - end = clock(); - prf->snk_spectra_stft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ - // +----------------------------------------------------------+ - // | SSL | - // +----------------------------------------------------------+ + begin = clock(); + for (iSink = 0; iSink < objs->snk_spectra_stft_object_count; iSink++) { + snk_spectra_process(objs->snk_spectra_stft_objects[iSink]); + } + end = clock(); + prf->snk_spectra_stft_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +------------------------------------------------------+ - // | Module | + // | SSL | // +------------------------------------------------------+ - begin = clock(); - mod_ssl_process(objs->mod_ssl_object); - end = clock(); - prf->mod_ssl_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + mod_ssl_process(objs->mod_ssl_object); + end = clock(); + prf->mod_ssl_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_pots_process(objs->con_pots_ssl_object); - end = clock(); - prf->con_pots_ssl_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + begin = clock(); + con_pots_process(objs->con_pots_ssl_object); + end = clock(); + prf->con_pots_ssl_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - for (iSink = 0; iSink < objs->snk_pots_ssl_object_count; iSink++) { - snk_pots_process(objs->snk_pots_ssl_objects[iSink]); - } - end = clock(); - prf->snk_pots_ssl_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ - // +----------------------------------------------------------+ - // | SST | - // +----------------------------------------------------------+ + begin = clock(); + for (iSink = 0; iSink < objs->snk_pots_ssl_object_count; iSink++) { + snk_pots_process(objs->snk_pots_ssl_objects[iSink]); + } + end = clock(); + prf->snk_pots_ssl_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +------------------------------------------------------+ - // | Module | + // | SST | // +------------------------------------------------------+ - begin = clock(); - mod_sst_process(objs->mod_sst_object); - end = clock(); - prf->mod_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + mod_sst_process(objs->mod_sst_object); + end = clock(); + prf->mod_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_tracks_process(objs->con_tracks_sst_object); - end = clock(); - prf->con_tracks_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + begin = clock(); + con_tracks_process(objs->con_tracks_sst_object); + end = clock(); + prf->con_tracks_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - for (iSink = 0; iSink < objs->snk_tracks_sst_object_count; iSink++) { - snk_tracks_process(objs->snk_tracks_sst_objects[iSink]); - } - end = clock(); - prf->snk_tracks_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ - // +----------------------------------------------------------+ - // | SSS | - // +----------------------------------------------------------+ + begin = clock(); + for (iSink = 0; iSink < objs->snk_tracks_sst_object_count; iSink++) { + snk_tracks_process(objs->snk_tracks_sst_objects[iSink]); + } + end = clock(); + prf->snk_tracks_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +------------------------------------------------------+ - // | Module | + // | SSS | // +------------------------------------------------------+ - begin = clock(); - mod_sss_process(objs->mod_sss_object); - end = clock(); - prf->mod_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + mod_sss_process(objs->mod_sss_object); + end = clock(); + prf->mod_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_spectra_process(objs->con_spectra_sss_object); - end = clock(); - prf->con_spectra_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + begin = clock(); + con_spectra_process(objs->con_spectra_sss_object); + end = clock(); + prf->con_spectra_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - for (iSink = 0; iSink < objs->snk_spectra_sss_object_count; iSink++) { - snk_spectra_process(objs->snk_spectra_sss_objects[iSink]); - } - end = clock(); - prf->snk_spectra_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ - // +----------------------------------------------------------+ - // | SSPF | - // +----------------------------------------------------------+ + begin = clock(); + for (iSink = 0; iSink < objs->snk_spectra_sss_object_count; iSink++) { + snk_spectra_process(objs->snk_spectra_sss_objects[iSink]); + } + end = clock(); + prf->snk_spectra_sss_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); // +------------------------------------------------------+ - // | Module | + // | SSPF | // +------------------------------------------------------+ - begin = clock(); - mod_sspf_process(objs->mod_sspf_object); - end = clock(); - prf->mod_sspf_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Module | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Connector | - // +------------------------------------------------------+ + begin = clock(); + mod_sspf_process(objs->mod_sspf_object); + end = clock(); + prf->mod_sspf_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - begin = clock(); - con_spectra_process(objs->con_spectra_sspf_object); - end = clock(); - prf->con_spectra_sspf_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); + // +--------------------------------------------------+ + // | Connector | + // +--------------------------------------------------+ - // +------------------------------------------------------+ - // | Sinks | - // +------------------------------------------------------+ + begin = clock(); + con_spectra_process(objs->con_spectra_sspf_object); + end = clock(); + prf->con_spectra_sspf_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC); - 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); + // +--------------------------------------------------+ + // | Sinks | + // +--------------------------------------------------+ + + 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); + + } return rtnValue; diff --git a/src/amodule/amod_resample.c b/src/amodule/amod_resample.c index 6db2d3e..16e93f4 100644 --- a/src/amodule/amod_resample.c +++ b/src/amodule/amod_resample.c @@ -45,34 +45,39 @@ amod_resample_obj * obj; msg_hops_obj * msg_hops_in; msg_hops_obj * msg_hops_out; - int rtnValue; + int rtnValuePush; + int rtnValuePop; obj = (amod_resample_obj *) ptr; - rtnValue = 4; + rtnValuePush = 0; + rtnValuePop = 0; while(1) { - - if ((rtnValue == 3) || (rtnValue == 4)) { - msg_hops_in = amsg_hops_filled_pop(obj->in); + + if (rtnValuePush != -1) { + msg_hops_in = amsg_hops_filled_pop(obj->in); } - if ((rtnValue == 2) || (rtnValue == 4)) { + if (rtnValuePop != -1) { msg_hops_out = amsg_hops_empty_pop(obj->out); - } - + } + mod_resample_connect(obj->mod_resample, msg_hops_in, msg_hops_out); - rtnValue = mod_resample_process(obj->mod_resample); + rtnValuePush = mod_resample_process_push(obj->mod_resample); + rtnValuePop = mod_resample_process_pop(obj->mod_resample); mod_resample_disconnect(obj->mod_resample); - if ((rtnValue == 3) || (rtnValue == 4) || (rtnValue == -1)) { + if (rtnValuePush != -1) { amsg_hops_empty_push(obj->in, msg_hops_in); } - if ((rtnValue == 2) || (rtnValue == 4) || (rtnValue == -1)) { + if (rtnValuePop != -1) { amsg_hops_filled_push(obj->out, msg_hops_out); } - // If this is the last frame, rtnValue = -1 - if (rtnValue == -1) { + // If this is the last frame + if ((rtnValuePush == -1) && (rtnValuePop == -1)) { + amsg_hops_empty_push(obj->in, msg_hops_in); + amsg_hops_filled_push(obj->out, msg_hops_out); break; } diff --git a/src/module/mod_resample.c b/src/module/mod_resample.c index 0034ca9..0d05a34 100644 --- a/src/module/mod_resample.c +++ b/src/module/mod_resample.c @@ -8,6 +8,7 @@ obj = (mod_resample_obj *) malloc(sizeof(mod_resample_obj)); obj->timeStamp = 0; + obj->noMorePush = 0; if (mod_resample_config->fSin == mod_resample_config->fSout) { obj->type = 's'; @@ -150,43 +151,59 @@ } - int mod_resample_process(mod_resample_obj * obj) { + int mod_resample_process_push(mod_resample_obj * obj) { int rtnValue; - if (msg_hops_isZero(obj->in) == 0) { + switch(obj->type) { - switch(obj->type) { + case 'd': - case 'd': + rtnValue = mod_resample_process_push_down(obj); - rtnValue = mod_resample_process_down(obj); + break; - break; + case 'u': - case 'u': + rtnValue = mod_resample_process_push_up(obj); - rtnValue = mod_resample_process_up(obj); + break; - break; + case 's': - case 's': + rtnValue = mod_resample_process_push_same(obj); - rtnValue = mod_resample_process_same(obj); + break; - break; + } - } + return rtnValue; - obj->timeStamp++; - obj->out->timeStamp = obj->timeStamp; - - } - else { + } - msg_hops_zero(obj->out); + int mod_resample_process_pop(mod_resample_obj * obj) { - rtnValue = -1; + int rtnValue; + + switch(obj->type) { + + case 'd': + + rtnValue = mod_resample_process_pop_down(obj); + + break; + + case 'u': + + rtnValue = mod_resample_process_pop_up(obj); + + break; + + case 's': + + rtnValue = mod_resample_process_pop_same(obj); + + break; } @@ -194,97 +211,155 @@ } - int mod_resample_process_down(mod_resample_obj * obj) { + int mod_resample_process_push_down(mod_resample_obj * obj) { int rtnValue; - char pushDone; - char popDone; - if (hop2hop_buffer_isFull(obj->hop2hop) == 0) { + if (msg_hops_isZero(obj->in) == 0) { - hop2frame_process(obj->hop2frame, - obj->in->hops, - obj->framesAnalysis); + if (hop2hop_buffer_isFull(obj->hop2hop) == 0) { - frame2freq_process(obj->frame2freq, - obj->framesAnalysis, - obj->freqsAnalysis); + hop2frame_process(obj->hop2frame, + obj->in->hops, + obj->framesAnalysis); - freq2freq_process_lowpass(obj->freq2freq, - obj->freqsAnalysis, - obj->freqsSynthesis); + frame2freq_process(obj->frame2freq, + obj->framesAnalysis, + obj->freqsAnalysis); - freq2frame_process(obj->freq2frame, - obj->freqsSynthesis, - obj->framesSynthesis); - - frame2hop_process(obj->frame2hop, - obj->framesSynthesis, - obj->hops); + freq2freq_process_lowpass(obj->freq2freq, + obj->freqsAnalysis, + obj->freqsSynthesis); + + freq2frame_process(obj->freq2frame, + obj->freqsSynthesis, + obj->framesSynthesis); + + frame2hop_process(obj->frame2hop, + obj->framesSynthesis, + obj->hops); - hop2hop_buffer_push(obj->hop2hop, - obj->hops); + hop2hop_buffer_push(obj->hop2hop, + obj->hops); - pushDone = 1; + rtnValue = 0; + + } + else { + + rtnValue = -1; + + } } else { - pushDone = 0; + obj->noMorePush = 1; + rtnValue = -1; } - if (hop2hop_buffer_isEmpty(obj->hop2hop) == 0) { + return rtnValue; - hop2hop_buffer_pop(obj->hop2hop, - obj->out->hops); + } + + int mod_resample_process_push_up(mod_resample_obj * obj) { + + int rtnValue; + + if (msg_hops_isZero(obj->in) == 0) { + + if (hop2hop_buffer_isFull(obj->hop2hop) == 0) { + + hop2hop_buffer_push(obj->hop2hop, + obj->in->hops); + + rtnValue = 0; + + } + else { - popDone = 1; + rtnValue = -1; + + } } else { - popDone = 0; + obj->noMorePush = 1; + rtnValue = -1; - } + } + + return rtnValue; + + } + + int mod_resample_process_push_same(mod_resample_obj * obj) { + + int rtnValue; + + if (msg_hops_isZero(obj->in) == 0) { + + if (hop2hop_buffer_isFull(obj->hop2hop) == 0) { + + hop2hop_buffer_push(obj->hop2hop, + obj->in->hops); + + rtnValue = 0; + + } + else { + + rtnValue = -1; + + } - if ((pushDone == 0) && (popDone == 0)) { - rtnValue = 1; - } - if ((pushDone == 0) && (popDone == 1)) { - rtnValue = 2; - } - if ((pushDone == 1) && (popDone == 0)) { - rtnValue = 3; } - if ((pushDone == 1) && (popDone == 1)) { - rtnValue = 4; + else { + + obj->noMorePush = 1; + rtnValue = -1; + } return rtnValue; } - int mod_resample_process_up(mod_resample_obj * obj) { + int mod_resample_process_pop_down(mod_resample_obj * obj) { int rtnValue; - char pushDone; - char popDone; - if (hop2hop_buffer_isFull(obj->hop2hop) == 0) { + if (hop2hop_buffer_isEmpty(obj->hop2hop) == 0) { - hop2hop_buffer_push(obj->hop2hop, - obj->in->hops); + hop2hop_buffer_pop(obj->hop2hop, + obj->out->hops); + + obj->timeStamp++; + obj->out->timeStamp = obj->timeStamp; - pushDone = 1; + rtnValue = 0; } else { - pushDone = 0; + if (obj->noMorePush == 1) { + msg_hops_zero(obj->out); + } + + rtnValue = -1; } + return rtnValue; + + } + + int mod_resample_process_pop_up(mod_resample_obj * obj) { + + int rtnValue; + if (hop2hop_buffer_isEmpty(obj->hop2hop) == 0) { hop2hop_buffer_pop(obj->hop2hop, @@ -310,77 +385,49 @@ obj->framesSynthesis, obj->out->hops); - popDone = 1; + obj->timeStamp++; + obj->out->timeStamp = obj->timeStamp; + + rtnValue = 0; } else { - popDone = 0; + if (obj->noMorePush == 1) { + msg_hops_zero(obj->out); + } - } + rtnValue = -1; - if ((pushDone == 0) && (popDone == 0)) { - rtnValue = 1; - } - if ((pushDone == 0) && (popDone == 1)) { - rtnValue = 2; - } - if ((pushDone == 1) && (popDone == 0)) { - rtnValue = 3; - } - if ((pushDone == 1) && (popDone == 1)) { - rtnValue = 4; } return rtnValue; } - int mod_resample_process_same(mod_resample_obj * obj) { + int mod_resample_process_pop_same(mod_resample_obj * obj) { int rtnValue; - char pushDone; - char popDone; - - if (hop2hop_buffer_isFull(obj->hop2hop) == 0) { - - hop2hop_buffer_push(obj->hop2hop, - obj->in->hops); - - pushDone = 1; - - } - else { - - pushDone = 0; - - } if (hop2hop_buffer_isEmpty(obj->hop2hop) == 0) { hop2hop_buffer_pop(obj->hop2hop, obj->out->hops); - popDone = 1; + obj->timeStamp++; + obj->out->timeStamp = obj->timeStamp; + + rtnValue = 0; } else { - popDone = 0; + if (obj->noMorePush == 1) { + msg_hops_zero(obj->out); + } - } + rtnValue = -1; - if ((pushDone == 0) && (popDone == 0)) { - rtnValue = 1; - } - if ((pushDone == 0) && (popDone == 1)) { - rtnValue = 2; - } - if ((pushDone == 1) && (popDone == 0)) { - rtnValue = 3; - } - if ((pushDone == 1) && (popDone == 1)) { - rtnValue = 4; } return rtnValue; diff --git a/src/module/mod_resample.h b/src/module/mod_resample.h index 65a6322..45f7b58 100644 --- a/src/module/mod_resample.h +++ b/src/module/mod_resample.h @@ -21,6 +21,7 @@ typedef struct mod_resample_obj { unsigned long long timeStamp; + char noMorePush; char type; @@ -64,13 +65,21 @@ void mod_resample_destroy(mod_resample_obj * obj); - int mod_resample_process(mod_resample_obj * obj); + int mod_resample_process_push(mod_resample_obj * obj); - int mod_resample_process_down(mod_resample_obj * obj); + int mod_resample_process_pop(mod_resample_obj * obj); - int mod_resample_process_up(mod_resample_obj * obj); + int mod_resample_process_push_down(mod_resample_obj * obj); - int mod_resample_process_same(mod_resample_obj * obj); + int mod_resample_process_push_up(mod_resample_obj * obj); + + int mod_resample_process_push_same(mod_resample_obj * obj); + + int mod_resample_process_pop_down(mod_resample_obj * obj); + + int mod_resample_process_pop_up(mod_resample_obj * obj); + + int mod_resample_process_pop_same(mod_resample_obj * obj); void mod_resample_connect(mod_resample_obj * obj, msg_hops_obj * in, msg_hops_obj * out); diff --git a/src/sink/snk_hops.c b/src/sink/snk_hops.c index 29f0a9d..c33d303 100644 --- a/src/sink/snk_hops.c +++ b/src/sink/snk_hops.c @@ -72,6 +72,10 @@ case interface_socket: + //struct sockaddr_in sserver; + //char * smessage; + //int sid; + printf("Not implemented yet.\n"); exit(EXIT_FAILURE); diff --git a/src/sink/snk_hops.h b/src/sink/snk_hops.h index 1e8eded..0cbdca6 100644 --- a/src/sink/snk_hops.h +++ b/src/sink/snk_hops.h @@ -23,6 +23,10 @@ FILE * fp; + //struct sockaddr_in sserver; + //char * smessage; + //int sid; + char bytes[4]; msg_hops_obj * in; diff --git a/src/utils/pcm.c b/src/utils/pcm.c index 7d66f16..b3a98b8 100644 --- a/src/utils/pcm.c +++ b/src/utils/pcm.c @@ -63,6 +63,26 @@ } + void pcm_signedXXbits2json(const char * bytes, const unsigned int nBytes, char * json) { + + unsigned int iByte; + char high; + char low; + + char hex[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + + for (iByte = 0; iByte < nBytes; iByte++) { + + high = (bytes[iByte] >> 4) & 0x0F; + low = (bytes[iByte]) & 0x0F; + + json[iByte*2+0] = hex[high]; + json[iByte*2+1] = hex[low]; + + } + + } + void pcm_normalized2signedXXbits(const float sample, const unsigned int nBytes, char * bytes) { int sample32; diff --git a/src/utils/pcm.h b/src/utils/pcm.h index df3b23a..270125b 100644 --- a/src/utils/pcm.h +++ b/src/utils/pcm.h @@ -6,6 +6,8 @@ float pcm_signedXXbits2normalized(const char * bytes, const unsigned int nBytes); + void pcm_signedXXbits2json(const char * bytes, const unsigned int nBytes, char * json); + void pcm_normalized2signedXXbits(const float sample, const unsigned int nBytes, char * bytes); #endif \ No newline at end of file