mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
globally remove all trailing whitespace from .cpp and .hpp files missed by previous commit
This commit is contained in:
parent
4dc63966f0
commit
4178db5f63
56 changed files with 50764 additions and 50764 deletions
|
|
@ -39,7 +39,7 @@ Pitch::getPitchForFrequency(float frequency,
|
|||
midiPitch = midiPitch + 1;
|
||||
centsOffset = -(100.0 - centsOffset);
|
||||
}
|
||||
|
||||
|
||||
if (centsOffsetReturn) *centsOffsetReturn = centsOffset;
|
||||
return midiPitch;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -124,7 +124,7 @@ void Chromagram::unityNormalise(double *src)
|
|||
double* Chromagram::process( const double *data )
|
||||
{
|
||||
if (!m_skGenerated) {
|
||||
// Generate CQ Kernel
|
||||
// Generate CQ Kernel
|
||||
m_ConstantQ->sparsekernel();
|
||||
m_skGenerated = true;
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ double* Chromagram::process( const double *data )
|
|||
double* Chromagram::process( const double *real, const double *imag )
|
||||
{
|
||||
if (!m_skGenerated) {
|
||||
// Generate CQ Kernel
|
||||
// Generate CQ Kernel
|
||||
m_ConstantQ->sparsekernel();
|
||||
m_skGenerated = true;
|
||||
}
|
||||
|
|
@ -164,10 +164,10 @@ double* Chromagram::process( const double *real, const double *imag )
|
|||
|
||||
// add each octave of cq data into Chromagram
|
||||
const unsigned octaves = (int)floor(double( m_uK/m_BPO))-1;
|
||||
for (unsigned octave = 0; octave <= octaves; octave++)
|
||||
for (unsigned octave = 0; octave <= octaves; octave++)
|
||||
{
|
||||
unsigned firstBin = octave*m_BPO;
|
||||
for (unsigned i = 0; i < m_BPO; i++)
|
||||
for (unsigned i = 0; i < m_BPO; i++)
|
||||
{
|
||||
m_chromadata[i] += kabs( m_CQRe[ firstBin + i ], m_CQIm[ firstBin + i ]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ void ConstantQ::sparsekernel()
|
|||
double* transfHammingWindowRe = new double [ m_FFTLength ];
|
||||
double* transfHammingWindowIm = new double [ m_FFTLength ];
|
||||
|
||||
for (unsigned u=0; u < m_FFTLength; u++)
|
||||
for (unsigned u=0; u < m_FFTLength; u++)
|
||||
{
|
||||
hammingWindowRe[u] = 0;
|
||||
hammingWindowIm[u] = 0;
|
||||
|
|
@ -111,26 +111,26 @@ void ConstantQ::sparsekernel()
|
|||
sk->imag.reserve( m_FFTLength*2 );
|
||||
|
||||
// for each bin value K, calculate temporal kernel, take its fft to
|
||||
//calculate the spectral kernel then threshold it to make it sparse and
|
||||
//calculate the spectral kernel then threshold it to make it sparse and
|
||||
//add it to the sparse kernels matrix
|
||||
double squareThreshold = m_CQThresh * m_CQThresh;
|
||||
|
||||
FFT m_FFT(m_FFTLength);
|
||||
|
||||
for (unsigned k = m_uK; k--; )
|
||||
for (unsigned k = m_uK; k--; )
|
||||
{
|
||||
for (unsigned u=0; u < m_FFTLength; u++)
|
||||
for (unsigned u=0; u < m_FFTLength; u++)
|
||||
{
|
||||
hammingWindowRe[u] = 0;
|
||||
hammingWindowIm[u] = 0;
|
||||
}
|
||||
|
||||
|
||||
// Computing a hamming window
|
||||
const unsigned hammingLength = (int) ceil( m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO)));
|
||||
|
||||
unsigned origin = m_FFTLength/2 - hammingLength/2;
|
||||
|
||||
for (unsigned i=0; i<hammingLength; i++)
|
||||
for (unsigned i=0; i<hammingLength; i++)
|
||||
{
|
||||
const double angle = 2*PI*m_dQ*i/hammingLength;
|
||||
const double real = cos(angle);
|
||||
|
|
@ -148,12 +148,12 @@ void ConstantQ::sparsekernel()
|
|||
hammingWindowIm[i] = hammingWindowIm[i + m_FFTLength/2];
|
||||
hammingWindowIm[i + m_FFTLength/2] = temp;
|
||||
}
|
||||
|
||||
|
||||
//do fft of hammingWindow
|
||||
m_FFT.process( 0, hammingWindowRe, hammingWindowIm, transfHammingWindowRe, transfHammingWindowIm );
|
||||
|
||||
|
||||
for (unsigned j=0; j<( m_FFTLength ); j++)
|
||||
for (unsigned j=0; j<( m_FFTLength ); j++)
|
||||
{
|
||||
// perform thresholding
|
||||
const double squaredBin = squaredModule( transfHammingWindowRe[ j ], transfHammingWindowIm[ j ]);
|
||||
|
|
@ -241,7 +241,7 @@ void ConstantQ::sparsekernel()
|
|||
cout << "}" << endl;
|
||||
*/
|
||||
// std::cerr << "done\n -> is: " << sk->is.size() << ", js: " << sk->js.size() << ", reals: " << sk->real.size() << ", imags: " << sk->imag.size() << std::endl;
|
||||
|
||||
|
||||
m_sparseKernel = sk;
|
||||
return;
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ double* ConstantQ::process( const double* fftdata )
|
|||
|
||||
SparseKernel *sk = m_sparseKernel;
|
||||
|
||||
for (unsigned row=0; row<2*m_uK; row++)
|
||||
for (unsigned row=0; row<2*m_uK; row++)
|
||||
{
|
||||
m_CQdata[ row ] = 0;
|
||||
m_CQdata[ row+1 ] = 0;
|
||||
|
|
@ -324,7 +324,7 @@ void ConstantQ::process(const double *FFTRe, const double* FFTIm,
|
|||
|
||||
SparseKernel *sk = m_sparseKernel;
|
||||
|
||||
for (unsigned row=0; row<m_uK; row++)
|
||||
for (unsigned row=0; row<m_uK; row++)
|
||||
{
|
||||
CQRe[ row ] = 0;
|
||||
CQIm[ row ] = 0;
|
||||
|
|
|
|||
|
|
@ -27,75 +27,75 @@ MFCC::MFCC(MFCCConfig config)
|
|||
|
||||
/* Calculate at startup */
|
||||
double *freqs, *lower, *center, *upper, *triangleHeight, *fftFreqs;
|
||||
|
||||
|
||||
lowestFrequency = 66.6666666;
|
||||
linearFilters = 13;
|
||||
linearSpacing = 66.66666666;
|
||||
logFilters = 27;
|
||||
logSpacing = 1.0711703;
|
||||
|
||||
|
||||
/* FFT and analysis window sizes */
|
||||
fftSize = config.fftsize;
|
||||
fft = new FFTReal(fftSize);
|
||||
|
||||
totalFilters = linearFilters + logFilters;
|
||||
logPower = config.logpower;
|
||||
|
||||
|
||||
samplingRate = config.FS;
|
||||
|
||||
|
||||
/* The number of cepstral componenents */
|
||||
nceps = config.nceps;
|
||||
|
||||
/* Set if user want C0 */
|
||||
WANT_C0 = (config.want_c0 ? 1 : 0);
|
||||
|
||||
|
||||
/* Allocate space for feature vector */
|
||||
if (WANT_C0 == 1) {
|
||||
ceps = (double*)calloc(nceps+1, sizeof(double));
|
||||
} else {
|
||||
ceps = (double*)calloc(nceps, sizeof(double));
|
||||
}
|
||||
|
||||
|
||||
/* Allocate space for local vectors */
|
||||
mfccDCTMatrix = (double**)calloc(nceps+1, sizeof(double*));
|
||||
for (i = 0; i < nceps+1; i++) {
|
||||
mfccDCTMatrix[i]= (double*)calloc(totalFilters, sizeof(double));
|
||||
mfccDCTMatrix[i]= (double*)calloc(totalFilters, sizeof(double));
|
||||
}
|
||||
|
||||
mfccFilterWeights = (double**)calloc(totalFilters, sizeof(double*));
|
||||
for (i = 0; i < totalFilters; i++) {
|
||||
mfccFilterWeights[i] = (double*)calloc(fftSize, sizeof(double));
|
||||
mfccFilterWeights[i] = (double*)calloc(fftSize, sizeof(double));
|
||||
}
|
||||
|
||||
|
||||
freqs = (double*)calloc(totalFilters+2,sizeof(double));
|
||||
|
||||
|
||||
lower = (double*)calloc(totalFilters,sizeof(double));
|
||||
center = (double*)calloc(totalFilters,sizeof(double));
|
||||
upper = (double*)calloc(totalFilters,sizeof(double));
|
||||
|
||||
|
||||
triangleHeight = (double*)calloc(totalFilters,sizeof(double));
|
||||
fftFreqs = (double*)calloc(fftSize,sizeof(double));
|
||||
|
||||
|
||||
for (i = 0; i < linearFilters; i++) {
|
||||
freqs[i] = lowestFrequency + ((double)i) * linearSpacing;
|
||||
}
|
||||
|
||||
|
||||
for (i = linearFilters; i < totalFilters+2; i++) {
|
||||
freqs[i] = freqs[linearFilters-1] *
|
||||
freqs[i] = freqs[linearFilters-1] *
|
||||
pow(logSpacing, (double)(i-linearFilters+1));
|
||||
}
|
||||
|
||||
|
||||
/* Define lower, center and upper */
|
||||
memcpy(lower, freqs,totalFilters*sizeof(double));
|
||||
memcpy(center, &freqs[1],totalFilters*sizeof(double));
|
||||
memcpy(upper, &freqs[2],totalFilters*sizeof(double));
|
||||
|
||||
|
||||
for (i=0;i<totalFilters;i++){
|
||||
triangleHeight[i] = 2./(upper[i]-lower[i]);
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<fftSize;i++){
|
||||
fftFreqs[i] = ((double) i / ((double) fftSize ) *
|
||||
fftFreqs[i] = ((double) i / ((double) fftSize ) *
|
||||
(double) samplingRate);
|
||||
}
|
||||
|
||||
|
|
@ -103,12 +103,12 @@ MFCC::MFCC(MFCCConfig config)
|
|||
for (i=0;i<totalFilters;i++){
|
||||
|
||||
for (j=0;j<fftSize;j++) {
|
||||
|
||||
|
||||
if ((fftFreqs[j] > lower[i]) && (fftFreqs[j] <= center[i])) {
|
||||
|
||||
mfccFilterWeights[i][j] = triangleHeight[i] *
|
||||
(fftFreqs[j]-lower[i]) / (center[i]-lower[i]);
|
||||
|
||||
|
||||
mfccFilterWeights[i][j] = triangleHeight[i] *
|
||||
(fftFreqs[j]-lower[i]) / (center[i]-lower[i]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -118,7 +118,7 @@ MFCC::MFCC(MFCCConfig config)
|
|||
if ((fftFreqs[j]>center[i]) && (fftFreqs[j]<upper[i])) {
|
||||
|
||||
mfccFilterWeights[i][j] = mfccFilterWeights[i][j]
|
||||
+ triangleHeight[i] * (upper[i]-fftFreqs[j])
|
||||
+ triangleHeight[i] * (upper[i]-fftFreqs[j])
|
||||
/ (upper[i]-center[i]);
|
||||
}
|
||||
else
|
||||
|
|
@ -130,15 +130,15 @@ MFCC::MFCC(MFCCConfig config)
|
|||
}
|
||||
|
||||
/*
|
||||
* We calculate now mfccDCT matrix
|
||||
* We calculate now mfccDCT matrix
|
||||
* NB: +1 because of the DC component
|
||||
*/
|
||||
|
||||
const double pi = 3.14159265358979323846264338327950288;
|
||||
|
||||
|
||||
for (i = 0; i < nceps+1; i++) {
|
||||
for (j = 0; j < totalFilters; j++) {
|
||||
mfccDCTMatrix[i][j] = (1./sqrt((double) totalFilters / 2.))
|
||||
mfccDCTMatrix[i][j] = (1./sqrt((double) totalFilters / 2.))
|
||||
* cos((double) i * ((double) j + 0.5) / (double) totalFilters * pi);
|
||||
}
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ MFCC::MFCC(MFCCConfig config)
|
|||
for (j = 0; j < totalFilters; j++){
|
||||
mfccDCTMatrix[0][j] = (sqrt(2.)/2.) * mfccDCTMatrix[0][j];
|
||||
}
|
||||
|
||||
|
||||
/* The analysis window */
|
||||
window = new Window<double>(config.window, fftSize);
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ MFCC::MFCC(MFCCConfig config)
|
|||
|
||||
earMag = (double*)calloc(totalFilters, sizeof(double));
|
||||
fftMag = (double*)calloc(fftSize/2, sizeof(double));
|
||||
|
||||
|
||||
free(freqs);
|
||||
free(lower);
|
||||
free(center);
|
||||
|
|
@ -168,27 +168,27 @@ MFCC::MFCC(MFCCConfig config)
|
|||
MFCC::~MFCC()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* Free the structure */
|
||||
for (i = 0; i < nceps+1; i++) {
|
||||
free(mfccDCTMatrix[i]);
|
||||
}
|
||||
free(mfccDCTMatrix);
|
||||
|
||||
|
||||
for (i = 0; i < totalFilters; i++) {
|
||||
free(mfccFilterWeights[i]);
|
||||
}
|
||||
free(mfccFilterWeights);
|
||||
|
||||
|
||||
/* Free the feature vector */
|
||||
free(ceps);
|
||||
|
||||
|
||||
/* The analysis window */
|
||||
delete window;
|
||||
|
||||
free(earMag);
|
||||
free(fftMag);
|
||||
|
||||
|
||||
/* Free the FFT */
|
||||
free(realOut);
|
||||
free(imagOut);
|
||||
|
|
@ -198,17 +198,17 @@ MFCC::~MFCC()
|
|||
|
||||
|
||||
/*
|
||||
*
|
||||
* Extract the MFCC on the input frame
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Extract the MFCC on the input frame
|
||||
*
|
||||
*/
|
||||
int MFCC::process(const double *inframe, double *outceps)
|
||||
{
|
||||
double *inputData = (double *)malloc(fftSize * sizeof(double));
|
||||
for (int i = 0; i < fftSize; ++i) inputData[i] = inframe[i];
|
||||
|
||||
window->cut(inputData);
|
||||
|
||||
|
||||
/* Calculate the fft on the input frame */
|
||||
fft->process(0, inputData, realOut, imagOut);
|
||||
|
||||
|
|
@ -244,14 +244,14 @@ int MFCC::process(const double *real, const double *imag, double *outceps)
|
|||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Calculate now the cepstral coefficients
|
||||
*
|
||||
* Calculate now the cepstral coefficients
|
||||
* with or without the DC component
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if (WANT_C0 == 1) {
|
||||
|
||||
|
||||
for (i = 0; i < nceps+1; i++) {
|
||||
double tmp = 0.;
|
||||
for (j = 0; j < totalFilters; j++){
|
||||
|
|
@ -260,8 +260,8 @@ int MFCC::process(const double *real, const double *imag, double *outceps)
|
|||
outceps[i] = tmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
for (i = 1; i < nceps+1; i++) {
|
||||
double tmp = 0.;
|
||||
for (j = 0; j < totalFilters; j++){
|
||||
|
|
@ -270,7 +270,7 @@ int MFCC::process(const double *real, const double *imag, double *outceps)
|
|||
outceps[i-1] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nceps;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ double DetectionFunction::complexSD(unsigned int length, double *srcMagnitude, d
|
|||
double tmpPhase = 0;
|
||||
double tmpReal = 0;
|
||||
double tmpImag = 0;
|
||||
|
||||
|
||||
double dev = 0;
|
||||
ComplexData meas = ComplexData( 0, 0 );
|
||||
ComplexData j = ComplexData( 0, 1 );
|
||||
|
|
@ -287,7 +287,7 @@ double DetectionFunction::broadband(unsigned int length, double *src)
|
|||
m_magHistory[i] = sqrmag;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
double* DetectionFunction::getSpectrumMagnitude()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ void PeakPicking::initialise( PPickParams Config )
|
|||
Qfiltb = Config.QuadThresh.b ;
|
||||
Qfiltc = Config.QuadThresh.c ;
|
||||
|
||||
m_DFProcessingParams.length = m_DFLength;
|
||||
m_DFProcessingParams.LPOrd = Config.LPOrd;
|
||||
m_DFProcessingParams.LPACoeffs = Config.LPACoeffs;
|
||||
m_DFProcessingParams.LPBCoeffs = Config.LPBCoeffs;
|
||||
m_DFProcessingParams.length = m_DFLength;
|
||||
m_DFProcessingParams.LPOrd = Config.LPOrd;
|
||||
m_DFProcessingParams.LPACoeffs = Config.LPACoeffs;
|
||||
m_DFProcessingParams.LPBCoeffs = Config.LPBCoeffs;
|
||||
m_DFProcessingParams.winPre = Config.WinT.pre;
|
||||
m_DFProcessingParams.winPost = Config.WinT.post;
|
||||
m_DFProcessingParams.winPost = Config.WinT.post;
|
||||
m_DFProcessingParams.AlphaNormParam = Config.alpha;
|
||||
m_DFProcessingParams.isMedianPositive = false;
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ void PeakPicking::process( double* src, unsigned int len, vector<int> &onsets )
|
|||
|
||||
vector <double> m_maxima;
|
||||
|
||||
// Signal conditioning
|
||||
// Signal conditioning
|
||||
m_DFSmoothing->process( src, m_workBuffer );
|
||||
|
||||
for( unsigned int u = 0; u < len; u++)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ void PhaseVocoder::getPhase(unsigned int size, double *theta, double *real, doub
|
|||
{
|
||||
unsigned int k;
|
||||
|
||||
// Phase Angle "matlab" style
|
||||
// Phase Angle "matlab" style
|
||||
//Watch out for quadrant mapping !!!
|
||||
for( k = 0; k < size; k++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ void ClusterMeltSegmenter::initialise(int fs)
|
|||
|
||||
if (featureType == FEATURE_TYPE_CONSTQ ||
|
||||
featureType == FEATURE_TYPE_CHROMA) {
|
||||
|
||||
|
||||
// run internal processing at 11025 or thereabouts
|
||||
int internalRate = 11025;
|
||||
int decimationFactor = samplerate / internalRate;
|
||||
|
|
@ -77,11 +77,11 @@ void ClusterMeltSegmenter::initialise(int fs)
|
|||
|
||||
constq = new ConstantQ(config);
|
||||
constq->sparsekernel();
|
||||
|
||||
|
||||
ncoeff = constq->getK();
|
||||
|
||||
fft = new FFTReal(constq->getfftlength());
|
||||
|
||||
|
||||
} else if (featureType == FEATURE_TYPE_MFCC) {
|
||||
|
||||
// run internal processing at 22050 or thereabouts
|
||||
|
|
@ -110,7 +110,7 @@ void ClusterMeltSegmenter::initialise(int fs)
|
|||
}
|
||||
}
|
||||
|
||||
ClusterMeltSegmenter::~ClusterMeltSegmenter()
|
||||
ClusterMeltSegmenter::~ClusterMeltSegmenter()
|
||||
{
|
||||
delete window;
|
||||
delete constq;
|
||||
|
|
@ -164,7 +164,7 @@ void ClusterMeltSegmenter::extractFeaturesConstQ(const double* samples, int nsam
|
|||
vector<double> cq(ncoeff);
|
||||
|
||||
for (int i = 0; i < ncoeff; ++i) cq[i] = 0.0;
|
||||
|
||||
|
||||
const double *psource = samples;
|
||||
int pcount = nsamples;
|
||||
|
||||
|
|
@ -174,9 +174,9 @@ void ClusterMeltSegmenter::extractFeaturesConstQ(const double* samples, int nsam
|
|||
decimator->process(samples, decout);
|
||||
psource = decout;
|
||||
}
|
||||
|
||||
|
||||
int origin = 0;
|
||||
|
||||
|
||||
// std::cerr << "nsamples = " << nsamples << ", pcount = " << pcount << std::endl;
|
||||
|
||||
int frames = 0;
|
||||
|
|
@ -208,9 +208,9 @@ void ClusterMeltSegmenter::extractFeaturesConstQ(const double* samples, int nsam
|
|||
}
|
||||
|
||||
window->cut(frame);
|
||||
|
||||
|
||||
fft->process(false, frame, real, imag);
|
||||
|
||||
|
||||
constq->process(real, imag, cqre, cqim);
|
||||
|
||||
for (int i = 0; i < ncoeff; ++i) {
|
||||
|
|
@ -255,7 +255,7 @@ void ClusterMeltSegmenter::extractFeaturesMFCC(const double* samples, int nsampl
|
|||
vector<double> cc(ncoeff);
|
||||
|
||||
for (int i = 0; i < ncoeff; ++i) cc[i] = 0.0;
|
||||
|
||||
|
||||
const double *psource = samples;
|
||||
int pcount = nsamples;
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ void ClusterMeltSegmenter::segment()
|
|||
decimator = 0;
|
||||
|
||||
if (features.size() < histogramLength) return;
|
||||
/*
|
||||
/*
|
||||
std::cerr << "ClusterMeltSegmenter::segment: have " << features.size()
|
||||
<< " features with " << features[0].size() << " coefficients (ncoeff = " << ncoeff << ", ncomponents = " << ncomponents << ")" << std::endl;
|
||||
*/
|
||||
|
|
@ -353,10 +353,10 @@ void ClusterMeltSegmenter::segment()
|
|||
|
||||
if (featureType == FEATURE_TYPE_UNKNOWN ||
|
||||
featureType == FEATURE_TYPE_MFCC)
|
||||
cluster_segment(q, arrFeatures, features.size(), features[0].size(), nHMMStates, histogramLength,
|
||||
cluster_segment(q, arrFeatures, features.size(), features[0].size(), nHMMStates, histogramLength,
|
||||
nclusters, neighbourhoodLimit);
|
||||
else
|
||||
constq_segment(q, arrFeatures, features.size(), nbins, ncoeff, featureType,
|
||||
constq_segment(q, arrFeatures, features.size(), nbins, ncoeff, featureType,
|
||||
nHMMStates, histogramLength, nclusters, neighbourhoodLimit);
|
||||
|
||||
// convert the cluster assignment sequence to a segmentation
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ ostream& operator<<(ostream& os, const Segmentation& s)
|
|||
for (int i = 0; i < s.segments.size(); i++)
|
||||
{
|
||||
Segment seg = s.segments[i];
|
||||
os << std::fixed << seg.type << ':' << '\t' << std::setprecision(6) << seg.start / static_cast<double>(s.samplerate)
|
||||
os << std::fixed << seg.type << ':' << '\t' << std::setprecision(6) << seg.start / static_cast<double>(s.samplerate)
|
||||
<< '\t' << std::setprecision(6) << seg.end / static_cast<double>(s.samplerate) << "\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ void DFProcess::medianFilter(double *src, double *dst)
|
|||
{
|
||||
if (index >= m_length) break;
|
||||
|
||||
|
||||
|
||||
l = 0;
|
||||
for( j = i; j < ( i + m_winPost + m_winPre + 1); j++)
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ void DFProcess::medianFilter(double *src, double *dst)
|
|||
l++;
|
||||
}
|
||||
|
||||
scratch[ index++ ] = MathUtilities::median( y, l);
|
||||
scratch[ index++ ] = MathUtilities::median( y, l);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -182,6 +182,6 @@ void DFProcess::removeDCNormalize( double *src, double*dst )
|
|||
|
||||
for(int i = 0; i< m_length; i++)
|
||||
{
|
||||
dst[ i ] = ( src[ i ] - DFMin ) / DFAlphaNorm;
|
||||
dst[ i ] = ( src[ i ] - DFMin ) / DFAlphaNorm;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
|
|||
m_filtScratchOut = new double[ nExt ];
|
||||
|
||||
|
||||
for( i = 0; i< nExt; i++ )
|
||||
for( i = 0; i< nExt; i++ )
|
||||
{
|
||||
m_filtScratchIn[ i ] = 0.0;
|
||||
m_filtScratchOut[ i ] = 0.0;
|
||||
|
|
@ -94,16 +94,16 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
|
|||
// Do 0Ph filtering
|
||||
m_filter->process( m_filtScratchIn, m_filtScratchOut, nExt);
|
||||
|
||||
// reverse the series for FILTFILT
|
||||
// reverse the series for FILTFILT
|
||||
for ( i = 0; i < nExt; i++)
|
||||
{
|
||||
{
|
||||
m_filtScratchIn[ i ] = m_filtScratchOut[ nExt - i - 1];
|
||||
}
|
||||
|
||||
// do FILTER again
|
||||
// do FILTER again
|
||||
m_filter->process( m_filtScratchIn, m_filtScratchOut, nExt);
|
||||
|
||||
// reverse the series back
|
||||
// reverse the series back
|
||||
for ( i = 0; i < nExt; i++)
|
||||
{
|
||||
m_filtScratchIn[ i ] = m_filtScratchOut[ nExt - i - 1 ];
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ void Framer::getFrame(double *dst)
|
|||
{
|
||||
for( unsigned int u = 0; u < m_frameLength; u++)
|
||||
{
|
||||
dst[ u ] = m_srcBuffer[ m_ulSrcIndex++ ];
|
||||
dst[ u ] = m_srcBuffer[ m_ulSrcIndex++ ];
|
||||
}
|
||||
m_ulSrcIndex -= ( m_frameLength - m_stepSize );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ DownBeat::pushAudioBlock(const float *audio)
|
|||
// std::cerr << "pushAudioBlock: rms in " << sqrt(rmsin) << ", out " << sqrt(rmsout) << std::endl;
|
||||
m_buffill += m_increment / m_factor;
|
||||
}
|
||||
|
||||
|
||||
const float *
|
||||
DownBeat::getBufferedAudio(size_t &length) const
|
||||
{
|
||||
|
|
@ -192,9 +192,9 @@ DownBeat::findDownBeats(const float *audio,
|
|||
}
|
||||
|
||||
// Now FFT beat frame
|
||||
|
||||
|
||||
m_fft->process(false, m_beatframe, m_fftRealOut, m_fftImagOut);
|
||||
|
||||
|
||||
// Calculate magnitudes
|
||||
|
||||
for (size_t j = 0; j < m_beatframesize/2; ++j) {
|
||||
|
|
@ -257,7 +257,7 @@ DownBeat::measureSpecDiff(d_vec_t oldspec, d_vec_t newspec)
|
|||
{
|
||||
// JENSEN-SHANNON DIVERGENCE BETWEEN SPECTRAL FRAMES
|
||||
|
||||
unsigned int SPECSIZE = 512; // ONLY LOOK AT FIRST 512 SAMPLES OF SPECTRUM.
|
||||
unsigned int SPECSIZE = 512; // ONLY LOOK AT FIRST 512 SAMPLES OF SPECTRUM.
|
||||
if (SPECSIZE > oldspec.size()/4) {
|
||||
SPECSIZE = oldspec.size()/4;
|
||||
}
|
||||
|
|
@ -266,37 +266,37 @@ DownBeat::measureSpecDiff(d_vec_t oldspec, d_vec_t newspec)
|
|||
|
||||
double sumnew = 0.;
|
||||
double sumold = 0.;
|
||||
|
||||
|
||||
for (unsigned int i = 0;i < SPECSIZE;i++)
|
||||
{
|
||||
newspec[i] +=EPS;
|
||||
oldspec[i] +=EPS;
|
||||
|
||||
|
||||
sumnew+=newspec[i];
|
||||
sumold+=oldspec[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (unsigned int i = 0;i < SPECSIZE;i++)
|
||||
{
|
||||
newspec[i] /= (sumnew);
|
||||
oldspec[i] /= (sumold);
|
||||
|
||||
|
||||
// IF ANY SPECTRAL VALUES ARE 0 (SHOULDN'T BE ANY!) SET THEM TO 1
|
||||
if (newspec[i] == 0)
|
||||
{
|
||||
newspec[i] = 1.;
|
||||
}
|
||||
|
||||
|
||||
if (oldspec[i] == 0)
|
||||
{
|
||||
oldspec[i] = 1.;
|
||||
}
|
||||
|
||||
|
||||
// JENSEN-SHANNON CALCULATION
|
||||
sd1 = 0.5*oldspec[i] + 0.5*newspec[i];
|
||||
SD = SD + (-sd1*log(sd1)) + (0.5*(oldspec[i]*log(oldspec[i]))) + (0.5*(newspec[i]*log(newspec[i])));
|
||||
}
|
||||
|
||||
|
||||
return SD;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ TempoTrackV2::filter_df(d_vec_t &df)
|
|||
b[0] = 0.2066;
|
||||
b[1] = 0.4131;
|
||||
b[2] = 0.2066;
|
||||
|
||||
|
||||
double inp1 = 0.;
|
||||
double inp2 = 0.;
|
||||
double out1 = 0.;
|
||||
|
|
@ -67,7 +67,7 @@ TempoTrackV2::filter_df(d_vec_t &df)
|
|||
|
||||
for (unsigned int i = 0;i < df.size();i++)
|
||||
{
|
||||
lp_df[i] = 0.;
|
||||
lp_df[i] = 0.;
|
||||
}
|
||||
|
||||
inp1 = 0.; inp2 = 0.;
|
||||
|
|
@ -130,9 +130,9 @@ TempoTrackV2::calculateBeatPeriod(const vector<double> &df,
|
|||
dfframe[k] = df[i+k];
|
||||
}
|
||||
// get rcf vector for current frame
|
||||
d_vec_t rcf(wv_len);
|
||||
d_vec_t rcf(wv_len);
|
||||
get_rcf(dfframe,wv,rcf);
|
||||
|
||||
|
||||
rcfmat.push_back( d_vec_t() ); // adds a new column
|
||||
col_counter++;
|
||||
for (unsigned int j=0; j<rcf.size(); j++)
|
||||
|
|
@ -140,7 +140,7 @@ TempoTrackV2::calculateBeatPeriod(const vector<double> &df,
|
|||
rcfmat[col_counter].push_back( rcf[j] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now call viterbi decoding function
|
||||
viterbi_decode(rcfmat,wv,beat_period,tempi);
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ TempoTrackV2::get_rcf(const d_vec_t &dfframe_in, const d_vec_t &wv, d_vec_t &rcf
|
|||
|
||||
d_vec_t acf(dfframe.size());
|
||||
|
||||
|
||||
|
||||
for (unsigned int lag=0; lag<dfframe.size(); lag++)
|
||||
{
|
||||
double sum = 0.;
|
||||
|
|
@ -169,7 +169,7 @@ TempoTrackV2::get_rcf(const d_vec_t &dfframe_in, const d_vec_t &wv, d_vec_t &rcf
|
|||
|
||||
for (unsigned int n=0; n<(dfframe.size()-lag); n++)
|
||||
{
|
||||
tmp = dfframe[n] * dfframe[n+lag];
|
||||
tmp = dfframe[n] * dfframe[n+lag];
|
||||
sum += tmp;
|
||||
}
|
||||
acf[lag] = static_cast<double> (sum/ (dfframe.size()-lag));
|
||||
|
|
@ -188,10 +188,10 @@ TempoTrackV2::get_rcf(const d_vec_t &dfframe_in, const d_vec_t &wv, d_vec_t &rcf
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// apply adaptive threshold to rcf
|
||||
MathUtilities::adaptiveThreshold(rcf);
|
||||
|
||||
|
||||
double rcfsum =0.;
|
||||
for (unsigned int i=0; i<rcf.size(); i++)
|
||||
{
|
||||
|
|
@ -222,7 +222,7 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
|||
tmat[i].push_back(0.); // fill with zeros initially
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// variance of Gaussians in transition matrix
|
||||
// formed of Gaussians on diagonal - implies slow tempo change
|
||||
double sigma = 8.;
|
||||
|
|
@ -265,16 +265,16 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
|||
delta[0][j] = wv[j] * rcfmat[0][j];
|
||||
psi[0][j] = 0;
|
||||
}
|
||||
|
||||
|
||||
double deltasum = 0.;
|
||||
for (unsigned int i=0; i<Q; i++)
|
||||
{
|
||||
deltasum += delta[0][i];
|
||||
}
|
||||
}
|
||||
for (unsigned int i=0; i<Q; i++)
|
||||
{
|
||||
delta[0][i] /= (deltasum + EPS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (unsigned int t=1; t<T; t++)
|
||||
|
|
@ -286,12 +286,12 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
|||
for (unsigned int i=0; i<Q; i++)
|
||||
{
|
||||
tmp_vec[i] = delta[t-1][i] * tmat[j][i];
|
||||
}
|
||||
|
||||
delta[t][j] = get_max_val(tmp_vec);
|
||||
}
|
||||
|
||||
delta[t][j] = get_max_val(tmp_vec);
|
||||
|
||||
psi[t][j] = get_max_ind(tmp_vec);
|
||||
|
||||
|
||||
delta[t][j] *= rcfmat[t][j];
|
||||
}
|
||||
|
||||
|
|
@ -300,23 +300,23 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
|||
for (unsigned int i=0; i<Q; i++)
|
||||
{
|
||||
deltasum += delta[t][i];
|
||||
}
|
||||
}
|
||||
for (unsigned int i=0; i<Q; i++)
|
||||
{
|
||||
delta[t][i] /= (deltasum + EPS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i_vec_t bestpath(T);
|
||||
d_vec_t tmp_vec(Q);
|
||||
for (unsigned int i=0; i<Q; i++)
|
||||
{
|
||||
{
|
||||
tmp_vec[i] = delta[T-1][i];
|
||||
}
|
||||
|
||||
// find starting point - best beat period for "last" frame
|
||||
bestpath[T-1] = get_max_ind(tmp_vec);
|
||||
|
||||
|
||||
// backtrace through index of maximum values in psi
|
||||
for (unsigned int t=T-2; t>0 ;t--)
|
||||
{
|
||||
|
|
@ -328,7 +328,7 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
|||
|
||||
unsigned int lastind = 0;
|
||||
for (unsigned int i=0; i<T; i++)
|
||||
{
|
||||
{
|
||||
unsigned int step = 128;
|
||||
for (unsigned int j=0; j<step; j++)
|
||||
{
|
||||
|
|
@ -361,7 +361,7 @@ TempoTrackV2::get_max_val(const d_vec_t &df)
|
|||
maxval = df[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return maxval;
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +378,7 @@ TempoTrackV2::get_max_ind(const d_vec_t &df)
|
|||
ind = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ind;
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ TempoTrackV2::normalise_vec(d_vec_t &df)
|
|||
{
|
||||
sum += df[i];
|
||||
}
|
||||
|
||||
|
||||
for (unsigned int i=0; i<df.size(); i++)
|
||||
{
|
||||
df[i]/= (sum + EPS);
|
||||
|
|
@ -436,7 +436,7 @@ TempoTrackV2::calculateBeats(const vector<double> &df,
|
|||
// ELSE LEAVE AT DEFAULT VALUE FROM INITIALISATION: D_VEC_T SCORECANDS (TXWT.SIZE());
|
||||
|
||||
int cscore_ind = i+prange_min+j;
|
||||
if (cscore_ind >= 0)
|
||||
if (cscore_ind >= 0)
|
||||
{
|
||||
scorecands[j] = txwt[j] * cumscore[cscore_ind];
|
||||
}
|
||||
|
|
@ -457,7 +457,7 @@ TempoTrackV2::calculateBeats(const vector<double> &df,
|
|||
for (unsigned int i=cumscore.size() - beat_period[beat_period.size()-1] ; i<cumscore.size(); i++)
|
||||
{
|
||||
tmp_vec.push_back(cumscore[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int startpoint = get_max_ind(tmp_vec) + cumscore.size() - beat_period[beat_period.size()-1] ;
|
||||
|
||||
|
|
@ -476,10 +476,10 @@ TempoTrackV2::calculateBeats(const vector<double> &df,
|
|||
if (backlink[b] == b) break; // shouldn't happen... haha
|
||||
ibeats.push_back(backlink[b]);
|
||||
}
|
||||
|
||||
|
||||
// REVERSE SEQUENCE OF IBEATS AND STORE AS BEATS
|
||||
for (unsigned int i=0; i<ibeats.size(); i++)
|
||||
{
|
||||
{
|
||||
beats.push_back( static_cast<double>(ibeats[ibeats.size()-i-1]) );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ TCSGram::~TCSGram()
|
|||
|
||||
void TCSGram::getTCSVector(int iPosition, TCSVector& rTCSVector) const
|
||||
{
|
||||
if (iPosition < 0)
|
||||
if (iPosition < 0)
|
||||
rTCSVector = TCSVector();
|
||||
else if (iPosition >= m_VectorList.size())
|
||||
rTCSVector = TCSVector();
|
||||
|
|
@ -52,7 +52,7 @@ void TCSGram::addTCSVector(const TCSVector& rTCSVector)
|
|||
{
|
||||
size_t uSize = m_VectorList.size();
|
||||
long lMilliSeconds = static_cast<long>(uSize*m_dFrameDurationMS);
|
||||
std::pair<long, TCSVector> p;
|
||||
std::pair<long, TCSVector> p;
|
||||
p.first = lMilliSeconds;
|
||||
p.second = rTCSVector;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Wavelet::createDecompositionFilters(Type wavelet,
|
|||
|
||||
switch (wavelet) {
|
||||
|
||||
case Haar:
|
||||
case Haar:
|
||||
lpd.push_back(0.70710678118655);
|
||||
lpd.push_back(0.70710678118655);
|
||||
hpd.push_back(-0.70710678118655);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ void Correlation::doAutoUnBiased(double *src, double *dst, unsigned int length)
|
|||
{
|
||||
for( j = i; j < length; j++)
|
||||
{
|
||||
tmp += src[ j-i ] * src[ j ];
|
||||
tmp += src[ j-i ] * src[ j ];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ double KLDivergence::distanceDistribution(const vector<double> &d1,
|
|||
|
||||
double d = 0;
|
||||
double small = 1e-20;
|
||||
|
||||
|
||||
for (int i = 0; i < sz; ++i) {
|
||||
d += d1[i] * log10((d1[i] + small) / (d2[i] + small));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ double MathUtilities::getAlphaNorm( const std::vector <double> &data, unsigned i
|
|||
double MathUtilities::round(double x)
|
||||
{
|
||||
double val = (double)floor(x + 0.5);
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ double MathUtilities::median(const double *src, unsigned int len)
|
|||
double tmp = 0.0;
|
||||
double tempMedian;
|
||||
double medianVal;
|
||||
|
||||
|
||||
double* scratch = new double[ len ];//Vector < double > sortedX = Vector < double > ( size );
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ Thread::start()
|
|||
#endif
|
||||
m_extant = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Thread::wait()
|
||||
{
|
||||
if (m_extant) {
|
||||
|
|
@ -233,7 +233,7 @@ Condition::unlock()
|
|||
ReleaseMutex(m_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Condition::wait(int us)
|
||||
{
|
||||
if (us == 0) {
|
||||
|
|
@ -248,7 +248,7 @@ Condition::wait(int us)
|
|||
|
||||
DWORD ms = us / 1000;
|
||||
if (us > 0 && ms == 0) ms = 1;
|
||||
|
||||
|
||||
#ifdef DEBUG_CONDITION
|
||||
cerr << "CONDITION DEBUG: " << (void *)GetCurrentThreadId() << ": Timed waiting on " << &m_condition << " \"" << m_name << "\"" << endl;
|
||||
#endif
|
||||
|
|
@ -310,9 +310,9 @@ Thread::start()
|
|||
#endif
|
||||
m_extant = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Thread::wait()
|
||||
{
|
||||
if (m_extant) {
|
||||
|
|
@ -490,7 +490,7 @@ Condition::unlock()
|
|||
pthread_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Condition::wait(int us)
|
||||
{
|
||||
if (us == 0) {
|
||||
|
|
@ -514,7 +514,7 @@ Condition::wait(int us)
|
|||
struct timespec timeout;
|
||||
timeout.tv_sec = now.tv_sec;
|
||||
timeout.tv_nsec = now.tv_usec * 1000;
|
||||
|
||||
|
||||
#ifdef DEBUG_CONDITION
|
||||
cerr << "CONDITION DEBUG: " << (void *)pthread_self() << ": Timed waiting on " << &m_condition << " \"" << m_name << "\"" << endl;
|
||||
#endif
|
||||
|
|
@ -551,9 +551,9 @@ void
|
|||
Thread::start()
|
||||
{
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Thread::wait()
|
||||
{
|
||||
abort();
|
||||
|
|
@ -611,7 +611,7 @@ Condition::lock()
|
|||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Condition::wait(int us)
|
||||
{
|
||||
abort();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue