c2sim working with phase0 at 16k, sounds quite reasonable, but room for improvement
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 4 Jun 2017 07:53:28 +0000 (07:53 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 4 Jun 2017 07:53:28 +0000 (07:53 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3154 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/c2sim.c
codec2-dev/src/dump.c
codec2-dev/src/newamp1.c

index af8eaecf9e68c42c230549efa6a7fa22663083ad..ee667ee46141ad309df21d0ac8316532b9440e34 100644 (file)
@@ -50,6 +50,7 @@
 #include "phaseexp.h"
 #include "bpf.h"
 #include "bpfb.h"
+#include "newamp1.h"
 
 void synth_one_frame(int n_samp, codec2_fftr_cfg fftr_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem, float gain);
 void print_help(const struct option *long_options, int num_opts, char* argv[]);
@@ -430,9 +431,12 @@ int main(int argc, char *argv[])
 
     /* Initialise ------------------------------------------------------------*/
 
-    fft_fwd_cfg = codec2_fft_alloc(FFT_ENC, 0, NULL, NULL); /* fwd FFT,used in several places   */
+    fft_fwd_cfg = codec2_fft_alloc(FFT_ENC, 0, NULL, NULL);   /* fwd FFT,used in several places   */
     fftr_fwd_cfg = codec2_fftr_alloc(FFT_ENC, 0, NULL, NULL); /* fwd FFT,used in several places   */
     fftr_inv_cfg = codec2_fftr_alloc(FFT_DEC, 1, NULL, NULL); /* inverse FFT, used just for synth */
+    codec2_fft_cfg phase_fft_fwd_cfg = codec2_fft_alloc(NEWAMP1_PHASE_NFFT, 0, NULL, NULL);
+    codec2_fft_cfg phase_fft_inv_cfg = codec2_fft_alloc(NEWAMP1_PHASE_NFFT, 1, NULL, NULL);
+
     make_analysis_window(&c2const, fft_fwd_cfg, w, W);
     make_synthesis_window(&c2const, Pn);
     quantise_init();
@@ -880,7 +884,8 @@ int main(int argc, char *argv[])
                         int ret = fread(H, sizeof(COMP), MAX_AMP, fhm);
                         assert(ret == MAX_AMP);
                     } else {
-                        sample_phase(&model_dec[i], H, Aw);
+                         determine_phase(&c2const, H, &model_dec[i], NEWAMP1_PHASE_NFFT, phase_fft_fwd_cfg, phase_fft_inv_cfg);
+                         //sample_phase(&model_dec[i], H, Aw);
                     }
                     phase_synth_zero_order(n_samp, &model_dec[i], ex_phase, H);
                 }
index 20bf02293c72a321645ff171c7ca9e480bb5b0af..c8b3b310566a43b853b3e09bc28207a5cb020b65 100644 (file)
@@ -238,7 +238,7 @@ void dump_softdec(float *softdec, int n)
 void dump_model(MODEL *model) {
     int l;
     char s[MAX_STR];
-    char line[2048];
+    char line[MAX_STR*10];
 
     if (!dumpon) return;
 
@@ -252,10 +252,12 @@ void dump_model(MODEL *model) {
     for(l=1; l<=model->L; l++) {
        sprintf(s,"%12f ",model->A[l]);
         strcat(line, s);
+        assert(strlen(line) < MAX_STR*10);
     }
     for(l=model->L+1; l<=MAX_AMP; l++) {
        sprintf(s,"%12f ", 0.0);
         strcat(line,s);
+        assert(strlen(line) < MAX_STR*10);
     }
 
     sprintf(s,"%d\n",model->voiced);
index ebb7257b268e65e47ee89ede1e38f724a61ca429..45c39f48ce68b1c36481b6a227970d58a87a5b3c 100644 (file)
@@ -378,7 +378,7 @@ void determine_phase(C2CONST *c2const, COMP H[], MODEL *model, int Nfft, codec2_
 
     for(m=1; m<=model->L; m++) {
         AmdB[m] = 20.0*log10(model->A[m]);
-        rate_L_sample_freqs_kHz[m] = (float)m*model->Wo*4.0/M_PI;
+        rate_L_sample_freqs_kHz[m] = (float)m*model->Wo*(c2const->Fs/2000.0)/M_PI;
     }
     
     for(i=0; i<Ns; i++) {