33 featureType(params.featureType),
34 hopSize(params.hopSize),
35 windowSize(params.windowSize),
39 ncomponents(params.ncomponents),
40 nHMMStates(params.nHMMStates),
41 nclusters(params.nclusters),
42 histogramLength(params.histogramLength),
43 neighbourhoodLimit(params.neighbourhoodLimit),
56 int internalRate = 11025;
57 int decimationFactor =
samplerate / internalRate;
58 if (decimationFactor < 1) decimationFactor = 1;
61 while (decimationFactor & (decimationFactor - 1)) ++decimationFactor;
67 if (decimationFactor > 1) {
88 int internalRate = 22050;
89 int decimationFactor =
samplerate / internalRate;
90 if (decimationFactor < 1) decimationFactor = 1;
93 while (decimationFactor & (decimationFactor - 1)) ++decimationFactor;
99 if (decimationFactor > 1) {
146 std::cerr <<
"ERROR: ClusterMeltSegmenter::extractFeaturesConstQ: " 147 <<
"No const-q: initialise not called?" 153 std::cerr <<
"ERROR: ClusterMeltSegmenter::extractFeatures: nsamples < windowsize (" << nsamples <<
" < " <<
getWindowsize() <<
")" << std::endl;
164 vector<double> cq(
ncoeff);
166 for (
int i = 0; i <
ncoeff; ++i) cq[i] = 0.0;
168 const double *psource = samples;
169 int pcount = nsamples;
173 double *decout =
new double[pcount];
184 double *frame =
new double[fftsize];
185 double *real =
new double[fftsize];
186 double *imag =
new double[fftsize];
187 double *cqre =
new double[
ncoeff];
188 double *cqim =
new double[
ncoeff];
190 while (origin <= pcount) {
194 if (origin > 0 && origin + fftsize >= pcount)
break;
196 for (
int i = 0; i < fftsize; ++i) {
197 if (origin + i < pcount) {
198 frame[i] = psource[origin + i];
204 for (
int i = 0; i < fftsize/2; ++i) {
205 double value = frame[i];
206 frame[i] = frame[i + fftsize/2];
207 frame[i + fftsize/2] = value;
216 for (
int i = 0; i <
ncoeff; ++i) {
217 cq[i] += sqrt(cqre[i] * cqre[i] + cqim[i] * cqim[i]);
230 for (
int i = 0; i <
ncoeff; ++i) {
242 std::cerr <<
"ERROR: ClusterMeltSegmenter::extractFeaturesMFCC: " 243 <<
"No mfcc: initialise not called?" 249 std::cerr <<
"ERROR: ClusterMeltSegmenter::extractFeatures: nsamples < windowsize (" << nsamples <<
" < " <<
getWindowsize() <<
")" << std::endl;
255 vector<double> cc(
ncoeff);
257 for (
int i = 0; i <
ncoeff; ++i) cc[i] = 0.0;
259 const double *psource = samples;
260 int pcount = nsamples;
264 double *decout =
new double[pcount];
272 double *frame =
new double[fftsize];
273 double *ccout =
new double[
ncoeff];
275 while (origin <= pcount) {
279 if (origin > 0 && origin + fftsize >= pcount)
break;
281 for (
int i = 0; i < fftsize; ++i) {
282 if (origin + i < pcount) {
283 frame[i] = psource[origin + i];
291 for (
int i = 0; i <
ncoeff; ++i) {
302 for (
int i = 0; i <
ncoeff; ++i) {
338 double** arrFeatures =
new double*[
features.size()];
339 for (
int i = 0; i <
features.size(); i++)
342 arrFeatures[i] =
new double[
features[0].size()];
343 for (
int j = 0; j < features[0].size(); j++)
344 arrFeatures[i][j] = features[i][j];
346 arrFeatures[i] =
new double[
ncoeff+1];
347 for (
int j = 0; j <
ncoeff; j++)
367 for (
int i = 0; i <
features.size(); i++)
368 delete [] arrFeatures[i];
369 delete [] arrFeatures;
385 for (
int i = 1; i < len; i++)
void process(const double *src, double *dst)
Process inLength samples (as supplied to constructor) from src and write inLength / decFactor samples...
void extractFeaturesMFCC(const double *, int)
void extractFeaturesConstQ(const double *, int)
virtual int getWindowsize()
int process(const double *inframe, double *outceps)
Process time-domain input data.
static int getHighestSupportedFactor()
virtual ~ClusterMeltSegmenter()
void cluster_segment(int *q, double **features, int frames_read, int feature_length, int nHMM_states, int histogram_length, int nclusters, int neighbour_limit)
void constq_segment(int *q, double **features, int frames_read, int bins, int ncoeff, int feature_type, int nHMM_states, int histogram_length, int nclusters, int neighbour_limit)
ClusterMeltSegmenter(ClusterMeltSegmenterParams params)
void process(const double *FFTRe, const double *FFTIm, double *CQRe, double *CQIm)
void setFeatures(const vector< vector< double > > &f)
void forward(const double *realIn, double *realOut, double *imagOut)
Carry out a forward real-to-complex transform of size nsamples, where nsamples is the value provided ...
vector< Segment > segments
Segmentation segmentation
Decimator carries out a fast downsample by a power-of-two factor.
Window< double > * window
feature_types featureType
virtual void initialise(int samplerate)
void makeSegmentation(int *q, int len)
virtual void extractFeatures(const double *samples, int nsamples)
vector< vector< double > > features