if (m <= Lrand) {
Ex[m].real = cos(ex_phase[0]*m);
Ex[m].imag = sin(ex_phase[0]*m);
+
+ /* following is an experiment in dispersing pulse energy over time,
+ didn't really change sound at all, e.g. mmt1 still sounded
+ "clicky"*/
+ //Ex[m].real = cos(ex_phase[0]*m + model.Wo*m*m*0.3);
+ //Ex[m].imag = sin(ex_phase[0]*m + model.Wo*m*m*0.3);
}
else {
/* we probably don't need to LPC filter phase in unvoiced case,
new_phi = atan2(A_[m].imag, A_[m].real+1E-12);
model.phi[m] = new_phi;
-
- /* little bit of randomness to phase - possibly makes females
- sound slightly better, need to do some more research. May not
- be needed */
-
- model.phi[m] += (m*model.Wo)*rand()/RAND_MAX;
}
}
#define PHASE_LPC_ORD 10
+void aks_to_H(MODEL *model, float aks[], float G, COMP H[], int order);
float phase_model_first_order(float aks[], COMP H[], float *n_min, COMP *min_Am);
void phase_synth_zero_order(float snr, COMP H[], float *prev_Wo, float *ex_phase);
void phase_synth_first_order(float snr, COMP H[], float n_min, COMP min_Am);
int phase, phase_model;
float prev_Wo, ex_phase;
- float phi_prev[MAX_AMP];
- float Wo_prev;
if (argc < 3) {
printf("usage: sinedec InputFile ModelFile [-o OutputFile] [-o lpc Order]\n");
dump_snr(snr);
if (phase_model == 0) {
+ /* just to make sure we are not cheating - kill all phases */
+ for(i=0; i<MAX_AMP; i++)
+ model.phi[i] = 0;
phase_synth_zero_order(snr, H, &prev_Wo, &ex_phase);
}
if (fout != NULL) {
- if (phase)
- synthesise_continuous_phase(Pn, &model, Sn_, (snr>2.0), &Wo_prev, phi_prev);
- else
- synthesise_mixed(Pn,&model,Sn_);
+ synthesise_mixed(Pn,&model,Sn_);
/* Save output speech to disk */
AUTHOR......: David Rowe
DATE CREATED: 11/9/09
- Test program for developing continuous phase track synthesis algorithms.
+ Test program for developing continuous phase track synthesis algorithm.
+ However while developing this it was discovered that synthesis_mixed()
+ worked just as well.
\*---------------------------------------------------------------------------*/
#define N 80 /* frame size */
#define F 160 /* frames to synthesis */
+#define P 10 /* LPC order */
#include <stdlib.h>
#include <stdio.h>
#include "sine.h"
#include "dump.h"
#include "synth.h"
+#include "phase.h"
int frames;
+float ak[] = {
+ 1.000000,
+-1.455836,
+ 1.361841,
+-0.879267,
+ 0.915985,
+-1.002202,
+ 0.944103,
+-0.743094,
+ 1.053356,
+-0.817491,
+ 0.431222
+};
+
+
/*---------------------------------------------------------------------------*\
switch_present()
int i,j;
int dump;
float phi_prev[MAX_AMP];
- float Wo_prev;
-
- if (argc < 2) {
- printf("\nusage: tcontphase OutputRawSpeechFile\n");
+ float Wo_prev, ex_phase, G;
+ //float ak[P+1];
+ COMP H[MAX_AMP];
+ float f0;
+
+ if (argc < 3) {
+ printf("\nusage: tcontphase OutputRawSpeechFile F0\n");
exit(0);
}
exit(1);
}
+ f0 = atof(argv[2]);
+
dump = switch_present("--dump",argc,argv);
if (dump)
dump_on(argv[dump+1]);
phi_prev[i] = 0.0;
Wo_prev = 0.0;
- model.L = 1;
- model.A[1] = 1000;
- model.Wo = PI*(50.0/4000.0);
- model.phi[1] = 0;
+ model.Wo = PI*(f0/4000.0);
+ G = 1000.0;
+ model.L = floor(PI/model.Wo);
+
+ //aks_to_H(&model, ak, G , H, P);
+ //for(i=1; i<=model.L; i++)
+ model.A[i] = sqrt(H[i].real*H[i].real + H[i].imag*H[i].imag);
+ //printf("L = %d\n", model.L);
+ //model.L = 10;
+ for(i=1; i<=model.L; i++) {
+ model.A[i] = 1000/model.L;
+ model.phi[i] = 0;
+ H[i].real = 1.0; H[i].imag = 0.0;
+ }
+
+ //ak[0] = 1.0;
+ //for(i=1; i<=P; i++)
+ // ak[i] = 0.0;
frames = 0;
for(j=0; j<F; j++) {
frames++;
+ #ifdef SWAP
+ /* lets make phases bounce around from frame to frame. This
+ could happen if H[m] is varying, for example due to frame
+ to frame Wo variations, or non-stationary speech.
+ Continous model generally results in smooth phase track
+ under these circumstances. */
+ if (j%2){
+ H[1].real = 1.0; H[1].imag = 0.0;
+ model.phi[1] = 0.0;
+ }
+ else {
+ H[1].real = 0.0; H[1].imag = 1.0;
+ model.phi[1] = PI/2;
+ }
+ #endif
+
+ //#define CONT
+ #ifdef CONT
synthesise_continuous_phase(Pn, &model, Sn_, 1, &Wo_prev, phi_prev);
+ #else
+ phase_synth_zero_order(5.0, H, &Wo_prev, &ex_phase);
+ synthesise_mixed(Pn,&model,Sn_);
+ #endif
+
for(i=0; i<N; i++)
buf[i] = Sn_[i];
fwrite(buf,sizeof(short),N,fout);