% 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;
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
% ----------------------------------------------------
- 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
% 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));
% 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);
--- /dev/null
+% 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