comparison sinsyn.cpp @ 7:9b1c0825cc77

TFileStream; redefining some function arguments
author Wen X <xue.wen@elec.qmul.ac.uk>
date Mon, 11 Oct 2010 17:54:32 +0100
parents 5f3c32dc6e17
children 977f541d6683
comparison
equal deleted inserted replaced
6:fda5b3561a13 7:9b1c0825cc77
5 #include "splines.h" 5 #include "splines.h"
6 6
7 /** \file sinsyn.h */ 7 /** \file sinsyn.h */
8 8
9 //--------------------------------------------------------------------------- 9 //---------------------------------------------------------------------------
10 /**
11 function CosSin: recursive cos-sin generator with trinomial frequency
12
13 In: CountSt, CountEn
14 f3, f2, f1, f0: trinomial coefficients of frequency
15 ph: initial phase angle at 0 (NOT at CountSt)
16 Out: datar[CountSt:CountEn-1], datai[CountSt:CountEn-1]: synthesized pair of cosine and sine functions
17 ph: phase angle at CountEn
18
19 No return value.
20 */
21 void CosSin(double* datar, double* datai, int CountSt, int CountEn, double f3, double f2, double f1, double f0, double &ph)
22 {
23 int i;
24 double dph, ddph, dddph, ddddph,
25 sph, cph, sdph, cdph, sddph, cddph, sdddph, cdddph, sddddph, cddddph,
26 p0=ph, p1=2*M_PI*f0, p2=M_PI*f1, p3=2.0*M_PI*f2/3, p4=2.0*M_PI*f3/4, tmp;
27 if (CountSt==0)
28 {
29 dph=p1+p2+p3+p4; ddph=2*p2+6*p3+14*p4; dddph=6*p3+36*p4; ddddph=24*p4;
30 }
31 else
32 {
33 ph=p0+CountSt*(p1+CountSt*(p2+CountSt*(p3+CountSt*p4)));
34 dph=p1+p2+p3+p4+CountSt*(2*p2+3*p3+4*p4+CountSt*(3*p3+6*p4+CountSt*4*p4));
35 ddph=2*p2+6*p3+14*p4+CountSt*(6*p3+24*p4+CountSt*12*p4);
36 dddph=6*p3+36*p4+CountSt*24*p4; ddddph=24*p4;
37 }
38 sph=sin(ph), cph=cos(ph);
39 sdph=sin(dph), cdph=cos(dph);
40 sddph=sin(ddph), cddph=cos(ddph);
41 sdddph=sin(dddph), cdddph=cos(dddph);
42 sddddph=sin(ddddph), cddddph=cos(ddddph);
43
44 for (i=CountSt; i<CountEn; i++)
45 {
46 datar[i]=cph; datai[i]=sph;
47 tmp=cph*cdph-sph*sdph; sph=sph*cdph+cph*sdph; cph=tmp;
48 tmp=cdph*cddph-sdph*sddph; sdph=sdph*cddph+cdph*sddph; cdph=tmp;
49 tmp=cddph*cdddph-sddph*sdddph; sddph=sddph*cdddph+cddph*sdddph; cddph=tmp;
50 tmp=cdddph*cddddph-sdddph*sddddph; sdddph=sdddph*cddddph+cdddph*sddddph; cdddph=tmp;
51 }
52 ph=p0+CountEn*(p1+CountEn*(p2+CountEn*(p3+CountEn*p4)));
53 }//CosSin*/
54
10 /** 55 /**
11 function Sinuoid: original McAuley-Quatieri synthesizer interpolation between two measurement points. 56 function Sinuoid: original McAuley-Quatieri synthesizer interpolation between two measurement points.
12 57
13 In: T: length from measurement point 1 to measurement point 2 58 In: T: length from measurement point 1 to measurement point 2
14 a1, f1, p2: amplitude, frequency and phase angle at measurement point 1 59 a1, f1, p2: amplitude, frequency and phase angle at measurement point 1
107 } 152 }
108 p1=p1+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4))); 153 p1=p1+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)));
109 }//Sinusoid 154 }//Sinusoid
110 155
111 /** 156 /**
157 function Sinusoid_direct: synthesizes sinusoid over [CountSt, CountEn) from tronomial coefficients of
158 amplitude and frequency, direct implementation returning sinusoid coefficients rather than waveform.
159
160 In: CountSt, CountEn
161 aa, ab, ac, ad: trinomial coefficients of amplitude
162 fa, fb, fc, fd: trinomial coefficients of frequency
163 p1: initial phase angle at 0 (NOT at CountSt)
164 Out: f[CountSt:CountEn-1], a[:], ph[:], da[:]: output buffers.
165 p1: phase angle at CountEn
166
167 No return value.
168 */
169 void Sinusoid_direct(double* f, double* a, double* ph, double* da, int CountSt, int CountEn, double aa, double ab, double ac, double ad,
170 double fa, double fb, double fc, double fd, double &p1, bool LogA)
171 {
172 int i;
173 if (LogA)
174 {
175 for (i=CountSt; i<CountEn; i++)
176 {
177 a[i]=exp(ad+i*(ac+i*(ab+i*aa)));
178 f[i]=fd+i*(fc+i*(fb+i*fa));
179 ph[i]=p1+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)));
180 da[i]=a[i]*(ac+i*(2*ab+3*i*aa));
181 }
182 }
183 else
184 {
185 for (i=CountSt; i<CountEn; i++)
186 {
187 a[i]=ad+i*(ac+i*(ab+i*aa));
188 f[i]=fd+i*(fc+i*(fb+i*fa));
189 ph[i]=p1+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)));
190 da[i]=ac+i*(2*ab+3*i*aa);
191 }
192 }
193 p1=p1+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)));
194 }//Sinusoid
195
196 /**
197 function Sinusoid_direct: synthesizes sinusoid over [CountSt, CountEn) from tronomial coefficients of
198 frequency, direct implementation returning frequency and phase rather than waveform.
199
200 In: CountSt, CountEn
201 fa, fb, fc, fd: trinomial coefficients of frequency
202 p1: initial phase angle at 0 (NOT at CountSt)
203 Out: f[CountSt:CountEn-1], ph[CountSt:CountEn-1]: output buffers.
204 p1: phase angle at CountEn
205
206 No return value.
207 */
208 void Sinusoid_direct(double* f, double* ph, int CountSt, int CountEn, double fa, double fb, double fc,
209 double fd, double &p1)
210 {
211 int i;
212 for (i=CountSt; i<CountEn; i++)
213 {
214 f[i]=fd+i*(fc+i*(fb+i*fa));
215 ph[i]=p1+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)));
216 }
217 p1=p1+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)));
218 }//Sinusoid
219
220 /**
112 function Sinusoid: synthesizes sinusoid over [CountSt, CountEn) from tronomial coefficients of 221 function Sinusoid: synthesizes sinusoid over [CountSt, CountEn) from tronomial coefficients of
113 amplitude and frequency, recursive implementation. 222 amplitude and frequency, recursive implementation.
114 223
115 In: CountSt, CountEn 224 In: CountSt, CountEn
116 a3, a2, a1, a0: trinomial coefficients of amplitude 225 a3, a2, a1, a0: trinomial coefficients of amplitude
292 401
293 /** 402 /**
294 function SinusoidExpA: synthesizes complex sinusoid whose log amplitude and frequency are trinomials 403 function SinusoidExpA: synthesizes complex sinusoid whose log amplitude and frequency are trinomials
295 with phase angle specified at both ends. 404 with phase angle specified at both ends.
296 405
297 In: CountSt, CountEn 406 In: T
298 a3, a2, a1, a0: trinomial coefficients for log amplitude 407 a3, a2, a1, a0: trinomial coefficients for log amplitude
299 omg3, omg2, omg1, omg0: trinomial coefficients for angular frequency 408 omg3, omg2, omg1, omg0: trinomial coefficients for angular frequency
300 ph0, ph2: phase angles at 0 and CountEn. 409 ph0, ph2: phase angles at 0 and CountEn.
301 add: specifies if the resynthesized sinusoid is to be added to or to replace the content of output buffer 410 add: specifies if the resynthesized sinusoid is to be added to or to replace the content of output buffer
302 Out: data[CountSt:CountEn-1]: output buffer. 411 Out: data[T]: output buffer.
303 412
304 No return value. 413 No return value.
305 */ 414 */
306 void SinusoidExpA(cdouble* data, int CountSt, int CountEn, double a3, double a2, double a1, double a0, 415 void SinusoidExpA(int T, cdouble* data, double a3, double a2, double a1, double a0,
307 double omg3, double omg2, double omg1, double omg0, double ph0, double ph2, bool add) 416 double omg3, double omg2, double omg1, double omg0, double ph0, double ph2, bool add)
308 { 417 {
309 double p0=ph0, p1=omg0, p2=0.5*omg1, p3=omg2/3, p4=omg3/4; 418 double p0=ph0, p1=omg0, p2=0.5*omg1, p3=omg2/3, p4=omg3/4;
310 double pend=p0+CountEn*(p1+CountEn*(p2+CountEn*(p3+CountEn*p4))); 419 double pend=p0+T*(p1+T*(p2+T*(p3+T*p4)));
311 420
312 int k=floor((pend-ph2)/2/M_PI+0.5); 421 int k=floor((pend-ph2)/2/M_PI+0.5);
313 double d=ph2-pend+2*M_PI*k; 422 double d=ph2-pend+2*M_PI*k;
314 double _p=-2*d/CountEn/CountEn/CountEn; 423 double _p=-2*d/T/T/T;
315 double _q=3*d/CountEn/CountEn; 424 double _q=3*d/T/T;
316 425
317 if (add) for (int i=CountSt; i<CountEn; i++) 426 if (add) for (int i=0; i<T; i++)
318 { 427 {
319 double lea=a0+i*(a1+i*(a2+i*a3)); 428 double lea=a0+i*(a1+i*(a2+i*a3));
320 double lph=p0+i*(p1+i*(p2+i*(p3+i*p4))); 429 double lph=p0+i*(p1+i*(p2+i*(p3+i*p4)));
321 data[i]+=exp(cdouble(lea, lph+(i*i*(_q+i*_p)))); 430 data[i]+=exp(cdouble(lea, lph+(i*i*(_q+i*_p))));
322 } 431 }
323 else for (int i=CountSt; i<CountEn; i++) 432 else for (int i=0; i<T; i++)
324 { 433 {
325 double lea=a0+i*(a1+i*(a2+i*a3)); 434 double lea=a0+i*(a1+i*(a2+i*a3));
326 double lph=p0+i*(p1+i*(p2+i*(p3+i*p4))); 435 double lph=p0+i*(p1+i*(p2+i*(p3+i*p4)));
327 data[i]=exp(cdouble(lea, lph+(i*i*(_q+i*_p)))); 436 data[i]=exp(cdouble(lea, lph+(i*i*(_q+i*_p))));
328 } 437 }
472 } 581 }
473 ea=e0+CountEn*(e1+CountEn*(e2+CountEn*(e3+CountEn*e4))); 582 ea=e0+CountEn*(e1+CountEn*(e2+CountEn*(e3+CountEn*e4)));
474 ph=p0+CountEn*(p1+CountEn*(p2+CountEn*(p3+CountEn*p4))); 583 ph=p0+CountEn*(p1+CountEn*(p2+CountEn*(p3+CountEn*p4)));
475 } //*/ 584 } //*/
476 585
477 /**
478 function Sinusoid: recursive cos-sin generator with trinomial frequency
479
480 In: CountSt, CountEn
481 f3, f2, f1, f0: trinomial coefficients of frequency
482 ph: initial phase angle at 0 (NOT at CountSt)
483 Out: datar[CountSt:CountEn-1], datai[CountSt:CountEn-1]: synthesized pair of cosine and sine functions
484 ph: phase angle at CountEn
485
486 No return value.
487 */
488 void Sinusoid(double* datar, double* datai, int CountSt, int CountEn, double f3, double f2, double f1, double f0, double &ph)
489 {
490 int i;
491 double dph, ddph, dddph, ddddph,
492 sph, cph, sdph, cdph, sddph, cddph, sdddph, cdddph, sddddph, cddddph,
493 p0=ph, p1=2*M_PI*f0, p2=M_PI*f1, p3=2.0*M_PI*f2/3, p4=2.0*M_PI*f3/4, tmp;
494 if (CountSt==0)
495 {
496 dph=p1+p2+p3+p4; ddph=2*p2+6*p3+14*p4; dddph=6*p3+36*p4; ddddph=24*p4;
497 }
498 else
499 {
500 ph=p0+CountSt*(p1+CountSt*(p2+CountSt*(p3+CountSt*p4)));
501 dph=p1+p2+p3+p4+CountSt*(2*p2+3*p3+4*p4+CountSt*(3*p3+6*p4+CountSt*4*p4));
502 ddph=2*p2+6*p3+14*p4+CountSt*(6*p3+24*p4+CountSt*12*p4);
503 dddph=6*p3+36*p4+CountSt*24*p4; ddddph=24*p4;
504 }
505 sph=sin(ph), cph=cos(ph);
506 sdph=sin(dph), cdph=cos(dph);
507 sddph=sin(ddph), cddph=cos(ddph);
508 sdddph=sin(dddph), cdddph=cos(dddph);
509 sddddph=sin(ddddph), cddddph=cos(ddddph);
510
511 for (i=CountSt; i<CountEn; i++)
512 {
513 datar[i]=cph; datai[i]=sph;
514 tmp=cph*cdph-sph*sdph; sph=sph*cdph+cph*sdph; cph=tmp;
515 tmp=cdph*cddph-sdph*sddph; sdph=sdph*cddph+cdph*sddph; cdph=tmp;
516 tmp=cddph*cdddph-sddph*sdddph; sddph=sddph*cdddph+cddph*sdddph; cddph=tmp;
517 tmp=cdddph*cddddph-sdddph*sddddph; sdddph=sdddph*cddddph+cdddph*sddddph; cdddph=tmp;
518 }
519 ph=p0+CountEn*(p1+CountEn*(p2+CountEn*(p3+CountEn*p4)));
520 }//Sinusoid*/
521 586
522 /** 587 /**
523 function Sinusoids: recursive harmonic multi-sinusoid generator 588 function Sinusoids: recursive harmonic multi-sinusoid generator
524 589
525 In: st, en 590 In: st, en
606 }//Sinusoids*/ 671 }//Sinusoids*/
607 672
608 /** 673 /**
609 function Sinusoid: synthesizes sinusoid piece from trinomial frequency and amplitude coefficients. 674 function Sinusoid: synthesizes sinusoid piece from trinomial frequency and amplitude coefficients.
610 675
611 In: CountSt, CountEn 676 In: T
612 aa, ab, ac, ad: trinomial coefficients of amplitude. 677 aa, ab, ac, ad: trinomial coefficients of amplitude.
613 fa, fb, fc, fd: trinomial coefficients of frequency. 678 fa, fb, fc, fd: trinomial coefficients of frequency.
614 ph0, ph2: phase angles at 0 and CountEn. 679 ph0, ph2: phase angles at 0 and CountEn.
615 add: specifies if the resynthesized sinusoid is to be added to or to replace the content of output buffer 680 add: specifies if the resynthesized sinusoid is to be added to or to replace the content of output buffer
616 Out: data[CountSt:CountEn-1]: output buffer. 681 Out: data[T]: output buffer.
617 682
618 No return value. 683 No return value.
619 */ 684 */
620 void Sinusoid(double* data, int CountSt, int CountEn, double aa, double ab, double ac, double ad, 685 void Sinusoid(int T, double* data, double aa, double ab, double ac, double ad,
621 double fa, double fb, double fc, double fd, double ph0, double ph2, bool add) 686 double fa, double fb, double fc, double fd, double ph0, double ph2, bool add)
622 { 687 {
623 double pend=ph0+2*M_PI*CountEn*(fd+CountEn*(fc/2+CountEn*(fb/3+CountEn*fa/4))); 688 double pend=ph0+2*M_PI*T*(fd+T*(fc/2+T*(fb/3+T*fa/4)));
624 int k=floor((pend-ph2)/2/M_PI+0.5); 689 int k=floor((pend-ph2)/2/M_PI+0.5);
625 double d=ph2-pend+2*M_PI*k; 690 double d=ph2-pend+2*M_PI*k;
626 double p=-2*d/CountEn/CountEn/CountEn; 691 double p=-2*d/T/T/T;
627 double q=3*d/CountEn/CountEn, a, ph; 692 double q=3*d/T/T, a, ph;
628 for (int i=CountSt; i<CountEn; i++) 693 for (int i=0; i<T; i++)
629 { 694 {
630 a=ad+i*(ac+i*(ab+i*aa)); if (a<0) a=0; 695 a=ad+i*(ac+i*(ab+i*aa)); if (a<0) a=0;
631 ph=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p); 696 ph=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p);
632 if (add) data[i]+=a*cos(ph); 697 if (add) data[i]+=a*cos(ph);
633 else data[i]=a*cos(ph); 698 else data[i]=a*cos(ph);
636 701
637 /** 702 /**
638 function Sinusoid: synthesizes sinusoid piece from trinomial frequency and amplitude coefficients, 703 function Sinusoid: synthesizes sinusoid piece from trinomial frequency and amplitude coefficients,
639 returning sinusoid coefficients instead of waveform. 704 returning sinusoid coefficients instead of waveform.
640 705
641 In: CountSt, CountEn 706 In: T
642 aa, ab, ac, ad: trinomial coefficients of amplitude (or log amplitude if LogA=true) 707 aa, ab, ac, ad: trinomial coefficients of amplitude (or log amplitude if LogA=true)
643 fa, fb, fc, fd: trinomial coefficients of frequency. 708 fa, fb, fc, fd: trinomial coefficients of frequency.
644 ph0, ph2: phase angles at 0 and CountEn. 709 ph0, ph2: phase angles at 0 and CountEn.
645 LogA: specifies whether log amplitude or amplitude is a trinomial 710 LogA: specifies whether log amplitude or amplitude is a trinomial
646 Out: f[CountSt:CountEn-1], a[CountSt:CountEn-1], ph[CountSt:CountEn-1]: synthesized sinusoid parameters 711 Out: f[CountSt:CountEn-1], a[CountSt:CountEn-1], ph[CountSt:CountEn-1]: synthesized sinusoid parameters
647 da[CountSt:CountEn-1]: derivative of synthesized amplitude, optional 712 da[CountSt:CountEn-1]: derivative of synthesized amplitude, optional
648 713
649 No return value. 714 No return value.
650 */ 715 */
651 void Sinusoid(double* f, double* a, double* ph, double* da, int CountSt, int CountEn, double aa, double ab, 716 void Sinusoid(int T, double* f, double* a, double* ph, double* da, double aa, double ab,
652 double ac, double ad, double fa, double fb, double fc, double fd, double ph0, double ph2, bool LogA) 717 double ac, double ad, double fa, double fb, double fc, double fd, double ph0, double ph2, bool LogA)
653 { 718 {
654 double pend=ph0+2*M_PI*CountEn*(fd+CountEn*(fc/2+CountEn*(fb/3+CountEn*fa/4))); 719 double pend=ph0+2*M_PI*T*(fd+T*(fc/2+T*(fb/3+T*fa/4)));
655 int k=floor((pend-ph2)/2/M_PI+0.5); 720 int k=floor((pend-ph2)/2/M_PI+0.5);
656 double d=ph2-pend+2*M_PI*k; 721 double d=ph2-pend+2*M_PI*k;
657 double p=-2*d/CountEn/CountEn/CountEn; 722 double p=-2*d/T/T/T;
658 double q=3*d/CountEn/CountEn; 723 double q=3*d/T/T;
659 if (LogA) for (int i=CountSt; i<CountEn; i++) 724 if (LogA) for (int i=0; i<T; i++)
660 { 725 {
661 a[i]=exp(ad+i*(ac+i*(ab+i*aa))); 726 a[i]=exp(ad+i*(ac+i*(ab+i*aa)));
662 if (da) da[i]=a[i]*(ac+i*(2*ab+i*3*aa)); 727 if (da) da[i]=a[i]*(ac+i*(2*ab+i*3*aa));
663 f[i]=fd+i*(fc+i*(fb+i*fa))+i*(2*q+3*i*p)/(2*M_PI); 728 f[i]=fd+i*(fc+i*(fb+i*fa))+i*(2*q+3*i*p)/(2*M_PI);
664 ph[i]=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p); 729 ph[i]=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p);
665 } 730 }
666 else for (int i=CountSt; i<CountEn; i++) 731 else for (int i=0; i<T; i++)
667 { 732 {
668 a[i]=ad+i*(ac+i*(ab+i*aa)); 733 a[i]=ad+i*(ac+i*(ab+i*aa));
669 if (da) da[i]=ac+i*(2*ab+i*3*aa); 734 if (da) da[i]=ac+i*(2*ab+i*3*aa);
670 f[i]=fd+i*(fc+i*(fb+i*fa))+i*(2*q+3*i*p)/(2*M_PI); 735 f[i]=fd+i*(fc+i*(fb+i*fa))+i*(2*q+3*i*p)/(2*M_PI);
671 ph[i]=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p); 736 ph[i]=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p);
673 }//Sinusoid 738 }//Sinusoid
674 739
675 /** 740 /**
676 function Sinusoid: generates trinomial frequency and phase with phase correction. 741 function Sinusoid: generates trinomial frequency and phase with phase correction.
677 742
678 In: CountSt, CountEn 743 In: T
679 fa, fb, fc, fd: trinomial coefficients of frequency. 744 fa, fb, fc, fd: trinomial coefficients of frequency.
680 ph0, ph2: phase angles at 0 and CountEn. 745 ph0, ph2: phase angles at 0 and CountEn.
681 Out: f[CountSt:CountEn-1], ph[CountSt:CountEn-1]: output buffers holding frequency and phase. 746 Out: f[T], ph[T]: output buffers holding frequency and phase.
682 747
683 No return value. 748 No return value.
684 */ 749 */
685 void Sinusoid(double* f, double* ph, int CountSt, int CountEn, double fa, double fb, 750 void Sinusoid(int T, double* f, double* ph, double fa, double fb,
686 double fc, double fd, double ph0, double ph2) 751 double fc, double fd, double ph0, double ph2)
687 { 752 {
688 double pend=ph0+2*M_PI*CountEn*(fd+CountEn*(fc/2+CountEn*(fb/3+CountEn*fa/4))); 753 double pend=ph0+2*M_PI*T*(fd+T*(fc/2+T*(fb/3+T*fa/4)));
689 int k=floor((pend-ph2)/2/M_PI+0.5); 754 int k=floor((pend-ph2)/2/M_PI+0.5);
690 double d=ph2-pend+2*M_PI*k; 755 double d=ph2-pend+2*M_PI*k;
691 double p=-2*d/CountEn/CountEn/CountEn; 756 double p=-2*d/T/T/T;
692 double q=3*d/CountEn/CountEn; 757 double q=3*d/T/T;
693 for (int i=CountSt; i<CountEn; i++) 758 for (int i=0; i<T; i++)
694 { 759 {
695 f[i]=fd+i*(fc+i*(fb+i*fa))+i*(2*q+3*i*p)/(2*M_PI); 760 f[i]=fd+i*(fc+i*(fb+i*fa))+i*(2*q+3*i*p)/(2*M_PI);
696 ph[i]=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p); 761 ph[i]=ph0+2*M_PI*i*(fd+i*((fc/2)+i*((fb/3)+i*fa/4)))+i*i*(q+i*p);
697 } 762 }
698 }//Sinusoid 763 }//Sinusoid
763 { 828 {
764 double *f3=new double[Fr*8], *f2=&f3[Fr], *f1=&f3[Fr*2], *f0=&f3[Fr*3], 829 double *f3=new double[Fr*8], *f2=&f3[Fr], *f1=&f3[Fr*2], *f0=&f3[Fr*3],
765 *a3=&f3[Fr*4], *a2=&a3[Fr], *a1=&a3[Fr*2], *a0=&a3[Fr*3]; 830 *a3=&f3[Fr*4], *a2=&a3[Fr], *a1=&a3[Fr*2], *a0=&a3[Fr*3];
766 CubicSpline(Fr-1, f3, f2, f1, f0, xs, fs, 1, 1); 831 CubicSpline(Fr-1, f3, f2, f1, f0, xs, fs, 1, 1);
767 CubicSpline(Fr-1, a3, a2, a1, a0, xs, as, 1, 1); 832 CubicSpline(Fr-1, a3, a2, a1, a0, xs, as, 1, 1);
768 for (int fr=0; fr<Fr-1; fr++) Sinusoid(&xrecm[(int)xs[fr]-dst], 0, xs[fr+1]-xs[fr], a3[fr], a2[fr], a1[fr], a0[fr], f3[fr], f2[fr], f1[fr], f0[fr], phs[fr], phs[fr+1], add); 833 for (int fr=0; fr<Fr-1; fr++) Sinusoid(xs[fr+1]-xs[fr], &xrecm[(int)xs[fr]-dst], a3[fr], a2[fr], a1[fr], a0[fr], f3[fr], f2[fr], f1[fr], f0[fr], phs[fr], phs[fr+1], add);
769 double tmpph=phs[0]; Sinusoid(&xrecm[(int)xs[0]-dst], dst-xs[0], 0, 0, 0, 0, a0[0], f3[0], f2[0], f1[0], f0[0], tmpph, add); 834 double tmpph=phs[0]; Sinusoid(&xrecm[(int)xs[0]-dst], dst-xs[0], 0, 0, 0, 0, a0[0], f3[0], f2[0], f1[0], f0[0], tmpph, add);
770 //extend the trinomials on [xs[Fr-2], xs[Fr-1]) based at xs[Fr-2] to beyond xs[Fr-1] based at xs[Fr-1]. 835 //extend the trinomials on [xs[Fr-2], xs[Fr-1]) based at xs[Fr-2] to beyond xs[Fr-1] based at xs[Fr-1].
771 tmpph=phs[Fr-1]; 836 tmpph=phs[Fr-1];
772 ShiftTrinomial(xs[Fr-1]-xs[Fr-2], f3[Fr-1], f2[Fr-1], f1[Fr-1], f0[Fr-1], f3[Fr-2], f2[Fr-2], f1[Fr-2], f0[Fr-2]); 837 ShiftTrinomial(xs[Fr-1]-xs[Fr-2], f3[Fr-1], f2[Fr-1], f1[Fr-1], f0[Fr-1], f3[Fr-2], f2[Fr-2], f1[Fr-2], f0[Fr-2]);
773 ShiftTrinomial(xs[Fr-1]-xs[Fr-2], a3[Fr-1], a2[Fr-1], a1[Fr-1], a0[Fr-1], a3[Fr-2], a2[Fr-2], a1[Fr-2], a0[Fr-2]); 838 ShiftTrinomial(xs[Fr-1]-xs[Fr-2], a3[Fr-1], a2[Fr-1], a1[Fr-1], a0[Fr-1], a3[Fr-2], a2[Fr-2], a1[Fr-2], a0[Fr-2]);