3 sample 700 bit/s baseline
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 13 Mar 2016 20:10:17 +0000 (20:10 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 13 Mar 2016 20:10:17 +0000 (20:10 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2739 01035d8c-6547-0410-b346-abe4f91aad63

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

index d49bbf35ccba1710cf88ecab9dd64421e35dcfaf..307c53f48c3196484fe22e1c3b4c923de6b50f34 100644 (file)
@@ -137,7 +137,7 @@ endfunction
 
 function [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz, freq_quant, amp_quant)
 
-    Nsamples = 4;
+    Nsamples = 3;
 
     % search range
 
@@ -215,9 +215,14 @@ function [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask
      
       % then quantise differences
 
-      for i=2:4
+      % create table of freq quantiser levels with log spacing
+      %m = (log10(2)-log10(0.2))/(8-1); c = log10(0.2)-m;
+      %logf_steps = 10.^(m*(1:8)+c)
+      logf_steps = [0.4 0.7 1 1 1.3 1.6 2 2.4]; 
+      
+      for i=2:Nsamples
         targ = masker_freqs_kHz(i) - masker_freqs_kHz(i-1);
-        [q_freq abits] = quantise(0.2:0.2:1.6, targ);
+        [q_freq abits] = quantise(logf_steps, targ);
         bits = [bits abits];
         masker_freqs_kHz(i) = masker_freqs_kHz(i-1) + q_freq;
       end
@@ -234,13 +239,13 @@ function [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask
       % Fit straight line
 
       f = masker_freqs_kHz*1000;
-      [gradient intercept] = linreg(f, masker_amps_dB, 4);
+      [gradient intercept] = linreg(f, masker_amps_dB, Nsamples);
       % use quantised gradient to take into account quantisation
       % errors in rest of quantisation
 
       gradient_ = quantise(-0.04:0.005:0.04, gradient);
       %gradient_ = gradient;
-      printf("gradient; %f gradient_: %f\n", gradient, gradient_);
+      %printf("gradient; %f gradient_: %f\n", gradient, gradient_);
 
       % determine deltas, or errors in straight line fit
 
@@ -254,10 +259,9 @@ function [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask
         clf;
         plot(f, masker_amps_dB, 'r+', 'markersize', 10, 'linewidth', 2)
 
-        fplt = 0:100:3900
+        fplt = 0:100:3900;
         hold on;
         plot(fplt, fplt*gradient + intercept, 'b')
-        fplt*gradient + intercept
 
         % plot lines for deltas
 
@@ -266,29 +270,31 @@ function [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask
           y2 = masker_amps_dB(i);
           plot([f(i) f(i)], [y1 y2], 'markersize', 10, 'linewidth', 2)
         end
+        axis([0 4000 0 80])
         hold off;
-      end
 
-      % quantise the deltas
+      end
 
-      masker_amps_dB_lin_delta_ = zeros(4,1);
+      masker_amps_dB_lin_delta_ = zeros(Nsamples,1);
       if amp_quant == 1
-        for i=1:4
+        for i=1:Nsamples
           masker_amps_dB_lin_delta_(i) = quantise(-21:3:21, masker_amps_dB_lin_delta(i));
-          printf("dlin: %f dlin_: %f\n", masker_amps_dB_lin_delta(i), masker_amps_dB_lin_delta_(i));
+          %printf("dlin: %f dlin_: %f\n", masker_amps_dB_lin_delta(i), masker_amps_dB_lin_delta_(i));
           % masker_amps_dB_lin_delta_(i) = masker_amps_dB_lin_delta(i);
         end
       end
 
-      masker_amps_dB = f*gradient_ + masker_amps_dB_lin_delta_ + intercept;
+      masker_amps_dB = f*gradient + masker_amps_dB_lin_delta_ + intercept;
       %decmaskdB = determine_mask(masker_amps_dB,  masker_freqs_kHz, mask_sample_freqs_kHz);
       decmaskdB = determine_mask(masker_amps_dB,  masker_freqs_kHz, mask_sample_freqs_kHz);
     end
 
+    if 0
     printf("\n");
-    for i=1:4
+    for i=1:Nsamples
       printf("freq: %f amp: %f\n", masker_freqs_kHz(i), masker_amps_dB(i));
     end
+    end
 endfunction
 
 
@@ -477,7 +483,7 @@ function maskdB_ = decimate_frame_rate(maskdB, model, decimate, f, frames, mask_
       maskdB_ = left_fraction*maskdB_left + right_fraction*maskdB_right;
     else
       maskdB_ = maskdB;
-      printf("\n");
+      %printf("\n");
     end
 endfunction
 
index 6b108b9b8c23cc004c1e7bf74f158759429035bf..a1fca9f08f0cafbb6f4c2f29cc2b0b0b93c976c1 100644 (file)
@@ -26,7 +26,7 @@ function [non_masked_f_log non_masked_amp_log] = newamp_batch(samname, optional_
   decimate_in_time = 1;
   synth_phase = 1;
   freq_quant = 1;
-  amp_quant = 1;
+  amp_quant = 2;
   non_masked_f_log = [];
   non_masked_m_log = [];
   non_masked_amp_log = [];
@@ -48,9 +48,12 @@ function [non_masked_f_log non_masked_amp_log] = newamp_batch(samname, optional_
   end
    
   fam  = fopen(Am_out_name,"wb"); 
+  if synth_phase
+    faw = fopen(Aw_out_name,"wb"); 
+  end
 
   for f=1:frames
-    printf("%d ", f);
+    %printf("%d ", f);
     L = min([model(f,2) max_amp-1]);
     Wo = model(f,1);
     Am = model(f,3:(L+2));
@@ -110,8 +113,9 @@ function [non_masked_f_log non_masked_amp_log] = newamp_batch(samname, optional_
     if synth_phase
       % synthesis phase spectra from magnitiude spectra using minimum phase techniques
       fft_enc = 512;
-      model(f,3:(L+1)) = Am_(2:L);
-      phase = determine_phase(model, f);
+      model_ = model;
+      model_(f,3:(L+1)) = Am_(2:L);
+      phase = determine_phase(model_, f);
       assert(length(phase) == fft_enc);
       Aw = zeros(1, fft_enc*2); 
       Aw(1:2:fft_enc*2) = cos(phase);
index 7a8150e7966cd486a0cc0a4f8d1f5c777afff215..5f1e32f9e93bcf0108049408ce4a6c4ece9fd227 100644 (file)
@@ -23,6 +23,7 @@ function newamp_fbf(samname, f=10)
   plot_spectrum = 1;
   freq_quant = 0;
   amp_quant = 0;
+  abys = 1;
 
   sn_name = strcat(samname,"_sn.txt");
   Sn = load(sn_name);
@@ -83,7 +84,12 @@ function newamp_fbf(samname, f=10)
     % decimate in frequency
 
     mask_sample_freqs_kHz = (1:L)*Wo*4/pi;
-    [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz, freq_quant, amp_quant);
+    if abys == 1
+      [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz, freq_quant, amp_quant);
+    end
+    if abys == 2
+      [decmaskdB masker_freqs_kHz min_error mse_log1 mse_log2] = make_decmask_abys2(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz, freq_quant, amp_quant);
+    end
     figure(2)
     
     tonef_kHz = masker_freqs_kHz;
@@ -94,6 +100,7 @@ function newamp_fbf(samname, f=10)
     legend('boxoff');
     %plot(mask_sample_freqs_kHz*1000, min_error);
     hold off;
+    grid
 
     figure(3)
     clf
@@ -138,6 +145,7 @@ function newamp_fbf(samname, f=10)
     % interactive menu
 
     printf("\rframe: %d  menu: n-next  b-back a-Am ", f);
+
     if freq_quant
       printf("F");
     else
@@ -145,11 +153,11 @@ function newamp_fbf(samname, f=10)
     end
     printf("-freq_quant ");
     if amp_quant
-      printf("M");
+      printf("M-amp_quant ");
     else
-      printf("m");
+      printf("m-amp_quant ");
     end
-    printf("-amp_quant q-quit");
+    printf("q-quit");
 
     fflush(stdout);
     k = kbhit();
@@ -161,7 +169,7 @@ function newamp_fbf(samname, f=10)
     endif
     if k == 'm'
       if amp_quant == 0
-         amp_quant = 1;
+         amp_quant = 2;
       else
          amp_quant = 0;
       end