annotate dsp/segmentation/SavedFeatureSegmenter.h @ 298:255e431ae3d4

* Key detector: when returning key strengths, use the peak value of the three underlying chromagram correlations (from 36-bin chromagram) corresponding to each key, instead of the mean. Rationale: This is the same method as used when returning the key value, and it's nice to have the same results in both returned value and plot. The peak performed better than the sum with a simple test set of triads, so it seems reasonable to change the plot to match the key output rather than the other way around. * FFT: kiss_fftr returns only the non-conjugate bins, synthesise the rest rather than leaving them (perhaps dangerously) undefined. Fixes an uninitialised data error in chromagram that could cause garbage results from key detector. * Constant Q: remove precalculated values again, I reckon they're not proving such a good tradeoff.
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 05 Jun 2009 15:12:39 +0000
parents cdfd0948a852
children
rev   line source
c@243 1 /*
c@243 2 * SavedFeatureSegmenter.h
c@243 3 * soundbite
c@243 4 *
c@243 5 * Created by Mark Levy on 23/03/2006.
c@243 6 * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. All rights reserved.
c@243 7 *
c@243 8 */
c@243 9
c@243 10 #include <vector>
c@243 11
c@243 12 #include "segment.h"
c@243 13 #include "Segmenter.h"
c@245 14 #include "hmm/hmm.h"
c@243 15
c@243 16 using std::vector;
c@243 17
c@243 18 class SavedFeatureSegmenterParams
c@243 19 {
c@243 20 public:
c@243 21 SavedFeatureSegmenterParams() : hopSize(0.2), windowSize(0.6),
c@243 22 nHMMStates(40), nclusters(10), histogramLength(15), neighbourhoodLimit(20) { }
c@243 23 double hopSize; // in secs
c@243 24 double windowSize; // in secs
c@243 25 int nHMMStates;
c@243 26 int nclusters;
c@243 27 int histogramLength;
c@243 28 int neighbourhoodLimit;
c@243 29 };
c@243 30
c@243 31 class SavedFeatureSegmenter : public Segmenter
c@243 32 {
c@243 33 public:
c@243 34 SavedFeatureSegmenter(SavedFeatureSegmenterParams params);
c@243 35 virtual ~SavedFeatureSegmenter();
c@243 36 virtual void initialise(int samplerate);
c@243 37 virtual int getWindowsize() { return static_cast<int>(windowSize * samplerate); }
c@243 38 virtual int getHopsize() { return static_cast<int>(hopSize * samplerate); }
c@243 39 virtual void extractFeatures(double* samples, int nsamples) { }
c@243 40 void setFeatures(const vector<vector<double> >& f); // provide the features yourself
c@243 41 virtual void segment(); // segment into default number of segment-types
c@243 42 void segment(int m); // segment into m segment-types
c@243 43 int getNSegmentTypes() { return nclusters; }
c@243 44 protected:
c@243 45 void makeSegmentation(int* q, int len);
c@243 46
c@243 47 model_t* model; // the HMM
c@243 48 int* q; // the decoded HMM state sequence
c@243 49 vector<vector<double> > histograms;
c@243 50
c@243 51 double hopSize; // in seconds
c@243 52 double windowSize; // in seconds
c@243 53
c@243 54 // HMM parameters
c@243 55 int nHMMStates;
c@243 56
c@243 57 // clustering parameters
c@243 58 int nclusters;
c@243 59 int histogramLength;
c@243 60 int neighbourhoodLimit;
c@245 61 };
c@245 62