Mercurial > hg > x
diff procedures.cpp @ 5:5f3c32dc6e17
* Adjust comment syntax to permit Doxygen to generate HTML documentation; add Doxyfile
author | Chris Cannam |
---|---|
date | Wed, 06 Oct 2010 15:19:49 +0100 |
parents | 42c078b19e9a |
children | f0d2c9b5d3a3 |
line wrap: on
line diff
--- a/procedures.cpp Tue Oct 05 17:03:27 2010 +0100 +++ b/procedures.cpp Wed Oct 06 15:19:49 2010 +0100 @@ -8,6 +8,8 @@ #include "opt.h" #include "sinest.h" +/** \file procedures.h */ + //--------------------------------------------------------------------------- //TGMM methods @@ -40,7 +42,7 @@ delete[] Items; }//~TTFSpans -/* +/** method Add: add a new span to the list In: ATFSpan: the new span to add @@ -60,7 +62,7 @@ Count++; }//Add -/* +/** method Clear: discard the current content without freeing memory. */ void TTFSpans::Clear() @@ -68,7 +70,7 @@ Count=0; }//Clear -/* +/** method Delete: delete a span from current list In: Index: index to the span to delete @@ -85,7 +87,7 @@ //--------------------------------------------------------------------------- //SpecTrack methods -/* +/** method TSpecTrack::Add: adds a SpecPeak to the track. In: APeak: the SpecPeak to add. @@ -117,7 +119,7 @@ return ind; }//Add -/* +/** method TSpecTrack::TSpecTrack: creates a SpecTrack with an inital capacity. In: ACapacity: initial capacity, i.e. the number SpecPeak's to allocate storage space for. @@ -135,7 +137,7 @@ delete[] Peaks; }//TSpecTrack -/* +/** method InsertPeak: inserts a new SpecPeak into the track at a given index. Internal use only. In: APeak: the SpecPeak to insert. @@ -149,7 +151,7 @@ Count++; }//InsertPeak -/* +/** method TSpecTrack::LocatePeak: looks for a SpecPeak in the track that has the same time (t) as APeak. In: APeak: a SpecPeak @@ -177,7 +179,7 @@ }//LocatePeak //--------------------------------------------------------------------------- -/* +/** function: ACPower: AC power In: data[Count]: a signal @@ -199,7 +201,7 @@ }//ACPower //--------------------------------------------------------------------------- -/* +/** function Add: vector addition In: dest[Count], source[Count]: two vectors @@ -212,7 +214,7 @@ for (int i=0; i<Count; i++) *(dest++)+=*(source++); }//Add -/* +/** function Add: vector addition In: addend[count], adder[count]: two vectors @@ -227,7 +229,7 @@ //--------------------------------------------------------------------------- -/* +/** function ApplyWindow: applies window function to signal buffer. In: Buffer[Size]: signal to be windowed @@ -242,7 +244,7 @@ }//ApplyWindow //--------------------------------------------------------------------------- -/* +/** function Avg: average In: data[Count]: a data array @@ -259,7 +261,7 @@ }//Avg //--------------------------------------------------------------------------- -/* +/** function AvgFilter: get slow-varying wave trace by averaging In: data[Count]: input signal @@ -294,7 +296,7 @@ }//AvgFilter //--------------------------------------------------------------------------- -/* +/** function CalculateSpectrogram: computes the spectrogram of a signal In: data[Count]: the time-domain signal @@ -337,7 +339,7 @@ }//CalculateSpectrogram //--------------------------------------------------------------------------- -/* +/** function Conv: simple convolution In: in1[N1], in2[N2]: two sequences @@ -355,7 +357,7 @@ }//Conv //--------------------------------------------------------------------------- -/* +/** function Correlation: computes correlation coefficient of 2 vectors a & b, equals cos(aOb). In: a[Count], b[Count]: two vectors @@ -375,7 +377,7 @@ }//Correlation //--------------------------------------------------------------------------- -/* +/** function DCAmplitude: DC amplitude In: data[Count]: a signal @@ -395,7 +397,7 @@ return sqrt(2*power); }//DCAmplitude -/* +/** function DCPower: DC power In: data[Count]: a signal @@ -416,7 +418,7 @@ }//DCPower //--------------------------------------------------------------------------- -/* +/** DCT: discrete cosine transform, direct computation. For fast DCT, see fft.cpp. In: input[N]: a signal @@ -439,7 +441,7 @@ } }//DCT -/* +/** function IDCT: inverse discrete cosine transform, direct computation. For fast IDCT, see fft.cpp. In: input[N]: a signal @@ -459,7 +461,7 @@ }//IDCT //--------------------------------------------------------------------------- -/* +/** function DeDC: removes DC component of a signal In: data[Count]: the signal @@ -477,7 +479,7 @@ delete[] data2; }//DeDC -/* +/** function DeDC_static: removes DC component statically In: data[Count]: the signal @@ -492,7 +494,7 @@ }//DeDC_static //--------------------------------------------------------------------------- -/* +/** function DoubleToInt: converts double-precision floating point array to integer array In: in[Count]: the double array @@ -507,7 +509,7 @@ else {__int16* out16=(__int16*)out; for (int k=0; k<Count; k++) *(out16++)=floor(*(in++)+0.5);} }//DoubleToInt -/* +/** function DoubleToIntAdd: adds double-precision floating point array to integer array In: in[Count]: the double array @@ -532,7 +534,7 @@ }//DoubleToIntAdd //--------------------------------------------------------------------------- -/* +/** DPower: in-frame power variation In: data[Count]: a signal @@ -547,8 +549,8 @@ }//DPower //--------------------------------------------------------------------------- -/* - funciton Energy: energy +/** + function Energy: energy In: data[Count]: a signal @@ -562,7 +564,7 @@ }//Energy //--------------------------------------------------------------------------- -/* +/** function ExpOnsetFilter: onset filter with exponential impulse response h(t)=Aexp(-t/Tr)-Bexp(-t/Ta), A=1-exp(-1/Tr), B=1-exp(-1/Ta). @@ -587,7 +589,7 @@ return NormFactor; }//ExpOnsetFilter -/* +/** function ExpOnsetFilter_balanced: exponential onset filter without starting step response. It extends the input signal at the front end by bal*Ta samples by repeating the its value at 0, then applies the onset filter on the extended signal instead. @@ -612,7 +614,7 @@ }//ExpOnsetFilter_balanced //--------------------------------------------------------------------------- -/* +/** function ExtractLinearComponent: Legendre linear component In: data[Count+1]: a signal @@ -632,7 +634,7 @@ }//ExtractLinearComponent //--------------------------------------------------------------------------- -/* +/** function FFTConv: fast convolution of two series by FFT overlap-add. In an overlap-add scheme it is assumed that one of the convolvends is short compared to the other one, which can be potentially infinitely long. The long convolvend is devided into short segments, each of which is convolved with @@ -779,7 +781,7 @@ delete[] hbitinv; }//FFTConv -/* +/** function FFTConv: the simplified version using two output buffers instead of three. This is almost equivalent to setting zero=-size2 in the three-output-buffer version (so that post_buffer no longer exists), except that this version requires size2 (renamed HWid) be a power of 2, and pre_buffer point @@ -881,7 +883,7 @@ delete[] x2; delete[] tmp; delete[] hbitinv; }//FFTConv -/* +/** function FFTConv: fast convolution of two series by FFT overlap-add. Same as the three-output-buffer version above but using integer output buffers as well as integer source1. @@ -1022,7 +1024,7 @@ }//FFTConv //--------------------------------------------------------------------------- -/* +/** function FFTFilter: FFT with cosine-window overlap-add: This FFT filter is not an actural LTI system, but an block processing with overlap-add. In this function the blocks are overlapped by 50% and summed up with Hann windowing. @@ -1089,8 +1091,8 @@ FreeFFTBuffer(ldata); }//FFTFilter -/* - funtion FFTFilterOLA: FFTFilter with overlap-add support. This is a true LTI filter whose impulse +/** + function FFTFilterOLA: FFTFilter with overlap-add support. This is a true LTI filter whose impulse response is constructed using IFFT. The filtering is implemented by fast convolution. In: data[Count]: input data @@ -1123,7 +1125,7 @@ FreeFFTBuffer(spec); }//FFTFilterOLA -/* +/** function FFTFilterOLA: FFT filter with overlap-add support. In: data[Count]: input data @@ -1152,7 +1154,7 @@ FreeFFTBuffer(spec); }//FFTFilterOLA -/* +/** function FFTMask: masks a band of a signal with noise In: data[Count]: input signal @@ -1247,7 +1249,7 @@ }//FFTMask //--------------------------------------------------------------------------- -/* +/** function FindInc: find the element in ordered list data that is closest to value. In: data[Count]: a ordered list @@ -1265,7 +1267,7 @@ }//FindInc //--------------------------------------------------------------------------- -/* +/** function Gaussian: Gaussian function In: Vector[Dim]: a vector @@ -1293,7 +1295,7 @@ //--------------------------------------------------------------------------- -/* +/** function Hamming: calculates the amplitude spectrum of Hamming window at a given frequency In: f: frequency @@ -1333,7 +1335,7 @@ }//Hamming*/ //--------------------------------------------------------------------------- -/* +/** function HannSq: computes the square norm of Hann window spectrum (window-size-normalized) In: x: frequency, in bins @@ -1370,7 +1372,7 @@ return (re*re+im*im)/(N*N); }//HannSq -/* +/** function Hann: computes the Hann window amplitude spectrum (window-size-normalized). In: x: frequency, in bins @@ -1406,7 +1408,7 @@ return result/N; }//HannC -/* +/** function HxPeak2: fine spectral peak detection. This does detection and high-precision LSE estimation in one go. However, since in practise most peaks are spurious, LSE estimation is not necessary on them. Accordingly, HxPeak2 is deprecated in favour of faster but coarser peak picking methods, such as @@ -1513,7 +1515,7 @@ }//HxPeak2 //--------------------------------------------------------------------------- -/* +/** function InsertDec: inserts value into sorted decreasing list In: data[Count]: a sorted decreasing list. @@ -1580,7 +1582,7 @@ return end; }//InsertDec -/* +/** function InsertDec: inserts value and attached integer into sorted decreasing list In: data[Count]: a sorted decreasing list @@ -1622,7 +1624,7 @@ return end; }//InsertDec -/* +/** InsertInc: inserts value into sorted increasing list. In: data[Count]: a sorted increasing list. @@ -1675,7 +1677,7 @@ return PosToInsert; }//InsertInc -/* +/** function InsertInc: inserts value into sorted increasing list In: data[Count]: a sorted increasing list. @@ -1749,7 +1751,7 @@ return end; }//InsertInc -/* +/** function InsertInc: inserts value and attached integer into sorted increasing list In: data[Count]: a sorted increasing list @@ -1821,7 +1823,7 @@ return end; }//InsertInc -/* +/** function InsertIncApp: inserts value into flexible-length sorted increasing list In: data[Count]: a sorted increasing list. @@ -1862,7 +1864,7 @@ }//InsertIncApp //--------------------------------------------------------------------------- -/* +/** function InstantFreq; calculates instantaneous frequency from spectrum, evaluated at bin k In: x[hwid]: spectrum with scale 2hwid @@ -1900,7 +1902,7 @@ return result; }//InstantFreq -/* +/** function InstantFreq; calculates "frequency spectrum", a sequence of frequencies evaluated at DFT bins In: x[hwid]: spectrum with scale 2hwid @@ -1916,7 +1918,7 @@ }//InstantFreq //--------------------------------------------------------------------------- -/* +/** function IntToDouble: copy content of integer array to double array In: in: pointer to integer array @@ -1936,7 +1938,7 @@ }//IntToDouble*/ //--------------------------------------------------------------------------- -/* +/** function IPHannC: inner product with Hann window spectrum In: x[N]: spectrum @@ -1955,7 +1957,7 @@ //--------------------------------------------------------------------------- -/* +/** function lse: linear regression y=ax+b In: x[Count], y[Count]: input points @@ -1978,7 +1980,7 @@ }//lse //-------------------------------------------------------------------------- -/* +/** memdoubleadd: vector addition In: dest[count], source[count]: addends @@ -1992,7 +1994,7 @@ }//memdoubleadd //-------------------------------------------------------------------------- -/* +/** function Mel: converts frequency in Hz to frequency in mel. In: f: frequency, in Hz @@ -2004,7 +2006,7 @@ return 1127.01048*log(1+f/700); }//Mel -/* +/** function InvMel: converts frequency in mel to frequency in Hz. In: f: frequency, in mel. @@ -2016,7 +2018,7 @@ return 700*(exp(mel/1127.01048)-1); }//InvMel -/* +/** function MFCC: calculates MFCC. In: Data[FrameWidth]: data @@ -2063,7 +2065,7 @@ } }//MFCC -/* +/** function MFCCPrepareBands: returns a array of OVERLAPPING bands given in triples, whose 1st and 3rd entries are the start and end of a band, in bins, and the 2nd is a middle frequency. @@ -2094,7 +2096,7 @@ }//MFCCPrepareBands //--------------------------------------------------------------------------- -/* +/** function Multi: vector-constant multiplication In: data[count]: a vector @@ -2108,7 +2110,7 @@ for (int i=0; i<count; i++){*data=*data*mul; data++;} }//Multi -/* +/** function Multi: vector-constant multiplication In: in[count]: a vector @@ -2122,7 +2124,7 @@ for (int i=0; i<count; i++) *(out++)=*(in++)*mul; }//Multi -/* +/** function Multi: vector-constant multiply-addition In: in[count], adder[count]: vectors @@ -2137,7 +2139,7 @@ }//MultiAdd //--------------------------------------------------------------------------- -/* +/** function NearestPeak: finds a peak value in an array that is nearest to a given index In: data[count]: an array @@ -2169,7 +2171,7 @@ }//NearestPeak //--------------------------------------------------------------------------- -/* +/** function NegativeExp: fits the curve y=1-x^lmd. In: x[Count], y[Count]: sample points to fit, x[0]=0, x[Count-1]=1, y[0]=1, y[Count-1]=0 @@ -2214,7 +2216,7 @@ }//NegativeExp //--------------------------------------------------------------------------- -/* +/** function: NL: noise level, calculated on 5% of total frames with least energy In: data[Count]: @@ -2240,7 +2242,7 @@ }//NL //--------------------------------------------------------------------------- -/* +/** function Normalize: normalizes data to [-Maxi, Maxi], without zero shift In: data[Count]: data to be normalized @@ -2267,7 +2269,7 @@ return max; }//Normalize -/* +/** function Normalize2: normalizes data to a specified Euclidian norm In: data[Count]: data to normalize @@ -2287,7 +2289,7 @@ }//Normalize2 //--------------------------------------------------------------------------- -/* +/** function PhaseSpan: computes the unwrapped phase variation across the Nyquist range In: data[Count]: time-domain data @@ -2314,7 +2316,7 @@ }//PhaseSpan //--------------------------------------------------------------------------- -/* +/** function PolyFit: least square polynomial fitting y=sum(i){a[i]*x^i} In: x[N], y[N]: sample points @@ -2344,7 +2346,7 @@ }//PolyFit //--------------------------------------------------------------------------- -/* +/** function Pow: vector power function In: data[Count]: a vector @@ -2360,7 +2362,7 @@ }//Power //--------------------------------------------------------------------------- -/* +/** Rectify: semi-wave rectification In: data[Count]: data to rectify @@ -2381,7 +2383,7 @@ }//Rectify //--------------------------------------------------------------------------- -/* +/** function Res: minimum absolute residue. In: in: a number @@ -2399,7 +2401,7 @@ }//Res //--------------------------------------------------------------------------- -/* +/** function Romberg: Romberg algorithm for numerical integration In: f: function to integrate @@ -2432,7 +2434,7 @@ return h; }//Romberg -/* +/** function Romberg: Romberg algorithm for numerical integration, may return before specified depth on convergence. @@ -2481,7 +2483,7 @@ //analog and digital sinc functions //sinca(0)=1, sincd(0)=N, sinca(1)=sincd(1)=0. -/* +/** function sinca: analog sinc function. In: x: frequency @@ -2494,7 +2496,7 @@ return sin(M_PI*x)/(M_PI*x); }//sinca -/* +/** function sincd_unn: unnormalized discrete sinc function In: x: frequency @@ -2509,7 +2511,7 @@ }//sincd //--------------------------------------------------------------------------- -/* +/** SmoothPhase: phase unwrapping on module mpi*PI, 2PI by default In: Arg[Count]: phase angles to unwrap @@ -2533,7 +2535,7 @@ //--------------------------------------------------------------------------- //the stiff string partial frequency model f[m]=mf[1]*sqrt(1+B(m*m-1)). -/* +/** StiffB: computes stiffness coefficient from fundamental and another partial frequency based on the stiff string partial frequency model f[m]=mf[1]*sqrt(1+B(m*m-1)). @@ -2550,7 +2552,7 @@ }//StiffB //StiffF: partial frequency of a stiff string -/* +/** StiffFm: computes a partial frequency from fundamental frequency and partial index based on the stiff string partial frequency model f[m]=mf[1]*sqrt(1+B(m*m-1)). @@ -2565,7 +2567,7 @@ return m*f0*sqrt(1+B*(m*m-1)); }//StiffFm -/* +/** StiffF0: computes fundamental frequency from another partial frequency and stiffness coefficient based on the stiff string partial frequency model f[m]=mf[1]*sqrt(1+B(m*m-1)). @@ -2580,7 +2582,7 @@ return fm/m/sqrt(1+B*(m*m-1)); }//StiffF0 -/* +/** StiffM: computes 1-based partial index from partial frequency, fundamental frequency and stiffness coefficient based on the stiff string partial frequency model f[m]=mf[1]*sqrt(1+B(m*m-1)). @@ -2603,7 +2605,7 @@ }//StiffMd //--------------------------------------------------------------------------- -/* +/** TFFilter: time-frequency filtering with Hann-windowed overlap-add. In: data[Count]: input data