Bug fixed with resampling for sequential processing
authorFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Fri, 28 Jul 2017 16:18:22 +0000 (12:18 -0400)
committerFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Fri, 28 Jul 2017 16:18:22 +0000 (12:18 -0400)
12 files changed:
config/azimut3_close.cfg [new file with mode: 0644]
config/azimut3_open.cfg
config/interfaces.ios
config/xmos.cfg
demo/threads.c
src/amodule/amod_resample.c
src/module/mod_resample.c
src/module/mod_resample.h
src/sink/snk_hops.c
src/sink/snk_hops.h
src/utils/pcm.c
src/utils/pcm.h

diff --git a/config/azimut3_close.cfg b/config/azimut3_close.cfg
new file mode 100644 (file)
index 0000000..0fc2403
--- /dev/null
@@ -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
index 78af4f8823416768712a92d8648af0fc6368a2ed..92d0d88da153f9a87250d513657aa32feefc2117 100644 (file)
@@ -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
+}
index 7196a9d2c8f901623ea1549545b073787a60d4af..dee4bf887f50a2303fd1fd29ec2fcae451359db1 100644 (file)
@@ -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
index 531b18dc6ff44224a85414b6e0f19b5f93ece99d..99d69ae8e16acf43cd0df962d9b47af0d5ed536c 100644 (file)
@@ -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
 
index 6999feaa726d35f4c6e6f8f6fc711e858e0b07b0..37259a180442123418cb8d6963a46f75cd2fc0e2 100644 (file)
     int threads_single_process(objects * objs, profiler * prf) {
 
         int rtnValue;
+        int rtnResample;
         unsigned int iSink;
 
         clock_t begin, end;
         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;
 
index 6db2d3e4554fc8e3b3c3c621b68d60f7a66ff1ea..16e93f43109896fe05b3527cabe74d48b4259ed3 100644 (file)
         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;
             }
 
index 0034ca96962e735c9bcfdd351eed34e782f0e575..0d05a340f0df7f6c2e87947899aeda09c702822a 100644 (file)
@@ -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';
 
     }
 
-    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;
 
         }
 
 
     }
 
-    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,
                               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;
index 65a632251556306f7e0db57f4e55090660084d2d..45f7b589805c90e4cefb4ca76422e4eedd4f3395 100644 (file)
@@ -21,6 +21,7 @@
     typedef struct mod_resample_obj {
 
         unsigned long long timeStamp;
+        char noMorePush;
 
         char type;
 
 
     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);
 
index 29f0a9d2fdd6345bb982355947d0108c1e3d950e..c33d3035d5b00a1f1a55bc422e6ff47c4a8b72cd 100644 (file)
 
             case interface_socket:
 
+                //struct sockaddr_in sserver;
+                //char * smessage;
+                //int sid;
+
                 printf("Not implemented yet.\n");
                 exit(EXIT_FAILURE);
 
index 1e8ededacba3a1b4b850622c65477e0dd671599f..0cbdca6dd055f3b4220745c80efbe767a20b1f61 100644 (file)
 
         FILE * fp;
 
+        //struct sockaddr_in sserver;
+        //char * smessage;
+        //int sid;
+
         char bytes[4];
 
         msg_hops_obj * in;
index 7d66f164903fcb7b08b539ea9023a8ae32e33880..b3a98b8841495e97524d034ce6d98823da7dc3cd 100644 (file)
 
     }
 
+    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;
index df3b23ad779de378f08d3114552c543f10d81623..270125b3dee7b0667730239a478abdc4f93ff40e 100644 (file)
@@ -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