changeset 115:54c657d621dd

Code style updates
author Adam Stark <adamstark.uk@gmail.com>
date Fri, 18 Aug 2023 20:00:10 +0200
parents d6d9df2db3e1
children 75aacd17ad03
files src/BTrack.cpp src/OnsetDetectionFunction.cpp
diffstat 2 files changed, 53 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/src/BTrack.cpp	Fri Aug 18 10:48:26 2023 +0200
+++ b/src/BTrack.cpp	Fri Aug 18 20:00:10 2023 +0200
@@ -151,7 +151,7 @@
 {	
 	hopSize = hop;
 	onsetDFBufferSize = (512 * 512) / hopSize;		// calculate df buffer size
-	beatPeriod = round(60/((((double) hopSize)/44100) * 120.));
+	beatPeriod = round (60 / ((((double) hopSize) / 44100) * 120.));
 
     // set size of onset detection function buffer
     onsetDF.resize (onsetDFBufferSize);
@@ -324,7 +324,7 @@
 	int tempoIndex = (int) round((tempo - 80) / 2);
 	
 	// now set previous fixed previous tempo observation values to zero
-	for (int i=0;i < 41;i++)
+	for (int i = 0; i < 41; i++)
 	{
 		prevDeltaFixed[i] = 0;
 	}
@@ -349,7 +349,7 @@
 	float output[512];
     float input[onsetDFBufferSize];
     
-    for (int i = 0;i < onsetDFBufferSize;i++)
+    for (int i = 0; i < onsetDFBufferSize; i++)
         input[i] = (float) onsetDF[i];
         
     double ratio = 512.0 / ((double) onsetDFBufferSize);
@@ -435,7 +435,7 @@
 	beatPeriod = round ((60.0 * 44100.0) / (((2 * maxIndex) + 80) * ((double) hopSize)));
 	
 	if (beatPeriod > 0)
-        estimatedTempo = 60.0/((((double) hopSize) / 44100.0) * beatPeriod);
+        estimatedTempo = 60.0 / ((((double) hopSize) / 44100.0) * beatPeriod);
 }
 
 //=======================================================================
@@ -491,7 +491,7 @@
 		{
 			for (int b = 1 - a; b <= a - 1; b++) // general state using normalisation of comb elements
 			{
-				combFilterBankOutput[i-1] += (acf[(a * i + b) - 1] * weightingVector[i - 1]) / (2 * a - 1);	// calculate value for comb filter row
+				combFilterBankOutput[i - 1] += (acf[(a * i + b) - 1] * weightingVector[i - 1]) / (2 * a - 1);	// calculate value for comb filter row
 			}
 		}
 	}
@@ -522,7 +522,7 @@
     fftw_execute (acfForwardFFT);
     
     // multiply by complex conjugate
-    for (int i = 0;i < FFTLengthForACFCalculation;i++)
+    for (int i = 0; i < FFTLengthForACFCalculation; i++)
     {
         complexOut[i][0] = complexOut[i][0] * complexOut[i][0] + complexOut[i][1] * complexOut[i][1];
         complexOut[i][1] = 0.0;
@@ -553,7 +553,7 @@
     kiss_fft (cfgForwards, fftIn, fftOut);
     
     // multiply by complex conjugate
-    for (int i = 0;i < FFTLengthForACFCalculation;i++)
+    for (int i = 0; i < FFTLengthForACFCalculation; i++)
     {
         fftOut[i].r = fftOut[i].r * fftOut[i].r + fftOut[i].i * fftOut[i].i;
         fftOut[i].i = 0.0;
@@ -639,7 +639,7 @@
 	double beatExpectationWindow[beatExpectationWindowSize];
     
 	// copy cumulativeScore to first part of futureCumulativeScore
-	for (int i = 0;i < onsetDFBufferSize;i++)
+	for (int i = 0; i < onsetDFBufferSize; i++)
         futureCumulativeScore[i] = cumulativeScore[i];
 	
 	// Create a beat expectation window for predicting future beats from the "future" of the cumulative score.
--- a/src/OnsetDetectionFunction.cpp	Fri Aug 18 10:48:26 2023 +0200
+++ b/src/OnsetDetectionFunction.cpp	Fri Aug 18 20:00:10 2023 +0200
@@ -23,7 +23,7 @@
 #include "OnsetDetectionFunction.h"
 
 //=======================================================================
-OnsetDetectionFunction::OnsetDetectionFunction (int hopSize_,int frameSize_)
+OnsetDetectionFunction::OnsetDetectionFunction (int hopSize_, int frameSize_)
  :  onsetDetectionFunctionType (ComplexSpectralDifferenceHWR), windowType (HanningWindow)
 {
     // indicate that we have not initialised yet
@@ -37,7 +37,7 @@
 }
 
 //=======================================================================
-OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_)
+OnsetDetectionFunction::OnsetDetectionFunction (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)
  :  onsetDetectionFunctionType (ComplexSpectralDifferenceHWR), windowType (HanningWindow)
 {	
 	// indicate that we have not initialised yet
@@ -69,7 +69,7 @@
 }
 
 //=======================================================================
-void OnsetDetectionFunction::initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_)
+void OnsetDetectionFunction::initialise (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_)
 {
 	hopSize = hopSize_; // set hopsize
 	frameSize = frameSize_; // set framesize
@@ -140,7 +140,7 @@
 #ifdef USE_KISS_FFT
     complexOut.resize (frameSize);
     
-    for (int i = 0; i < frameSize;i++)
+    for (int i = 0; i < frameSize; i++)
     {
         complexOut[i].resize(2);
     }
@@ -266,11 +266,11 @@
 //=======================================================================
 void OnsetDetectionFunction::performFFT()
 {
-    int fsize2 = (frameSize/2);
+    int fsize2 = (frameSize / 2);
     
 #ifdef USE_FFTW
 	// window frame and copy to complex array, swapping the first and second half of the signal
-	for (int i = 0;i < fsize2;i++)
+	for (int i = 0; i < fsize2; i++)
 	{
 		complexIn[i][0] = frame[i + fsize2] * window[i + fsize2];
 		complexIn[i][1] = 0.0;
@@ -315,7 +315,7 @@
 	sum = 0;	// initialise sum
 	
 	// sum the squares of the samples
-	for (int i = 0;i < frameSize;i++)
+	for (int i = 0; i < frameSize; i++)
 	{
 		sum = sum + (frame[i] * frame[i]);
 	}
@@ -360,15 +360,15 @@
 	// perform the FFT
 	performFFT();
 	
-	// compute first (N/2)+1 mag values
-	for (int i = 0;i < (frameSize/2)+1;i++)
+	// compute first (N / 2) + 1 mag values
+	for (int i = 0; i < (frameSize / 2) + 1; i++)
 	{
 		magSpec[i] = sqrt (pow (complexOut[i][0], 2) + pow (complexOut[i][1], 2));
 	}
-	// mag spec symmetric above (N/2)+1 so copy previous values
-	for (int i = (frameSize/2)+1; i < frameSize; i++)
+	// mag spec symmetric above (N / 2) + 1 so copy previous values
+	for (int i = (frameSize / 2) + 1; i < frameSize; i++)
 	{
-		magSpec[i] = magSpec[frameSize-i];
+		magSpec[i] = magSpec[frameSize - i];
 	}
 	
 	sum = 0;	// initialise sum to zero
@@ -381,7 +381,7 @@
 		// ensure all difference values are positive
 		if (diff < 0)
 		{
-			diff = diff*-1;
+			diff = diff * -1;
 		}
 		
 		// add difference to sum
@@ -403,20 +403,20 @@
 	// perform the FFT
 	performFFT();
 	
-	// compute first (N/2)+1 mag values
-	for (int i = 0;i < (frameSize/2) + 1; i++)
+	// compute first (N / 2) + 1 mag values
+	for (int i = 0; i < (frameSize / 2) + 1; i++)
 	{
 		magSpec[i] = sqrt (pow (complexOut[i][0],2) + pow (complexOut[i][1],2));
 	}
-	// mag spec symmetric above (N/2)+1 so copy previous values
-	for (int i = (frameSize/2)+1;i < frameSize;i++)
+	// mag spec symmetric above (N / 2) + 1 so copy previous values
+	for (int i = (frameSize / 2) + 1; i < frameSize; i++)
 	{
-		magSpec[i] = magSpec[frameSize-i];
+		magSpec[i] = magSpec[frameSize - i];
 	}
 	
 	sum = 0;	// initialise sum to zero
 	
-	for (int i = 0;i < frameSize;i++)
+	for (int i = 0; i < frameSize; i++)
 	{
 		// calculate difference
 		diff = magSpec[i] - prevMagSpec[i];
@@ -448,7 +448,7 @@
 	sum = 0; // initialise sum to zero
 	
 	// compute phase values from fft output and sum deviations
-	for (int i = 0;i < frameSize;i++)
+	for (int i = 0; i < frameSize; i++)
 	{
 		// calculate phase value
 		phase[i] = atan2 (complexOut[i][1], complexOut[i][0]);
@@ -460,13 +460,13 @@
 		// if bin is not just a low energy bin then examine phase deviation
 		if (magSpec[i] > 0.1)
 		{
-			dev = phase[i] - (2*prevPhase[i]) + prevPhase2[i];	// phase deviation
+			dev = phase[i] - (2 * prevPhase[i]) + prevPhase2[i];	// phase deviation
 			pdev = princarg (dev);	// wrap into [-pi,pi] range
 		
 			// make all values positive
 			if (pdev < 0)	
 			{
-				pdev = pdev*-1;
+				pdev = pdev * -1;
 			}
 						
 			// add to sum
@@ -494,7 +494,7 @@
 	sum = 0; // initialise sum to zero
 	
 	// compute phase values from fft output and sum deviations
-	for (int i = 0;i < frameSize;i++)
+	for (int i = 0; i < frameSize; i++)
 	{
 		// calculate phase value
 		phase[i] = atan2 (complexOut[i][1], complexOut[i][0]);
@@ -534,7 +534,7 @@
 	sum = 0; // initialise sum to zero
 	
 	// compute phase values from fft output and sum deviations
-	for (int i = 0;i < frameSize;i++)
+	for (int i = 0; i < frameSize; i++)
 	{
 		// calculate phase value
 		phase[i] = atan2 (complexOut[i][1], complexOut[i][0]);
@@ -585,7 +585,7 @@
 		magSpec[i] = sqrt (pow (complexOut[i][0],2) + pow (complexOut[i][1],2));
 		
 		
-		sum = sum + (magSpec[i] * ((double) (i+1)));
+		sum = sum + (magSpec[i] * ((double) (i + 1)));
 		
 		// store values for next calculation
 		prevMagSpec[i] = magSpec[i];
@@ -606,7 +606,7 @@
 	sum = 0; // initialise sum to zero
 	
 	// compute phase values from fft output and sum deviations
-	for (int i = 0;i < frameSize;i++)
+	for (int i = 0; i < frameSize; i++)
 	{		
 		// calculate magnitude value
 		magSpec[i] = sqrt (pow (complexOut[i][0],2) + pow (complexOut[i][1],2));
@@ -619,7 +619,7 @@
 			mag_diff = -mag_diff;
 		}
 		
-		sum = sum + (mag_diff * ((double) (i+1)));
+		sum = sum + (mag_diff * ((double) (i + 1)));
 		
 		// store values for next calculation
 		prevMagSpec[i] = magSpec[i];
@@ -640,7 +640,7 @@
 	sum = 0; // initialise sum to zero
 	
 	// compute phase values from fft output and sum deviations
-	for (int i = 0;i < frameSize;i++)
+	for (int i = 0; i < frameSize; i++)
 	{		
 		// calculate magnitude value
 		magSpec[i] = sqrt (pow (complexOut[i][0],2) + pow (complexOut[i][1],2));
@@ -650,7 +650,7 @@
 		
 		if (mag_diff > 0)
 		{
-			sum = sum + (mag_diff * ((double) (i+1)));
+			sum = sum + (mag_diff * ((double) (i + 1)));
 		}
 
 		// store values for next calculation
@@ -670,7 +670,7 @@
 {
 	double N;		// variable to store framesize minus 1
 	
-	N = (double) (frameSize-1);	// framesize minus 1
+	N = (double) (frameSize - 1);	// framesize minus 1
 	
 	// Hanning window calculation
 	for (int n = 0; n < frameSize; n++)
@@ -685,13 +685,13 @@
 	double N;		// variable to store framesize minus 1
 	double n_val;	// double version of index 'n'
 	
-	N = (double) (frameSize-1);	// framesize minus 1
+	N = (double) (frameSize - 1);	// framesize minus 1
 	n_val = 0;
 	
 	// Hamming window calculation
-	for (int n = 0;n < frameSize;n++)
+	for (int n = 0; n < frameSize; n++)
 	{
-		window[n] = 0.54 - (0.46 * cos (2 * pi * (n_val/N)));
+		window[n] = 0.54 - (0.46 * cos (2 * pi * (n_val / N)));
 		n_val = n_val+1;
 	}
 }
@@ -702,14 +702,14 @@
 	double N;		// variable to store framesize minus 1
 	double n_val;	// double version of index 'n'
 	
-	N = (double) (frameSize-1);	// framesize minus 1
+	N = (double) (frameSize - 1);	// framesize minus 1
 	n_val = 0;
 	
 	// Blackman window calculation
-	for (int n = 0;n < frameSize;n++)
+	for (int n = 0; n < frameSize; n++)
 	{
-		window[n] = 0.42 - (0.5*cos(2*pi*(n_val/N))) + (0.08*cos(4*pi*(n_val/N)));
-		n_val = n_val+1;
+		window[n] = 0.42 - (0.5 * cos (2 * pi * (n_val / N))) + (0.08 * cos (4 * pi * (n_val / N)));
+		n_val = n_val + 1;
 	}
 }
 
@@ -722,28 +722,28 @@
 	
 	alpha = 0.5;
 	
-	N = (double) (frameSize-1);	// framesize minus 1
+	N = (double) (frameSize - 1);	// framesize minus 1
 		
 	// Tukey window calculation
 	
-	n_val = (double) (-1*((frameSize/2)))+1;
+	n_val = (double) (-1 * ((frameSize / 2))) + 1;
 
-	for (int n = 0;n < frameSize;n++)	// left taper
+	for (int n = 0; n < frameSize; n++)	// left taper
 	{
-		if ((n_val >= 0) && (n_val <= (alpha*(N/2))))
+		if ((n_val >= 0) && (n_val <= (alpha * (N / 2))))
 		{
 			window[n] = 1.0;
 		}
-		else if ((n_val <= 0) && (n_val >= (-1*alpha*(N/2))))
+		else if ((n_val <= 0) && (n_val >= (-1 * alpha * (N / 2))))
 		{
 			window[n] = 1.0;
 		}
 		else
 		{
-			window[n] = 0.5*(1+cos(pi*(((2*n_val)/(alpha*N))-1)));
+			window[n] = 0.5 * (1 + cos (pi * (((2 * n_val) / (alpha * N)) - 1)));
 		}
 
-		n_val = n_val+1;			 
+		n_val = n_val + 1;
 	}
 
 }
@@ -752,7 +752,7 @@
 void OnsetDetectionFunction::calculateRectangularWindow()
 {
 	// Rectangular window calculation
-	for (int n = 0;n < frameSize;n++)
+	for (int n = 0; n < frameSize; n++)
 	{
 		window[n] = 1.0;
 	}