Mercurial > hg > btrack
comparison src/OnsetDetectionFunction.cpp @ 29:bddd59087c36 develop
Overloaded initialise in OnsetDetectionFunction so the hopSize and frameSize can be set independently of the window type and onset detection function type
author | Adam <adamstark.uk@gmail.com> |
---|---|
date | Tue, 28 Jan 2014 00:49:53 +0000 |
parents | 98f7a54faa0c |
children | 5eeabb24d677 |
comparison
equal
deleted
inserted
replaced
28:7af87d3f2ce2 | 29:bddd59087c36 |
---|---|
20 //======================================================================= | 20 //======================================================================= |
21 | 21 |
22 #include <math.h> | 22 #include <math.h> |
23 #include "OnsetDetectionFunction.h" | 23 #include "OnsetDetectionFunction.h" |
24 | 24 |
25 //======================================================================= | 25 |
26 OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType) | 26 //======================================================================= |
27 OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_,int frameSize_) : onsetDetectionFunctionType(ComplexSpectralDifferenceHWR), windowType(HanningWindow) | |
28 { | |
29 // indicate that we have not initialised yet | |
30 initialised = false; | |
31 | |
32 // set pi | |
33 pi = 3.14159265358979; | |
34 | |
35 // initialise with arguments to constructor | |
36 initialise(hopSize_,frameSize_,ComplexSpectralDifferenceHWR,HanningWindow); | |
37 } | |
38 | |
39 //======================================================================= | |
40 OnsetDetectionFunction::OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_) : onsetDetectionFunctionType(ComplexSpectralDifferenceHWR), windowType(HanningWindow) | |
27 { | 41 { |
28 // indicate that we have not initialised yet | 42 // indicate that we have not initialised yet |
29 initialised = false; | 43 initialised = false; |
30 | 44 |
31 // set pi | 45 // set pi |
32 pi = 3.14159265358979; | 46 pi = 3.14159265358979; |
33 | 47 |
34 // initialise with arguments to constructor | 48 // initialise with arguments to constructor |
35 initialise(hopSize_,frameSize_,onsetDetectionFunctionType_,windowType); | 49 initialise(hopSize_,frameSize_,onsetDetectionFunctionType_,windowType_); |
36 } | 50 } |
37 | 51 |
38 | 52 |
39 //======================================================================= | 53 //======================================================================= |
40 OnsetDetectionFunction::~OnsetDetectionFunction() | 54 OnsetDetectionFunction::~OnsetDetectionFunction() |
47 fftw_free(complexOut); | 61 fftw_free(complexOut); |
48 } | 62 } |
49 } | 63 } |
50 | 64 |
51 //======================================================================= | 65 //======================================================================= |
52 void OnsetDetectionFunction::initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType) | 66 void OnsetDetectionFunction::initialise(int hopSize_,int frameSize_) |
67 { | |
68 // use the already initialised onset detection function and window type and | |
69 // pass the new frame and hop size to the main initialisation function | |
70 initialise(hopSize_, frameSize_, onsetDetectionFunctionType, windowType); | |
71 } | |
72 | |
73 //======================================================================= | |
74 void OnsetDetectionFunction::initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_) | |
53 { | 75 { |
54 if (initialised) // if we have already initialised FFT plan | 76 if (initialised) // if we have already initialised FFT plan |
55 { | 77 { |
56 // destroy fft plan | 78 // destroy fft plan |
57 fftw_destroy_plan(p); | 79 fftw_destroy_plan(p); |
62 | 84 |
63 hopSize = hopSize_; // set hopsize | 85 hopSize = hopSize_; // set hopsize |
64 frameSize = frameSize_; // set framesize | 86 frameSize = frameSize_; // set framesize |
65 | 87 |
66 onsetDetectionFunctionType = onsetDetectionFunctionType_; // set detection function type | 88 onsetDetectionFunctionType = onsetDetectionFunctionType_; // set detection function type |
89 windowType = windowType_; // set window type | |
67 | 90 |
68 // initialise buffers | 91 // initialise buffers |
69 frame.resize(frameSize); | 92 frame.resize(frameSize); |
70 window.resize(frameSize); | 93 window.resize(frameSize); |
71 magSpec.resize(frameSize); | 94 magSpec.resize(frameSize); |