# HG changeset patch # User Wen X # Date 1312976015 -3600 # Node ID 977f541d66834667eb21a44be3e45f197cf04921 # Parent c6528c38b23cbf86c6aad11b640ec7756d0aea5c GPL and cosmetic changes diff -r c6528c38b23c -r 977f541d6683 align8.cpp --- a/align8.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/align8.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- diff -r c6528c38b23c -r 977f541d6683 align8.h --- a/align8.h Thu Jul 28 10:36:57 2011 +0100 +++ b/align8.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #ifndef align8H diff -r c6528c38b23c -r 977f541d6683 arrayalloc.h --- a/arrayalloc.h Thu Jul 28 10:36:57 2011 +0100 +++ b/arrayalloc.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef ARRAYALLOC #define ARRAYALLOC diff -r c6528c38b23c -r 977f541d6683 fft.cpp --- a/fft.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/fft.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include @@ -19,6 +31,16 @@ }//Atan2 /** + function Log2: Log2 + + Returns x for Log2(2^x) if x is integer. +*/ +int Log2(int x) +{ + return floor(log(x)/log(2)+0.5); +}//Log2 + +/** function BitInv: inverse bit order of Value within an $Order-bit expression. In: integer Value smaller than 2^Order diff -r c6528c38b23c -r 977f541d6683 fft.h --- a/fft.h Thu Jul 28 10:36:57 2011 +0100 +++ b/fft.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef fftH #define fftH @@ -75,6 +87,7 @@ //--tools-------------------------------------------------------------------- double Atan2(double, double); +int Log2(int); int* CreateBitInvTable(int Order); //creates table of bit-inversed integers void SetTwiddleFactors(int N, cdouble* w); //set twiddle factors diff -r c6528c38b23c -r 977f541d6683 hs.cpp --- a/hs.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/hs.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include #include "hs.h" @@ -4608,6 +4620,7 @@ atom* part=partials[m]; bool fzero=false; for (int fr=0; frM, HS->Fr, HS->Partials, dst, den, terminatetag); +}//SynthesisHS + /** function SynthesisHS2: synthesizes a perfectly harmonic sinusoid without aligning the phases. Frequencies of partials above the fundamental are not used in this synthesis process. diff -r c6528c38b23c -r 977f541d6683 hs.h --- a/hs.h Thu Jul 28 10:36:57 2011 +0100 +++ b/hs.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef hsH #define hsH @@ -13,7 +25,12 @@ #include "align8.h" #include "fft.h" #include "quickspec.h" + +#ifndef __BORLANDC__ #include "tstream.h" +#else +#include +#endif #define ATOM_LOCALANCHOR 1 #define HS_CONSTF 1 @@ -127,7 +144,6 @@ THS is the data structure hosting a harmonic sinusoid representation. Its key members include the number of partials, number of frames, and all its atoms (sinusoid parameters of all partials at measurement points). */ - class THS { public: @@ -239,6 +255,7 @@ void InitializeR(TPolygon* R, int apind, double af, double ef, double maxB); //--internal structure conversion routines----------------------------------- +void AtomsToPartials(int k, atom* part, int& M, int& Fr, atom**& partials, int offst); int NMResultToAtoms(int M, atom* HP, int t, int wid, NMResults results); int NMResultToPartials(int M, int fr, atom** Partials, int t, int wid, NMResults results); @@ -263,6 +280,7 @@ //--harmonic sinusoid synthesis routines------------------------------------- double* SynthesisHS(int pm, int pfr, atom** partials, int& dst, int& den, bool* terminatetag=0); +double* SynthesisHS(THS* HS, int& dst, int& den, bool* terminatetag=0); double* SynthesisHS2(int M, int Fr, atom** partials, int& dst, int& den, bool* terminatetag=0); double* SynthesisHSp(int pm, int pfr, atom** partials, int& dst, int& den, double** startamp=0, int st_start=0, int st_offst=0, int st_count=0); double* SynthesisHSp(THS* HS, int& dst, int& den); diff -r c6528c38b23c -r 977f541d6683 hsedit.cpp --- a/hsedit.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/hsedit.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include "hsedit.h" diff -r c6528c38b23c -r 977f541d6683 hsedit.h --- a/hsedit.h Thu Jul 28 10:36:57 2011 +0100 +++ b/hsedit.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef hseditH #define hseditH diff -r c6528c38b23c -r 977f541d6683 hssf.cpp --- a/hssf.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/hssf.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include @@ -65,6 +77,7 @@ */ void TSF::Duplicate(TSF& SF) { + TSF::~TSF(); memcpy(this, &SF, sizeof(TSF)); lp=F0=avgh=avgb=0, h=b=0; AllocateL(L); memcpy(F0, SF.F0, sizeof(double)*(L+2)*6); AllocateP(); memcpy(lp, SF.lp, sizeof(double)*(P+2)); diff -r c6528c38b23c -r 977f541d6683 hssf.h --- a/hssf.h Thu Jul 28 10:36:57 2011 +0100 +++ b/hssf.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef hssfH #define hssfH diff -r c6528c38b23c -r 977f541d6683 main.cpp --- a/main.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/main.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,4 @@ + /* Sample program: analysis of harmonic sinusoid in low-noise monophonic context. diff -r c6528c38b23c -r 977f541d6683 matrix.cpp --- a/matrix.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/matrix.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include #include diff -r c6528c38b23c -r 977f541d6683 matrix.h --- a/matrix.h Thu Jul 28 10:36:57 2011 +0100 +++ b/matrix.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef MatrixH #define MatrixH diff -r c6528c38b23c -r 977f541d6683 multires.cpp --- a/multires.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/multires.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include diff -r c6528c38b23c -r 977f541d6683 multires.h --- a/multires.h Thu Jul 28 10:36:57 2011 +0100 +++ b/multires.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef multiresH #define multiresH diff -r c6528c38b23c -r 977f541d6683 opt.cpp --- a/opt.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/opt.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include diff -r c6528c38b23c -r 977f541d6683 opt.h --- a/opt.h Thu Jul 28 10:36:57 2011 +0100 +++ b/opt.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef optH #define optH diff -r c6528c38b23c -r 977f541d6683 procedures.cpp --- a/procedures.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/procedures.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include @@ -318,7 +330,7 @@ for (int i=0; iAmp, Count); - RFFTC(Amp, Amp, Arg, log2(Count*Pad), w, x, 0); + RFFTC(Amp, Amp, Arg, Log2(Count*Pad), w, x, 0); SmoothPhase(Arg, Count*Pad/2+1); double result=Arg[Count*Pad/2]-Arg[0]; @@ -2622,7 +2634,7 @@ { int HWid=Wid/2; int Fr=Count/HWid-1; - int Order=log2(Wid); + int Order=Log2(Wid); int** lspan=new int*[Fr]; double* lxspan=new double[Fr]; @@ -2742,7 +2754,7 @@ { int HWid=Wid/2; int Fr=Count/HWid-1; - int Order=log2(Wid); + int Order=Log2(Wid); int** lspan=new int*[Fr]; double* lxspan=new double[Fr]; diff -r c6528c38b23c -r 977f541d6683 procedures.h --- a/procedures.h Thu Jul 28 10:36:57 2011 +0100 +++ b/procedures.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef proceduresH #define proceduresH diff -r c6528c38b23c -r 977f541d6683 quickspec.cpp --- a/quickspec.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/quickspec.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include #include @@ -123,8 +135,8 @@ */ void CalculateSpectrum(void* Data, int BytesPerSample, double* win, QSPEC_FORMAT* Amp, QSPEC_FORMAT* Arg, int Wid, cdouble* w, cdouble* x, int* hbi) { - if (BytesPerSample==2) RFFTCW((__int16*)Data, win, 0, 0, log2(Wid), w, x, hbi); - else {IntToDouble((double*)x, Data, BytesPerSample, Wid); RFFTCW((double*)x, win, 0, 0, log2(Wid), w, x, hbi);} + if (BytesPerSample==2) RFFTCW((__int16*)Data, win, 0, 0, Log2(Wid), w, x, hbi); + else {IntToDouble((double*)x, Data, BytesPerSample, Wid); RFFTCW((double*)x, win, 0, 0, Log2(Wid), w, x, hbi);} for (int j=0; j<=Wid/2; j++) { Amp[j]=sqrt(x[j].x*x[j].x+x[j].y*x[j].y); @@ -157,7 +169,7 @@ { double* doublex=(double*)x; IntToDouble(doublex, Data, BytesPerSample, eff); memset(&doublex[eff], 0, sizeof(double)*(Wid-eff)); - RFFTCW(doublex, win, 0, 0, log2(Wid), w, x, hbi); + RFFTCW(doublex, win, 0, 0, Log2(Wid), w, x, hbi); for (int j=0; j<=Wid/2; j++) { Amp[j]=sqrt(x[j].x*x[j].x+x[j].y*x[j].y); @@ -190,7 +202,7 @@ free8(fw); free(fhbi); fw=(cdouble*)malloc8(sizeof(cdouble)*Wid*1.5); SetTwiddleFactors(Wid, fw); fx=&fw[Wid/2]; - fhbi=CreateBitInvTable(log2(Wid)-1); + fhbi=CreateBitInvTable(Log2(Wid)-1); } if (Wid!=fWid || WinType!=fwt || WinParam!=fwdp) { //then update internal window function to the new window type diff -r c6528c38b23c -r 977f541d6683 quickspec.h --- a/quickspec.h Thu Jul 28 10:36:57 2011 +0100 +++ b/quickspec.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef QuickSpecH #define QuickSpecH @@ -123,7 +135,6 @@ void AddBuffer(); void AddBuffer(int AddFrCount); void __fastcall CalculateSpectrum(int fr); - void SetFrCapacity(int AnFrCapacity); public: //if specified, Parent is responsible to supply FFT buffers through GetFFTBuffers (optional) @@ -153,6 +164,7 @@ void FreeBuffers(); ///< discards all computed frames and free memory int Invalidate(int From, int To); ///< discards computed frames QSPEC_FORMAT* __fastcall Ph(int fr); ///< accesses phase spectrogram at frame fr + void SetFrCapacity(int AnFrCapacity); cmplx* __fastcall Spec(int fr); ///< accesses complex spectrogram at frame fr }; #endif diff -r c6528c38b23c -r 977f541d6683 sinest.cpp --- a/sinest.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/sinest.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include @@ -1798,7 +1810,7 @@ __int16* lx=&x[Offst*fr]; double* lph=&ph[Offst*(fr-frst)]; for (int i=0; iAmp[mpf]) mpf=k; if (mpf>pf-4 && mpfabuf[fr]) @@ -1985,7 +1997,7 @@ for (int i=hWid; iabuf[fr]) @@ -2089,7 +2101,7 @@ SetTwiddleFactors(lWid, w); double *lwin=NewWindow(wtHann, lWid), lc[4], liH2; windowspec(wtHann, lWid, &lM, lc, &liH2); - CFFTCW(&xs[hWid-lhWid], lwin, NULL, NULL, log2(lWid), w, xc); + CFFTCW(&xs[hWid-lhWid], lwin, NULL, NULL, Log2(lWid), w, xc); delete[] lwin; double lf=fbuf[fr]*lWid, la, lp; LSESinusoid(lf, lf-3, lf+3, xc, lWid, 3, lM, lc, liH2, la, lp, 1e-3); @@ -2097,7 +2109,7 @@ } else { - CFFTCW(xs, win, NULL, NULL, log2(Wid), w, xc); + CFFTCW(xs, win, NULL, NULL, Log2(Wid), w, xc); double lf=fbuf[fr]*Wid, la, lp; LSESinusoid(lf, lf-3, lf+3, xc, Wid, 3, M, c, iH2, la, lp, 1e-3); if (la*2>abuf[fr]) fbuf[fr]=lf/Wid, abuf[fr]=la*2, pbuf[fr]=lp; @@ -2209,7 +2221,7 @@ void Derivative(int Wid, double* win, cdouble* x, cdouble* dx, cdouble* ddx, double& f0, double* f1, double* a0, double* a1, double* ph) { AllocateFFTBuffer(Wid, fft, W, X); - CFFTCW(x, win, fft, NULL, log2(Wid), W, X); + CFFTCW(x, win, fft, NULL, Log2(Wid), W, X); int m=f0*Wid, m0=m-10, m1=m+10, hWid=Wid/2; if (m0<0) m0=0; if (m1>hWid) m1=hWid; for (int n=m0; n<=m1; n++) if (fft[n]>fft[m]) m=n; diff -r c6528c38b23c -r 977f541d6683 sinest.h --- a/sinest.h Thu Jul 28 10:36:57 2011 +0100 +++ b/sinest.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef SinEstH #define SinEstH diff -r c6528c38b23c -r 977f541d6683 sinsyn.cpp --- a/sinsyn.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/sinsyn.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include "align8.h" @@ -788,7 +800,7 @@ ALIGN8(Sinusoid(&xrec[(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], ph, add);) if (terminatetag && *terminatetag) {delete[] f3; return 0;} } - phs[Fr-1]=ph; + phs[Fr-1]=ph; ph=phs[Fr-2]; ALIGN8(Sinusoid(&xrec[(int)xs[Fr-2]-dst], xs[Fr-1]-xs[Fr-2], den-xs[Fr-2], a3[Fr-2], a2[Fr-2], a1[Fr-2], a0[Fr-2], f3[Fr-2], f2[Fr-2], f1[Fr-2], f0[Fr-2], ph, add); Sinusoid(&xrec[(int)xs[0]-dst], dst-xs[0], 0, a3[0], a2[0], a1[0], a0[0], f3[0], f2[0], f1[0], f0[0], phs[0], add);) delete[] f3; diff -r c6528c38b23c -r 977f541d6683 sinsyn.h --- a/sinsyn.h Thu Jul 28 10:36:57 2011 +0100 +++ b/sinsyn.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef SinSynH #define SinSynH diff -r c6528c38b23c -r 977f541d6683 splines.cpp --- a/splines.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/splines.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include "splines.h" diff -r c6528c38b23c -r 977f541d6683 splines.h --- a/splines.h Thu Jul 28 10:36:57 2011 +0100 +++ b/splines.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef splinesH #define splinesH diff -r c6528c38b23c -r 977f541d6683 tstream.h --- a/tstream.h Thu Jul 28 10:36:57 2011 +0100 +++ b/tstream.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef TSTREAM_H #define TSTREAM_H diff -r c6528c38b23c -r 977f541d6683 vibrato.cpp --- a/vibrato.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/vibrato.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include @@ -462,10 +474,10 @@ */ void DeAM(double* A2, double* A1, int npfr, double* lp, int Fr) { - int* peakfr=new int[npfr]; + int* peakfr=(int*)malloc(sizeof(int)*npfr); for (int i=0; iP=inewP; - newV->peakfr=new int[inewP]; + newV->peakfr=(int*)malloc(sizeof(int)*inewP); newV->AllocateP(); newV->AllocatePK(); newV->lp[0]=V.lp[0]/rate; @@ -907,7 +919,7 @@ { rate=0; regularity=0; //find the section used for calculating regularity and rate - int frlen=fren-frst+1, frlenp=1<<(int(log2(fren))+2), frlenpp=frlenp*padrate; + int frlen=fren-frst+1, frlenp=1<<(int(Log2(fren))+2), frlenpp=frlenp*padrate; double *lf=new double[frlenpp*4]; cdouble *w=(cdouble*)&lf[frlenpp]; cdouble *x=(cdouble*)&lf[frlenpp*2]; @@ -924,13 +936,13 @@ } - RFFTC(lf, NULL, NULL, log2(frlenp), w, x, 0); + RFFTC(lf, NULL, NULL, Log2(frlenp), w, x, 0); // xr[0]=0; for (int i=0; i diff -r c6528c38b23c -r 977f541d6683 wavelet.h --- a/wavelet.h Thu Jul 28 10:36:57 2011 +0100 +++ b/wavelet.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef waveletH #define waveletH diff -r c6528c38b23c -r 977f541d6683 windowfunctions.cpp --- a/windowfunctions.cpp Thu Jul 28 10:36:57 2011 +0100 +++ b/windowfunctions.cpp Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ //--------------------------------------------------------------------------- #include #include diff -r c6528c38b23c -r 977f541d6683 windowfunctions.h --- a/windowfunctions.h Thu Jul 28 10:36:57 2011 +0100 +++ b/windowfunctions.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef WindowFunctionsH #define WindowFunctionsH diff -r c6528c38b23c -r 977f541d6683 xcomplex.h --- a/xcomplex.h Thu Jul 28 10:36:57 2011 +0100 +++ b/xcomplex.h Wed Aug 10 12:33:35 2011 +0100 @@ -1,3 +1,15 @@ +/* + Harmonic sinusoidal modelling and tools + + C++ code package for harmonic sinusoidal modelling and relevant signal processing. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2011 Wen Xue. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. +*/ #ifndef XCOMPLEX #define XCOMPLEX