# HG changeset patch # User Adam Stark # Date 1505202016 -3600 # Node ID a6701b3f636f3e3a89c270248cfb04192d387b01 # Parent e354bb51b875b6a18f78ecb4297a04c3c6346ee4 Tidying up the interface to some functions diff -r e354bb51b875 -r a6701b3f636f src/BTrack.cpp --- a/src/BTrack.cpp Tue Sep 12 08:27:51 2017 +0100 +++ b/src/BTrack.cpp Tue Sep 12 08:40:16 2017 +0100 @@ -30,21 +30,21 @@ BTrack::BTrack() : odf (512, 1024, ComplexSpectralDifferenceHWR, HanningWindow) { - initialise (512, 1024); + initialise (512); } //======================================================================= -BTrack::BTrack (int hopSize_) - : odf (hopSize_, 2 * hopSize_, ComplexSpectralDifferenceHWR, HanningWindow) +BTrack::BTrack (int hop) + : odf (hop, 2 * hop, ComplexSpectralDifferenceHWR, HanningWindow) { - initialise (hopSize_, 2 * hopSize_); + initialise (hop); } //======================================================================= -BTrack::BTrack (int hopSize_, int frameSize_) - : odf (hopSize_, frameSize_, ComplexSpectralDifferenceHWR, HanningWindow) +BTrack::BTrack (int hop, int frame) + : odf (hop, frame, ComplexSpectralDifferenceHWR, HanningWindow) { - initialise (hopSize_, frameSize_); + initialise (hop); } //======================================================================= @@ -67,17 +67,13 @@ } //======================================================================= -double BTrack::getBeatTimeInSeconds (long frameNumber, int hopSize, int fs) +double BTrack::getBeatTimeInSeconds (long frameNumber, int hopSize, int samplingFrequency) { - double hop = (double) hopSize; - double samplingFrequency = (double) fs; - double frameNum = (double) frameNumber; - - return ((hop / samplingFrequency) * frameNum); + return ((static_cast (hopSize) / static_cast (samplingFrequency)) * static_cast (frameNumber)); } //======================================================================= -void BTrack::initialise (int hopSize_, int frameSize_) +void BTrack::initialise (int hop) { // set vector sizes resampledOnsetDF.resize (512); @@ -91,7 +87,6 @@ double rayleighParameter = 43; - // initialise parameters tightness = 5; alpha = 0.9; @@ -129,7 +124,7 @@ tempoFixed = false; // initialise algorithm given the hopsize - setHopSize (hopSize_); + setHopSize (hop); // Set up FFT for calculating the auto-correlation function FFTLengthForACFCalculation = 1024; @@ -151,9 +146,9 @@ } //======================================================================= -void BTrack::setHopSize (int hopSize_) +void BTrack::setHopSize (int hop) { - hopSize = hopSize_; + hopSize = hop; onsetDFBufferSize = (512 * 512) / hopSize; // calculate df buffer size beatPeriod = round(60/((((double) hopSize)/44100) * 120.)); @@ -177,13 +172,13 @@ } //======================================================================= -void BTrack::updateHopAndFrameSize (int hopSize_, int frameSize_) +void BTrack::updateHopAndFrameSize (int hop, int frame) { // update the onset detection function object - odf.initialise (hopSize_, frameSize_); + odf.initialise (hop, frame); // update the hop size being used by the beat tracker - setHopSize (hopSize_); + setHopSize (hop); } //======================================================================= diff -r e354bb51b875 -r a6701b3f636f src/BTrack.h --- a/src/BTrack.h Tue Sep 12 08:27:51 2017 +0100 +++ b/src/BTrack.h Tue Sep 12 08:40:16 2017 +0100 @@ -43,13 +43,13 @@ /** Constructor assuming frame size will be double the hopSize * @param hopSize the hop size in audio samples */ - BTrack (int hopSize_); + BTrack (int hopSize); /** Constructor taking both hopSize and frameSize * @param hopSize the hop size in audio samples * @param frameSize the frame size in audio samples */ - BTrack (int hopSize_, int frameSize_); + BTrack (int hopSize, int frameSize); /** Destructor */ ~BTrack(); @@ -114,15 +114,14 @@ private: /** Initialises the algorithm, setting internal parameters and creating weighting vectors - * @param hopSize_ the hop size in audio samples - * @param frameSize_ the frame size in audio samples + * @param hopSize the hop size in audio samples */ - void initialise (int hopSize_, int frameSize_); + void initialise (int hopSize); /** Initialise with hop size and set all array sizes accordingly - * @param hopSize_ the hop size in audio samples + * @param hopSize the hop size in audio samples */ - void setHopSize (int hopSize_); + void setHopSize (int hopSize); /** Resamples the onset detection function from an arbitrary number of samples to 512 */ void resampleOnsetDetectionFunction();