Mercurial > hg > qm-dsp
comparison dsp/segmentation/ClusterMeltSegmenter.cpp @ 64:6cb2b3cd5356
* Refactor FFT a little bit so as to separate construction and processing
rather than have a single static method -- will make it easier to use a
different implementation
* pull in KissFFT implementation (not hooked up yet)
author | cannam |
---|---|
date | Wed, 13 May 2009 09:19:12 +0000 |
parents | d72fcd34d9a7 |
children | e5907ae6de17 |
comparison
equal
deleted
inserted
replaced
63:0dcbce5d7dce | 64:6cb2b3cd5356 |
---|---|
20 #include "dsp/rateconversion/Decimator.h" | 20 #include "dsp/rateconversion/Decimator.h" |
21 #include "dsp/mfcc/MFCC.h" | 21 #include "dsp/mfcc/MFCC.h" |
22 | 22 |
23 ClusterMeltSegmenter::ClusterMeltSegmenter(ClusterMeltSegmenterParams params) : | 23 ClusterMeltSegmenter::ClusterMeltSegmenter(ClusterMeltSegmenterParams params) : |
24 window(NULL), | 24 window(NULL), |
25 fft(NULL), | |
25 constq(NULL), | 26 constq(NULL), |
26 mfcc(NULL), | 27 mfcc(NULL), |
27 featureType(params.featureType), | 28 featureType(params.featureType), |
28 hopSize(params.hopSize), | 29 hopSize(params.hopSize), |
29 windowSize(params.windowSize), | 30 windowSize(params.windowSize), |
71 | 72 |
72 constq = new ConstantQ(config); | 73 constq = new ConstantQ(config); |
73 constq->sparsekernel(); | 74 constq->sparsekernel(); |
74 | 75 |
75 ncoeff = constq->getK(); | 76 ncoeff = constq->getK(); |
77 | |
78 fft = new FFTReal(constq->getfftlength()); | |
76 | 79 |
77 } else if (featureType == FEATURE_TYPE_MFCC) { | 80 } else if (featureType == FEATURE_TYPE_MFCC) { |
78 | 81 |
79 // run internal processing at 22050 or thereabouts | 82 // run internal processing at 22050 or thereabouts |
80 int internalRate = 22050; | 83 int internalRate = 22050; |
105 ClusterMeltSegmenter::~ClusterMeltSegmenter() | 108 ClusterMeltSegmenter::~ClusterMeltSegmenter() |
106 { | 109 { |
107 delete window; | 110 delete window; |
108 delete constq; | 111 delete constq; |
109 delete decimator; | 112 delete decimator; |
113 delete fft; | |
110 } | 114 } |
111 | 115 |
112 int | 116 int |
113 ClusterMeltSegmenter::getWindowsize() | 117 ClusterMeltSegmenter::getWindowsize() |
114 { | 118 { |
198 frame[i + fftsize/2] = value; | 202 frame[i + fftsize/2] = value; |
199 } | 203 } |
200 | 204 |
201 window->cut(frame); | 205 window->cut(frame); |
202 | 206 |
203 FFT::process(fftsize, false, frame, 0, real, imag); | 207 fft->process(false, frame, real, imag); |
204 | 208 |
205 constq->process(real, imag, cqre, cqim); | 209 constq->process(real, imag, cqre, cqim); |
206 | 210 |
207 for (int i = 0; i < ncoeff; ++i) { | 211 for (int i = 0; i < ncoeff; ++i) { |
208 cq[i] += sqrt(cqre[i] * cqre[i] + cqim[i] * cqim[i]); | 212 cq[i] += sqrt(cqre[i] * cqre[i] + cqim[i] * cqim[i]); |