From: drowe67 Date: Thu, 8 Dec 2016 06:23:02 +0000 (+0000) Subject: experimental variable rate decimation in time X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=95d76ceb9fdd4173faec0d28912bcf6443ca6c02;p=freetel-svn-tracking.git experimental variable rate decimation in time git-svn-id: https://svn.code.sf.net/p/freetel/code@2928 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/newamp1_batch.m b/codec2-dev/octave/newamp1_batch.m index 43510985..0fb04737 100644 --- a/codec2-dev/octave/newamp1_batch.m +++ b/codec2-dev/octave/newamp1_batch.m @@ -16,12 +16,17 @@ % codec2-dev/build_linux/src$ ./c2sim ../../raw/hts2a.raw --amread hts2a_am.out --awread hts2a_aw.out --phase0 --postfilter --Woread hts2a_Wo.out -o - | play -q -t raw -r 8000 -s -2 - % process a whole file and write results +% TODO: +% [ ] refactor decimate-in-time to avoid extra to/from model conversions +% [ ] switches to turn on/off quantisation +% [ ] rename mask_sample_freqs, do we need "mask" any more function [fvec_log amps_log] = newamp1_batch(samname, optional_Am_out_name, optional_Aw_out_name) newamp; more off; max_amp = 80; + decimate = 4; load vq; model_name = strcat(samname,"_model.txt"); @@ -40,33 +45,34 @@ function [fvec_log amps_log] = newamp1_batch(samname, optional_Am_out_name, opti fvec_log = []; amps_log = []; - for f=1:frames - printf("%d ", f); + % prime initial values so first pass iterpolator works. TODO: improve this + for f=1:frames Wo = model(f,1); L = min([model(f,2) max_amp-1]); Am = model(f,3:(L+2)); AmdB = 20*log10(Am); + e(f) = sum(AmdB)/L; - % find mask + % fit model - #{ - maskdB = mask_model(AmdB, Wo, L); - AmdB_ = maskdB; - [mx mx_ind] = max(AmdB_); - AmdB_(mx_ind) += 6; - #} - - [AmdB_ res fvec fvec_ amps] = piecewise_model(AmdB, Wo, vq, 1); + [AmdB_ res fvec fvec_ amps] = piecewise_model(AmdB, Wo); fvec_log = [fvec_log; fvec]; amps_log = [amps_log; amps]; - #{ - l1000 = floor(L/4); - AmdB_ = AmdB; - [mx mx_ind] = max(AmdB_(1:l1000)); - mask_sample_freqs_kHz = (1:l1000)*Wo*4/pi; - AmdB_(1:l1000) = parabolic_resonator(mx_ind*Wo*4/pi, mask_sample_freqs_kHz) + mx; - #} + + model_(f,1) = Wo; model_(f,2) = L; model_(f,3:(L+2)) = 10 .^ (AmdB_(1:L)/20); + end + + for f=1:frames + if (f > 1) && (e(f) > (e(f-1)+3)) + decimate = 2; + else + decimate = 4; + end + printf("%d ", decimate); + + AmdB_ = decimate_frame_rate(model_, decimate, f, frames); + L = length(AmdB_); Am_ = zeros(1,max_amp); Am_(2:L) = 10 .^ (AmdB_(1:L-1)/20); % C array doesnt use A[0] @@ -77,5 +83,7 @@ function [fvec_log amps_log] = newamp1_batch(samname, optional_Am_out_name, opti fclose(fam); printf("\n") + figure(1); clf; + plot(e,'+-'); endfunction