better visualisation of AbyS
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 5 Jan 2016 01:43:15 +0000 (01:43 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 5 Jan 2016 01:43:15 +0000 (01:43 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2606 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/newamp.m
codec2-dev/octave/newamp_fbf.m

index b170810f971c499b0e62ec185f2f5e5da12901f8..44f0611deb30cb8fdebbf2840f26093c4efe44b4 100644 (file)
@@ -135,7 +135,9 @@ endfunction
 % Ahh, takes me back to when I was a slip of a speech coder, playing
 % with my first CELP codec!
 
-function [decmaskdB dec_samples error_log candidate_log target_log] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz)
+function [decmaskdB dec_samples mse_log] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz)
+
+    Nsamples = 4;
 
     % band pass filter: limit search to 250 to 3800 Hz
 
@@ -149,8 +151,9 @@ function [decmaskdB dec_samples error_log candidate_log target_log] = make_decma
     dec_samples = [];
     error_log = [];
     candidate_log = [];
+    mse_log = zeros(Nsamples, L);
 
-    for sample=1:4
+    for sample=1:Nsamples
 
       target_log = target;
 
@@ -161,7 +164,7 @@ function [decmaskdB dec_samples error_log candidate_log target_log] = make_decma
         single_mask_m = schroeder(m*Wo*4/pi, mask_sample_freqs_kHz) + AmdB(m);
         candidate = max(decmaskdB, single_mask_m);
         error = target - candidate;
-        mse = sum(abs(error)); % MSE in log domain
+        mse_log(sample,m) = mse = sum(abs(error)); % MSE in log domain
         error_log = [error_log; error];
         candidate_log = [candidate_log; candidate];
         %printf("m: %d f: %f error: %f\n", m, m*Wo*4/pi, mse);
index 663c3b41e86fe01849179e9f766746bd2811ae42..5ab6325cfb23b636124320f9403ea0c217ddb98c 100644 (file)
@@ -20,7 +20,7 @@ function newamp_fbf(samname, f)
   newamp;
   phase_stuff = 0;
   plot_not_masked = 0;
-  thresh = 0;
+  plot_spectrum = 0;
 
   sn_name = strcat(samname,"_sn.txt");
   Sn = load(sn_name);
@@ -58,18 +58,20 @@ function newamp_fbf(samname, f)
 
     % plotting
 
-    plot((1:L)*Wo*4000/pi, AmdB,";Am;r");
     axis([1 4000 0 80]);
     hold on;
-    plot((1:L)*Wo*4000/pi, AmdB,";Am;r+");
-    plot((0:255)*4000/256, Sw(f,:),";Sw;");
+    if plot_spectrum
+      plot((1:L)*Wo*4000/pi, AmdB,";Am;r");
+      plot((1:L)*Wo*4000/pi, AmdB,";Am;r+");
+      plot((0:255)*4000/256, Sw(f,:),";Sw;");
+    end
 
     [maskdB Am_freqs_kHz] = mask_model(AmdB, Wo, L);
     plot(Am_freqs_kHz*1000, maskdB, 'g');
 
     % optionally show harmonics that are not masked
 
-    not_masked_m = find(maskdB < (AmdB+thresh));
+    not_masked_m = find(maskdB < AmdB);
     if plot_not_masked
       plot(not_masked_m*Wo*4000/pi, 70*ones(1,length(not_masked_m)), 'bk+');
     end
@@ -86,7 +88,7 @@ function newamp_fbf(samname, f)
     % decimate in frequency
 
     mask_sample_freqs_kHz = (1:L)*Wo*4/pi;
-    [decmaskdB local_maxima error_log candidate_log target_log] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz);
+    [decmaskdB local_maxima mse_log] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz);
     
     [nlm tmp] = size(local_maxima(:,2));
     nlm = min(nlm,4);
@@ -96,6 +98,11 @@ function newamp_fbf(samname, f)
     plot(tonef_kHz*1000, 70*ones(1,nlm), 'bk+');
     plot(mask_sample_freqs_kHz*1000, decmaskdB, 'm');
 
+    figure(3)
+    clf
+    plot((1:L)*Wo*4000/pi, mse_log');
+    axis([0 4000 0 max(mse_log(1,:))])
+
     % fit a line to amplitudes
 
     %[m b] = linreg(tonef_kHz, toneamp_dB, nlm);
@@ -138,7 +145,7 @@ function newamp_fbf(samname, f)
 
     % interactive menu
 
-    printf("\rframe: %d  menu: n-next  b-back m-allmasks o-notmasked q-quit", f);
+    printf("\rframe: %d  menu: n-next  b-back m-allmasks o-notmasked s-spectrum q-quit", f);
     fflush(stdout);
     k = kbhit();
     if (k == 'n')
@@ -161,11 +168,11 @@ function newamp_fbf(samname, f)
          plot_not_masked = 0;
       end
     end
-    if k == 't'
-      if thresh == 0
-         thresh = -3;
+    if k == 's'
+      if plot_spectrum == 0
+         plot_spectrum = 1;
       else
-         thresh = 0;
+         plot_spectrum = 0;
       end
     end
   until (k == 'q')