$ octave
octave:1> c2wideband_batch("../build_linux/src/speech", "mode", "generate map")
- Then to run bathc simulation and generate output speech:
+ Then to run batch simulation and generate output speech:
octave:1> c2wideband_batch("../build_linux/src/speech");
~/codec2-dev/build_linux/src$ ./c2sim ~/Desktop/c2_hd/speech_orig_16k.wav --Fs 16000 --phase0 --postfilter --amread speech_am.out --hmread speech_hm.out -o | play -t raw -r 16000 -s -2 -
#}
-#{
- TODO:
- [ ] how to generate dct coeff readout map for wideband
- + maybe sep function
- + save map as disk file for sucessive runs
- + document process, special mode
-#}
function [surface mean_f] = c2wideband_batch(input_prefix, varargin)
newamp;
--- /dev/null
+% c2wideband_fbf.m
+%
+% Copyright David Rowe 2017
+% This program is distributed under the terms of the GNU General Public License
+% Version 2
+%
+
+% Interactive Octave script to explore frame by frame operation of
+% wideband Codc 2.
+
+#{
+ Make sure codec2-dev is compiled with the -DDUMP option - see README for
+ instructions.
+
+ Usage:
+ ~/codec2-dev/build_linux/src$ ./c2sim ~/Desktop/c2_hd/speech_orig_16k.wav --Fs 16000 --dump speech
+
+ $ cd ~/codec2-dev/octave
+ $ octave
+ octave:1> c2wideband_fbf("../build_linux/src/speech")
+#}
+
+function c2wideband_fbf(samname, f=70, varargin)
+ more off;
+ newamp;
+
+ Fs = 16000; Fs2 = Fs/2; K = 30;
+
+ % load up text files dumped from c2sim ---------------------------------------
+
+ sn_name = strcat(samname,"_sn.txt");
+ Sn = load(sn_name);
+ sw_name = strcat(samname,"_sw.txt");
+ Sw = load(sw_name);
+ model_name = strcat(samname,"_model.txt");
+ model = load(model_name);
+ [frames tmp] = size(model);
+
+ % Keyboard loop --------------------------------------------------------------
+
+ k = ' ';
+ do
+ s = [ Sn(2*f-1,:) Sn(2*f,:) ];
+ figure(1); clf; plot(s); axis([1 length(s) -20000 20000]);
+
+ Wo = model(f,1); L = model(f,2); Am = model(f,3:(L+2)); AmdB = 20*log10(Am);
+ Am_freqs_kHz = (1:L)*Wo*Fs2/(1000*pi);
+
+ [rate_K_vec rate_K_sample_freqs_kHz] = resample_const_rate_f_mel(model(f,:), K, Fs);
+
+ % plots ----------------------------------
+
+ figure(2); clf;
+ plot((1:L)*Wo*Fs2/pi, AmdB,";AmdB;g+-");
+ axis([1 Fs2 -20 80]);
+ hold on;
+ stem(rate_K_sample_freqs_kHz*1000, rate_K_vec, ";rate K;b+-");
+
+ [model_ AmdB_] = resample_rate_L(model(f,:), rate_K_vec, rate_K_sample_freqs_kHz, Fs);
+ AmdB_ = AmdB_(1:L);
+
+ plot((1:L)*Wo*Fs2/pi, AmdB_,";AmdB;r+-");
+ hold off;
+
+ % interactive menu ------------------------------------------
+
+ printf("\rframe: %d menu: n-next b-back q-quit [%d]", f);
+ fflush(stdout);
+ k = kbhit();
+
+ if k == 'n'
+ f = f + 1;
+ endif
+ if k == 'b'
+ f = f - 1;
+ endif
+ until (k == 'q')
+ printf("\n");
+
+endfunction
+
+
+function ind = arg_exists(v, str)
+ ind = 0;
+ for i=1:length(v)
+ if strcmp(v{i}, str)
+ ind = i;
+ end
+ end
+endfunction
+
+
% Take a rate K surface and convert back to time varying rate L
function [model_ AmdB_] = resample_rate_L(model, rate_K_surface, rate_K_sample_freqs_kHz, Fs=8000)
- max_amp = 160;
+ max_amp = 160; K = columns(rate_K_surface);
[frames col] = size(model);
AmdB_ = zeros(frames, max_amp);
% back down to rate L
- AmdB_(f,1:L) = interp1(rate_K_sample_freqs_kHz, rate_K_surface(f,:), rate_L_sample_freqs_kHz, "spline", rate_K_surface(f,1));
+ AmdB_(f,1:L) = interp1([0 rate_K_sample_freqs_kHz Fs/2000],
+ [rate_K_surface(f,1) rate_K_surface(f,:) rate_K_surface(f,K)],
+ rate_L_sample_freqs_kHz,
+ "spline");
%AmdB_(f,1:L) = interp_para(rate_K_sample_freqs_kHz, rate_K_surface(f,:), Fs/(2*1000), rate_L_sample_freqs_kHz);
%printf("f: %d %f %f %f\n", f, rate_K_sample_freqs_kHz(1), rate_L_sample_freqs_kHz(1), AmdB_(1));
model_(f,1) = Wo; model_(f,2) = L; model_(f,3:(L+2)) = 10 .^ (AmdB_(f, 1:L)/20);