From: drowe67 Date: Tue, 27 Dec 2016 00:01:48 +0000 (+0000) Subject: better naming conventions and framework for comparing output vectors as we refactor... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=7ca01dbbb9b62ef0b1516dfc1336946073baa630;p=freetel-svn-tracking.git better naming conventions and framework for comparing output vectors as we refactor Octave and write C code git-svn-id: https://svn.code.sf.net/p/freetel/code@2946 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/newamp1_batch.m b/codec2-dev/octave/newamp1_batch.m index 65da0ddf..d72d62b6 100644 --- a/codec2-dev/octave/newamp1_batch.m +++ b/codec2-dev/octave/newamp1_batch.m @@ -40,7 +40,7 @@ % In general, this function processes a bunch of amplitudes, we then % use c2sim to hear the results. Bunch of different experiments below -function surface = newamp1_batch(samname, optional_Am_out_name, optional_Aw_out_name) +function surface = newamp1_batch(input_prefix, output_prefix) newamp; more off; @@ -48,11 +48,14 @@ function surface = newamp1_batch(samname, optional_Am_out_name, optional_Aw_out_ postfilter = 0; % optional postfiler that runs on Am, not used atm synth_phase = 1; - model_name = strcat(samname,"_model.txt"); + if nargin == 1 + output_prefix = input_prefix; + end + model_name = strcat(input_prefix,"_model.txt"); model = load(model_name); [frames nc] = size(model); - voicing_name = strcat(samname,"_pitche.txt"); + voicing_name = strcat(input_prefix,"_pitche.txt"); voicing = zeros(1,frames); if exist(voicing_name, "file") == 2 @@ -79,19 +82,14 @@ function surface = newamp1_batch(samname, optional_Am_out_name, optional_Aw_out_ % ---------------------------------------------------- - if nargin == 2 - Am_out_name = optional_Am_out_name; - else - Am_out_name = sprintf("%s_am.out", samname); - end - + Am_out_name = sprintf("%s_am.out", output_prefix); fam = fopen(Am_out_name,"wb"); - Wo_out_name = sprintf("%s_Wo.out", samname); + Wo_out_name = sprintf("%s_Wo.out", output_prefix); fWo = fopen(Wo_out_name,"wb"); if synth_phase - Aw_out_name = sprintf("%s_aw.out", samname); + Aw_out_name = sprintf("%s_aw.out", output_prefix); faw = fopen(Aw_out_name,"wb"); end @@ -141,7 +139,7 @@ function surface = newamp1_batch(samname, optional_Am_out_name, optional_Aw_out_ % save voicing file if exist("voicing_", "var") - v_out_name = sprintf("%s_v.txt", samname); + v_out_name = sprintf("%s_v.txt", output_prefix); fv = fopen(v_out_name,"wt"); for f=1:length(voicing_) fprintf(fv,"%d\n", voicing_(f)); @@ -408,7 +406,7 @@ function [model_ voicing_] = model_from_indexes(indexes) % enable these to use original (non interpolated) voicing and Wo %voicing_ = voicing; - %model_(:,1) = model(:,1); + %model_(:,1) = model(:,1); model_(:,2) = floor(pi ./ model_(:,1)); % calculate L for each interpolated Wo model_ = resample_rate_L(model_, interpolated_surface_, sample_freqs_kHz); diff --git a/codec2-dev/octave/newamp1_compare.m b/codec2-dev/octave/newamp1_compare.m new file mode 100644 index 00000000..497c7aaa --- /dev/null +++ b/codec2-dev/octave/newamp1_compare.m @@ -0,0 +1,54 @@ +% newamp1_compare.m +% +% Copyright David Rowe 2016 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Compare model, Wo, and voicing files, used for checking refactoring and C port + + +function newamp1_compare(prefixa, prefixb) + autotest; + + frames = 100; + a = load_params(prefixa, frames); + b = load_params(prefixb, frames); + + check(a.Am, b.Am, 'Am'); + check(a.Aw, b.Aw, 'Aw'); + check(a.Wo, b.Wo, 'Wo'); + check(a.v, b.v, 'v'); +endfunction + + +function params = load_params(prefix, frames) + max_amp = 80; + fft_enc = 512; + + Am_out_name = sprintf("%s_am.out", prefix); + fam = fopen(Am_out_name,"rb"); + Wo_out_name = sprintf("%s_Wo.out", prefix); + fWo = fopen(Wo_out_name,"rb"); + Aw_out_name = sprintf("%s_aw.out", prefix); + faw = fopen(Aw_out_name,"rb"); + + % load up values from binary files + + params.Am = zeros(frames, max_amp); + params.Wo = zeros(frames, 1); + params.v = zeros(frames, 1); + params.Aw = zeros(frames, fft_enc); + for f=1:frames + params.Am(f,:) = fread(fam, max_amp, "float32"); + params.Wo(f) = fread(fWo, 1, "float32"); + params.Aw(f,:) = fread(faw, fft_enc, "float32"); + end + + fclose(fam); fclose(fWo); fclose(faw); + + % voicing is a text file + + v_out_name = sprintf("%s_v.txt", prefix); + params.v = load(v_out_name); + +endfunction